|
1 /* |
|
2 * Copyright (c) 2002-2004 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 #include "AknLayout2ScalableDataDef.h" |
|
20 #include "AknLayout2ScalableDef.h" |
|
21 #include <layoutmetadata.cdl.h> |
|
22 #include <CdlEngine.h> |
|
23 |
|
24 |
|
25 #define AKNLAYOUT_DEFINE_BYTECODE(name,byte) const TUint8 name = byte; |
|
26 #include "AknLayoutByteCodes.h" |
|
27 |
|
28 // in the simple case, numCols and numRows are missing |
|
29 const TInt KNumCellsNotSimple = 2; |
|
30 |
|
31 // first two cells are numCols and numRows |
|
32 const TInt KNumCellsWindow = 7; |
|
33 const TInt KNumCellsText = 9; |
|
34 |
|
35 // this is the total possible number |
|
36 const TInt KNumCells = 11; |
|
37 |
|
38 #ifndef EKA2 |
|
39 GLDEF_C TInt E32Dll(TDllReason) |
|
40 { |
|
41 return KErrNone; |
|
42 } |
|
43 #endif |
|
44 |
|
45 // |
|
46 // Panic |
|
47 // |
|
48 |
|
49 enum TLayoutScalablePanic |
|
50 { |
|
51 ENegativeOffset, |
|
52 EOffsetOutOfRange, |
|
53 EIllegalLineIndex, |
|
54 EMultiLineOffsetOutOfRange, |
|
55 EParameterOutOfRange, |
|
56 EWrongType |
|
57 }; |
|
58 |
|
59 void Panic(TLayoutScalablePanic aCode) |
|
60 { |
|
61 _LIT(KLayoutPanic, "Layout panic"); |
|
62 User::Panic(KLayoutPanic, aCode); |
|
63 } |
|
64 |
|
65 |
|
66 // |
|
67 // Helpers |
|
68 // |
|
69 |
|
70 TInt16 Max(TInt16 aValue1, TInt16 aValue2) |
|
71 { |
|
72 if (aValue1 > aValue2) return aValue1; |
|
73 return aValue2; |
|
74 } |
|
75 TInt16 MinusInt(TInt16 aValue1, TInt16 aValue2) |
|
76 { |
|
77 return TInt16(aValue1 - aValue2); |
|
78 } |
|
79 |
|
80 TBool IsParentRelative(TInt aVal) |
|
81 { |
|
82 return aVal > ELayoutP-ELayoutPRange && aVal <= ELayoutP; |
|
83 } |
|
84 |
|
85 struct TAknTextComponentLayoutAttrs |
|
86 { |
|
87 TInt32 iFontId; |
|
88 TInt16 iJustification; |
|
89 }; |
|
90 |
|
91 TAknTextComponentLayoutAttrs ExtractAttributes(TAknTextComponentLayout aText) |
|
92 { |
|
93 TAknTextComponentLayoutAttrs attrs; |
|
94 attrs.iFontId = aText.Font(); |
|
95 attrs.iJustification = aText.J(); |
|
96 return attrs; |
|
97 } |
|
98 |
|
99 TAknWindowComponentLayout TAknWindowComponentLayout::ExtractWindow(TAknTextComponentLayout aText) |
|
100 { |
|
101 TAknWindowComponentLayout layout; |
|
102 layout.Setl(aText.l()); |
|
103 layout.Sett(aText.t()); |
|
104 layout.SetW(aText.W()); |
|
105 layout.SetH(aText.H()); |
|
106 layout.Setb(aText.b()); |
|
107 layout.Setr(aText.r()); |
|
108 |
|
109 layout.SetC(aText.C()); // colour is separate. |
|
110 return layout; |
|
111 } |
|
112 |
|
113 TAknTextComponentLayout TAknWindowComponentLayout::CombineAttrs(TAknWindowComponentLayout aLine1, const TAknTextComponentLayoutAttrs &aAttrs) |
|
114 { |
|
115 TAknTextComponentLayout layout; |
|
116 layout.Setl(aLine1.l()); |
|
117 layout.Sett(aLine1.t()); |
|
118 layout.SetW(aLine1.W()); |
|
119 layout.SetH(aLine1.H()); |
|
120 layout.Setb(aLine1.b()); |
|
121 layout.Setr(aLine1.r()); |
|
122 layout.SetC(aLine1.C()); |
|
123 layout.SetJ(aAttrs.iJustification); |
|
124 layout.SetFont(aAttrs.iFontId); |
|
125 return layout; |
|
126 } |
|
127 |
|
128 struct TAknWindowComponentLayoutAttrs |
|
129 { |
|
130 TInt16 iGap; |
|
131 }; |
|
132 |
|
133 TAknWindowComponentLayout TAknWindowComponentLayout::RemoveLayoutEmptys(TAknWindowComponentLayout aLine1) |
|
134 { |
|
135 if (aLine1.r() == ELayoutEmpty) |
|
136 { |
|
137 aLine1.Setr( TInt16(ELayoutP - aLine1.W() - aLine1.l())); |
|
138 } |
|
139 if (aLine1.b() == ELayoutEmpty) |
|
140 { |
|
141 aLine1.Setb(TInt16(ELayoutP - aLine1.H() - aLine1.t())); |
|
142 } |
|
143 |
|
144 if (aLine1.l() == ELayoutEmpty) |
|
145 { |
|
146 aLine1.Setl(TInt16(ELayoutP - aLine1.W() - aLine1.r())); |
|
147 } |
|
148 if (aLine1.t() == ELayoutEmpty) |
|
149 { |
|
150 aLine1.Sett(TInt16(ELayoutP - aLine1.H() - aLine1.b())); |
|
151 } |
|
152 if (aLine1.W() == ELayoutEmpty) |
|
153 { |
|
154 aLine1.SetW(TInt16(ELayoutP - aLine1.l() - aLine1.r())); |
|
155 } |
|
156 if (aLine1.H() == ELayoutEmpty) |
|
157 { |
|
158 aLine1.SetH(TInt16(ELayoutP - aLine1.t() - aLine1.b())); |
|
159 } |
|
160 #if defined (_DEBUG) |
|
161 TBool noerror1 = aLine1.il + aLine1.iW + aLine1.ir == ELayoutP; |
|
162 TBool noerror2 = aLine1.it + aLine1.iH + aLine1.ib == ELayoutP; |
|
163 if (!noerror1 || !noerror2) |
|
164 { |
|
165 noerror1 = noerror1; // good place for breakpoint. |
|
166 } |
|
167 /* |
|
168 __ASSERT_DEBUG(noerror1, Panic(EInvalidLayoutData)); |
|
169 __ASSERT_DEBUG(noerror2, Panic(EInvalidLayoutData)); |
|
170 |
|
171 */ |
|
172 #endif |
|
173 |
|
174 return aLine1; |
|
175 } |
|
176 |
|
177 EXPORT_C TAknTextComponentLayout TAknTextComponentLayout::RemoveLayoutEmptys(TAknTextComponentLayout aLine1) |
|
178 { |
|
179 if (aLine1.r() == ELayoutEmpty) |
|
180 { |
|
181 aLine1.Setr( TInt16(ELayoutP - aLine1.W() - aLine1.l())); |
|
182 } |
|
183 if (aLine1.b() == ELayoutEmpty) |
|
184 { |
|
185 aLine1.Setb(TInt16(ELayoutP - aLine1.H() - aLine1.t())); |
|
186 } |
|
187 |
|
188 if (aLine1.l() == ELayoutEmpty) |
|
189 { |
|
190 aLine1.Setl(TInt16(ELayoutP - aLine1.W() - aLine1.r())); |
|
191 } |
|
192 if (aLine1.t() == ELayoutEmpty) |
|
193 { |
|
194 aLine1.Sett(TInt16(ELayoutP - aLine1.H() - aLine1.b())); |
|
195 } |
|
196 if (aLine1.W() == ELayoutEmpty) |
|
197 { |
|
198 aLine1.SetW(TInt16(ELayoutP - aLine1.l() - aLine1.r())); |
|
199 } |
|
200 if (aLine1.H() == ELayoutEmpty) |
|
201 { |
|
202 aLine1.SetH(TInt16(ELayoutP - aLine1.t() - aLine1.b())); |
|
203 } |
|
204 |
|
205 |
|
206 return aLine1; |
|
207 |
|
208 } |
|
209 |
|
210 |
|
211 // |
|
212 // class TAknLayoutScalableTableLimits |
|
213 // |
|
214 |
|
215 EXPORT_C TAknLayoutScalableTableLimits::TAknLayoutScalableTableLimits(TInt aFirstIndex, TInt aLastIndex) |
|
216 : |
|
217 iFirstIndex(aFirstIndex), |
|
218 iLastIndex(aLastIndex) |
|
219 { |
|
220 |
|
221 } |
|
222 |
|
223 EXPORT_C TAknLayoutScalableTableLimits::TAknLayoutScalableTableLimits() |
|
224 { |
|
225 |
|
226 } |
|
227 |
|
228 EXPORT_C TAknLayoutTableLimits TAknLayoutScalableTableLimits::LayoutLimits() const |
|
229 { |
|
230 TAknLayoutTableLimits limits; |
|
231 limits.iFirstIndex = iFirstIndex; |
|
232 limits.iLastIndex = iLastIndex; |
|
233 return limits; |
|
234 } |
|
235 |
|
236 EXPORT_C TInt TAknLayoutScalableTableLimits::FirstIndex() const |
|
237 { |
|
238 return iFirstIndex; |
|
239 } |
|
240 |
|
241 EXPORT_C TInt TAknLayoutScalableTableLimits::LastIndex() const |
|
242 { |
|
243 return iLastIndex; |
|
244 } |
|
245 |
|
246 EXPORT_C void TAknLayoutScalableTableLimits::SetFirstIndex(TInt aIndex) |
|
247 { |
|
248 iFirstIndex = aIndex; |
|
249 } |
|
250 |
|
251 EXPORT_C void TAknLayoutScalableTableLimits::SetLastIndex(TInt aIndex) |
|
252 { |
|
253 iLastIndex = aIndex; |
|
254 } |
|
255 |
|
256 // |
|
257 // class TAknLayoutScalableParameterLimits |
|
258 // |
|
259 |
|
260 EXPORT_C TAknLayoutScalableParameterLimits::TAknLayoutScalableParameterLimits() |
|
261 : |
|
262 iFirstVariety(0), iLastVariety(0), |
|
263 iFirstColumn(0), iLastColumn(0), |
|
264 iFirstRow(0), iLastRow(0) |
|
265 { |
|
266 |
|
267 } |
|
268 |
|
269 EXPORT_C TAknLayoutScalableParameterLimits::TAknLayoutScalableParameterLimits( |
|
270 TInt aFirstVariety, TInt aLastVariety, |
|
271 TInt aFirstColumn, TInt aLastColumn, |
|
272 TInt aFirstRow, TInt aLastRow) |
|
273 : |
|
274 iFirstVariety(aFirstVariety), iLastVariety(aLastVariety), |
|
275 iFirstColumn(aFirstColumn), iLastColumn(aLastColumn), |
|
276 iFirstRow(aFirstRow), iLastRow(aLastRow) |
|
277 { |
|
278 |
|
279 } |
|
280 |
|
281 EXPORT_C TInt TAknLayoutScalableParameterLimits::FirstVariety() const |
|
282 { |
|
283 return iFirstVariety; |
|
284 } |
|
285 |
|
286 EXPORT_C TInt TAknLayoutScalableParameterLimits::LastVariety() const |
|
287 { |
|
288 return iLastVariety; |
|
289 } |
|
290 |
|
291 EXPORT_C TInt TAknLayoutScalableParameterLimits::FirstColumn() const |
|
292 { |
|
293 return iFirstColumn; |
|
294 } |
|
295 |
|
296 EXPORT_C TInt TAknLayoutScalableParameterLimits::LastColumn() const |
|
297 { |
|
298 return iLastColumn; |
|
299 } |
|
300 |
|
301 EXPORT_C TInt TAknLayoutScalableParameterLimits::FirstRow() const |
|
302 { |
|
303 return iFirstRow; |
|
304 } |
|
305 |
|
306 EXPORT_C TInt TAknLayoutScalableParameterLimits::LastRow() const |
|
307 { |
|
308 return iLastRow; |
|
309 } |
|
310 |
|
311 EXPORT_C void TAknLayoutScalableParameterLimits::SetFirstVariety(TInt aFirstVariety) |
|
312 { |
|
313 iFirstVariety = aFirstVariety; |
|
314 } |
|
315 |
|
316 EXPORT_C void TAknLayoutScalableParameterLimits::SetLastVariety(TInt aLastVariety) |
|
317 { |
|
318 iLastVariety = aLastVariety; |
|
319 } |
|
320 |
|
321 EXPORT_C void TAknLayoutScalableParameterLimits::SetFirstColumn(TInt aFirstColumn) |
|
322 { |
|
323 iFirstColumn = aFirstColumn; |
|
324 } |
|
325 |
|
326 EXPORT_C void TAknLayoutScalableParameterLimits::SetLastColumn(TInt aLastColumn) |
|
327 { |
|
328 iLastColumn = aLastColumn; |
|
329 } |
|
330 |
|
331 EXPORT_C void TAknLayoutScalableParameterLimits::SetFirstRow(TInt aFirstRow) |
|
332 { |
|
333 iFirstRow = aFirstRow; |
|
334 } |
|
335 |
|
336 EXPORT_C void TAknLayoutScalableParameterLimits::SetLastRow(TInt aLastRow) |
|
337 { |
|
338 iLastRow = aLastRow; |
|
339 } |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 // |
|
345 // class TAknWindowComponentLayout |
|
346 // |
|
347 |
|
348 EXPORT_C TAknWindowComponentLayout::TAknWindowComponentLayout() |
|
349 : |
|
350 iC(ELayoutEmpty), |
|
351 il(0), |
|
352 it(0), |
|
353 ir(0), |
|
354 ib(0), |
|
355 iW(ELayoutEmpty), |
|
356 iH(ELayoutEmpty) |
|
357 { |
|
358 |
|
359 } |
|
360 |
|
361 EXPORT_C TAknWindowLineLayout TAknWindowComponentLayout::LayoutLine() const |
|
362 { |
|
363 TAknWindowLineLayout line; |
|
364 line.iC = iC; |
|
365 line.il = il; |
|
366 line.it = it; |
|
367 line.ir = ir; |
|
368 line.ib = ib; |
|
369 line.iW = iW; |
|
370 line.iH = iH; |
|
371 |
|
372 // Swap parent relative and empty based on equation l+W+r = p.W |
|
373 TInt16 *empty = NULL; |
|
374 if (line.il == ELayoutEmpty) empty = &line.il; |
|
375 if (line.iW == ELayoutEmpty) empty = &line.iW; |
|
376 if (line.ir == ELayoutEmpty) empty = &line.ir; |
|
377 |
|
378 TInt16 *parentRelative = NULL; |
|
379 if (IsParentRelative(line.il)) parentRelative = &line.il; |
|
380 if (IsParentRelative(line.iW)) parentRelative = &line.iW; |
|
381 if (IsParentRelative(line.ir)) parentRelative = &line.ir; |
|
382 |
|
383 TInt16 *number = NULL; |
|
384 if (&line.il != empty && (&line.il) != parentRelative) number=&line.il; |
|
385 if (&line.iW != empty && (&line.iW) != parentRelative) number=&line.iW; |
|
386 if (&line.ir != empty && (&line.ir) != parentRelative) number=&line.ir; |
|
387 |
|
388 if (empty && parentRelative && number) |
|
389 { |
|
390 *empty = TInt16(ELayoutP - *parentRelative - *number); |
|
391 *parentRelative = ELayoutEmpty; |
|
392 } |
|
393 |
|
394 // Swap parent relative and empty based on equation t+H+b = p.H |
|
395 empty = NULL; |
|
396 if (line.it == ELayoutEmpty) empty = &line.it; |
|
397 if (line.iH == ELayoutEmpty) empty = &line.iH; |
|
398 if (line.ib == ELayoutEmpty) empty = &line.ib; |
|
399 |
|
400 parentRelative = NULL; |
|
401 if (IsParentRelative(line.it)) parentRelative = &line.it; |
|
402 if (IsParentRelative(line.iH)) parentRelative = &line.iH; |
|
403 if (IsParentRelative(line.ib)) parentRelative = &line.ib; |
|
404 |
|
405 number = NULL; |
|
406 if (&line.it != empty && (&line.it) != parentRelative) number=&line.it; |
|
407 if (&line.iH != empty && (&line.iH) != parentRelative) number=&line.iH; |
|
408 if (&line.ib != empty && (&line.ib) != parentRelative) number=&line.ib; |
|
409 |
|
410 if (empty && parentRelative && number) |
|
411 { |
|
412 *empty = TInt16(ELayoutP - *parentRelative - *number); |
|
413 *parentRelative = ELayoutEmpty; |
|
414 } |
|
415 |
|
416 |
|
417 |
|
418 return line; |
|
419 } |
|
420 |
|
421 EXPORT_C TAknWindowLineLayout TAknWindowComponentLayout::LayoutLineNoEmptys() const |
|
422 { |
|
423 TAknWindowLineLayout line; |
|
424 line.iC = iC; |
|
425 line.il = (il == ELayoutEmpty) ? TInt16(ELayoutP - iW - ir) : il; |
|
426 line.it = (it == ELayoutEmpty) ? TInt16(ELayoutP - iH - ib) : it; |
|
427 line.ir = (ir == ELayoutEmpty) ? TInt16(ELayoutP - iW - il) : ir; |
|
428 line.ib = (ib == ELayoutEmpty) ? TInt16(ELayoutP - iH - it) : ib; |
|
429 line.iW = (iW == ELayoutEmpty) ? TInt16(ELayoutP - il - ir) : iW; |
|
430 line.iH = (iH == ELayoutEmpty) ? TInt16(ELayoutP - it - ib) : iH; |
|
431 return line; |
|
432 } |
|
433 |
|
434 EXPORT_C TAknLayoutScalableComponentType TAknWindowComponentLayout::LayoutComponentType() const |
|
435 { |
|
436 TAknLayoutScalableComponentType type = (TAknLayoutScalableComponentType)iType; |
|
437 return type; |
|
438 } |
|
439 |
|
440 EXPORT_C TInt16 TAknWindowComponentLayout::C() const |
|
441 { |
|
442 return iC; |
|
443 } |
|
444 |
|
445 EXPORT_C TInt16 TAknWindowComponentLayout::l() const |
|
446 { |
|
447 return il; |
|
448 } |
|
449 |
|
450 EXPORT_C TInt16 TAknWindowComponentLayout::t() const |
|
451 { |
|
452 return it; |
|
453 } |
|
454 |
|
455 EXPORT_C TInt16 TAknWindowComponentLayout::r() const |
|
456 { |
|
457 return ir; |
|
458 } |
|
459 |
|
460 EXPORT_C TInt16 TAknWindowComponentLayout::b() const |
|
461 { |
|
462 return ib; |
|
463 } |
|
464 |
|
465 EXPORT_C TInt16 TAknWindowComponentLayout::W() const |
|
466 { |
|
467 return iW; |
|
468 } |
|
469 |
|
470 EXPORT_C TInt16 TAknWindowComponentLayout::H() const |
|
471 { |
|
472 return iH; |
|
473 } |
|
474 |
|
475 EXPORT_C void TAknWindowComponentLayout::SetC(TInt16 aC) |
|
476 { |
|
477 iC = aC; |
|
478 } |
|
479 |
|
480 EXPORT_C void TAknWindowComponentLayout::Setl(TInt16 al) |
|
481 { |
|
482 il = al; |
|
483 } |
|
484 |
|
485 EXPORT_C void TAknWindowComponentLayout::Sett(TInt16 at) |
|
486 { |
|
487 it = at; |
|
488 } |
|
489 |
|
490 EXPORT_C void TAknWindowComponentLayout::Setr(TInt16 ar) |
|
491 { |
|
492 ir = ar; |
|
493 } |
|
494 |
|
495 EXPORT_C void TAknWindowComponentLayout::Setb(TInt16 ab) |
|
496 { |
|
497 ib = ab; |
|
498 } |
|
499 |
|
500 EXPORT_C void TAknWindowComponentLayout::SetW(TInt16 aW) |
|
501 { |
|
502 iW = aW; |
|
503 } |
|
504 |
|
505 EXPORT_C void TAknWindowComponentLayout::SetH(TInt16 aH) |
|
506 { |
|
507 iH = aH; |
|
508 } |
|
509 |
|
510 |
|
511 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::Compose(TAknWindowComponentLayout aLine1, TAknWindowComponentLayout aLine2) |
|
512 { |
|
513 if (aLine1.r() == ELayoutEmpty) |
|
514 { |
|
515 aLine1.Setr( TInt16(ELayoutP - aLine1.W() - aLine1.l())); |
|
516 } |
|
517 if (aLine1.b() == ELayoutEmpty) |
|
518 { |
|
519 aLine1.Setb(TInt16(ELayoutP - aLine1.H() - aLine1.t())); |
|
520 } |
|
521 |
|
522 if (aLine1.l() == ELayoutEmpty) |
|
523 { |
|
524 aLine1.Setl(TInt16(ELayoutP - aLine1.W() - aLine1.r())); |
|
525 } |
|
526 if (aLine1.t() == ELayoutEmpty) |
|
527 { |
|
528 aLine1.Sett(TInt16(ELayoutP - aLine1.H() - aLine1.b())); |
|
529 } |
|
530 |
|
531 |
|
532 if (aLine2.r() == ELayoutEmpty) |
|
533 { |
|
534 aLine2.Setr(TInt16(ELayoutP /*-p2Xdiff*/ - aLine2.W() - aLine2.l())); |
|
535 } |
|
536 if (aLine2.b() == ELayoutEmpty) |
|
537 { |
|
538 aLine2.Setb(TInt16(ELayoutP /*-p2Ydiff*/ - aLine2.H() - aLine2.t())); |
|
539 } |
|
540 |
|
541 if (aLine2.l() == ELayoutEmpty) |
|
542 { |
|
543 aLine2.Setl(TInt16(ELayoutP /*-p2Xdiff*/ - aLine2.W()- aLine2.r())); |
|
544 } |
|
545 if (aLine2.t() == ELayoutEmpty) |
|
546 { |
|
547 aLine2.Sett(TInt16(ELayoutP /*-p2Ydiff*/ - aLine2.H() - aLine2.b())); |
|
548 } |
|
549 #if defined(_DEBUG) |
|
550 // these are only in debug build, because the rest of the Compose() does not need W and H; so this should have no effect. |
|
551 if (aLine1.W() == ELayoutEmpty) |
|
552 { |
|
553 aLine1.SetW(TInt16(ELayoutP - aLine1.l() - aLine1.r()) ); |
|
554 } |
|
555 if (aLine1.H() == ELayoutEmpty) |
|
556 { |
|
557 aLine1.SetH(TInt16(ELayoutP - aLine1.t() - aLine1.b()) ); |
|
558 } |
|
559 if (aLine2.W() == ELayoutEmpty) |
|
560 { |
|
561 aLine2.SetW(TInt16(ELayoutP - aLine2.l() - aLine2.r()) ); |
|
562 } |
|
563 if (aLine2.H() == ELayoutEmpty) |
|
564 { |
|
565 aLine2.SetH(TInt16(ELayoutP - aLine2.t() - aLine2.b()) ); |
|
566 } |
|
567 TBool noerror1 = aLine1.il + aLine1.iW + aLine1.ir == ELayoutP; |
|
568 TBool noerror2 = aLine1.it + aLine1.iH + aLine1.ib == ELayoutP; |
|
569 TBool noerror3 = aLine2.il + aLine2.iW + aLine2.ir == ELayoutP; |
|
570 TBool noerror4 = aLine2.it + aLine2.iH + aLine2.ib == ELayoutP; |
|
571 if (!noerror1 || !noerror2 || !noerror3 || !noerror4) |
|
572 { |
|
573 noerror1 = noerror1; // good place for breakpoint. |
|
574 } |
|
575 /* |
|
576 __ASSERT_DEBUG(noerror1, Panic(EInvalidLayoutData)); |
|
577 __ASSERT_DEBUG(noerror2, Panic(EInvalidLayoutData)); |
|
578 |
|
579 __ASSERT_DEBUG(noerror3, Panic(EInvalidLayoutData)); |
|
580 __ASSERT_DEBUG(noerror4, Panic(EInvalidLayoutData)); |
|
581 */ |
|
582 #endif |
|
583 |
|
584 // Upgrade all p-XX type expressions, these are only for aLine2. Parent of aLine2 is different |
|
585 // from aLine1's parent, so we need to do conversion from parent of aLine2 to parent of aLine1 |
|
586 if (IsParentRelative(aLine2.r())) |
|
587 { |
|
588 TInt p2Xdiff = aLine1.l() + aLine1.r(); |
|
589 aLine2.Setr(TInt16(aLine2.r() - p2Xdiff)); |
|
590 } |
|
591 if (IsParentRelative(aLine2.b())) |
|
592 { |
|
593 TInt p2Ydiff = aLine1.t() + aLine1.b(); |
|
594 aLine2.Setb(TInt16(aLine2.b() - p2Ydiff)); |
|
595 } |
|
596 if (IsParentRelative(aLine2.l())) |
|
597 { |
|
598 TInt p2Xdiff = aLine1.l() + aLine1.r(); |
|
599 aLine2.Setl(TInt16(aLine2.l() - p2Xdiff)); |
|
600 } |
|
601 if (IsParentRelative(aLine2.t())) |
|
602 { |
|
603 TInt p2Ydiff = aLine1.t() + aLine1.b(); |
|
604 aLine2.Sett(TInt16(aLine2.t() - p2Ydiff)); |
|
605 } |
|
606 |
|
607 if (IsParentRelative(aLine1.r()) && IsParentRelative(aLine2.r())) |
|
608 { |
|
609 aLine1.Setr(TInt16(aLine1.r() - ELayoutP)); |
|
610 } |
|
611 if (IsParentRelative(aLine1.b()) && IsParentRelative(aLine2.b())) |
|
612 { |
|
613 aLine1.Setb(TInt16(aLine1.b() - ELayoutP)); |
|
614 } |
|
615 |
|
616 // It might be possible that here we need parent relative checks for t and l too. |
|
617 // We might need to do some changes to allow multiply() to work, for example ELayoutEmpty's |
|
618 // need to handle the p-values. (i.e. r == ElayoutEmpty -check doesnt work anymore etc) |
|
619 |
|
620 TAknWindowComponentLayout result; |
|
621 result.Setl(TInt16(aLine1.l() + aLine2.l())); |
|
622 result.Sett(TInt16(aLine1.t() + aLine2.t())); |
|
623 result.Setr(TInt16(aLine1.r() + aLine2.r())); |
|
624 result.Setb(TInt16(aLine1.b() + aLine2.b())); |
|
625 result.SetW(ELayoutEmpty); |
|
626 result.SetH(ELayoutEmpty); |
|
627 result.SetC(aLine2.C()); |
|
628 return result; |
|
629 } |
|
630 |
|
631 |
|
632 TBool IsValueEmpty(TInt aValue) |
|
633 { |
|
634 return aValue >= ELayoutEmpty && aValue < (ELayoutEmpty +8192); |
|
635 } |
|
636 //TReal FromEmptyToDividingFloat(TInt aValue) |
|
637 //{ |
|
638 //} |
|
639 //TReal MultiplyRealAndReal(TReal aReal, TReal aReal2) |
|
640 //{ |
|
641 // return aReal * aReal2; |
|
642 //} |
|
643 |
|
644 //TInt MultiplyIntAndReal(TInt aValue, TReal aReal) |
|
645 //{ |
|
646 // return aValue * aReal; |
|
647 //} |
|
648 /* |
|
649 class TScaledInt |
|
650 { |
|
651 public: |
|
652 TScaledInt(TInt16 aValue) : iValue(aValue) { } |
|
653 |
|
654 friend inline TScaledInt operator*(TScaledInt aValue, TScaledInt aValue2) |
|
655 { |
|
656 return TInt16( (TInt32(aValue.Value()) * TInt32(aValue2.Value())) >> 12 ); |
|
657 } |
|
658 |
|
659 friend TInt16 MultiplyByScaled(TInt16 aValue, TScaledInt aValue2) |
|
660 { |
|
661 return TInt16( TInt32(aValue) * TInt32(aValue2.Value()) ); |
|
662 } |
|
663 |
|
664 TInt16 Value() { return iValue; } |
|
665 |
|
666 private: |
|
667 TInt16 iValue; |
|
668 }; |
|
669 */ |
|
670 /* |
|
671 struct TTriplet |
|
672 { |
|
673 TScaledInt iX; |
|
674 TScaledInt iY; |
|
675 TScaledInt iP; |
|
676 }; |
|
677 */ |
|
678 TAknWindowComponentLayout::TTriplet::TTriplet(TInt16 aX, TInt16 aY, TInt16 aP) |
|
679 : iX(aX), iY(aY), iP(aP) { } |
|
680 TAknWindowComponentLayout::TTriplet::TTriplet(const TTriplet &aValue) |
|
681 : iX(aValue.iX), iY(aValue.iY), iP(aValue.iP) |
|
682 { |
|
683 } |
|
684 |
|
685 TInt16 AddEmptyFlag(TInt16 aValue) { return (TInt16)(aValue + ELayoutEmpty); } |
|
686 TInt16 RemoveEmptyFlag(TInt16 aValue) { return (TInt16)(aValue - ELayoutEmpty); } |
|
687 |
|
688 TInt16 AddPFlag(TInt16 aValue) { return (TInt16)(aValue + ELayoutP); } |
|
689 TInt16 RemovePFlag(TInt16 aValue) { return (TInt16)(aValue - ELayoutP); } |
|
690 |
|
691 |
|
692 TInt16 TAknWindowComponentLayout::MultiplyValue(TInt16 aValue, TAknWindowComponentLayout::TScaledInt aMultiplier, TAknWindowComponentLayout::TScaledInt aPMultiplier) |
|
693 { |
|
694 TInt16 result; |
|
695 if (IsValueEmpty(aValue)) |
|
696 { |
|
697 // remove ELayoutEmpty flag from aValue |
|
698 TInt16 newval = RemoveEmptyFlag(aValue); |
|
699 |
|
700 // Multiply aValue by aPMultiplier (aValue is scaled integer). |
|
701 TAknWindowComponentLayout::TScaledInt sval(newval); |
|
702 TAknWindowComponentLayout::TScaledInt res = sval * aPMultiplier; |
|
703 |
|
704 result = AddEmptyFlag((TInt16)res.Value()); |
|
705 // add ELayoutEmpty flag |
|
706 // done |
|
707 } |
|
708 else if (!IsParentRelative(aValue)) |
|
709 { // normal values |
|
710 // Multiply aValue by aMultiplier |
|
711 result = MultiplyByScaled(aValue, aMultiplier).NonScaled(); |
|
712 } |
|
713 else |
|
714 { // parent-relative values |
|
715 // remove ELayoutP flag |
|
716 TInt16 newval = RemovePFlag(aValue); |
|
717 |
|
718 // multiply aValue by aMultiplier |
|
719 TInt16 res = MultiplyByScaled(newval, aMultiplier).NonScaled(); |
|
720 |
|
721 // add ELayoutP flag |
|
722 result = AddPFlag(res); |
|
723 // done |
|
724 } |
|
725 return result; |
|
726 } |
|
727 |
|
728 // Multiply requires the following representation for TAknWindowComponentLayout: |
|
729 // 1) There are 3 dimensions in each TAknWindowComponentLayout: |
|
730 // a) X-dimension (l,W,r) |
|
731 // b) Y-dimension (t,H,b) |
|
732 // c) P-dimension p-XX expressions |
|
733 // 2) In each empty cell, there are "value" for P encoded as a scaled int from 0.0 .. 1.0 |
|
734 // 3) In each P-cell there are value encoding "p-10" expressions as a ELayoutP flag together with value 10. |
|
735 |
|
736 TAknWindowComponentLayout TAknWindowComponentLayout::Multiply(TAknWindowComponentLayout aLine, const TTriplet &aTriplet) |
|
737 { |
|
738 aLine = RemoveLayoutEmptys(aLine); |
|
739 aLine.iW = ELayoutEmpty; |
|
740 aLine.iH = ELayoutEmpty; |
|
741 TAknWindowComponentLayout layout; |
|
742 // multiply l,W,r by iX |
|
743 layout.il = MultiplyValue(aLine.il, aTriplet.iX, aTriplet.iP); |
|
744 layout.iW = MultiplyValue(aLine.iW, aTriplet.iX, aTriplet.iP); |
|
745 layout.ir = MultiplyValue(aLine.ir, aTriplet.iX, aTriplet.iP); |
|
746 |
|
747 // multiply t,H,b by iY |
|
748 layout.it = MultiplyValue(aLine.it, aTriplet.iY, aTriplet.iP); |
|
749 layout.iH = MultiplyValue(aLine.iH, aTriplet.iY, aTriplet.iP); |
|
750 layout.ib = MultiplyValue(aLine.ib, aTriplet.iY, aTriplet.iP); |
|
751 |
|
752 layout.iC = aLine.iC; |
|
753 |
|
754 // multiply p by iP |
|
755 // nothing to be done, since MultiplyValue handles P-values. |
|
756 |
|
757 // REQUIRES THAT LAYOUT LINES HAVE ALWAYS ONE EMPTY CELL in l,W,r and in t,H,b |
|
758 return layout; |
|
759 } |
|
760 /* |
|
761 struct TRangeTriplet |
|
762 { |
|
763 TInt16 iX; // 0.0 .. 1.0 |
|
764 TInt16 iY; // 0.0 .. 1.0 |
|
765 TInt16 iP; |
|
766 }; |
|
767 */ |
|
768 TAknWindowComponentLayout::TRangeTriplet OneMinus(TAknWindowComponentLayout::TRangeTriplet aValue) |
|
769 { |
|
770 TAknWindowComponentLayout::TRangeTriplet triplet; |
|
771 triplet.iX = (TInt16) ((1 << 12) - aValue.iX); |
|
772 triplet.iY = (TInt16) ((1 << 12) - aValue.iY); |
|
773 triplet.iP = (TInt16) ((1 << 12) - aValue.iP); |
|
774 return triplet; |
|
775 } |
|
776 TAknWindowComponentLayout::TTriplet TAknWindowComponentLayout::FromRangeToTriplet(const TRangeTriplet &aRange) |
|
777 { |
|
778 TTriplet triplet(aRange.iX, aRange.iY, aRange.iP); |
|
779 return triplet; |
|
780 } |
|
781 |
|
782 /* |
|
783 TRangeTriplet TripletFromPath(TPathDefinition aPath, TReal aPos) |
|
784 { |
|
785 |
|
786 } |
|
787 */ |
|
788 |
|
789 TBool HasParentRelative(TInt alt, TInt aWH, TInt arb) |
|
790 { |
|
791 if (IsParentRelative(alt)) return ETrue; |
|
792 if (IsParentRelative(aWH)) return ETrue; |
|
793 if (IsParentRelative(arb)) return ETrue; |
|
794 return EFalse; |
|
795 } |
|
796 |
|
797 EXPORT_C TAknTextComponentLayout TAknTextComponentLayout::Anim(TAknTextComponentLayout aLine, |
|
798 TAknTextComponentLayout aLine2, |
|
799 const TAknWindowComponentLayout::TRangeTriplet &aTriplet) |
|
800 { |
|
801 TAknTextComponentLayoutAttrs attrs = ExtractAttributes(aLine); |
|
802 TAknWindowComponentLayout window1 = TAknWindowComponentLayout::ExtractWindow(aLine); |
|
803 TAknWindowComponentLayout window2 = TAknWindowComponentLayout::ExtractWindow(aLine2); |
|
804 TAknWindowComponentLayout animated = TAknWindowComponentLayout::Anim(window1, window2, aTriplet); |
|
805 TAknTextComponentLayout text = TAknWindowComponentLayout::CombineAttrs(animated, attrs); |
|
806 return text; |
|
807 } |
|
808 |
|
809 // Layout animation should be something like this: |
|
810 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::Anim(TAknWindowComponentLayout aLine, |
|
811 TAknWindowComponentLayout aLine2, |
|
812 const TRangeTriplet &aTriplet) |
|
813 { |
|
814 TTriplet triplet(FromRangeToTriplet(aTriplet)); |
|
815 TTriplet oneminustriplet(FromRangeToTriplet(OneMinus(aTriplet))); |
|
816 TAknWindowComponentLayout m1 = Multiply(aLine, triplet); |
|
817 TAknWindowComponentLayout m2 = Multiply(aLine2, oneminustriplet); |
|
818 TAknWindowComponentLayout c = Compose(m1, m2); |
|
819 |
|
820 // the code below assumes that Compose() returns ELayoutEmpty as W and H. |
|
821 |
|
822 // X-dimension |
|
823 if (HasParentRelative(m1.il, m1.iW, m1.ir) && |
|
824 !HasParentRelative(m2.il, m2.iW, m2.ir)) |
|
825 { |
|
826 c.iW = (TInt16)(ELayoutEmpty + TInt16(triplet.iX.Value())); |
|
827 } |
|
828 if (!HasParentRelative(m1.il, m1.iW, m1.ir) && |
|
829 HasParentRelative(m2.il, m2.iW, m2.ir)) |
|
830 { |
|
831 c.iW = (TInt16)(ELayoutEmpty + TInt16(oneminustriplet.iX.Value())); |
|
832 } |
|
833 |
|
834 // Y-dimension |
|
835 if (HasParentRelative(m1.it, m1.iH, m1.ib) && |
|
836 !HasParentRelative(m2.it, m2.iH, m2.ib)) |
|
837 { |
|
838 c.iH = (TInt16)(ELayoutEmpty + TInt16(triplet.iY.Value())); |
|
839 } |
|
840 if (!HasParentRelative(m1.it, m1.iH, m1.ib) && |
|
841 HasParentRelative(m2.it, m2.iH, m2.ib)) |
|
842 { |
|
843 c.iH = (TInt16)(ELayoutEmpty + TInt16(oneminustriplet.iY.Value())); |
|
844 } |
|
845 |
|
846 // NOTE, to really make this work, AknLayoutUtils need to handle the ELayoutEmpty + triplet.iX in the following way: |
|
847 /* |
|
848 TInt FindMultiplier(TInt alt, TInt aWH, TInt arb) |
|
849 { |
|
850 TInt mult = 4096; |
|
851 if (alt == ELayoutEmpty || aWH == ELayoutEmpty || arb == ELayoutEmpty) { return mult; } |
|
852 if (IsValueEmpty(alt)) { mult = RemoveEmptyFlag(alt); } |
|
853 if (IsValueEmpty(aWH)) { mult = RemoveEmptyFlag(aWH); } |
|
854 if (IsValueEmpty(arb)) { mult = RemoveEmptyFlag(arb); } |
|
855 return mult; |
|
856 } |
|
857 TInt MultiplyParent(TInt parent, TInt alt, TInt awh, TInt arb) |
|
858 { |
|
859 TInt16 multiplier = FindMultiplier(ilt,iWH,irb); |
|
860 parent = MultiplyByScaled(parent, multiplier).NonScaled(); |
|
861 return parent; |
|
862 } |
|
863 ... inside AknLayoutUtils (or RectFromCoords() method actually), need to put the following: |
|
864 if (IsParentRelative(il)) { |
|
865 TInt parent = aParent.Width(); |
|
866 parent = MultiplyParent(parent, il, iW, ir); |
|
867 il = il + parent - ELayoutP; |
|
868 } |
|
869 */ |
|
870 // Or something like that. (and that for all the components il, it, ir, ib, iW, iH.) |
|
871 // BUT, This is really quite complicated thing to do as we would need to do the same |
|
872 // for TEXT LINES TOO. (a text line has a layout line inside them, so those probably would need to be animated too) |
|
873 // TEXT LINES ARE CLEARLY SOMETHING WE NEED TO THINK ABOUT VERY CAREFULLY. Currently Anim() only works with window lines :-) |
|
874 // TEXT LINES HAS A PROBLEM THAT THE FINDMULTIPLIER() is impossible to do with TAknTextLineLayout data structure. |
|
875 // and the findmultiplier needs the aParent.Width() value which is only available at TextRectFromCoords. |
|
876 // (in TAknTextLineLayout we only have ONE Dimension(x-dimension) fully implemented. y-dimension is missing top value.) |
|
877 |
|
878 // |
|
879 // |
|
880 // Anim method for text lines would work about the same as ComposeText() compared to Compose(). I.e. it'd separate |
|
881 // window line layout first from the text line layout and then call Anim on the window line and then combine |
|
882 // the results back to text line :-) (and then try to think of how to animate justification attribute :-) |
|
883 // |
|
884 |
|
885 return c; |
|
886 } |
|
887 |
|
888 |
|
889 |
|
890 EXPORT_C TAknTextComponentLayout TAknWindowComponentLayout::ComposeText(TAknWindowComponentLayout aLine1, TAknTextComponentLayout aLine2) |
|
891 { |
|
892 TAknTextComponentLayoutAttrs attrs = ExtractAttributes(aLine2); |
|
893 TAknWindowComponentLayout window1 = ExtractWindow(aLine2); |
|
894 TAknWindowComponentLayout combined = Compose(aLine1, window1); |
|
895 TAknTextComponentLayout text = CombineAttrs(combined, attrs); |
|
896 return text; |
|
897 } |
|
898 |
|
899 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::Intersect(TAknWindowComponentLayout aLine, TAknWindowComponentLayout aLine2) |
|
900 { |
|
901 aLine = RemoveLayoutEmptys(aLine); |
|
902 aLine2 = RemoveLayoutEmptys(aLine2); |
|
903 // Should get rid of W and H |
|
904 // Something to do with ELayoutEmpty's and p-10's. |
|
905 TAknWindowComponentLayout result; |
|
906 result.Setl(Max(aLine.l(), aLine2.l())); |
|
907 result.Sett(Max(aLine.t(), aLine2.t())); |
|
908 result.SetW(ELayoutEmpty); |
|
909 result.SetH(ELayoutEmpty); |
|
910 result.Setb(Max(aLine.b(), aLine2.b())); |
|
911 result.Setr(Max(aLine.r(), aLine2.r())); |
|
912 result.SetC(aLine2.C()); |
|
913 return result; |
|
914 } |
|
915 |
|
916 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::Minus(TAknWindowComponentLayout aLine, TAknWindowComponentLayout aParentDiff) |
|
917 { |
|
918 aLine = RemoveLayoutEmptys(aLine); |
|
919 aParentDiff = RemoveLayoutEmptys(aParentDiff); |
|
920 // Should get rid of W and H |
|
921 // Something to do with ELayoutEmpty's and p-10's. |
|
922 TAknWindowComponentLayout result; |
|
923 result.Setl(MinusInt(aLine.l(),aParentDiff.l())); |
|
924 result.Sett(MinusInt(aLine.t(),aParentDiff.t())); |
|
925 result.SetW(ELayoutEmpty); |
|
926 result.SetH(ELayoutEmpty); |
|
927 result.Setb(MinusInt(aLine.b(),aParentDiff.b())); |
|
928 result.Setr(MinusInt(aLine.r(),aParentDiff.r())); |
|
929 result.SetC(aLine.C()); |
|
930 |
|
931 TInt16 pxdiff = TInt16(aParentDiff.l() + aParentDiff.r()); |
|
932 TInt16 pydiff = TInt16(aParentDiff.t() + aParentDiff.b()); |
|
933 if (IsParentRelative(result.l())) { result.Setl( TInt16( result.l() + pxdiff ) ); } |
|
934 if (IsParentRelative(result.t())) { result.Sett( TInt16( result.t() + pydiff ) ); } |
|
935 if (IsParentRelative(result.r())) { result.Setr( TInt16( result.r() + pxdiff ) ); } |
|
936 if (IsParentRelative(result.b())) { result.Setb( TInt16( result.b() + pydiff ) ); } |
|
937 |
|
938 return result; |
|
939 } |
|
940 |
|
941 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::SiblingAsChild( |
|
942 TAknWindowComponentLayout aLine1, |
|
943 TAknWindowComponentLayout aLine2) |
|
944 { |
|
945 aLine1 = RemoveLayoutEmptys(aLine1); |
|
946 aLine2 = RemoveLayoutEmptys(aLine2); |
|
947 TAknWindowComponentLayout result; |
|
948 // Consider aLine2 as being wholly inside aLine1; Relative positions should all then be +ve |
|
949 // From this you can see, somewhat counter-intuitively, that the orderings of the |
|
950 // subtractions is line2 - line1. |
|
951 result.Setl(MinusInt(aLine2.l(),aLine1.l())); |
|
952 result.Sett(MinusInt(aLine2.t(),aLine1.t())); |
|
953 result.SetW(ELayoutEmpty); |
|
954 result.SetH(ELayoutEmpty); |
|
955 result.Setb(MinusInt(aLine2.b(),aLine1.b())); |
|
956 result.Setr(MinusInt(aLine2.r(),aLine1.r())); |
|
957 result.SetC(aLine1.C()); |
|
958 |
|
959 return result; |
|
960 } |
|
961 |
|
962 EXPORT_C void TAknWindowComponentLayout::SetZeroSized() |
|
963 { |
|
964 // Position is set to top left; size is 0,0 |
|
965 Setl(0); |
|
966 Sett(0); |
|
967 Setr(ELayoutP); |
|
968 Setb(ELayoutP); |
|
969 SetW(0); |
|
970 SetH(0); |
|
971 SetC(ELayoutEmpty); |
|
972 } |
|
973 |
|
974 // aValue is value 0..8: |
|
975 // |
|
976 // 0 1 2 |
|
977 // 3 4 5 |
|
978 // 6 7 8 |
|
979 // |
|
980 |
|
981 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::Split(TAknWindowComponentLayout aLine, TInt aValue) |
|
982 { |
|
983 __ASSERT_DEBUG(aValue >=0 && aValue <=8, Panic(EParameterOutOfRange)); |
|
984 TAknWindowComponentLayout result = aLine; |
|
985 |
|
986 if (aLine.il == ELayoutEmpty) |
|
987 { |
|
988 aLine.il = TInt16(ELayoutP - result.ir - result.iW); |
|
989 } |
|
990 if (aLine.ir == ELayoutEmpty) |
|
991 { |
|
992 aLine.ir = TInt16(ELayoutP - result.il - result.iW); |
|
993 } |
|
994 if (aLine.iW == ELayoutEmpty) |
|
995 { |
|
996 aLine.iW = TInt16(ELayoutP - result.ir - result.il); |
|
997 } |
|
998 if (aLine.it == ELayoutEmpty) |
|
999 { |
|
1000 aLine.it = TInt16(ELayoutP - result.ib - result.iH); |
|
1001 } |
|
1002 if (aLine.ib == ELayoutEmpty) |
|
1003 { |
|
1004 aLine.ib = TInt16(ELayoutP - result.it - result.iH); |
|
1005 } |
|
1006 if (aLine.iH == ELayoutEmpty) |
|
1007 { |
|
1008 aLine.iH = TInt16(ELayoutP - result.it - result.ib); |
|
1009 } |
|
1010 |
|
1011 |
|
1012 if (aValue == 0 || aValue == 1 || aValue == 2) |
|
1013 { |
|
1014 result.it = 0; |
|
1015 result.ib = ELayoutEmpty; |
|
1016 result.iH = aLine.it; |
|
1017 } |
|
1018 if (aValue == 6 || aValue == 7 || aValue == 8) |
|
1019 { |
|
1020 result.it = ELayoutEmpty; |
|
1021 result.ib = 0; |
|
1022 result.iH = aLine.ib; |
|
1023 } |
|
1024 if (aValue == 0 || aValue == 3 || aValue == 6) |
|
1025 { |
|
1026 result.il = 0; |
|
1027 result.ir = ELayoutEmpty; |
|
1028 result.iW = aLine.il; |
|
1029 } |
|
1030 if (aValue == 2 || aValue == 5 || aValue == 8) |
|
1031 { |
|
1032 result.il = ELayoutEmpty; |
|
1033 result.ir = 0; |
|
1034 result.iW = aLine.ir; |
|
1035 } |
|
1036 return result; |
|
1037 } |
|
1038 |
|
1039 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::MultiLineGrid(TAknWindowComponentLayout aFirst, TInt aColumnIndex, TInt aRowIndex, TInt aGapBetweenColumns, TInt aGapBetweenRows) |
|
1040 { |
|
1041 TAknWindowComponentLayout layout = MultiLineX(aFirst, aColumnIndex, aGapBetweenColumns); |
|
1042 TAknWindowComponentLayout layout2 = MultiLineY(layout, aRowIndex, aGapBetweenRows); |
|
1043 return layout2; |
|
1044 } |
|
1045 |
|
1046 |
|
1047 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::MultiLineY(TAknWindowComponentLayout aFirst, TInt aItem, TInt aGapBetweenItems) |
|
1048 { |
|
1049 TAknWindowComponentLayout first = RemoveLayoutEmptys(aFirst); |
|
1050 |
|
1051 TAknWindowComponentLayout layout; |
|
1052 layout.il = first.il; |
|
1053 layout.it = TInt16(first.it + aItem * (first.iH + aGapBetweenItems)); |
|
1054 layout.ib = ELayoutEmpty; |
|
1055 layout.ir = ELayoutEmpty; |
|
1056 layout.iW = first.iW; |
|
1057 layout.iH = first.iH; |
|
1058 return layout; |
|
1059 } |
|
1060 |
|
1061 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::MultiLineX(TAknWindowComponentLayout aFirst, TInt aItem, TInt aGapBetweenColumns) |
|
1062 { |
|
1063 TAknWindowComponentLayout first = RemoveLayoutEmptys(aFirst); |
|
1064 |
|
1065 TAknWindowComponentLayout layout; |
|
1066 layout.il = TInt16(first.il + aItem * (first.iW + aGapBetweenColumns)); |
|
1067 layout.it = first.it; |
|
1068 layout.ib = ELayoutEmpty; |
|
1069 layout.ir = ELayoutEmpty; |
|
1070 layout.iW = first.iW; |
|
1071 layout.iH = first.iH; |
|
1072 return layout; |
|
1073 } |
|
1074 |
|
1075 |
|
1076 // |
|
1077 // class TAknTextComponentLayout |
|
1078 // |
|
1079 |
|
1080 EXPORT_C TAknTextComponentLayout::TAknTextComponentLayout() |
|
1081 : |
|
1082 iC(ELayoutEmpty), |
|
1083 il(0), |
|
1084 it(0), |
|
1085 ir(0), |
|
1086 ib(0), |
|
1087 iW(ELayoutEmpty), |
|
1088 iH(ELayoutEmpty), |
|
1089 iJ(0), |
|
1090 iFont(0) |
|
1091 { |
|
1092 |
|
1093 } |
|
1094 |
|
1095 EXPORT_C TAknTextLineLayout TAknTextComponentLayout::LayoutLine() const |
|
1096 { |
|
1097 TAknTextLineLayout line; |
|
1098 line.iC = iC; |
|
1099 line.il = il; |
|
1100 // there is no top value |
|
1101 line.ir = ir; |
|
1102 if(ib == ELayoutEmpty) |
|
1103 { |
|
1104 line.iB = TInt16(ELayoutP - it - iH); |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 line.iB = ib; |
|
1109 } |
|
1110 line.iW = iW; |
|
1111 // there is no height value |
|
1112 line.iJ = iJ; |
|
1113 line.iFont = iFont; |
|
1114 |
|
1115 line.iBaselineSkip = 0; |
|
1116 line.iNumberOfLinesShown = 1; |
|
1117 return line; |
|
1118 } |
|
1119 |
|
1120 EXPORT_C TAknMultiLineTextLayout TAknTextComponentLayout::Multiline(const RArray<TAknTextComponentLayout> &aLayouts) |
|
1121 { |
|
1122 __ASSERT_ALWAYS(aLayouts.Count() >= 1, Panic(EParameterOutOfRange)); |
|
1123 TAknTextComponentLayout layout0 = aLayouts[0]; |
|
1124 TAknTextComponentLayout layout0NoEmptys = RemoveLayoutEmptys(layout0); |
|
1125 TAknTextLineLayout layout = layout0NoEmptys.LayoutLine(); |
|
1126 |
|
1127 |
|
1128 TAknMultiLineTextLayout multiline; |
|
1129 multiline.iC = layout.iC; |
|
1130 multiline.il = layout.il; |
|
1131 multiline.ir = layout.ir; |
|
1132 multiline.iB = layout.iB; |
|
1133 multiline.iW = layout.iW; |
|
1134 multiline.iJ = layout.iJ; |
|
1135 multiline.iFont = layout.iFont; |
|
1136 |
|
1137 if (aLayouts.Count() >= 2) |
|
1138 { |
|
1139 TAknTextComponentLayout layout1 = aLayouts[1]; |
|
1140 TAknTextComponentLayout layout1NoEmptys = RemoveLayoutEmptys(layout1); |
|
1141 multiline.iBaselineSkip = layout0NoEmptys.ib - layout1NoEmptys.ib; |
|
1142 multiline.iNumberOfLinesShown = aLayouts.Count(); |
|
1143 } |
|
1144 else |
|
1145 { |
|
1146 multiline.iBaselineSkip = 0; |
|
1147 multiline.iNumberOfLinesShown = 1; |
|
1148 } |
|
1149 return multiline; |
|
1150 } |
|
1151 |
|
1152 EXPORT_C TAknTextLineLayout TAknTextComponentLayout::LayoutLineNoEmptys() const |
|
1153 { |
|
1154 TAknTextLineLayout line; |
|
1155 line.iC = iC; |
|
1156 line.il = (il == ELayoutEmpty) ? TInt16(ELayoutP - iW - ir) : il; |
|
1157 // there is no top value |
|
1158 line.ir = (ir == ELayoutEmpty) ? TInt16(ELayoutP - iW - il) : ir; |
|
1159 line.iB = (ib == ELayoutEmpty) ? TInt16(ELayoutP - iH - it) : ib; |
|
1160 line.iW = (iW == ELayoutEmpty) ? TInt16(ELayoutP - il - ir) : iW; |
|
1161 // there is no height value |
|
1162 line.iJ = iJ; |
|
1163 line.iFont = iFont; |
|
1164 line.iBaselineSkip = 0; |
|
1165 line.iNumberOfLinesShown = 1; |
|
1166 return line; |
|
1167 } |
|
1168 |
|
1169 EXPORT_C TAknLayoutScalableComponentType TAknTextComponentLayout::LayoutComponentType() const |
|
1170 { |
|
1171 TAknLayoutScalableComponentType type = (TAknLayoutScalableComponentType)iType; |
|
1172 return type; |
|
1173 } |
|
1174 |
|
1175 EXPORT_C TInt16 TAknTextComponentLayout::C() const |
|
1176 { |
|
1177 return iC; |
|
1178 } |
|
1179 |
|
1180 EXPORT_C TInt16 TAknTextComponentLayout::l() const |
|
1181 { |
|
1182 return il; |
|
1183 } |
|
1184 |
|
1185 EXPORT_C TInt16 TAknTextComponentLayout::t() const |
|
1186 { |
|
1187 return it; |
|
1188 } |
|
1189 |
|
1190 EXPORT_C TInt16 TAknTextComponentLayout::r() const |
|
1191 { |
|
1192 return ir; |
|
1193 } |
|
1194 |
|
1195 EXPORT_C TInt16 TAknTextComponentLayout::b() const |
|
1196 { |
|
1197 return ib; |
|
1198 } |
|
1199 |
|
1200 EXPORT_C TInt16 TAknTextComponentLayout::W() const |
|
1201 { |
|
1202 return iW; |
|
1203 } |
|
1204 |
|
1205 EXPORT_C TInt16 TAknTextComponentLayout::H() const |
|
1206 { |
|
1207 return iH; |
|
1208 } |
|
1209 |
|
1210 EXPORT_C TInt16 TAknTextComponentLayout::J() const |
|
1211 { |
|
1212 return iJ; |
|
1213 } |
|
1214 |
|
1215 EXPORT_C TInt32 TAknTextComponentLayout::Font() const |
|
1216 { |
|
1217 return iFont; |
|
1218 } |
|
1219 |
|
1220 EXPORT_C void TAknTextComponentLayout::SetC(TInt16 aC) |
|
1221 { |
|
1222 iC = aC; |
|
1223 } |
|
1224 |
|
1225 EXPORT_C void TAknTextComponentLayout::Setl(TInt16 al) |
|
1226 { |
|
1227 il = al; |
|
1228 } |
|
1229 |
|
1230 EXPORT_C void TAknTextComponentLayout::Sett(TInt16 at) |
|
1231 { |
|
1232 it = at; |
|
1233 } |
|
1234 |
|
1235 EXPORT_C void TAknTextComponentLayout::Setr(TInt16 ar) |
|
1236 { |
|
1237 ir = ar; |
|
1238 } |
|
1239 |
|
1240 EXPORT_C void TAknTextComponentLayout::Setb(TInt16 ab) |
|
1241 { |
|
1242 ib = ab; |
|
1243 } |
|
1244 |
|
1245 EXPORT_C void TAknTextComponentLayout::SetW(TInt16 aW) |
|
1246 { |
|
1247 iW = aW; |
|
1248 } |
|
1249 |
|
1250 EXPORT_C void TAknTextComponentLayout::SetH(TInt16 aH) |
|
1251 { |
|
1252 iH = aH; |
|
1253 } |
|
1254 |
|
1255 EXPORT_C void TAknTextComponentLayout::SetJ(TInt16 aJ) |
|
1256 { |
|
1257 iJ = aJ; |
|
1258 } |
|
1259 |
|
1260 EXPORT_C void TAknTextComponentLayout::SetFont(TInt32 aFont) |
|
1261 { |
|
1262 iFont = aFont; |
|
1263 } |
|
1264 |
|
1265 |
|
1266 // |
|
1267 // class AknLayoutScalableDecodeSupport |
|
1268 // |
|
1269 |
|
1270 TInt32 AknLayoutScalableDecodeSupport::DecodeBytes(const TUint8*& aPtr) |
|
1271 { |
|
1272 TInt32 result = 0; |
|
1273 TUint16* pResult = (TUint16*)(&result); // assumes little endian, low word will get filled first |
|
1274 DecodeBytes(aPtr, pResult); |
|
1275 return result; |
|
1276 }; |
|
1277 |
|
1278 // ------------------------------------------------------------------------------------------------ |
|
1279 // This routine is slightly inefficient, as the main decode routine increments both pointers. |
|
1280 // However, this one is only called for ParamLimits, so there are in general less values |
|
1281 // to decode, and also SkipBytes is called more often. |
|
1282 // ------------------------------------------------------------------------------------------------ |
|
1283 TInt32 AknLayoutScalableDecodeSupport::SumBytes(const TUint8*& aPtr, TInt aNum) |
|
1284 { |
|
1285 TInt32 total = 0; |
|
1286 TInt32 result = 0; |
|
1287 for ( ; aNum ; --aNum) |
|
1288 { |
|
1289 TUint16* pResult = (TUint16*)(&result); // assumes little endian, low word will get filled first |
|
1290 DecodeBytes(aPtr, pResult); |
|
1291 total += result; |
|
1292 } |
|
1293 return total; |
|
1294 } |
|
1295 |
|
1296 void AknLayoutScalableDecodeSupport::DecodeBytes(const TUint8*& aPtr, TUint16*& aDecodedPtr) |
|
1297 { |
|
1298 if(!aDecodedPtr) |
|
1299 return; |
|
1300 TUint8 ch = *aPtr++; |
|
1301 switch (ch) |
|
1302 { |
|
1303 case KByteWord: |
|
1304 { |
|
1305 TUint16 high = *aPtr++; |
|
1306 TUint16 low = *aPtr++; |
|
1307 *aDecodedPtr++ = TUint16((high<<8) | low); |
|
1308 break; |
|
1309 } |
|
1310 case KByteEmpty: |
|
1311 { |
|
1312 *aDecodedPtr++ = TUint16(ELayoutEmpty); |
|
1313 break; |
|
1314 } |
|
1315 case KByteP1: |
|
1316 { |
|
1317 TInt8 offset = *aPtr++; |
|
1318 *aDecodedPtr++ = TUint16(p+offset); |
|
1319 break; |
|
1320 } |
|
1321 case KByteP2: |
|
1322 { |
|
1323 TInt16 high = *aPtr++; |
|
1324 TUint16 low = *aPtr++; |
|
1325 *aDecodedPtr++ = TUint16(p+((high<<8) | low)); |
|
1326 break; |
|
1327 } |
|
1328 case KByteLong: |
|
1329 { |
|
1330 TUint16 maskFF000000 = *aPtr++; |
|
1331 TUint16 mask00FF0000 = *aPtr++; |
|
1332 TUint16 mask0000FF00 = *aPtr++; |
|
1333 TUint16 mask000000FF = *aPtr++; |
|
1334 // assume little endian, so start with the low word |
|
1335 *aDecodedPtr++ = TUint16((mask0000FF00<<8) | mask000000FF); |
|
1336 *aDecodedPtr++ = TUint16((maskFF000000<<8) | mask00FF0000); |
|
1337 break; |
|
1338 } |
|
1339 default: |
|
1340 *aDecodedPtr++ = ch; |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 void AknLayoutScalableDecodeSupport::SkipBytes(const TUint8*& aPtr, TInt aNum) |
|
1345 { |
|
1346 for ( ; aNum ; --aNum) |
|
1347 { |
|
1348 TUint8 ch = *aPtr++; |
|
1349 switch (ch) |
|
1350 { |
|
1351 case KByteWord: |
|
1352 { |
|
1353 aPtr+=2; |
|
1354 break; |
|
1355 } |
|
1356 case KByteP1: |
|
1357 { |
|
1358 ++aPtr; |
|
1359 break; |
|
1360 } |
|
1361 case KByteP2: |
|
1362 { |
|
1363 aPtr+=2; |
|
1364 break; |
|
1365 } |
|
1366 case KByteLong: |
|
1367 { |
|
1368 aPtr+=4; |
|
1369 break; |
|
1370 } |
|
1371 default: |
|
1372 break; |
|
1373 } |
|
1374 } |
|
1375 } |
|
1376 |
|
1377 |
|
1378 const TUint8* AknLayoutScalableDecodeSupport::DecodeTable(const SCompDataImplData* aImplData, TInt aLineIndex) |
|
1379 { |
|
1380 const TUint8* data = DataPtr(aImplData); |
|
1381 TUint16 numElements = DecodeBytes(data); |
|
1382 __ASSERT_ALWAYS(aLineIndex < numElements, Panic(EIllegalLineIndex)); |
|
1383 const TUint8* tableOffsetData = data+(aLineIndex*2); |
|
1384 TUint16 high = *tableOffsetData++; |
|
1385 TUint16 low = *tableOffsetData++; |
|
1386 TUint16 tableOffset = TUint16 ((high<<8) | low); |
|
1387 return aImplData->iByteCodedData + tableOffset; |
|
1388 } |
|
1389 |
|
1390 |
|
1391 const TUint8* AknLayoutScalableDecodeSupport::DataPtr(const SCompDataImplData* aImplData) |
|
1392 { |
|
1393 return aImplData->iByteCodedData + aImplData->iDataLookup[CdlEngine::LastApiId()]; |
|
1394 } |
|
1395 |
|
1396 const TUint8* AknLayoutScalableDecodeSupport::DataPtr(const SCompDataImplData* aImplData, TInt aComponentId) |
|
1397 { |
|
1398 return aImplData->iByteCodedData + aImplData->iDataLookup[aComponentId]; |
|
1399 } |
|
1400 |
|
1401 void AknLayoutScalableDecodeSupport::DecodeTypeId(TInt16& aType, TBool& aHasHeaderBlock, const TUint8*& aData) |
|
1402 { |
|
1403 TUint16 typeBitfield = *aData++; |
|
1404 aHasHeaderBlock = typeBitfield & 1; |
|
1405 aType = typeBitfield >> 1; |
|
1406 } |
|
1407 |
|
1408 void AknLayoutScalableDecodeSupport::DecodeSimple(TUint16* aLine, const TUint8* aData, TInt aNumCells) |
|
1409 { |
|
1410 TInt16 type; |
|
1411 TBool hasHeaderBlock; |
|
1412 DecodeTypeId(type, hasHeaderBlock, aData); |
|
1413 DecodeSimpleCells(aLine, aData, type, aNumCells); |
|
1414 } |
|
1415 |
|
1416 void AknLayoutScalableDecodeSupport::DecodeSimpleCells(TUint16* aLine, const TUint8* aData, TUint16 aType, TInt aNumCells) |
|
1417 { |
|
1418 // header block data is not used, and there are five 16bit values to skip |
|
1419 // iFirstChildID;iNextSiblingID;iParentID;iParentVariety;iAttributeSetID; |
|
1420 aLine+=5; |
|
1421 *aLine++ = aType; |
|
1422 |
|
1423 // decode a non-parameterised line by decoding the bytes for each cell |
|
1424 for (TInt ii=0; ii<aNumCells; ii++) |
|
1425 DecodeBytes(aData, aLine); |
|
1426 } |
|
1427 |
|
1428 |
|
1429 void AknLayoutScalableDecodeSupport::DecodeHeaderBlock( |
|
1430 TInt*& aLimits, |
|
1431 TInt& aNumVarieties, |
|
1432 TInt& aNumMultiValues, |
|
1433 const TUint8*& aParamsPtr, |
|
1434 const TUint8*& aData, |
|
1435 TInt aVariety) |
|
1436 { |
|
1437 aNumVarieties = *aData++; |
|
1438 |
|
1439 *aLimits++ = 0; |
|
1440 *aLimits++ = aNumVarieties - 1; |
|
1441 |
|
1442 __ASSERT_ALWAYS(0 <= aVariety && aVariety < aNumVarieties, Panic(EOffsetOutOfRange)); |
|
1443 |
|
1444 aNumMultiValues = *aData++; |
|
1445 aParamsPtr = aData; |
|
1446 |
|
1447 // decode params to find data ptr |
|
1448 TInt numBytes = aNumMultiValues * 2; |
|
1449 if (numBytes) |
|
1450 SkipBytes(aData, numBytes); |
|
1451 } |
|
1452 |
|
1453 void AknLayoutScalableDecodeSupport::DecodeParamLimitParam( |
|
1454 TInt*& aLimits, |
|
1455 TInt& aNumMultiValues, |
|
1456 const TUint8*& aParamsPtr, |
|
1457 const TUint8*& aData, |
|
1458 TInt aVariety, |
|
1459 TInt aCellIndex, |
|
1460 TInt& aVarietyOffset) |
|
1461 { |
|
1462 TBool optimized(EFalse); |
|
1463 TInt max; |
|
1464 TInt param; |
|
1465 TUint32 limit; |
|
1466 TUint32* pLimit = &limit; |
|
1467 |
|
1468 // always exactly one value for each variety, therefore: |
|
1469 // - multi is always 0 |
|
1470 // - the variety offset for decoding this cell is always the variety index |
|
1471 DecodeParam(aCellIndex, optimized, max, param, aParamsPtr, aNumMultiValues, 0, aVariety, aVariety); |
|
1472 |
|
1473 // now calculate the variety offset for decoding real cells |
|
1474 DecodeParamLimitsCell(aVariety, max, param, aData, pLimit, aVarietyOffset); |
|
1475 |
|
1476 *aLimits++ = 0; // first values currently not implemented |
|
1477 *aLimits++ = limit - 1; // currently stored as "number of values", but we need to return "last" |
|
1478 } |
|
1479 |
|
1480 // {numCols; numRows; iC; il; it; ir; ib; iW; iH; iJ; iFont}; |
|
1481 const TInt isCol[KNumCells] = {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0}; |
|
1482 |
|
1483 void AknLayoutScalableDecodeSupport::DecodeParams(TUint16* aLine, const TUint8* aData, TInt aNumCells, TInt aVariety, TInt aColumn, TInt aRow) |
|
1484 { |
|
1485 TInt16 type; |
|
1486 TBool hasHeaderBlock; |
|
1487 DecodeTypeId(type, hasHeaderBlock, aData); |
|
1488 if(hasHeaderBlock) |
|
1489 DecodeParamCells(aLine, aData, type, aNumCells + KNumCellsNotSimple, aVariety, aColumn, aRow); |
|
1490 else |
|
1491 DecodeSimpleCells(aLine, aData, type, aNumCells); |
|
1492 } |
|
1493 |
|
1494 void AknLayoutScalableDecodeSupport::DecodeParamCells(TUint16* aLine, const TUint8* aData, TUint16 aType, TInt aNumCells, TInt aVariety, TInt aColumn, TInt aRow) |
|
1495 { |
|
1496 // header block data is not used, and there are five 16bit values to skip |
|
1497 // iFirstChildID;iNextSiblingID;iParentID;iParentVariety;iAttributeSetID; |
|
1498 aLine+=5; |
|
1499 *aLine++ = aType; |
|
1500 |
|
1501 TAknLayoutScalableParameterLimitsImp limits; |
|
1502 TInt* pLimits = (TInt*)&limits; |
|
1503 TInt numVarieties = 0; |
|
1504 TInt numMultiValues = 0; |
|
1505 const TUint8* paramsPtr = 0; |
|
1506 DecodeHeaderBlock(pLimits, numVarieties, numMultiValues, paramsPtr, aData, aVariety); |
|
1507 |
|
1508 // decode the param limit params, always cols then rows |
|
1509 TFixedArray<TInt, KNumCellsNotSimple> varietyOffsets; |
|
1510 TInt ii=0; |
|
1511 for(; ii<KNumCellsNotSimple; ii++) |
|
1512 { |
|
1513 DecodeParamLimitParam(pLimits, numMultiValues, paramsPtr, aData, aVariety, ii, varietyOffsets[ii]); |
|
1514 } |
|
1515 |
|
1516 TInt numCols = limits.iLastColumn + 1; |
|
1517 TInt numRows = limits.iLastRow + 1; |
|
1518 |
|
1519 __ASSERT_ALWAYS(0 <= aColumn && aColumn <= numCols, Panic(EOffsetOutOfRange)); |
|
1520 __ASSERT_ALWAYS(0 <= aRow && aRow <= numRows, Panic(EOffsetOutOfRange)); |
|
1521 |
|
1522 // decode each cell |
|
1523 TBool optimized(EFalse); |
|
1524 TInt max; |
|
1525 TInt param; |
|
1526 // continuing after numRows |
|
1527 for (; ii<aNumCells; ii++) |
|
1528 { |
|
1529 // calculate the requested and maximum parameter value for this cell |
|
1530 TInt multi = isCol[ii] ? aColumn : aRow; |
|
1531 TInt colRow = isCol[ii] ? 0 : 1; |
|
1532 DecodeParam(ii, optimized, max, param, paramsPtr, numMultiValues, multi, aVariety, varietyOffsets[colRow]); |
|
1533 DecodeCell(max, param, aData, aLine); |
|
1534 } |
|
1535 } |
|
1536 |
|
1537 void AknLayoutScalableDecodeSupport::DecodeParam(TInt aCell, TBool& aOptimizedVarieties, TInt& aMax, TInt& aParam, const TUint8* aParamsPtr, TInt aNumParams, TInt aMulti, TInt aVariety, TInt aVarietyOffset) |
|
1538 { |
|
1539 // Parameter coding is sequence of pairs of bytes, one for each parameter. |
|
1540 // The first byte is a bit field indicating which cells the parameter affects. |
|
1541 // The second is the number of items in the cell. |
|
1542 TInt ii=0; |
|
1543 // This is the bit in the bit-fields we are looking for |
|
1544 TUint bit = 1<<aCell; |
|
1545 |
|
1546 // scan through the parameters and break if one has the relevant bit set for this cell |
|
1547 for (; ii<aNumParams; ii++) |
|
1548 { |
|
1549 TUint16 bits = DecodeBytes(aParamsPtr); // increments pointer |
|
1550 if (bits & bit) |
|
1551 break; |
|
1552 DecodeBytes(aParamsPtr); // consume the unwanted max value |
|
1553 } |
|
1554 |
|
1555 if (ii == aNumParams) |
|
1556 { |
|
1557 // No parameter was found for this cell. |
|
1558 aMax = 1; |
|
1559 aParam = 0; |
|
1560 |
|
1561 // there is only one value stored, so whatever was requested, |
|
1562 // that's the value we'll return, so effectively there's no difference |
|
1563 // whether it was optimized or not. |
|
1564 aOptimizedVarieties = false; |
|
1565 } |
|
1566 else |
|
1567 { |
|
1568 // A parameter was found for the cell, extract the number of items in the cell |
|
1569 // and the correct parameter index value. |
|
1570 TInt bitfield = DecodeBytes(aParamsPtr); // increments pointer |
|
1571 |
|
1572 const static TUint optimizedVarietiesMask = 0x0001; |
|
1573 aOptimizedVarieties = (bitfield & optimizedVarietiesMask) != 0; |
|
1574 |
|
1575 const static TUint optimizedCalcsMask = 0x0002; |
|
1576 TBool optimizedCalcs = (bitfield & optimizedCalcsMask) != 0; |
|
1577 |
|
1578 aMax = bitfield >> 2; |
|
1579 |
|
1580 // the variety offset must be re-calculated in the case of compressed calcs |
|
1581 TInt actualVarietyOffset = optimizedCalcs ? aVariety : aVarietyOffset; |
|
1582 |
|
1583 // if optimized, we can ignore the variety as they're all the same |
|
1584 // otherwise, just start counting from the variety offset |
|
1585 aParam = aOptimizedVarieties ? 0 : actualVarietyOffset; |
|
1586 |
|
1587 // if optimized, we can ingore the index, as they're all the same |
|
1588 aParam += optimizedCalcs ? 0 : aMulti; |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 void AknLayoutScalableDecodeSupport::DecodeCell(TInt& aMax, TInt& aParam, const TUint8*& aDataPtr, TUint16*& aDecodedPtr) |
|
1593 { |
|
1594 __ASSERT_ALWAYS(0 <= aParam && aParam < aMax, Panic(EOffsetOutOfRange)); |
|
1595 |
|
1596 if (aParam) |
|
1597 { |
|
1598 SkipBytes(aDataPtr, aParam); |
|
1599 } |
|
1600 DecodeBytes(aDataPtr, aDecodedPtr); // increments ptr |
|
1601 TInt post = aMax - (aParam+1); |
|
1602 if (post) |
|
1603 { |
|
1604 SkipBytes(aDataPtr, post); |
|
1605 } |
|
1606 } |
|
1607 |
|
1608 void AknLayoutScalableDecodeSupport::DecodeParamLimitsCell(TInt aVariety, TInt aMax, TInt& aParam, const TUint8*& aDataPtr, TUint32*& aDecodedPtr, TInt& aVarietyOffset) |
|
1609 { |
|
1610 __ASSERT_ALWAYS(0 <= aParam && aParam < aMax, Panic(EOffsetOutOfRange)); |
|
1611 |
|
1612 // In the case of only one value being stored, it might be optimized. |
|
1613 // Either way, the variety offset will be 0. |
|
1614 aVarietyOffset = 0; |
|
1615 |
|
1616 // However, if more than one value is stored, need to |
|
1617 // accumulate the previous values |
|
1618 if (aParam) |
|
1619 { |
|
1620 // must be not optimized |
|
1621 aVarietyOffset = SumBytes(aDataPtr, aParam); |
|
1622 } |
|
1623 |
|
1624 TInt32 value = 0; |
|
1625 TUint16* pValue = (TUint16*)(&value); // assumes little endian, low word will get filled first |
|
1626 DecodeBytes(aDataPtr, pValue); // increments ptr |
|
1627 |
|
1628 // Record the position of the start of the variety that we're looking for (in the actual cells). |
|
1629 // if this cell is optimized or only has one value, we simulate the location of the required variety |
|
1630 // and if there is only one variety, then aVariety will always be 0. |
|
1631 if(aMax == 1) |
|
1632 { |
|
1633 aVarietyOffset = aVariety * value; |
|
1634 } |
|
1635 |
|
1636 // record the actual value |
|
1637 *aDecodedPtr++ = value; |
|
1638 |
|
1639 // we don't need to know the total for all the varieties, so we can just skip |
|
1640 // the last few, without accumulating |
|
1641 TInt post = aMax - (aParam+1); |
|
1642 if (post) |
|
1643 { |
|
1644 SkipBytes(aDataPtr, post); |
|
1645 } |
|
1646 } |
|
1647 |
|
1648 void AknLayoutScalableDecodeSupport::DecodeParamLimits(TInt* aLimits, const TUint8* aData, TInt aVariety) |
|
1649 { |
|
1650 TInt16 type; |
|
1651 TBool hasHeaderBlock; |
|
1652 DecodeTypeId(type, hasHeaderBlock, aData); |
|
1653 // *aLine++ = aType; |
|
1654 |
|
1655 if(hasHeaderBlock) |
|
1656 { |
|
1657 TInt numVarieties = 0; |
|
1658 TInt numMultiValues = 0; |
|
1659 const TUint8* paramsPtr = 0; |
|
1660 DecodeHeaderBlock(aLimits, numVarieties, numMultiValues, paramsPtr, aData, aVariety); |
|
1661 |
|
1662 // decode the param limits, always cols then rows |
|
1663 TInt ii = 0; |
|
1664 for (ii=0; ii<2; ii++) |
|
1665 { |
|
1666 TInt unusedVarietyOffset; |
|
1667 DecodeParamLimitParam(aLimits, numMultiValues, paramsPtr, aData, aVariety, ii, unusedVarietyOffset); |
|
1668 } |
|
1669 } |
|
1670 } |
|
1671 |
|
1672 void AknLayoutScalableDecodeSupport::MirrorValues(TAknWindowComponentLayoutImp& aLine) |
|
1673 { |
|
1674 // data is currently mirrored in separate layout instances |
|
1675 // but if the instance is mirrored, it will be stored with l and r swapped, so unswap them |
|
1676 if(Layout_Meta_Data::IsMirrored()) |
|
1677 { |
|
1678 TInt16 temp = aLine.il; |
|
1679 aLine.il = aLine.ir; |
|
1680 aLine.ir = temp; |
|
1681 } |
|
1682 } |
|
1683 |
|
1684 void AknLayoutScalableDecodeSupport::MirrorValues(TAknTextComponentLayoutImp& aLine) |
|
1685 { |
|
1686 // data is currently mirrored in separate layout instances |
|
1687 // but if the instance is mirrored, it will be stored with l and r swapped, |
|
1688 // and justification reversed, so unswap them |
|
1689 if(Layout_Meta_Data::IsMirrored()) |
|
1690 { |
|
1691 TInt16 temp = aLine.il; |
|
1692 aLine.il = aLine.ir; |
|
1693 aLine.ir = temp; |
|
1694 if(aLine.iJ == ELayoutAlignLeft) |
|
1695 aLine.iJ = ELayoutAlignRight; |
|
1696 else if(aLine.iJ == ELayoutAlignRight) |
|
1697 aLine.iJ = ELayoutAlignLeft; |
|
1698 } |
|
1699 } |
|
1700 |
|
1701 // The following functions could be factorised, but that would extend the call depth |
|
1702 // of an already tricky calculation, with expensive function calls. |
|
1703 // So these functions are individually coded - they're short anyway. |
|
1704 EXPORT_C void AknLayoutScalableDecodeSupport::WindowLine(TAknWindowComponentLayoutImp& aLine, const SCompDataImplData* aImplData) |
|
1705 { |
|
1706 DecodeSimple((TUint16*)&aLine, DataPtr(aImplData), KNumCellsWindow); |
|
1707 MirrorValues(aLine); |
|
1708 } |
|
1709 |
|
1710 EXPORT_C void AknLayoutScalableDecodeSupport::WindowLine(TAknWindowComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aVariety, TInt aColumn, TInt aRow) |
|
1711 { |
|
1712 DecodeParams((TUint16*)&aLine, DataPtr(aImplData), KNumCellsWindow, aVariety, aColumn, aRow); |
|
1713 MirrorValues(aLine); |
|
1714 } |
|
1715 |
|
1716 EXPORT_C void AknLayoutScalableDecodeSupport::TextLine(TAknTextComponentLayoutImp& aLine, const SCompDataImplData* aImplData) |
|
1717 { |
|
1718 DecodeSimple((TUint16*)&aLine, DataPtr(aImplData), KNumCellsText); |
|
1719 MirrorValues(aLine); |
|
1720 } |
|
1721 |
|
1722 EXPORT_C void AknLayoutScalableDecodeSupport::TextLine(TAknTextComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aVariety, TInt aColumn, TInt aRow) |
|
1723 { |
|
1724 DecodeParams((TUint16*)&aLine, DataPtr(aImplData), KNumCellsText, aVariety, aColumn, aRow); |
|
1725 MirrorValues(aLine); |
|
1726 } |
|
1727 |
|
1728 EXPORT_C void AknLayoutScalableDecodeSupport::WindowTable(TAknWindowComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aLineIndex) |
|
1729 { |
|
1730 const TUint8* data = DecodeTable(aImplData, aLineIndex); |
|
1731 DecodeSimple((TUint16*)&aLine, data, KNumCellsWindow); |
|
1732 MirrorValues(aLine); |
|
1733 } |
|
1734 |
|
1735 EXPORT_C void AknLayoutScalableDecodeSupport::WindowTable(TAknWindowComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aLineIndex, TInt aVariety, TInt aColumn, TInt aRow) |
|
1736 { |
|
1737 const TUint8* data = DecodeTable(aImplData, aLineIndex); |
|
1738 DecodeParams((TUint16*)&aLine, data, KNumCellsWindow, aVariety, aColumn, aRow); |
|
1739 MirrorValues(aLine); |
|
1740 } |
|
1741 |
|
1742 EXPORT_C void AknLayoutScalableDecodeSupport::TextTable(TAknTextComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aLineIndex) |
|
1743 { |
|
1744 const TUint8* data = DecodeTable(aImplData, aLineIndex); |
|
1745 DecodeSimple((TUint16*)&aLine, data, KNumCellsText); |
|
1746 MirrorValues(aLine); |
|
1747 } |
|
1748 |
|
1749 EXPORT_C void AknLayoutScalableDecodeSupport::TextTable(TAknTextComponentLayoutImp& aLine, const SCompDataImplData* aImplData, TInt aLineIndex, TInt aVariety, TInt aColumn, TInt aRow) |
|
1750 { |
|
1751 const TUint8* data = DecodeTable(aImplData, aLineIndex); |
|
1752 DecodeParams((TUint16*)&aLine, data, KNumCellsText, aVariety, aColumn, aRow); |
|
1753 MirrorValues(aLine); |
|
1754 } |
|
1755 |
|
1756 EXPORT_C TAknLayoutScalableTableLimits AknLayoutScalableDecodeSupport::TableLimits(const TUint16* aDataLookup) |
|
1757 { |
|
1758 TUint8* encoded = (TUint8*)(aDataLookup + CdlEngine::LastApiId()); |
|
1759 TAknLayoutScalableTableLimits limits(encoded[1], encoded[0]); |
|
1760 return limits; |
|
1761 } |
|
1762 |
|
1763 |
|
1764 EXPORT_C void AknLayoutScalableDecodeSupport::ParameterLimits(TAknLayoutScalableParameterLimitsImp& aLimits, const SCompDataImplData* aImplData, TInt aVariety) |
|
1765 { |
|
1766 DecodeParamLimits((TInt*)&aLimits, DataPtr(aImplData), aVariety); |
|
1767 } |
|
1768 |
|
1769 EXPORT_C void AknLayoutScalableDecodeSupport::ParameterLimitsTable(TAknLayoutScalableParameterLimitsImp& aLimits, const SCompDataImplData* aImplData, TInt aLineIndex, TInt aVariety) |
|
1770 { |
|
1771 const TUint8* data = DecodeTable(aImplData, aLineIndex); |
|
1772 DecodeParamLimits((TInt*)&aLimits, data, aVariety); |
|
1773 } |
|
1774 |
|
1775 |
|
1776 EXPORT_C void AknLayoutScalableDecodeSupport::GetComponentTypeById(TAknLayoutScalableComponentType& aType, const SCompDataImplData* aImplData, TInt aComponentId) |
|
1777 { |
|
1778 TInt16 type(0); |
|
1779 TBool hasHeaderBlock; |
|
1780 const TUint8* dataPtr = DataPtr(aImplData, aComponentId); |
|
1781 DecodeTypeId(type, hasHeaderBlock, dataPtr); |
|
1782 aType = (TAknLayoutScalableComponentType)type; |
|
1783 } |
|
1784 |
|
1785 EXPORT_C void AknLayoutScalableDecodeSupport::GetParamLimitsById(TAknLayoutScalableParameterLimitsImp& aLimits, const SCompDataImplData* aImplData, TInt aComponentId, TInt aVariety) |
|
1786 { |
|
1787 const TUint8* dataPtr = DataPtr(aImplData, aComponentId); |
|
1788 DecodeParamLimits((TInt*)&aLimits, dataPtr, aVariety); |
|
1789 } |
|
1790 |
|
1791 EXPORT_C void AknLayoutScalableDecodeSupport::GetWindowComponentById(TAknWindowComponentLayoutImp & aLine, const SCompDataImplData* aImplData, TInt aComponentId, TInt aVariety, TInt aCol, TInt aRow) |
|
1792 { |
|
1793 const TUint8* dataPtr = DataPtr(aImplData, aComponentId); |
|
1794 |
|
1795 TInt16 type(0); |
|
1796 TBool hasHeaderBlock; |
|
1797 DecodeTypeId(type, hasHeaderBlock, dataPtr); |
|
1798 |
|
1799 TAknLayoutScalableComponentType compType((TAknLayoutScalableComponentType)type); |
|
1800 TInt numCells = (compType == EAknLayoutScalableComponentTypeText) ? KNumCellsText : KNumCellsWindow; |
|
1801 |
|
1802 if(hasHeaderBlock) |
|
1803 DecodeParamCells((TUint16*)&aLine, dataPtr, type, numCells + KNumCellsNotSimple, aVariety, aCol, aRow); |
|
1804 else |
|
1805 DecodeSimpleCells((TUint16*)&aLine, dataPtr, type, numCells); |
|
1806 |
|
1807 MirrorValues(aLine); |
|
1808 } |
|
1809 |
|
1810 EXPORT_C void AknLayoutScalableDecodeSupport::GetTextComponentById(TAknTextComponentLayoutImp & aLine, const SCompDataImplData* aImplData, TInt aComponentId, TInt aVariety, TInt aCol, TInt aRow) |
|
1811 { |
|
1812 const TUint8* dataPtr = DataPtr(aImplData, aComponentId); |
|
1813 |
|
1814 TInt16 type(0); |
|
1815 TBool hasHeaderBlock; |
|
1816 DecodeTypeId(type, hasHeaderBlock, dataPtr); |
|
1817 |
|
1818 __ASSERT_DEBUG(type == EAknLayoutScalableComponentTypeText, Panic(EWrongType)); |
|
1819 |
|
1820 if(hasHeaderBlock) |
|
1821 DecodeParamCells((TUint16*)&aLine, dataPtr, type, KNumCellsText + KNumCellsNotSimple, aVariety, aCol, aRow); |
|
1822 else |
|
1823 DecodeSimpleCells((TUint16*)&aLine, dataPtr, type, KNumCellsText); |
|
1824 |
|
1825 MirrorValues(aLine); |
|
1826 } |
|
1827 |
|
1828 |
|
1829 // |
|
1830 // struct implementations |
|
1831 // |
|
1832 |
|
1833 EXPORT_C TAknTextComponentLayout TAknTextComponentLayout::MultiLineY(TAknTextComponentLayout aFirst, TInt aItem, TInt aGapBetweenItems) |
|
1834 { |
|
1835 TAknTextComponentLayout first = TAknTextComponentLayout::RemoveLayoutEmptys(aFirst); |
|
1836 |
|
1837 TAknTextComponentLayout layout; |
|
1838 layout.SetC(first.C()); |
|
1839 layout.Setl(first.l()); |
|
1840 layout.Sett(TInt16(first.t() + aItem * (first.H() + aGapBetweenItems))); |
|
1841 layout.Setb(ELayoutEmpty); |
|
1842 layout.Setr(ELayoutEmpty); |
|
1843 layout.SetW(first.W()); |
|
1844 layout.SetH(first.H()); |
|
1845 layout.SetJ(first.J()); |
|
1846 layout.SetFont(first.Font()); |
|
1847 return layout; |
|
1848 } |
|
1849 EXPORT_C TAknWindowComponentLayout TAknWindowComponentLayout::operator=( TAknWindowLineLayout aLine ) |
|
1850 { |
|
1851 iC = aLine.iC; |
|
1852 il = aLine.il; |
|
1853 it = aLine.it; |
|
1854 ir = aLine.ir; |
|
1855 ib = aLine.ib; |
|
1856 iW = aLine.iW; |
|
1857 iH = aLine.iH; |
|
1858 return *this; |
|
1859 } |
|
1860 |
|
1861 EXPORT_C TAknWindowComponentLayout::TAknWindowComponentLayout( TAknWindowLineLayout aLine ) |
|
1862 { |
|
1863 iC = aLine.iC; |
|
1864 il = aLine.il; |
|
1865 it = aLine.it; |
|
1866 ir = aLine.ir; |
|
1867 ib = aLine.ib; |
|
1868 iW = aLine.iW; |
|
1869 iH = aLine.iH; |
|
1870 } |
|
1871 EXPORT_C TAknTextComponentLayout::TAknTextComponentLayout( TAknTextLineLayout aLine ) |
|
1872 { |
|
1873 iC = aLine.iC; |
|
1874 il = aLine.il; |
|
1875 ir = aLine.ir; |
|
1876 ib = aLine.iB; |
|
1877 iW = aLine.iW; |
|
1878 iJ = aLine.iJ; |
|
1879 iFont = aLine.iFont; |
|
1880 } |
|
1881 |
|
1882 |
|
1883 EXPORT_C TAknTextComponentLayout TAknTextComponentLayout::operator=( TAknTextLineLayout aLine ) |
|
1884 { |
|
1885 iC = aLine.iC; |
|
1886 il = aLine.il; |
|
1887 ir = aLine.ir; |
|
1888 ib = aLine.iB; |
|
1889 iW = aLine.iW; |
|
1890 iJ = aLine.iJ; |
|
1891 iFont = aLine.iFont; |
|
1892 return *this; |
|
1893 } |