BankEdit.c++ 2.29 KB
/*******************************************************************************
 *  File:  BankEdit.c
 *
 *  Impliments the gui for the bank editor portion of AudioEditor.
 *
 ******************************************************************************/
#include <stdio.h>

#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/BulletinB.h>

#include "Editor.h"
#include "EditMgr.h"

#include "AssetMgr.h"
#include "Mgrs.h"

static void destroy_cb(Widget w, XtPointer client_data, XmAnyCallbackStruct *call_data);


BankEditor::BankEditor(void *theEdMgr, Display *display)
{

    shellWidget = XtVaAppCreateShell("BankEditor", "XBankEditor",
                                           topLevelShellWidgetClass, display,
                                           XmNheight, 300,
                                           XmNwidth, 300, NULL); 
    
    XtAddCallback(shellWidget, XmNdestroyCallback, destroy_cb, (XtPointer)theEdMgr);

    theForm = XtVaCreateManagedWidget("BankForm", xmFormWidgetClass, shellWidget,
                                      NULL);

    assetList = theAssetMgr->ListBanks(&numBanks);
    if(numBanks)
        this->CreateBankMenu();
    
    XtRealizeWidget(shellWidget);
}

void BankEditor::CreateBankMenu(void)
{
    int        c;
    Widget     bankMenu, subMenu, menuItem, menuItem1;
    XmString   menuTitle;
    Arg        args[8];
    Cardinal   argc = 0;
    
    
    subMenu = XmCreatePulldownMenu(theForm, "BankMenu", NULL, 0);
    
    for(c = 0; c < numBanks; c++)
    {
        menuItem = XmCreatePushButton(subMenu, assetList[c].name, NULL, 0);
        XtManageChild(menuItem);
        if(c == 0)
            menuItem1 = menuItem;
    }
    menuTitle = XmStringCreateSimple("Banks");

    XtSetArg(args[argc], XmNy, 10);                    argc++;
    XtSetArg(args[argc], XmNx, 10);                    argc++;
    XtSetArg(args[argc], XmNlabelString, menuTitle);   argc++;
    XtSetArg(args[argc], XmNsubMenuId, subMenu);       argc++;
    XtSetArg(args[argc], XmNmenuHistory, menuItem1);   argc++;
    bankMenu = XmCreateOptionMenu(theForm, "Banks", args, argc);
    XtManageChild(bankMenu);
    XmStringFree(menuTitle);
}

    

static void destroy_cb(Widget w, XtPointer client_data, XmAnyCallbackStruct *call_data)
{
    EditMgr *theEdMgr = (EditMgr*)client_data;

    theEdMgr->removeBank();
}