AeFieldUI.h
7.65 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#ifndef __AeFieldUI__
#define __AeFieldUI__
#include <Xm/TextF.h>
#include "AeTypes.h"
#include "AeBinEditor.h"
class VkPopupMenu;
class AeAsset;
class AeAssetUI;
class AeAssetBin;
typedef int (*TIntGetProc)(AeAsset *);
typedef void (*TIntSetProc)(AeAsset *, int);
typedef float (*TFloatGetProc)(AeAsset *);
typedef void (*TFloatSetProc)(AeAsset *, float);
typedef char * (*TStringGetProc)(AeAsset *);
typedef void (*TStringSetProc)(AeAsset *, char *);
typedef AeAsset * (*TRefGetProc)(AeAsset *);
typedef void (*TRefSetProc)(AeAsset *, AeAsset *);
typedef enum
{
kLeftJustify = XmALIGNMENT_BEGINNING,
kCenterJustify = XmALIGNMENT_CENTER,
kRightJustify = XmALIGNMENT_END
} TJustify;
// note that widths are column attributes while
// lens are value attributes. widths may be less
// than lens to keep the lists from growing too big.
enum
{
kMinWidth = 3,
kMaxWidth = 25,
kIntMaxLen = 16,
kFloatMaxLen = 16,
kStringMaxLen = kNameMaxLen
};
class AeFieldUI
{
public:
AeFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
Boolean isCommon,
TJustify justify,
int maxLen);
virtual ~AeFieldUI (void);
virtual Boolean IsIcon (void) { return False; }
virtual Boolean HasPopup (void) { return False; }
virtual void GetValueString (AeAsset *, String);
virtual Boolean SetValueString (AeAsset *, String);
virtual Boolean VerifyValueString (String);
virtual Boolean VerifyInput (XmTextVerifyCallbackStruct *, const char * prevStr);
virtual Boolean SetValue (AeAsset *, void * value) { return False; }
virtual Boolean HandleButtonPress (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual void HandleDoubleClick (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
char * GetName (void) { return fName; }
TJustify GetJustify (void) { return fJustify; }
int GetMaxLen (void) { return fMaxLen; }
virtual Boolean IsEditable (AeAsset *) { return fIsEditable; }
Boolean IsSelectable (void) { return fIsSelectable; }
Boolean IsHierarchical (void) { return fIsHierarchical; }
Boolean IsCommon (void) { return fIsCommon; }
int GetWidth (void) { return fWidth; }
int GetMaxWidth (void) { return fMaxWidth; }
int GetLabelWidth (void) { return fLabelWidth; }
Boolean NeedsWidthUpdate (void) { return fNeedsWidthUpdate; }
virtual Boolean NeedsWidthRecalc (void) { return fNeedsWidthRecalc; }
void SetNeedsWidthRecalc (Boolean needsRecalc) { fNeedsWidthRecalc = needsRecalc; }
void SetWidth (int width);
void UpdateWidth (String newString, String oldString);
static void CalcListFontRatio (void);
protected:
TString63 fName;
TJustify fJustify;
Boolean fIsEditable;
Boolean fIsSelectable;
Boolean fIsHierarchical; // true if field is part of hierarchy
Boolean fIsCommon; // true if field is common to all assets
int fMaxLen;
// width information to make updating column widths easy
int fWidth;
int fMaxWidth;
int fLabelWidth;
Boolean fNeedsWidthUpdate;
Boolean fNeedsWidthRecalc;
static double fLabel2CellFontRatio;
};
class AeFloatFieldUI : public AeFieldUI
{
public:
AeFloatFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
TFloatGetProc getProc,
TFloatSetProc setProc);
AeFloatFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
TFloatGetProc getProc,
TFloatSetProc setProc,
float min, float max, float def);
virtual ~AeFloatFieldUI (void);
virtual void GetValueString (AeAsset *, String);
virtual Boolean SetValueString (AeAsset *, String);
virtual Boolean VerifyValueString (String);
virtual Boolean VerifyInput (XmTextVerifyCallbackStruct *, const char * prevStr);
private:
TFloatGetProc fGetProc;
TFloatSetProc fSetProc;
float fMin;
float fMax;
float fDefault;
};
class AeRefFieldUI : public AeFieldUI
{
public:
AeRefFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
TJustify justify,
AeAssetBin * refBin,
TRefGetProc getProc,
TRefSetProc setProc);
virtual ~AeRefFieldUI (void);
virtual Boolean HasPopup (void) { return True; }
virtual void GetValueString (AeAsset *, String);
virtual Boolean SetValueString (AeAsset *, String);
virtual Boolean VerifyValueString (String);
virtual Boolean SetValue (AeAsset *, void * value);
AeAsset * GetValue (AeAsset *);
virtual Boolean HandleButtonPress (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual void HandleDoubleClick (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
private:
TRefGetProc fGetProc;
TRefSetProc fSetProc;
AeAssetBin * fRefBin;
// routines and variables to handle reference field menu editing
void addMenuItems (VkPopupMenu *);
};
class AeStringFieldUI : public AeFieldUI
{
public:
AeStringFieldUI (const char * name,
Boolean isEditable,
Boolean isSelectable,
Boolean isHierarchical,
Boolean isCommon,
TJustify justify,
TStringGetProc getProc,
TStringSetProc setProc);
virtual ~AeStringFieldUI (void);
virtual void GetValueString (AeAsset *, String);
virtual Boolean SetValueString (AeAsset *, String);
virtual Boolean VerifyValueString (String);
private:
TStringGetProc fGetProc;
TStringSetProc fSetProc;
};
class AeIconFieldUI : public AeFieldUI
{
public:
AeIconFieldUI (const char * name,
Boolean isSelectable,
Boolean isCommon,
TJustify justify);
virtual ~AeIconFieldUI (void);
virtual void GetValueString (AeAsset *, String);
virtual Boolean HandleButtonPress (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual void HandleDoubleClick (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual Boolean IsIcon (void) { return True; }
virtual Boolean NeedsWidthRecalc (void) { return False; }
private:
};
class AeContainerFieldUI : public AeFieldUI
{
public:
AeContainerFieldUI (const char * name,
Boolean orphansOnly,
TIntGetProc getProc);
virtual ~AeContainerFieldUI (void);
virtual void GetValueString (AeAsset *, String);
virtual Boolean HandleButtonPress (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual void HandleDoubleClick (AeBinEditor *, AeAssetUI *, XEvent *, TEditModifier);
virtual Boolean NeedsWidthRecalc (void) { return False; }
private:
void addMenuItems (VkPopupMenu *, AeBinEditor *, AeAssetUI *);
void handleMenuItem (AeBinEditor *, AeAssetUI *, AeAsset *);
static void MenuCallback (Widget, XtPointer, XtPointer);
TIntGetProc fGetProc;
AeAssetBin * fParentBin;
Boolean fOrphansOnly;
};
class AeTypeFieldUI : public AeFieldUI
{
public:
AeTypeFieldUI (const char * name,
TJustify justify,
TIntGetProc getProc);
virtual ~AeTypeFieldUI (void);
virtual void GetValueString (AeAsset *, String);
private:
void assettype2assetstr (int, String);
TIntGetProc fGetProc;
};
#endif __AeFieldUI__