|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MLEQCOMPDATA_H |
|
20 #define MLEQCOMPDATA_H |
|
21 |
|
22 // disable "identifier was truncated to '255' characters in the browser information" warning |
|
23 #pragma warning (disable:4786) |
|
24 |
|
25 // disable "decorated name length exceeded, name was truncated" |
|
26 #pragma warning (disable:4503) |
|
27 |
|
28 #include "MLAttributes.h" |
|
29 |
|
30 #include <vector> |
|
31 #include <string> |
|
32 #include <iosfwd> |
|
33 #include <map> |
|
34 |
|
35 using namespace std; |
|
36 |
|
37 class TMLEqCompDataLine; |
|
38 class TMLEqCompDataTable; |
|
39 class TMLEqCompData; |
|
40 class TMLAttributes; |
|
41 class FormulaTreeNode; |
|
42 |
|
43 extern const string KEqCompDataPaneOutputOrder[]; |
|
44 extern const int KEqCompDataPaneOutputOrderSize; |
|
45 |
|
46 extern const string KEqCompDataKeywordParamLeft; |
|
47 extern const string KEqCompDataKeywordParamTop; |
|
48 extern const string KEqCompDataKeywordParamRight; |
|
49 extern const string KEqCompDataKeywordParamBottom; |
|
50 extern const string KEqCompDataKeywordParamWidth; |
|
51 extern const string KEqCompDataKeywordParamHeight; |
|
52 |
|
53 |
|
54 /** |
|
55 * TMLEqCompDataFormula |
|
56 * |
|
57 * This represents a formula entry. It contains both the original string representation and any |
|
58 * subsequent parsed and resolved versions. |
|
59 */ |
|
60 struct TMLEqCompDataFormula |
|
61 { |
|
62 public: |
|
63 TMLEqCompDataFormula(); |
|
64 TMLEqCompDataFormula(const TMLEqCompDataFormula& aOther); |
|
65 TMLEqCompDataFormula(string aFormulaString); |
|
66 const TMLEqCompDataFormula& operator=(const TMLEqCompDataFormula& aOther); |
|
67 bool operator==(const TMLEqCompDataFormula& aOther) const; |
|
68 virtual ~TMLEqCompDataFormula(); |
|
69 public: // new methods |
|
70 void Compile(); |
|
71 public: |
|
72 string iFormulaString; // owned, must be present for lifetime of iFormulaTree |
|
73 int iZoomId; |
|
74 |
|
75 // don't think that we need these as they don't seem to be used |
|
76 // string lowerMargin; |
|
77 // string upperMargin; |
|
78 // string minLimit; |
|
79 // string maxLimit; |
|
80 |
|
81 public: |
|
82 FormulaTreeNode* iFormulaTree; // owned, but it references iFormulaString |
|
83 }; |
|
84 |
|
85 typedef vector<TMLEqCompDataFormula> TMLEqCompDataFormulae; |
|
86 |
|
87 enum TMLEqCompDataOptionSetOrientation |
|
88 { |
|
89 EMLEqCompDataOptionSetOrientationUndefined = 0x00, |
|
90 EMLEqCompDataOptionSetOrientationPortrait = 0x01, |
|
91 EMLEqCompDataOptionSetOrientationLandscape = 0x02 |
|
92 }; |
|
93 |
|
94 /** |
|
95 * TMLEqCompDataValuesOptionSet |
|
96 * an option set for a given value, which may apply to either or both orientation |
|
97 */ |
|
98 struct TMLEqCompDataValuesOptionSet : public TMLEqCompDataFormulae |
|
99 { |
|
100 public: |
|
101 void Compile(); |
|
102 public: |
|
103 TMLEqCompDataOptionSetOrientation iOrientation; |
|
104 }; |
|
105 |
|
106 typedef map<int, TMLEqCompDataValuesOptionSet> TMLEqCompDataValuesOptionSets; |
|
107 |
|
108 /** |
|
109 * TMLEqCompDataValues |
|
110 * The values stored in a cell in a layout line |
|
111 */ |
|
112 class TMLEqCompDataValues : public TMLEqCompDataFormulae |
|
113 { |
|
114 public: // constructors, operators, etc |
|
115 TMLEqCompDataValues(); |
|
116 TMLEqCompDataValues(TMLEqCompDataLine* aLine); |
|
117 virtual ~TMLEqCompDataValues(); |
|
118 bool operator==(const TMLEqCompDataValues& aOther) const; |
|
119 |
|
120 public: // new methods |
|
121 bool Merge(TMLEqCompDataLine* aLine, string aName, TMLEqCompDataValues& aOtherValues, bool aMirrorMerge); |
|
122 void Compile(int aOptionSetId); |
|
123 static string CppValue(const string& aValue); |
|
124 static string MirrorJustificationValue(const string& aValue); |
|
125 |
|
126 public: // member data |
|
127 TMLEqCompDataLine* iLine; // not owned |
|
128 TMLEqCompDataValuesOptionSets iOptionSets; // owned |
|
129 string iName; |
|
130 }; |
|
131 |
|
132 |
|
133 // |
|
134 // Parent Info |
|
135 // |
|
136 |
|
137 /** |
|
138 * TMLEqCompDataParentInfoSelector |
|
139 * |
|
140 * The parent id and parent variety index for each variety index |
|
141 */ |
|
142 struct TMLEqCompDataParentInfoSelector |
|
143 { |
|
144 public: |
|
145 TMLEqCompDataParentInfoSelector(); |
|
146 TMLEqCompDataParentInfoSelector(int aParentId, int aParentVariety); |
|
147 public: |
|
148 int iParentId; |
|
149 int iParentVariety; |
|
150 }; |
|
151 |
|
152 typedef map<int, TMLEqCompDataParentInfoSelector> TMLEqCompDataParentInfoVarieties; |
|
153 |
|
154 /** |
|
155 * TMLEqCompDataParentInfo |
|
156 * |
|
157 * Contains the parent info selector for each variety index |
|
158 */ |
|
159 class TMLEqCompDataParentInfo : public TMLEqCompDataParentInfoVarieties |
|
160 { |
|
161 public: // constructors etc |
|
162 TMLEqCompDataParentInfo(); |
|
163 TMLEqCompDataParentInfo(TMLEqCompDataLine* aLine); |
|
164 virtual ~TMLEqCompDataParentInfo(); |
|
165 public: // new methods |
|
166 void Merge(const TMLEqCompDataParentInfo& aOther); |
|
167 public: // member data |
|
168 TMLEqCompDataLine* iLine; // not owned |
|
169 }; |
|
170 |
|
171 class TMLEqCompDataAttributeInfo; |
|
172 |
|
173 /** |
|
174 * TMLEqCompDataLine |
|
175 * A layout line |
|
176 */ |
|
177 class TMLEqCompDataLine : public map<string, TMLEqCompDataValues> |
|
178 { |
|
179 public: |
|
180 enum TComponentType |
|
181 { |
|
182 EUnknownComponent, |
|
183 EScreenComponent, |
|
184 EContainerComponent, |
|
185 EPaneComponent, |
|
186 EGraphicComponent, |
|
187 ETextComponent |
|
188 }; |
|
189 |
|
190 public: // constructors etc |
|
191 TMLEqCompDataLine(); |
|
192 TMLEqCompDataLine(const TMLEqCompDataLine& aOther); |
|
193 virtual ~TMLEqCompDataLine(); |
|
194 |
|
195 bool operator==(const TMLEqCompDataLine& aOther) const; |
|
196 static bool lessthan(TMLEqCompDataLine* aLeft, TMLEqCompDataLine* aRight); |
|
197 bool ValuesEqual(const TMLEqCompDataLine& aOther) const; |
|
198 |
|
199 public: // new methods |
|
200 bool Merge(TMLEqCompDataLine& aOther); |
|
201 void Compile(int aOptionSetId); |
|
202 TMLAttributeZoomLevels* GetAttributeZoomLevels(string aAttribName, int aVariety); |
|
203 |
|
204 public: // get and set methods |
|
205 string Name() const; |
|
206 int NumCols() const; |
|
207 int NumRows() const; |
|
208 void SetNumCols(int aNumCols); |
|
209 void SetNumRows(int aNumRows); |
|
210 |
|
211 public: // helpers |
|
212 int EncodeFontId(int aHeight, int aPosture, int aWeight, int aCategory) const; |
|
213 bool MatchParams(const TMLEqCompDataLine& aLine) const; |
|
214 bool MatchNameDiscountingSuffix(const TMLEqCompDataLine& aLine) const; |
|
215 bool MatchType(const TMLEqCompDataLine& aLine) const; |
|
216 string NameDiscountingSuffix() const; |
|
217 string NameSuffix() const; |
|
218 |
|
219 private: // helpers |
|
220 TMLAttributeZoomLevels* GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety); |
|
221 TMLAttributeZoomLevels* FindAttributeZoomLevels(string aAttribSetName, int aAttribId); |
|
222 |
|
223 public: // member data |
|
224 int iId; |
|
225 string iName; |
|
226 TComponentType iType; |
|
227 int iDrawingOrder; |
|
228 TMLEqCompDataTable* iParentTable; |
|
229 TMLEqCompDataParentInfo* iParentInfo;// owned |
|
230 // TMLEqCompDataAttributeInfo* iAttributeInfo;// owned |
|
231 bool iIsUnique; |
|
232 int iGlobalIndex; |
|
233 bool iIsMirroredHorizontally; // i.e. l and r are swapped |
|
234 |
|
235 private: |
|
236 int iNumCols; // there is always at least one column |
|
237 int iNumRows; // there is always at least one row |
|
238 }; |
|
239 |
|
240 |
|
241 // |
|
242 // Attribute Info |
|
243 // |
|
244 |
|
245 /** |
|
246 * TMLEqCompDataAttributeInfoSelector |
|
247 * |
|
248 * Contains the attribute set name, which is used to |
|
249 * disambiguate the attribute data for a given component |
|
250 */ |
|
251 struct TMLEqCompDataAttributeInfoSelector |
|
252 { |
|
253 public: |
|
254 TMLEqCompDataAttributeInfoSelector(); |
|
255 TMLEqCompDataAttributeInfoSelector(string aAttributeSetName); |
|
256 public: |
|
257 string iAttributeSetName; |
|
258 }; |
|
259 |
|
260 typedef map<int, TMLEqCompDataAttributeInfoSelector> TMLEqCompDataAttributeInfoVarieties; |
|
261 |
|
262 /** |
|
263 * TMLEqCompDataAttributeInfo |
|
264 * |
|
265 * Contains the attribute info selector for each variety |
|
266 */ |
|
267 class TMLEqCompDataAttributeInfo : public TMLEqCompDataAttributeInfoVarieties |
|
268 { |
|
269 public: // constructors etc |
|
270 TMLEqCompDataAttributeInfo(); |
|
271 TMLEqCompDataAttributeInfo(TMLEqCompDataLine* aLine); |
|
272 virtual ~TMLEqCompDataAttributeInfo(); |
|
273 public: // new methods |
|
274 void Merge(const TMLEqCompDataAttributeInfo& aOther); |
|
275 public: // member data |
|
276 TMLEqCompDataLine* iLine; // not owned |
|
277 }; |
|
278 |
|
279 |
|
280 typedef vector<TMLEqCompDataLine*> TMLEqCompDataLines; |
|
281 |
|
282 /** |
|
283 * TMLEqCompDataTableOptionSet |
|
284 * an option set for a given value, which may apply to either or both orientation |
|
285 */ |
|
286 struct TMLEqCompDataTableOptionSet : public TMLEqCompDataLines |
|
287 { |
|
288 public: |
|
289 TMLEqCompDataTableOptionSet(); |
|
290 TMLEqCompDataTableOptionSet(const TMLEqCompDataTableOptionSet& aOther); |
|
291 virtual ~TMLEqCompDataTableOptionSet(); |
|
292 void Compile(int aOptionSetId); |
|
293 public: |
|
294 TMLEqCompDataLine* FindLine(int aId) const; |
|
295 public: |
|
296 TMLEqCompDataOptionSetOrientation iOrientation; |
|
297 }; |
|
298 |
|
299 typedef map<int, TMLEqCompDataTableOptionSet> TMLEqCompDataTableOptionSets; |
|
300 |
|
301 /** |
|
302 * TMLEqCompDataTable |
|
303 * A layout table |
|
304 */ |
|
305 class TMLEqCompDataTable : public TMLEqCompDataTableOptionSets |
|
306 { |
|
307 public: // constructors etc |
|
308 TMLEqCompDataTable(TMLEqCompData* aTables); |
|
309 TMLEqCompDataTable(TMLEqCompData* aTables, const TMLEqCompDataTable& aOther); |
|
310 virtual ~TMLEqCompDataTable(); |
|
311 |
|
312 public: // new methods |
|
313 TMLEqCompDataLine* FindLine(const string& aName); |
|
314 void Merge(TMLEqCompDataTable& aOther); |
|
315 void Compile(); |
|
316 void SetDefaultColumnNames(); |
|
317 |
|
318 public: // accessors |
|
319 string Name(); |
|
320 static bool IsValueColumn(string aName); |
|
321 static bool IsNumericColumn(string aName); |
|
322 static bool IsHorizontalColumn(string aName); |
|
323 static bool IsVerticalColumn(string aName); |
|
324 |
|
325 public: // member data |
|
326 int iId; |
|
327 string iName; |
|
328 TMLEqCompData* iTables; |
|
329 vector<string> iColumnNames; |
|
330 TMLEqCompDataLine* iParentLine; // not owned |
|
331 string iParentName; |
|
332 }; |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 // |
|
338 // the "List" xml is needed to get the name of each component. |
|
339 // |
|
340 |
|
341 /** |
|
342 * TMLEqListComponent |
|
343 * |
|
344 * This is the component element stored in the list xml. |
|
345 */ |
|
346 struct TMLEqListComponent |
|
347 { |
|
348 public: |
|
349 TMLEqListComponent(); |
|
350 public: |
|
351 int iId; |
|
352 string iName; |
|
353 }; |
|
354 |
|
355 // |
|
356 // the "ParChild" xml is needed to get the parent relations |
|
357 // |
|
358 |
|
359 /** |
|
360 * TMLEqParChildComponent |
|
361 * |
|
362 * This is the component element stored in the parent chlid xml. |
|
363 */ |
|
364 struct TMLEqParChildComponent |
|
365 { |
|
366 public: |
|
367 TMLEqParChildComponent(); |
|
368 public: |
|
369 int iId; |
|
370 int iParentId; |
|
371 }; |
|
372 |
|
373 |
|
374 |
|
375 /** |
|
376 * TMLEqCompData |
|
377 * |
|
378 * The core layout class - this represents a complete master layout, |
|
379 * typically loaded from a .xml file that has been extracted from the internal |
|
380 * xml data of the layout tool |
|
381 */ |
|
382 class TMLEqCompData : public vector<TMLEqCompDataTable*> |
|
383 { |
|
384 public: |
|
385 typedef map<int, TMLEqListComponent*> TMLEqListComponents; |
|
386 typedef map<int, TMLEqCompDataLine*> TMLEqCompDataComponents; |
|
387 typedef map<int, TMLEqParChildComponent*> TMLEqParChildComponents; |
|
388 |
|
389 public: // constructors |
|
390 TMLEqCompData(); |
|
391 TMLEqCompData(const TMLEqCompData& aOther); |
|
392 TMLEqCompData& operator=(const TMLEqCompData& aOther); |
|
393 |
|
394 public: // new methods |
|
395 virtual ~TMLEqCompData(); |
|
396 TMLEqCompDataLine* FindComponent(const string& aName) const; |
|
397 TMLEqCompDataLine* FindLine(const string& aName) const; |
|
398 TMLEqCompDataTable* FindTable(int aId) const; |
|
399 TMLEqCompDataTable* FindTable(const string& aName) const; |
|
400 void Merge(TMLEqCompData& aOther); |
|
401 void MergeComponents(TMLEqCompData& aOther); |
|
402 void Compile(); |
|
403 void UpdateNames(); |
|
404 void CreateTables(); |
|
405 void DeleteComponents(); |
|
406 |
|
407 public: // member data |
|
408 string iName; |
|
409 bool iCanBeMirror; |
|
410 string iMasterName; |
|
411 string iLayoutName; |
|
412 string iVariantName; |
|
413 string iResolutionHeight; |
|
414 string iResolutionWidth; |
|
415 string iTimestamp; |
|
416 TMLEqListComponents iListComponents; // this is used to accumulate the lines from the , which are then compiled into tables |
|
417 TMLEqCompDataComponents iComponents; // this is used to accumulate the lines, which are then compiled into tables |
|
418 TMLEqParChildComponents iParChildComponents; // this is used to accumulate the lines, which are then compiled into tables |
|
419 bool iIsBaseInstance; |
|
420 TMLAttributes* iAttributes; // owned |
|
421 }; |
|
422 |
|
423 |
|
424 #endif |
|
425 |
|
426 // End of File |