AeRefFieldUI.c++
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <assert.h>
#include <string.h>
#include <Vk/VkPopupMenu.h>
#include "GList.h"
#include "AeTypes.h"
#include "AeBinEditor.h"
#include "AeAsset.h"
#include "AeAssetBin.h"
#include "AeAssetBinUI.h"
#include "AeAssetUI.h"
#include "AeFieldUI.h"
#include "AeBinView.h"
AeRefFieldUI::AeRefFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
AeAssetBin * refBin,
TRefGetProc getProc,
TRefSetProc setProc) :
AeFieldUI (name, isEditable, isSelectable, isHierarchical, False, justify, kStringMaxLen)
{
fGetProc = getProc;
fSetProc = setProc;
fRefBin = refBin;
}
AeRefFieldUI::~AeRefFieldUI (void)
{
}
void
AeRefFieldUI::GetValueString (AeAsset * asset, String string)
{
AeAsset * value = fGetProc (asset);
if (value)
strcpy (string, value->GetName ());
else
strcpy (string, "--");
}
Boolean
AeRefFieldUI::SetValueString (AeAsset * asset, String string)
{
assert (fSetProc);
if (fRefBin)
{
AeAsset * refAsset;
if (fRefBin->FindNamedAsset (string, refAsset))
{
if (refAsset != fGetProc (asset))
{
fSetProc (asset, refAsset);
return True;
}
}
}
return False;
}
Boolean
AeRefFieldUI::VerifyValueString (String string)
{
AeAsset * refAsset;
Boolean okay = True;
if (fRefBin)
okay = fRefBin->FindNamedAsset (string, refAsset);
return okay;
}
Boolean
AeRefFieldUI::SetValue (AeAsset * asset, void * refAsset)
{
assert (fSetProc);
if (refAsset == fGetProc (asset))
return False;
fSetProc (asset, (AeAsset *)refAsset);
return True;
}
AeAsset *
AeRefFieldUI::GetValue (AeAsset * asset)
{
assert (fGetProc);
return fGetProc (asset);
}
Boolean
AeRefFieldUI::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 (view->PopupGet ());
view->PopupShow (event);
return True;
}
void
AeRefFieldUI::addMenuItems (VkPopupMenu * popup)
{
// if we have a reference asset bin and a popup menu to
// display the reference assets in, then continue
if (fRefBin)
{
GList<AeAsset *> * refAssetList;
AeAsset * refAsset;
int i;
refAssetList = fRefBin->GetAssetList ();
refAssetList->Start (i);
while (refAssetList->Next (i, refAsset))
popup->addAction (refAsset->GetName (), &AeBinEditor::MenuCallback, (XtPointer)refAsset);
if (popup->numItems () == 0)
popup->addLabel ("none available");
}
}
void
AeRefFieldUI::HandleDoubleClick (AeBinEditor * editor,
AeAssetUI * assetUI,
XEvent * event,
TEditModifier modifier)
{
assert (editor);
assert (assetUI);
AeAsset * refAsset = GetValue (assetUI->GetAsset ());
editor->SelectTypedBinUI (refAsset->GetType ());
}