AeTabPanelUI.c++ 1.66 KB
#include <assert.h>
#include <stdlib.h>
#include <Vk/VkTabPanel.h>

#include "AeBinView.h"
#include "AeBinEditor.h"


void
AeBinView::TabCreate (void)
{
    fTabpanel = new VkTabPanel ("tabpanel", _baseWidget);
    fTabpanel->show();

    XtVaSetValues (
        fTabpanel->baseWidget(),
        XmNtopAttachment,		XmATTACH_NONE, 
        XmNbottomAttachment,		XmATTACH_FORM, 
        XmNleftAttachment,		XmATTACH_FORM, 
        XmNrightAttachment, 		XmATTACH_FORM, 
        XmNtopPosition,			0, 
        XmNbottomPosition,		0, 
        XmNrightPosition,		0, 
        XmNtopOffset,			0, 
        XmNbottomOffset,		8, 
        XmNleftOffset,			0, 
        XmNrightOffset,			0, 
        (XtPointer) NULL);

    // setup callback routines
    fTabpanel->addCallback (VkTabPanel::tabSelectCallback, (VkCallbackObject *)this, (VkCallbackMethod)&AeBinView::TabSelectCallback, NULL);
}


void
AeBinView::TabSetLabels (void)
{
    int			numBins;
    String *		tabLabels = NULL;
    int			i;

    assert (fTabpanel);
    assert (fEditor);

    numBins = fEditor->GetNumBins ();

    if ((tabLabels = (String *)malloc (numBins * sizeof (String))) == NULL)
	goto Exit;
    
    fEditor->GetBinNames (tabLabels);

    for (i=0; i<numBins; i++)
	fTabpanel->addTab (tabLabels[i], NULL, False);

Exit:

    if (tabLabels)
	free (tabLabels);
}


void
AeBinView::TabSelectName (String name)
{
    assert (fTabpanel);
    assert (name);

    fTabpanel->selectTab (name);
}


void
AeBinView::TabSelectCallback (VkCallbackObject * object, void * clientData, void * callData)
{
    VkTabCallbackStruct	* tabData = (VkTabCallbackStruct *)callData;

    assert (fEditor);

    fEditor->SetIndexedBinUI (tabData->tabIndex);
}