|
1 /* |
|
2 * Copyright (c) 2006 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: Base class for layouts. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alf/alflayout.h" |
|
21 #include "alf/alfcontrol.h" |
|
22 #include "alf/alfenv.h" |
|
23 #include "alfclient.h" |
|
24 #include "alf/alfgencomponent.h" |
|
25 #include "alf/alfconstants.h" |
|
26 #include "alflogger.h" |
|
27 |
|
28 #include <uiacceltk/HuiUtil.h> |
|
29 |
|
30 // Private structure |
|
31 struct CAlfLayout::TLayoutPrivateData |
|
32 { |
|
33 TLayoutPrivateData():iScrollOffset(0),iSkipServer(EFalse), |
|
34 iTransitionTime(KAlfLayoutDefaultTransitionTime){} |
|
35 RPointerArray<CAlfVisual> iChildren; // not owned. |
|
36 TAlfTimedPoint* iScrollOffset; // owned. |
|
37 TBool iSkipServer; // should rather use flags than booleans |
|
38 TInt iTransitionTime; |
|
39 TAlfXYMetric iInnerPadding; |
|
40 }; |
|
41 |
|
42 |
|
43 |
|
44 // ======== LOCAL FUNCTIONS ======== |
|
45 |
|
46 void AssertInnerPaddingsWereSetUsingDeprecatedPixelAPIs(const TAlfXYMetric& aMetric) |
|
47 { |
|
48 __ASSERT_DEBUG( |
|
49 (aMetric.iX.iMagnitude == aMetric.iY.iMagnitude) && |
|
50 (aMetric.iX.iUnit == EAlfUnitPixel) && |
|
51 (aMetric.iY.iUnit == EAlfUnitPixel) |
|
52 , USER_INVARIANT()); |
|
53 #ifndef _DEBUG // Remove compile warnings |
|
54 TAlfXYMetric tmp = aMetric; |
|
55 tmp = tmp; |
|
56 #endif |
|
57 } |
|
58 |
|
59 |
|
60 // ======== MEMBER FUNCTIONS ======== |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Constructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CAlfLayout::CAlfLayout() |
|
67 { |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // ConstructL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C void CAlfLayout::ConstructL( CAlfControl& aOwner ) |
|
76 { |
|
77 CAlfVisual::ConstructL( aOwner ); |
|
78 |
|
79 iLayoutData = new (ELeave) TLayoutPrivateData; |
|
80 iLayoutData->iInnerPadding = TAlfXYMetric(TAlfMetric(0)); |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Create new layout. |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CAlfLayout* CAlfLayout::AddNewL( |
|
89 CAlfControl& aOwner, |
|
90 CAlfLayout* aParentLayout ) |
|
91 { |
|
92 CAlfLayout* layout = aOwner.AppendLayoutL( |
|
93 EAlfLayoutTypeLayout, |
|
94 aParentLayout); |
|
95 return layout; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Destructor |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C CAlfLayout::~CAlfLayout() |
|
103 { |
|
104 if (iLayoutData ) |
|
105 { |
|
106 // Remove children in reverse order. |
|
107 for(TInt i = iLayoutData->iChildren.Count() - 1; i >= 0; --i) |
|
108 { |
|
109 Remove(iLayoutData->iChildren[i]); |
|
110 } |
|
111 iLayoutData->iChildren.Reset(); |
|
112 |
|
113 delete iLayoutData->iScrollOffset; |
|
114 iLayoutData->iScrollOffset = NULL; |
|
115 } |
|
116 delete iLayoutData; |
|
117 iLayoutData = NULL; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Appends new visual as a child. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C void CAlfLayout::RemoveAndDestroyAllD() |
|
125 { |
|
126 TBuf8<1> dum; |
|
127 // Remove and destory from the server side |
|
128 TInt err = Comms()->DoSynchronousCmd( EAlfVisualRemoveAndDestroyAll,KNullDesC8, dum); |
|
129 |
|
130 if ( err != KErrNone ) |
|
131 { |
|
132 __ALFLOGSTRING1( "CAlfLayout::RemoveAndDestroyAllD ignore error %d", err ) |
|
133 } |
|
134 |
|
135 DoRemoveAndDestroyAllD(); |
|
136 } |
|
137 |
|
138 EXPORT_C void CAlfLayout::DoRemoveAndDestroyAllD() |
|
139 { |
|
140 iLayoutData->iSkipServer = ETrue; |
|
141 for(TInt i = iLayoutData->iChildren.Count() - 1; i >= 0; --i) |
|
142 { |
|
143 iLayoutData->iChildren[i]->DoRemoveAndDestroyAllD(); |
|
144 } |
|
145 iLayoutData->iChildren.Reset(); |
|
146 |
|
147 // Calls the server function and removes the link |
|
148 // from the owner |
|
149 CAlfVisual::DoRemoveAndDestroyAllD(); |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // Appends new visual as a child. |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TInt CAlfLayout::Append( CAlfVisual* aVisual, TBool aConstructedWithParentInformation, TInt aLayoutTransitionTime ) |
|
158 { |
|
159 ASSERT( aVisual && aVisual->Identifier()); |
|
160 |
|
161 __ASSERT_ALWAYS( iLayoutData->iChildren.Find(aVisual) == KErrNotFound, |
|
162 USER_INVARIANT() ); |
|
163 |
|
164 TInt err = iLayoutData->iChildren.Append(aVisual); |
|
165 if ( err != KErrNone ) |
|
166 { |
|
167 return err; |
|
168 } |
|
169 |
|
170 if (!aConstructedWithParentInformation) // other wise visual was added to this layout |
|
171 { // during construction -> we mustn't apped visual to same layout twice |
|
172 |
|
173 TInt2 params(aVisual->Identifier(), aLayoutTransitionTime); |
|
174 TPckgC<TInt2> buf(params); |
|
175 TBuf8<1> dum; |
|
176 |
|
177 err = Comms()->DoSynchronousCmd(EAlfLayoutAppendVisual, buf, dum); |
|
178 if ( err != KErrNone ) |
|
179 { |
|
180 __ALFLOGSTRING1( "CAlfLayout::Append return error %d", err ) |
|
181 } |
|
182 } |
|
183 |
|
184 if ( err == KErrNone ) |
|
185 { |
|
186 aVisual->SetLayout(this); |
|
187 } |
|
188 else |
|
189 { |
|
190 // remove the last one |
|
191 iLayoutData->iChildren.Remove( iLayoutData->iChildren.Count()-1 ); |
|
192 } |
|
193 return err; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // Removes visual |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 EXPORT_C void CAlfLayout::Remove(CAlfVisual* aVisual, TInt aLayoutTransitionTime) |
|
201 { |
|
202 ASSERT( aVisual ); |
|
203 TInt index = iLayoutData->iChildren.Find(aVisual); |
|
204 __ASSERT_DEBUG(index != KErrNotFound, |
|
205 USER_INVARIANT()); |
|
206 if(index != KErrNotFound) |
|
207 { |
|
208 if ( !iLayoutData->iSkipServer ) |
|
209 { |
|
210 TInt2 params(aVisual->Identifier(), aLayoutTransitionTime); |
|
211 TPckgC<TInt2> buf(params); |
|
212 TBuf8<1> dum; |
|
213 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutRemoveVisual, buf, dum ); |
|
214 |
|
215 if ( err ) |
|
216 { |
|
217 __ALFLOGSTRING1( "CAlfLayout::Remove panic error %d", err ) |
|
218 USER_INVARIANT(); |
|
219 } |
|
220 } |
|
221 |
|
222 iLayoutData->iChildren.Remove(index); |
|
223 aVisual->SetLayout(NULL); |
|
224 } |
|
225 } |
|
226 |
|
227 EXPORT_C void CAlfLayout::Reorder(CAlfVisual& aVisual, TInt aPosition, TInt aLayoutTransitionTime) |
|
228 { |
|
229 TInt index = iLayoutData->iChildren.Find(&aVisual); |
|
230 if(index == aPosition) |
|
231 { |
|
232 // No need to change anything. |
|
233 return; |
|
234 } |
|
235 |
|
236 ASSERT( aPosition >= 0 && aPosition < iLayoutData->iChildren.Count()); |
|
237 ASSERT( index != KErrNotFound ); |
|
238 TInt3 params(aVisual.Identifier(), aPosition, aLayoutTransitionTime); |
|
239 |
|
240 TPckgC<TInt3> buf(params); |
|
241 TBuf8<1> dum; |
|
242 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutReorderVisual, buf, dum ); |
|
243 |
|
244 if ( err ) |
|
245 { |
|
246 __ALFLOGSTRING1( "CAlfLayout::Reorder panic error %d", err ) |
|
247 USER_INVARIANT(); |
|
248 } |
|
249 |
|
250 // Move the children around in the array, so that aVisual ends up |
|
251 // at aPosition. |
|
252 TInt direction = (aPosition>index)? 1:-1; |
|
253 for(TInt i = index; i != aPosition; i += direction) |
|
254 { |
|
255 iLayoutData->iChildren[i] = iLayoutData->iChildren[i + direction]; |
|
256 } |
|
257 iLayoutData->iChildren[aPosition] = &aVisual; |
|
258 |
|
259 iLayoutData->iSkipServer = ETrue; // don't post update to server unless derived class implements its own |
|
260 // override for UpdateChildrenLayout |
|
261 |
|
262 // use time set in CAlfEnv::StaticSetTransitionTime() |
|
263 UpdateChildrenLayout(KAlfLayoutDefaultTransitionTime); // should use LOCAL time like Env.StaticTransitionTime() |
|
264 |
|
265 iLayoutData->iSkipServer = EFalse; |
|
266 } |
|
267 |
|
268 EXPORT_C void CAlfLayout::MoveVisualToFront(CAlfVisual& aVisual, TInt aLayoutTransitionTime) |
|
269 { |
|
270 ASSERT(iLayoutData); |
|
271 Reorder(aVisual, iLayoutData->iChildren.Count() - 1, aLayoutTransitionTime); |
|
272 } |
|
273 |
|
274 |
|
275 EXPORT_C void CAlfLayout::MoveVisualToBack(CAlfVisual& aVisual, TInt aLayoutTransitionTime) |
|
276 { |
|
277 Reorder(aVisual, 0, aLayoutTransitionTime); |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // Returns visual count |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 EXPORT_C TInt CAlfLayout::Count() const |
|
287 { |
|
288 return iLayoutData->iChildren.Count(); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // Returns indexed visual |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 EXPORT_C CAlfVisual& CAlfLayout::Visual(TInt aIndex) const |
|
296 { |
|
297 return *iLayoutData->iChildren[aIndex]; |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // Enables scrolling |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 EXPORT_C void CAlfLayout::EnableScrollingL( TBool aScrolling ) |
|
305 { |
|
306 // Already enabled? |
|
307 if ( aScrolling && iLayoutData->iScrollOffset ) |
|
308 { |
|
309 return; |
|
310 } |
|
311 |
|
312 // Already disabled? |
|
313 if ( !aScrolling && !iLayoutData->iScrollOffset ) |
|
314 { |
|
315 return; |
|
316 } |
|
317 |
|
318 // Allocate scroll object if enabling. |
|
319 if ( aScrolling ) |
|
320 { |
|
321 iLayoutData->iScrollOffset = new (ELeave) TAlfTimedPoint; |
|
322 } |
|
323 |
|
324 TPckgC<TInt> buf(aScrolling); |
|
325 TBuf8<1> dum; |
|
326 |
|
327 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutEnableScrolling, buf, dum); |
|
328 |
|
329 // If disabled from server side, free the old scrolling object on client side. |
|
330 if ( err == KErrNone && !aScrolling ) |
|
331 { |
|
332 delete iLayoutData->iScrollOffset; |
|
333 iLayoutData->iScrollOffset = NULL; |
|
334 } |
|
335 |
|
336 // If error on enabling the server side, we need to free the allocated scroll |
|
337 // object on the client side. |
|
338 if ( err != KErrNone && aScrolling ) |
|
339 { |
|
340 delete iLayoutData->iScrollOffset; |
|
341 iLayoutData->iScrollOffset = NULL; |
|
342 } |
|
343 |
|
344 if ( err ) |
|
345 { |
|
346 __ALFLOGSTRING1( "CAlfLayout::EnableScrollingL leave error %d", err ) |
|
347 User::Leave( err ); |
|
348 } |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // Is scrolling enabled? |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C TBool CAlfLayout::Scrolling() const |
|
356 { |
|
357 return iLayoutData->iScrollOffset != NULL; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // Returns scrolling offset |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 EXPORT_C const TAlfTimedPoint& CAlfLayout::ScrollOffset() const |
|
365 { |
|
366 __ASSERT_ALWAYS( iLayoutData->iScrollOffset, USER_INVARIANT() ); |
|
367 |
|
368 |
|
369 TPckg<TAlfTimedPoint> offsetPckg(*iLayoutData->iScrollOffset); |
|
370 |
|
371 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutScrollOffset, KNullDesC8, offsetPckg); |
|
372 |
|
373 if ( err ) |
|
374 { |
|
375 __ALFLOGSTRING1( "CAlfLayout::ScrollOffset ignore error %d", err ) |
|
376 } |
|
377 |
|
378 return *iLayoutData->iScrollOffset; |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // Sets scrolling offset |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 EXPORT_C void CAlfLayout::SetScrollOffset(const TAlfTimedPoint& aPoint ) |
|
386 { |
|
387 __ASSERT_ALWAYS( iLayoutData->iScrollOffset, USER_INVARIANT() ); |
|
388 |
|
389 iLayoutData->iScrollOffset->iX = aPoint.iX; |
|
390 iLayoutData->iScrollOffset->iY = aPoint.iY; |
|
391 |
|
392 |
|
393 TPckgC<TAlfTimedPoint> offsetPckg(*iLayoutData->iScrollOffset); |
|
394 |
|
395 TInt err = Comms()->DoCmdNoReply(EAlfLayoutSetScrollOffset, offsetPckg ); |
|
396 |
|
397 if ( err ) |
|
398 { |
|
399 __ALFLOGSTRING1( "CAlfLayout::SetScrollOffset panic error %d", err ) |
|
400 USER_INVARIANT(); |
|
401 } |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // Returns indexed child ordinal. |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 EXPORT_C TInt CAlfLayout::ChildOrdinal(TInt aIndex) |
|
409 { |
|
410 TInt ordinal = 0; |
|
411 |
|
412 TPckgC<TInt> buf(aIndex); |
|
413 TPckg<TInt> ordinalPckg(ordinal); |
|
414 |
|
415 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutChildOrdinal, buf, ordinalPckg); |
|
416 |
|
417 if ( err ) |
|
418 { |
|
419 __ALFLOGSTRING1( "CAlfLayout::ChildOrdinal panic error %d", err ) |
|
420 USER_INVARIANT(); |
|
421 } |
|
422 |
|
423 return ordinal; |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // Returns position of the child in the given ordinal value. |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 EXPORT_C TBool CAlfLayout::ChildPos(TInt aOrdinal, TPoint& aPos) |
|
431 { |
|
432 TAlfPosInt pos = |
|
433 { |
|
434 aPos, |
|
435 aOrdinal |
|
436 }; |
|
437 |
|
438 TPckgC<TAlfPosInt> posBuf(pos); |
|
439 //TBool reply(EFalse); |
|
440 TPckg<TAlfPosInt> rBuf(pos); |
|
441 |
|
442 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutChildPos, posBuf, rBuf); |
|
443 |
|
444 if ( err ) |
|
445 { |
|
446 __ALFLOGSTRING1( "CAlfLayout::ChildPos panic error %d", err ) |
|
447 USER_INVARIANT(); |
|
448 } |
|
449 |
|
450 aPos = pos.iPoint; |
|
451 return pos.iInt; |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // Returns size of the child in the given ordinal value. |
|
456 // --------------------------------------------------------------------------- |
|
457 // |
|
458 EXPORT_C TBool CAlfLayout::ChildSize(TInt aOrdinal, TSize& aSize) |
|
459 { |
|
460 TAlfSizeInt size = |
|
461 { |
|
462 aSize, |
|
463 aOrdinal |
|
464 }; |
|
465 |
|
466 TPckgC<TAlfSizeInt> sizeBuf(size); |
|
467 //TBool reply(EFalse); |
|
468 TPckg<TAlfSizeInt> rBuf(size); |
|
469 |
|
470 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutChildSize, sizeBuf, rBuf); |
|
471 |
|
472 if ( err ) |
|
473 { |
|
474 __ALFLOGSTRING1( "CAlfLayout::ChildSize panic error %d", err ) |
|
475 USER_INVARIANT(); |
|
476 } |
|
477 |
|
478 aSize = size.iSize; |
|
479 |
|
480 return size.iInt; |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // basecall only when really needed, in case of reordering, the server does |
|
485 // this automatically |
|
486 // --------------------------------------------------------------------------- |
|
487 // |
|
488 EXPORT_C void CAlfLayout::UpdateChildrenLayout(TInt aTransitionTime) |
|
489 { |
|
490 if (!iLayoutData->iSkipServer) |
|
491 { |
|
492 CAlfVisual::UpdateChildrenLayout(aTransitionTime); |
|
493 } |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // |
|
498 // |
|
499 // --------------------------------------------------------------------------- |
|
500 // |
|
501 EXPORT_C CAlfVisual* CAlfLayout::FindTag(const TDesC8& aTag) |
|
502 { |
|
503 CAlfVisual* result = CAlfVisual::FindTag(aTag); |
|
504 if(!result && iLayoutData) |
|
505 { |
|
506 for(TInt i = 0; i < iLayoutData->iChildren.Count(); ++i) |
|
507 { |
|
508 result = iLayoutData->iChildren[i]->FindTag(aTag); |
|
509 if(result) |
|
510 { |
|
511 break; |
|
512 } |
|
513 } |
|
514 } |
|
515 |
|
516 return result; |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------------------------- |
|
520 // |
|
521 // |
|
522 // --------------------------------------------------------------------------- |
|
523 // |
|
524 EXPORT_C void CAlfLayout::SetTransitionTime(TInt aTransitionTime) |
|
525 { |
|
526 TPckgC<TInt> buf(aTransitionTime); |
|
527 |
|
528 TInt err = Comms()->DoCmdNoReply( EAlfLayoutSetTransitionTime, buf ); |
|
529 |
|
530 if ( err == KErrNone ) |
|
531 { |
|
532 iLayoutData->iTransitionTime = aTransitionTime; |
|
533 } |
|
534 else |
|
535 { |
|
536 USER_INVARIANT(); |
|
537 } |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 // |
|
543 // --------------------------------------------------------------------------- |
|
544 // |
|
545 EXPORT_C TInt CAlfLayout::TransitionTime() const |
|
546 { |
|
547 return iLayoutData->iTransitionTime; |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------------------------- |
|
551 // |
|
552 // |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 EXPORT_C TSize CAlfLayout::VirtualSize() const |
|
556 { |
|
557 TSize size(0,0); |
|
558 TPckg<TSize> buf(size); |
|
559 TInt err = Comms()->DoSynchronousCmd( EAlfLayoutVirtualSize, KNullDesC8, buf); |
|
560 |
|
561 if ( err ) |
|
562 { |
|
563 __ALFLOGSTRING1( "CAlfLayout::VirtualSize panic error %d", err ) |
|
564 USER_INVARIANT(); |
|
565 } |
|
566 |
|
567 return size; |
|
568 } |
|
569 |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 // |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 EXPORT_C void CAlfLayout::SetInnerPadding(const TPoint& aInnerPadding) |
|
577 { |
|
578 |
|
579 TPckgC<TPoint> buf(aInnerPadding); |
|
580 |
|
581 TInt err = Comms()->DoCmdNoReply( EAlfLayoutSetInnerPaddingPoint, buf ); |
|
582 |
|
583 if ( err == KErrNone ) |
|
584 { |
|
585 iLayoutData->iInnerPadding = TAlfXYMetric(TAlfMetric(aInnerPadding.iX), TAlfMetric(aInnerPadding.iY)); |
|
586 } |
|
587 else |
|
588 { |
|
589 __ALFLOGSTRING1( "CAlfLayout::SetInnerPadding panic error %d", err ) |
|
590 USER_INVARIANT(); |
|
591 } |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 // |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 EXPORT_C void CAlfLayout::SetInnerPadding(const TAlfXYMetric& aInnerPadding) |
|
600 { |
|
601 TPckgC<TAlfXYMetric> buf(aInnerPadding); |
|
602 |
|
603 TInt err = Comms()->DoCmdNoReply( EAlfLayoutSetInnerPaddingMetric, buf ); |
|
604 |
|
605 if ( err == KErrNone ) |
|
606 { |
|
607 iLayoutData->iInnerPadding = aInnerPadding; |
|
608 } |
|
609 else |
|
610 { |
|
611 __ALFLOGSTRING1( "CAlfLayout::SetInnerPadding panic error %d", err ) |
|
612 USER_INVARIANT(); |
|
613 } |
|
614 } |
|
615 |
|
616 |
|
617 // --------------------------------------------------------------------------- |
|
618 // |
|
619 // |
|
620 // --------------------------------------------------------------------------- |
|
621 // |
|
622 EXPORT_C TInt CAlfLayout::HorizontalInnerPadding() const |
|
623 { |
|
624 AssertInnerPaddingsWereSetUsingDeprecatedPixelAPIs(iLayoutData->iInnerPadding); |
|
625 return iLayoutData->iInnerPadding.iX.iMagnitude; |
|
626 } |
|
627 |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // |
|
631 // |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 EXPORT_C TInt CAlfLayout::VerticalInnerPadding() const |
|
635 { |
|
636 AssertInnerPaddingsWereSetUsingDeprecatedPixelAPIs(iLayoutData->iInnerPadding); |
|
637 return iLayoutData->iInnerPadding.iY.iMagnitude; |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 // |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 EXPORT_C TPoint CAlfLayout::InnerPadding() const |
|
646 { |
|
647 AssertInnerPaddingsWereSetUsingDeprecatedPixelAPIs(iLayoutData->iInnerPadding); |
|
648 return TPoint(iLayoutData->iInnerPadding.iX.iMagnitude, iLayoutData->iInnerPadding.iY.iMagnitude); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // |
|
653 // |
|
654 // --------------------------------------------------------------------------- |
|
655 // |
|
656 EXPORT_C const TAlfXYMetric& CAlfLayout::InnerPaddingAsMetric() const |
|
657 { |
|
658 return iLayoutData->iInnerPadding; |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 // |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 EXPORT_C TAlfRealPoint CAlfLayout::InnerPaddingInBaseUnits() const |
|
667 { |
|
668 TBufC8<1> inDum; |
|
669 TAlfRealPoint value; |
|
670 TPckg<TAlfRealPoint> outBuf(value); |
|
671 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutInnerPaddingInBaseUnits, inDum, outBuf); |
|
672 |
|
673 if ( err ) |
|
674 { |
|
675 __ALFLOGSTRING1( "CAlfLayout::InnerPaddingInBaseUnits ignore error %d", err ) |
|
676 } |
|
677 |
|
678 return value; |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // |
|
683 // |
|
684 // --------------------------------------------------------------------------- |
|
685 // |
|
686 EXPORT_C TInt CAlfLayout::FindVisual(CAlfVisual* aVisual) const |
|
687 { |
|
688 return iLayoutData->iChildren.Find(aVisual); |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------------------------- |
|
692 // |
|
693 // |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 EXPORT_C TInt CAlfLayout::Insert(CAlfVisual* aVisual, TInt aPosition) |
|
697 { |
|
698 ASSERT( aVisual && aVisual->Identifier()); |
|
699 |
|
700 __ASSERT_ALWAYS( iLayoutData->iChildren.Find(aVisual) == KErrNotFound, |
|
701 USER_INVARIANT() ); |
|
702 |
|
703 CAlfLayout* oldLayout = aVisual->Layout(); |
|
704 |
|
705 // These could be optimized to one server call if needed. |
|
706 TInt err = Append(aVisual); |
|
707 if ( err == KErrNone ) |
|
708 { |
|
709 if (oldLayout != NULL) |
|
710 { |
|
711 // If this visual is already a member of another layout, |
|
712 // remove it from the old one |
|
713 oldLayout->Remove(aVisual); |
|
714 } |
|
715 Reorder(*aVisual, aPosition); |
|
716 } |
|
717 return err; |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------------------------- |
|
721 // |
|
722 // |
|
723 // --------------------------------------------------------------------------- |
|
724 // |
|
725 EXPORT_C TInt CAlfLayout::EffectiveLayoutOrdinal(const CAlfVisual& aVisual) const |
|
726 { |
|
727 TInt ordinal = 0; |
|
728 |
|
729 for(TInt i = 0; i < iLayoutData->iChildren.Count(); ++i) |
|
730 { |
|
731 if(iLayoutData->iChildren[i] == &aVisual) |
|
732 { |
|
733 return ordinal; |
|
734 } |
|
735 |
|
736 // The visuals that are laid out completely manually do not affect |
|
737 // the layout ordinal. |
|
738 if((iLayoutData->iChildren[i]->Flags() & EAlfVisualFlagManualLayout) != |
|
739 EAlfVisualFlagManualLayout) |
|
740 { |
|
741 ++ordinal; |
|
742 } |
|
743 } |
|
744 |
|
745 __ALFLOGSTRING( "CAlfLayout::EffectiveLayoutOrdinal panic visual not found") |
|
746 USER_INVARIANT(); |
|
747 return 0; |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // |
|
752 // |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 EXPORT_C void CAlfLayout::SetBaseUnit(const TAlfMetric& aBaseUnit) |
|
756 { |
|
757 TPckg<TAlfMetric> inBuf(aBaseUnit); |
|
758 TInt err = Comms()->DoCmdNoReply(EAlfLayoutSetBaseUnit, inBuf); |
|
759 |
|
760 if ( err ) |
|
761 { |
|
762 __ALFLOGSTRING1( "CAlfLayout::SetBaseUnit panic error %d", err ) |
|
763 USER_INVARIANT(); |
|
764 } |
|
765 } |
|
766 |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 // |
|
770 // --------------------------------------------------------------------------- |
|
771 // |
|
772 EXPORT_C void CAlfLayout::SetBaseUnit(const TAlfXYMetric& aBaseUnit) |
|
773 { |
|
774 TPckg<TAlfXYMetric> inBuf(aBaseUnit); |
|
775 TInt err = Comms()->DoCmdNoReply(EAlfLayoutSetBaseUnitXY, inBuf); |
|
776 |
|
777 if ( err ) |
|
778 { |
|
779 __ALFLOGSTRING1( "CAlfLayout::SetBaseUnit panic error %d", err ) |
|
780 USER_INVARIANT(); |
|
781 } |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------------------------- |
|
785 // |
|
786 // |
|
787 // --------------------------------------------------------------------------- |
|
788 // |
|
789 EXPORT_C TAlfXYMetric CAlfLayout::BaseUnit() const |
|
790 { |
|
791 TAlfXYMetric baseUnit; |
|
792 |
|
793 TBuf8<1> inDum; |
|
794 TPckg<TAlfXYMetric> outBuf(baseUnit); |
|
795 |
|
796 TInt err = Comms()->DoSynchronousCmd(EAlfLayoutBaseUnit, |
|
797 inDum, outBuf); |
|
798 |
|
799 if ( err ) |
|
800 { |
|
801 __ALFLOGSTRING1( "CAlfLayout::BaseUnit panic error %d", err ) |
|
802 USER_INVARIANT(); |
|
803 } |
|
804 |
|
805 return baseUnit; |
|
806 } |
|
807 |
|
808 // --------------------------------------------------------------------------- |
|
809 // future proofing |
|
810 // --------------------------------------------------------------------------- |
|
811 // |
|
812 EXPORT_C void CAlfLayout::PropertyOwnerExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
813 { |
|
814 CAlfVisual::PropertyOwnerExtension(aExtensionUid,aExtensionParams); |
|
815 } |
|
816 |