AeAssetBinUI.c++
4.18 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
#include <assert.h>
#include <string.h>
#include "Matrix.h"
#include "GList.h"
#include "AeAssetBinUI.h"
#include "AeAssetUI.h"
#include "AeFieldUI.h"
#include "AeAssetBin.h"
#include "AeAsset.h"
#include "AeBinView.h"
AeAssetBinUI::AeAssetBinUI (AeAssetBin * bin, AeClient * client)
{
fBin = bin;
fChildBinUI = NULL;
fClient = client;
fFieldUIList = new GList<AeFieldUI *>;
}
AeAssetBinUI::~AeAssetBinUI (void)
{
int i;
if (fFieldUIList)
{
AeFieldUI * fieldUI;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
delete fieldUI;
delete fFieldUIList;
}
}
TAssetType
AeAssetBinUI::GetType (void)
{
assert (fBin);
return fBin->GetType ();
}
void
AeAssetBinUI::SetName (const char * name)
{
assert (name);
assert (strlen(name) < kNameMaxLen);
strcpy (fName, name);
}
int
AeAssetBinUI::GetNumFields (void)
{
return fFieldUIList->GetNum ();
}
void
AeAssetBinUI::GetFieldLabels (String * labelArray)
{
AeFieldUI * fieldUI;
int i;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
*labelArray++ = fieldUI->GetName ();
}
void
AeAssetBinUI::GetFieldMaxLens (int * maxLenArray)
{
AeFieldUI * fieldUI;
int i;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
*maxLenArray++ = fieldUI->GetMaxLen ();
}
void
AeAssetBinUI::GetFieldAligns (unsigned char * alignArray)
{
AeFieldUI * fieldUI;
int i;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
*alignArray++ = (unsigned char)fieldUI->GetJustify ();
}
void
AeAssetBinUI::GetFieldWidths (short * widthArray)
{
AeAssetBin * bin;
GList<AeAsset *> * assetList;
AeFieldUI * fieldUI;
int widthMax;
int i;
bin = GetBin ();
assetList = bin->GetAssetList ();
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
{
if (fieldUI->NeedsWidthRecalc ())
{
widthMax = fieldUI->GetLabelWidth ();
calcWidth (assetList, fieldUI, widthMax);
fieldUI->SetWidth (widthMax);
}
*widthArray++ = fieldUI->GetWidth ();
}
}
void
AeAssetBinUI::SetNeedsWidthRecalc (Boolean recalc)
{
AeFieldUI * fieldUI;
int i;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
fieldUI->SetNeedsWidthRecalc (recalc);
}
void
AeAssetBinUI::AppendFieldUI (AeFieldUI * fieldUI)
{
fFieldUIList->Append (fieldUI);
}
void
AeAssetBinUI::UpdateHierarchy (void)
{
AeFieldUI * fieldUI;
int i;
// Mark each hierarchical field for width recalculation
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
if (fieldUI->IsHierarchical ())
fieldUI->SetNeedsWidthRecalc (True);
}
void
AeAssetBinUI::UpdateAssetUIFields (AeBinView * view, AeAssetUI * assetUI, int row)
{
AeFieldUI * fieldUI;
int col;
TString63 string;
fFieldUIList->Start (col);
while (fFieldUIList->Next (col, fieldUI))
{
if (assetUI->IsEditable (fieldUI))
{
assetUI->GetFieldString (fieldUI, string);
view->ListUpdateCell (row, col-1, string);
}
}
}
void
AeAssetBinUI::SetListFieldData (Widget list)
{
AeFieldUI * fieldUI;
int i;
fFieldUIList->Start (i);
while (fFieldUIList->Next (i, fieldUI))
XbaeMatrixSetColumnUserData (list, i-1, fieldUI);
assert (i == XbaeMatrixNumColumns (list));
}
//
// This routine updates the width of the given fieldUI
// by finding the asset with the largest value in terms
// of string length.
// The width value is used by list views of asset data.
//
void
AeAssetBinUI::calcWidth (GList<AeAsset *> * assetList,
AeFieldUI * fieldUI, int & widthMax)
{
AeAsset * asset;
AeAssetUI * assetUI;
int width;
TString63 string;
int i;
assetList->Start (i);
while (assetList->Next (i, asset))
{
if (asset->GetClientData (fClient, (void **)&assetUI))
{
assetUI->GetFieldString (fieldUI, string);
if ((width = strlen (string)) > widthMax)
{
widthMax = width;
if (widthMax >= fieldUI->GetMaxWidth ())
break;
}
if (assetUI->IsOpen ())
fChildBinUI->calcWidth (((AeContainerAsset *)asset)->GetChildList (), fieldUI, widthMax);
}
}
}