AePriorityFieldUI.c++ 2.04 KB
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <Vk/VkPopupMenu.h>

#include "GList.h"
#include "AeTypes.h"
#include "AeBinEditor.h"
#include "AeAsset.h"
#include "AeAssetBinUI.h"
#include "AeAssetUI.h"
#include "AeFieldUI.h"
#include "AeBinView.h"



AePriorityFieldUI::AePriorityFieldUI (const char * name,
			    Boolean isEditable,
			    Boolean isSelectable,
			    Boolean isHierarchical,
			    TJustify justify,
			    TIntGetProc getProc,
			    TIntSetProc setProc) : 
    AeIntFieldUI (name, isEditable, isSelectable, isHierarchical,
		  justify, getProc, setProc)
{
}


AePriorityFieldUI::AePriorityFieldUI (const char * name,
			    Boolean isEditable,
			    Boolean isSelectable,
			    Boolean isHierarchical,
			    TJustify justify,
			    TIntGetProc getProc,
			    TIntSetProc setProc,
			    int min, int max, int def) : 
    AeIntFieldUI (name, isEditable, isSelectable, isHierarchical, justify,
		  getProc, setProc, min, max, def)
{
}

AePriorityFieldUI::~AePriorityFieldUI (void)
{
}


void
AePriorityFieldUI::SetValue (AeAsset * asset, void * value)
{
    assert (fSetProc);
    fSetProc (asset, (int)value);
}


Boolean
AePriorityFieldUI::HandleButtonPress (AeBinEditor * editor,
				      AeAssetUI * assetUI,
				      XEvent * event,
				      TEditModifier modifier)
{
    assert (editor);
    assert (assetUI);

    if (modifier == kModMotion)
	return False;

    AeBinEditor::fMenuEditor = editor;
    AeBinEditor::fMenuAssetUI = assetUI;
    AeBinEditor::fMenuFieldUI = this;

    AeBinView * view = editor->GetView ();
    addMenuItems (assetUI, view->PopupGet ());

    view->PopupShow (event);

    return True;
}


void
AePriorityFieldUI::addMenuItems (AeAssetUI * assetUI, VkPopupMenu * popup)
{
    TString63			string;
    int				i;

    popup->addAction ("Hi", &AeBinEditor::MenuCallback, (XtPointer)fMax);

    for (i=fMax; --i>fMin; )
    {
	sprintf (string, "%d", i);
	popup->addAction (string, &AeBinEditor::MenuCallback, (XtPointer)i);
    }

    popup->addAction ("Lo", &AeBinEditor::MenuCallback, (XtPointer)fMin);
}