AePopupUI.c++ 1.3 KB
#include <assert.h>
#include <Xm/RowColumn.h>
#include "Matrix.h"
#include <Vk/VkApp.h>
#include <Vk/VkPopupMenu.h>

#include "AeBinView.h"


void
AeBinView::PopupCreate (void)
{
    assert (fList);

    if (fPopup = new VkPopupMenu)
    {
	fPopup->build (fList);

	XtVaSetValues (fPopup->baseWidget (), XmNpopupEnabled, False, NULL);

	XtAddCallback (fPopup->baseWidget (), XmNunmapCallback,
		       AeBinView::PopupUnmapCallback, (XtPointer)this);
    }
}


void
AeBinView::PopupShow (XEvent * event)
{
    PopupSetFont ();
    XtVaSetValues (fPopup->baseWidget (), XmNpopupEnabled, True, NULL);
    fPopup->show (event);
}


void
AeBinView::PopupUnmap (void)
{
    int			i;

    XtVaSetValues (fPopup->baseWidget (), XmNpopupEnabled, False, NULL);

    // remove all items currently in the menu
    for (i=fPopup->numItems (); --i>=0; )
	(*fPopup)[i]->remove ();
}


void
AeBinView::PopupUnmapCallback (Widget list, XtPointer view, XtPointer callData)
{
    assert (view);
    ((AeBinView *)view)->PopupUnmap ();
}


void
AeBinView::PopupSetFont (void)
{
    WidgetList	widgetList;
    int		widgetNum;
    int		i;

    XtVaGetValues (fPopup->baseWidget (),
		   XmNnumChildren, &widgetNum,
		   XmNchildren, &widgetList, 
		   NULL);

    for (i=0; i<widgetNum; i++)
	XtVaSetValues (widgetList[i], XmNfontList, fListFont, NULL);
}