|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Layout calculation and UI rendering mechanism implementations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <utf.h> |
|
21 #include <eikapp.h> |
|
22 #include <AknUtils.h> |
|
23 #include <layoutmetadata.cdl.h> |
|
24 #include <AknPriv.hrh> |
|
25 #include <debug.h> |
|
26 |
|
27 // User includes |
|
28 #include "xnuiengine.h" |
|
29 #include "xnuiengineimpl.h" |
|
30 #include "xnuistatelistener.h" |
|
31 #include "xnpointerarray.h" |
|
32 #include "xnodt.h" |
|
33 #include "xndomlist.h" |
|
34 #include "xndompropertyvalue.h" |
|
35 #include "xnmenuadapter.h" |
|
36 #include "xnpopupcontroladapter.h" |
|
37 #include "xnviewcontroladapter.h" |
|
38 #include "xnviewdata.h" |
|
39 #include "xnnodebreadthfirstiterator.h" |
|
40 #include "xntype.h" |
|
41 #include "xnnodepluginif.h" |
|
42 #include "xncomponentnodeimpl.h" |
|
43 #include "xnproperty.h" |
|
44 #include "xnappuiadapter.h" |
|
45 #include "xnviewadapter.h" |
|
46 #include "xnwidgetextensionadapter.h" |
|
47 #include "xnscrollablecontroladapter.h" |
|
48 #include "xnkeyeventdispatcher.h" |
|
49 #include <aknlayoutscalable_avkon.cdl.h> |
|
50 #include "xuikon_builds_cfg.hrh" |
|
51 #include "xndomdocument.h" |
|
52 #include "xndomnode.h" |
|
53 #include "xneditmode.h" |
|
54 #include "xnnode.h" |
|
55 #include "xnpanic.h" |
|
56 #include "xneffectmanager.h" |
|
57 #include "xneditor.h" |
|
58 #include "xnbackgroundmanager.h" |
|
59 #include "xntexteditor.h" |
|
60 #include "xnrootdata.h" |
|
61 |
|
62 #ifdef _XN_PERFORMANCE_TEST_ |
|
63 #include "xntimemon.h" |
|
64 #endif |
|
65 |
|
66 #ifdef _XN3_DEBUG_ |
|
67 #include "xndepthfirsttreeiterator.h" // for TraceTreeL |
|
68 #endif |
|
69 |
|
70 |
|
71 // CONSTANTS |
|
72 const TInt KXnBorderThin = 1; |
|
73 const TInt KXnBorderMedium = 3; |
|
74 const TInt KXnBorderThick = 5; |
|
75 const TInt KXnStackPriorityKeyEventDispatcher = 55; |
|
76 const TInt KFocusGrowValue = 3; |
|
77 |
|
78 _LIT8( KBoxNodeName, "box" ); |
|
79 _LIT8( KButtonNodeName, "button" ); |
|
80 _LIT8( KWidgetNodeName, "widget" ); |
|
81 _LIT8( KWidgetExtensionNodeName, "widgetextension" ); |
|
82 _LIT8( KScrollableBoxNodeName, "scrollablebox" ); |
|
83 _LIT8( KMenuBar, "menubar" ); |
|
84 _LIT8( KPopUpNodeName, "popup" ); |
|
85 _LIT8( KEditorNodeName, "texteditor" ); |
|
86 |
|
87 _LIT8( KPlugin, "plugin" ); |
|
88 |
|
89 // LOCAL CONSTANTS AND MACROS |
|
90 static const TReal KIntConversionConstant = 0.5; |
|
91 static const TReal KIntPercentageConstant = |
|
92 static_cast< TReal >( 1 ) / static_cast< TReal >( 100 ); |
|
93 static const TReal KInchesAsTwips = 1440; |
|
94 static const TReal KCentimetersAsInches = static_cast< TReal >( 1 ) / 2.54; |
|
95 static const TReal KCentimetersAsTwips = KCentimetersAsInches * KInchesAsTwips; |
|
96 static const TReal KMillimetersAsInches = |
|
97 KCentimetersAsInches / static_cast< TReal >( 10 ); |
|
98 static const TReal KMillimetersAsTwips = KMillimetersAsInches * KInchesAsTwips; |
|
99 static const TReal KPointsAsInches = |
|
100 static_cast< TReal >( 1 ) / static_cast< TReal >( 72 ); |
|
101 static const TReal KPointsAsTwips = KPointsAsInches * KInchesAsTwips; |
|
102 static const TReal KPicasAsInches = |
|
103 KPointsAsInches / static_cast< TReal >( 12 ); |
|
104 static const TReal KPicasAsTwips = KPicasAsInches * KInchesAsTwips; |
|
105 |
|
106 // MODULE DATA STRUCTURES |
|
107 |
|
108 // LOCAL FUNCTION PROTOTYPES |
|
109 |
|
110 static TRect AddRect( const TRect& aOriginal, const TRect& aAdded ); |
|
111 static TRect SubtractRect( const TRect& aOriginal, const TRect& aSubtracter ); |
|
112 static TSize AutoStaticBTL( CXnNode& aNode, TInt aWidthToFit, |
|
113 TInt aHeightToFit, RArray< TPtrC8 >& aAutoProperties, |
|
114 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
115 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
116 static TSize AutoStaticLRL( CXnNode& aNode, TInt aWidthToFit, |
|
117 TInt aHeightToFit, RArray< TPtrC8 >& aAutoProperties, |
|
118 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
119 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
120 static TSize AutoStaticRLL( CXnNode& aNode, TInt aWidthToFit, |
|
121 TInt aHeightToFit, RArray< TPtrC8 >& aAutoProperties, |
|
122 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
123 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
124 static TSize AutoStaticTBL( CXnNode& aNode, TInt aWidthToFit, |
|
125 TInt aHeightToFit, RArray< TPtrC8 >& aAutoProperties, |
|
126 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
127 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
128 static void CalculateAbsolutePositionsL( CXnNode& aNode, |
|
129 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
130 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
131 static void CalculateBorderL( CXnNode& aNode, |
|
132 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
133 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
134 static void CalculateMarginL( CXnNode& aParent, CXnNode& aNode, |
|
135 CXnNode* aPreviousSibling, const TDesC8& aParentBlockProgression, |
|
136 const TDesC8& aParentDirection, TRect& aParentRect, |
|
137 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
138 TReal aVerticalUnitInPixels, TInt& aColumnWidth, TInt& aColumnMargin ); |
|
139 static void CalculatePaddingL( const TRect& aParentRect, CXnNode& aNode, |
|
140 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
141 TReal aVerticalUnitInPixels ); |
|
142 |
|
143 static void CalculateRectL( CXnNode& aNode, CXnNode& aParent, |
|
144 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
145 TReal aVerticalUnitInPixels ); |
|
146 |
|
147 static void CalculateRelativePositionsL( const TRect& aRect, CXnNode& aNode, |
|
148 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
149 TReal aVerticalUnitInPixels ); |
|
150 static TSize CalculateSpaceUsedByChildrenL( RPointerArray< CXnNode >& aChildren, |
|
151 CXnNode& aNode, const TDesC8& aParentBlockProgression, |
|
152 const TDesC8& aParentDirection, CGraphicsDevice& aScreenDevice, |
|
153 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
154 |
|
155 static TSize CalculateTotalDimensionsL( CXnNode& aNode, TBool aIgnoreAutoValues, |
|
156 TBool aIgnoreMinSizes, TRect& aParentRect, |
|
157 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
158 TReal aVerticalUnitInPixels ); |
|
159 static TBool CutOnePixelFromPercentChildNodeL( CXnNode& aNode, |
|
160 const TDesC8& aParentBlockProgression ); |
|
161 static void DetermineBorderWidthsL( CXnProperty* aBorderWidthProperty, |
|
162 TInt& aBordervertical, TInt& aBorderhorizontal, |
|
163 TRect& aParentRect, CGraphicsDevice& aGraphicsDevice, |
|
164 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
165 static TInt DisplayedChildrenCountL( CXnNode& aNode, |
|
166 RPointerArray< CXnNode >* aDisplayedChildren = NULL ); |
|
167 static CXnNode* DisplayedParentL( CXnNode& aNode ); |
|
168 static CXnDomPropertyValue* DomPropertyValueFromProperty( |
|
169 CXnProperty* aProperty ); |
|
170 static void DropExceedingRectL( const TRect& aParentRect, CXnNode& aNode, |
|
171 TBool aDropRelativeNode = EFalse ); |
|
172 static TBool CalculateExceedingArea( CXnNode& aParent, CXnNode& aChild, |
|
173 TInt& aLeftOffset, TInt& aRightOffset, TInt& aTopOffset, |
|
174 TInt& aBottomOffset ); |
|
175 static void AdjustRectsL( CXnNode& aNode, TInt aLeftOffset, TInt aRightOffset, |
|
176 TInt aTopOffset, TInt aBottomOffset ); |
|
177 static void ClearRects( CXnNode& aNode, TBool aRecurse = EFalse ); |
|
178 static void FitChildrenIntoParentL( CXnNode& aNode, |
|
179 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
180 TReal aVerticalUnitInPixels ); |
|
181 static TInt GetPositionL( CXnNode& aNode, |
|
182 const TDesC8& aParentBlockProgression, const TDesC8& aParentDirection ); |
|
183 static TInt HasNodeAutoValuesL( CXnNode& aNode ); |
|
184 static TInt HasNodeHorizontalAutoValuesL( CXnNode& aNode ); |
|
185 static TInt HasNodeVerticalAutoValuesL( CXnNode& aNode ); |
|
186 static TBool HasNodeMinSizesL( CXnNode& aNode ); |
|
187 static TBool HasNodeMaxSizesL( CXnNode& aNode ); |
|
188 static TInt HorizontalPixelValueL( CXnProperty* aValue, TInt aReferenceValue, |
|
189 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels ); |
|
190 static TInt HorizontalValueToPixelsL( CXnDomPropertyValue* aValue, |
|
191 TReal aReferenceValue, CGraphicsDevice& aScreenDevice, |
|
192 TReal aHorizontalUnitInPixels ); |
|
193 static void GrowToMinSizeL( CXnNode& aNode, TRect& aParentRect, |
|
194 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
195 TReal aVerticalUnitInPixels ); |
|
196 static void ShrinkToMaxSizeL( CXnNode& aNode, TRect& aParentRect, |
|
197 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
198 TReal aVerticalUnitInPixels ); |
|
199 static TBool IsAbsoluteL( CXnNode& aNode ); |
|
200 static TBool IsLargerThanMaxSizeL( const TRect& aParentRect, CXnNode& aNode, |
|
201 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
202 TReal aVerticalUnitInPixels ); |
|
203 static TBool IsNodeDisplayedL( CXnNode& aNode ); |
|
204 |
|
205 static TBool IsNodeTooltip( CXnNode& aNode ); |
|
206 static TBool IsPropertyAutoL( CXnProperty& aProperty ); |
|
207 static TBool IsPropertyNone( CXnProperty& aProperty ); |
|
208 static TBool IsRelativeL( CXnNode& aNode ); |
|
209 static TBool IsSmallerThanMinSizeL( const TRect& aParentRect, CXnNode& aNode, |
|
210 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
211 TReal aVerticalUnitInPixels ); |
|
212 static TBool IsValuePercentageL( CXnProperty& aProperty ); |
|
213 static TInt PercentageToPixelsL( TReal& aPercentage, TReal aReferenceValue ); |
|
214 static void PlaceAreasL( CXnNode& aNode, |
|
215 RPointerArray< CXnNode >& aLaidOutList, |
|
216 TInt aLayoutPhase, CGraphicsDevice& aGraphicsDevice, |
|
217 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
218 static void PriorizeChildrenL( CXnNode& aNode ); |
|
219 static void CalculateAutoPropertiesOfNodesL( |
|
220 RPointerArray< CXnNode >* aAutoNodeArray, TInt& aWidthAutoCount, |
|
221 TInt& aHeightAutoCount ); |
|
222 static void ProcessAutoAreasL( CXnNode& aParentNode, |
|
223 RPointerArray< CXnNode >* aArray, const TDesC8& aParentBlockProgression, |
|
224 const TDesC8& aParentDirection, CGraphicsDevice& aGraphicsDevice, |
|
225 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ); |
|
226 static void CalculateCollapseMarginsL( RPointerArray< CXnNode >& aChildren, |
|
227 RArray< TInt >& aCollapsedMarginsWidth, |
|
228 RArray< TInt >& aCollapsedMarginsHeight, |
|
229 const TDesC8& aParentBlockProgression, |
|
230 const TDesC8& aParentDirection ); |
|
231 static TSize CalculateSpaceUsedByAutoChildrenL( |
|
232 RPointerArray< CXnNode >& aAutoChildren, |
|
233 RPointerArray< CXnNode >& aCalculatedAutoChildren, |
|
234 CXnNode& aParent, |
|
235 const TDesC8& aParentBlockProgression, |
|
236 const TDesC8& aParentDirection, |
|
237 CGraphicsDevice& aScreenDevice ); |
|
238 static void MoveAutoAreaL( TRect& parentRect, |
|
239 RPointerArray< CXnNode >& aChildren, |
|
240 const TDesC8& aParentBlockProgression, |
|
241 const TDesC8& aParentDirection ); |
|
242 static TSize ScaleAutoAreaL( CXnNode& aNode, TInt aWidthToFit, |
|
243 TInt aHeightToFit, const TDesC8& aParentBlockProgression, |
|
244 const TDesC8& aParentDirection, TRect& aParentRect, |
|
245 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
246 TReal aVerticalUnitInPixels ); |
|
247 static void FitAutoChildrenIntoParentL( RPointerArray< CXnNode >& aAutoChildren, |
|
248 RPointerArray< CXnNode >& aCalculatedAutoChildren, CXnNode& aParent, |
|
249 const TDesC8& aParentBlockProgression, const TDesC8& aParentDirection, |
|
250 CGraphicsDevice& aGraphicsDevice ); |
|
251 static TInt VerticalPixelValueL( CXnProperty* aValue, TInt aReferenceValue, |
|
252 CGraphicsDevice& aScreenDevice, TReal aVerticalUnitInPixels ); |
|
253 static TInt VerticalValueToPixelsL( CXnDomPropertyValue* aValue, |
|
254 TReal aReferenceValue, CGraphicsDevice& aScreenDevice, |
|
255 TReal aVerticalUnitInPixels ); |
|
256 static TBool IsStringValueL( CXnProperty& aProperty ); |
|
257 static TInt HorizontalUnitsToPixelsL( TReal aUnits, |
|
258 TReal aHorizontalUnitInPixels ); |
|
259 static TInt VerticalUnitsToPixelsL( TReal aUnits, TReal aVerticalUnitInPixels ); |
|
260 static void ProcessAdaptiveAreasL( CXnNode& aParent, |
|
261 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
262 TReal aVerticalUnitInPixels ); |
|
263 |
|
264 static void CalculateAdaptiveSizeL( CXnNode& aNode, |
|
265 const TDesC8& aParentBlockProgression, const TDesC8& aParentDirection, |
|
266 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
267 TReal aVerticalUnitInPixels ); |
|
268 |
|
269 static CXnNode* BuildTriggerNodeLC( CXnUiEngine& aUiEngine, |
|
270 const TDesC8& aTriggerName ); |
|
271 static void UpdateInternalUnits( TReal& aHorizontalUnitInPixels, |
|
272 TReal& aVerticalUnitInPixels, TRect aRect ); |
|
273 static CXnNode* BuildScreenDeviceChangeTriggerNodeLC( |
|
274 CXnUiEngine& aUiEngine ); |
|
275 static void FillFocusCandidatesL( CXnNode* aParent, |
|
276 RPointerArray< CXnNode >& aArray ); |
|
277 static TBool SetAdaptivesL( CXnNode& aNode ); |
|
278 |
|
279 static void FindNodeByClassL( CXnNode* aRootNode, const TDesC8& aClassId, |
|
280 CXnPointerArray& aArray, const TDesC8& aNamespace ); |
|
281 static CXnNode* FindNodeByIdL( CXnNode* aRootNode, const TDesC8& aAreaId, |
|
282 const TDesC8& aNamespace ); |
|
283 |
|
284 #ifdef _XN3_DEBUG_ |
|
285 static void TraceTreeL( CXnNode* aRootNode ); |
|
286 #endif |
|
287 |
|
288 // ============================= LOCAL FUNCTIONS =============================== |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 CXnNode* FindPlugin( CXnNode& aNode ) |
|
294 { |
|
295 CXnNode* pluginNode( NULL ); |
|
296 for( CXnNode* node = &aNode; node; node = node->Parent() ) |
|
297 { |
|
298 if( node->DomNode()->Name() == KPlugin ) |
|
299 { |
|
300 pluginNode = node; |
|
301 break; |
|
302 } |
|
303 } |
|
304 return pluginNode; |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // GrowIfNeeded() |
|
309 // When a plugin is focused, the focus is a bit bigger than its control |
|
310 // (this is a hack fix to get focus visible with WRT widgets). |
|
311 // Therefore we need to check if focused node is a plugin, |
|
312 // or focused node has same size with its plugin, and grow dirty rect accordingly. |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 static void GrowIfNeeded(CXnNode* aNode, TRect& aRect) |
|
316 { |
|
317 CXnNode* focusedNode(NULL); |
|
318 for( CXnNode* node = aNode; node; node = node->Parent() ) |
|
319 { |
|
320 if( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
321 { |
|
322 if( node->DomNode()->Name() == KPlugin ) |
|
323 { |
|
324 CXnControlAdapter* adapter( node->Control() ); |
|
325 if(adapter) |
|
326 { |
|
327 aRect = adapter->Rect(); |
|
328 aRect.Grow( KFocusGrowValue, KFocusGrowValue ); |
|
329 } |
|
330 break; |
|
331 } |
|
332 focusedNode = node; |
|
333 } |
|
334 else if( node->DomNode()->Name() == KPlugin ) |
|
335 { |
|
336 if( focusedNode && focusedNode->MarginRect() == node->Rect() ) |
|
337 { |
|
338 CXnControlAdapter* adapter( focusedNode->Control() ); |
|
339 if(adapter) |
|
340 { |
|
341 aRect = adapter->Rect(); |
|
342 aRect.Grow( KFocusGrowValue, KFocusGrowValue ); |
|
343 } |
|
344 } |
|
345 break; |
|
346 } |
|
347 } |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // ----------------------------------------------------------------------------- |
|
352 static TBool IsSrollableBox( CXnNode& aNode ) |
|
353 { |
|
354 if( aNode.Type()->Type() == KScrollableBoxNodeName ) |
|
355 { |
|
356 return ETrue; |
|
357 } |
|
358 return EFalse; |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // FindNodeByClassL() |
|
363 // Finds recursively a node from current view by class |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 static void FindNodeByClassL( CXnNode* aRootNode, const TDesC8& aClassId, |
|
367 CXnPointerArray& aArray, const TDesC8& aNamespace ) |
|
368 { |
|
369 ASSERT( aRootNode ); |
|
370 |
|
371 if ( aNamespace != KNullDesC8 && aNamespace != aRootNode->Namespace() ) |
|
372 { |
|
373 // Recursed to wrong namespace |
|
374 return; |
|
375 } |
|
376 |
|
377 CXnProperty* prop( aRootNode->ClassL() ); |
|
378 |
|
379 if ( prop && prop->StringValue() == aClassId ) |
|
380 { |
|
381 // Correct id found |
|
382 if ( aNamespace == KNullDesC8 ) |
|
383 { |
|
384 aArray.Container().AppendL( aRootNode ); |
|
385 } |
|
386 else if ( aNamespace == aRootNode->DomNode()->Namespace() ) |
|
387 { |
|
388 // Namespace is defined and this node is in that namespace |
|
389 // -> this is perfect match |
|
390 aArray.Container().AppendL( aRootNode ); |
|
391 } |
|
392 } |
|
393 |
|
394 // Recurse children |
|
395 RPointerArray< CXnNode >& children( aRootNode->Children() ); |
|
396 |
|
397 for ( TInt i = 0; i < children.Count(); i++ ) |
|
398 { |
|
399 FindNodeByClassL( children[i], aClassId, aArray, aNamespace ); |
|
400 } |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // FindNodeByIdL() |
|
405 // Finds recursively a node from current view by id |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 static CXnNode* FindNodeByIdL( CXnNode* aRootNode, const TDesC8& aAreaId, |
|
409 const TDesC8& aNamespace ) |
|
410 { |
|
411 ASSERT( aRootNode ); |
|
412 |
|
413 if ( aNamespace != KNullDesC8 && aNamespace != aRootNode->Namespace() ) |
|
414 { |
|
415 // Recursed to wrong namespace |
|
416 return NULL; |
|
417 } |
|
418 |
|
419 CXnProperty* prop( aRootNode->IdL() ); |
|
420 |
|
421 if ( prop && prop->StringValue() == aAreaId ) |
|
422 { |
|
423 // Correct id found |
|
424 if ( aNamespace == KNullDesC8 ) |
|
425 { |
|
426 // No namespace defined, so this is the first found best match |
|
427 return aRootNode; |
|
428 } |
|
429 else if ( aNamespace == aRootNode->DomNode()->Namespace() ) |
|
430 { |
|
431 // Namespace is defined and this node is in that namespace |
|
432 // -> this is perfect match |
|
433 return aRootNode; |
|
434 } |
|
435 } |
|
436 |
|
437 // No match found, recurse children |
|
438 RPointerArray< CXnNode >& children( aRootNode->Children() ); |
|
439 |
|
440 for ( TInt i = 0; i < children.Count(); i++ ) |
|
441 { |
|
442 CXnNode* retval( FindNodeByIdL( children[i], aAreaId, aNamespace ) ); |
|
443 |
|
444 if ( retval ) |
|
445 { |
|
446 return retval; |
|
447 } |
|
448 } |
|
449 |
|
450 return NULL; |
|
451 } |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // AutoStaticVerticalBTL() |
|
455 // Calculate properties set to AUTO when positioning is static, layout vertical |
|
456 // and direction right-to-left |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 static TSize AutoStaticBTL( CXnNode& aNode, TInt aWidthToFit, TInt aHeightToFit, |
|
460 RArray< TPtrC8 >& aAutoProperties, TRect& aParentRect, |
|
461 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
462 TReal aVerticalUnitInPixels ) |
|
463 { |
|
464 // Static positioning, vertical, right to left |
|
465 TBool horizontalMarginProcessed = EFalse; |
|
466 TBool verticalMarginProcessed = EFalse; |
|
467 TBool allVerticalValuesProcessed = EFalse; |
|
468 TBool allHorizontalValuesProcessed = EFalse; |
|
469 |
|
470 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
471 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
472 CXnProperty* minHeightProperty = aNode.MinHeightL(); |
|
473 CXnProperty* minWidthProperty = aNode.MinWidthL(); |
|
474 |
|
475 TRect contentRect( aNode.Rect() ); |
|
476 TRect paddingRect( aNode.PaddingRect() ); |
|
477 TRect borderRect( aNode.BorderRect() ); |
|
478 TRect marginRect( aNode.MarginRect() ); |
|
479 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
480 |
|
481 TSize size = CalculateTotalDimensionsL( aNode, EFalse, ETrue, aParentRect, |
|
482 aGraphicsDevice, aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
483 |
|
484 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
485 { |
|
486 // search for height property |
|
487 const TDesC8& attributeName = aAutoProperties[i]; |
|
488 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
489 { |
|
490 // height was AUTO, all other vertical auto values are 0 |
|
491 TInt newHeight = aHeightToFit - size.iHeight; |
|
492 |
|
493 // Calculate the difference so that it can be returned |
|
494 TRect paddingRectDiff( SubtractRect( paddingRect, contentRect ) ); |
|
495 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
496 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
497 TRect normalFlowBorderRectDiff( SubtractRect ( normalFlowBorderRect, |
|
498 contentRect ) ); |
|
499 |
|
500 // grow height to fill the void |
|
501 contentRect.SetHeight( newHeight ); |
|
502 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
503 borderRect = AddRect( contentRect, borderRectDiff ); |
|
504 normalFlowBorderRect = AddRect( contentRect, |
|
505 normalFlowBorderRectDiff ); |
|
506 marginRect = AddRect( contentRect, marginRectDiff ); |
|
507 |
|
508 size = TSize( size.iWidth, aHeightToFit ); |
|
509 } |
|
510 } |
|
511 |
|
512 // if exactly one value is AUTO, value is computed to make equality true |
|
513 if ( aAutoProperties.Count() == 1 ) |
|
514 { |
|
515 if ( !allHorizontalValuesProcessed ) |
|
516 { |
|
517 const TDesC8& attributeName = aAutoProperties[0]; |
|
518 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
519 { |
|
520 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
521 if ( remainingWidth < 0 ) |
|
522 { |
|
523 remainingWidth = 0; |
|
524 } |
|
525 // Calculate the difference so that it can be returned |
|
526 TRect paddingRectDiff( SubtractRect( paddingRect, |
|
527 contentRect ) ); |
|
528 TRect borderRectDiff( SubtractRect( borderRect, |
|
529 contentRect ) ); |
|
530 TRect marginRectDiff( SubtractRect( marginRect, |
|
531 contentRect ) ); |
|
532 TRect normalFlowBorderRectDiff( SubtractRect( |
|
533 normalFlowBorderRect, contentRect ) ); |
|
534 |
|
535 // grow width to fill the void |
|
536 contentRect.SetWidth( remainingWidth ); |
|
537 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
538 borderRect = AddRect( contentRect, borderRectDiff ); |
|
539 normalFlowBorderRect = AddRect( contentRect, |
|
540 normalFlowBorderRectDiff ); |
|
541 marginRect = AddRect( contentRect, marginRectDiff ); |
|
542 |
|
543 size = TSize( aWidthToFit, size.iHeight ); |
|
544 } |
|
545 |
|
546 if ( attributeName == |
|
547 XnPropertyNames::style::common::KMarginLeft ) |
|
548 { |
|
549 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
550 if ( remainingWidth < 0 ) |
|
551 { |
|
552 remainingWidth = 0; |
|
553 } |
|
554 contentRect.Move( remainingWidth, 0 ); |
|
555 borderRect.Move( remainingWidth, 0 ); |
|
556 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
557 marginRect.Resize( remainingWidth, 0 ); |
|
558 paddingRect.Move( remainingWidth, 0 ); |
|
559 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
560 } |
|
561 |
|
562 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
563 { |
|
564 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
565 if ( remainingWidth < 0 ) |
|
566 { |
|
567 remainingWidth = 0; |
|
568 } |
|
569 marginRect.Resize( remainingWidth, 0 ); |
|
570 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
571 } |
|
572 |
|
573 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
574 { |
|
575 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
576 if ( remainingHeight < 0 ) |
|
577 { |
|
578 remainingHeight = 0; |
|
579 } |
|
580 marginRect.Resize( 0, remainingHeight ); |
|
581 marginRect.Move( 0, -remainingHeight ); |
|
582 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
583 } |
|
584 |
|
585 if ( attributeName == |
|
586 XnPropertyNames::style::common::KMarginBottom ) |
|
587 { |
|
588 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
589 if ( remainingHeight < 0 ) |
|
590 { |
|
591 remainingHeight = 0; |
|
592 } |
|
593 marginRect.Resize( 0, remainingHeight ); |
|
594 marginRect.Move( 0, -remainingHeight ); |
|
595 paddingRect.Move( 0, -remainingHeight ); |
|
596 borderRect.Move( 0, -remainingHeight ); |
|
597 normalFlowBorderRect.Move( 0, -remainingHeight ); |
|
598 contentRect.Move( 0, -remainingHeight ); |
|
599 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
600 } |
|
601 } |
|
602 } |
|
603 else |
|
604 { |
|
605 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
606 { |
|
607 const TDesC8& attributeName = aAutoProperties[i]; |
|
608 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
609 { |
|
610 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
611 if ( remainingWidth < 0 ) |
|
612 { |
|
613 remainingWidth = 0; |
|
614 } |
|
615 // Calculate the difference so that it can be returned |
|
616 TRect paddingRectDiff( SubtractRect( |
|
617 paddingRect, contentRect ) ); |
|
618 TRect borderRectDiff( SubtractRect( |
|
619 borderRect, contentRect ) ); |
|
620 TRect marginRectDiff( SubtractRect( |
|
621 marginRect, contentRect ) ); |
|
622 TRect normalFlowBorderRectDiff( SubtractRect( |
|
623 normalFlowBorderRect, contentRect ) ); |
|
624 |
|
625 // grow width to fill the void |
|
626 contentRect.SetWidth( remainingWidth ); |
|
627 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
628 borderRect = AddRect( contentRect, borderRectDiff ); |
|
629 normalFlowBorderRect = AddRect( |
|
630 contentRect, normalFlowBorderRectDiff ); |
|
631 marginRect = AddRect( contentRect, marginRectDiff ); |
|
632 |
|
633 size = TSize( aWidthToFit, size.iHeight ); |
|
634 } |
|
635 |
|
636 // several auto properties |
|
637 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
638 { |
|
639 if ( !horizontalMarginProcessed ) |
|
640 { |
|
641 // is right margin also set to AUTO? |
|
642 CXnProperty* rightMargin = aNode.MarginRightL(); |
|
643 if ( rightMargin ) |
|
644 { |
|
645 if ( IsPropertyAutoL( *rightMargin ) ) |
|
646 { |
|
647 // both margins set to AUTO, values equal |
|
648 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
649 if ( remainingWidth < 0 ) |
|
650 { |
|
651 remainingWidth = 0; |
|
652 } |
|
653 // move rect right to fill the void |
|
654 contentRect.Move( ( remainingWidth / 2 ), 0 ); |
|
655 marginRect.Resize( remainingWidth, 0 ); |
|
656 borderRect.Move( ( remainingWidth / 2 ), 0 ); |
|
657 normalFlowBorderRect.Move( ( |
|
658 remainingWidth / 2 ), 0 ); |
|
659 paddingRect.Move( remainingWidth / 2, 0 ); |
|
660 horizontalMarginProcessed = ETrue; |
|
661 size = TSize( size.iWidth + remainingWidth, |
|
662 size.iHeight ); |
|
663 } |
|
664 else |
|
665 { |
|
666 // only left margin set to AUTO |
|
667 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
668 if ( remainingWidth < 0 ) |
|
669 { |
|
670 remainingWidth = 0; |
|
671 } |
|
672 // move rect right to fill the void |
|
673 contentRect.Move( ( remainingWidth ), 0 ); |
|
674 marginRect.Resize( remainingWidth, 0 ); |
|
675 borderRect.Move( remainingWidth, 0 ); |
|
676 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
677 paddingRect.Move( remainingWidth, 0 ); |
|
678 horizontalMarginProcessed = ETrue; |
|
679 size = TSize( size.iWidth + remainingWidth, |
|
680 size.iHeight ); |
|
681 } |
|
682 } |
|
683 } |
|
684 } |
|
685 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
686 { |
|
687 if ( !horizontalMarginProcessed ) |
|
688 { |
|
689 // is left margin also set to AUTO? |
|
690 CXnProperty* leftMargin = aNode.MarginLeftL(); |
|
691 if ( leftMargin ) |
|
692 { |
|
693 if ( IsPropertyAutoL( *leftMargin ) ) |
|
694 { |
|
695 // both margins set to AUTO, values equal |
|
696 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
697 if ( remainingWidth < 0 ) |
|
698 { |
|
699 remainingWidth = 0; |
|
700 } |
|
701 contentRect.Move( remainingWidth / 2, 0 ); |
|
702 marginRect.Resize( remainingWidth, 0 ); |
|
703 borderRect.Move( ( remainingWidth / 2 ), 0 ); |
|
704 normalFlowBorderRect.Move( ( |
|
705 remainingWidth / 2 ), 0 ); |
|
706 paddingRect.Move( remainingWidth / 2, 0 ); |
|
707 horizontalMarginProcessed = ETrue; |
|
708 size = TSize( size.iWidth + remainingWidth, |
|
709 size.iHeight ); |
|
710 } |
|
711 else |
|
712 { |
|
713 // only right margin set to AUTO |
|
714 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
715 if ( remainingWidth < 0 ) |
|
716 { |
|
717 remainingWidth = 0; |
|
718 } |
|
719 marginRect.Resize( remainingWidth, 0 ); |
|
720 horizontalMarginProcessed = ETrue; |
|
721 size = TSize( size.iWidth + remainingWidth, |
|
722 size.iHeight ); |
|
723 } |
|
724 } |
|
725 } |
|
726 } |
|
727 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
728 { |
|
729 if ( !verticalMarginProcessed && |
|
730 !allVerticalValuesProcessed ) |
|
731 { |
|
732 // is bottom margin also set to AUTO? |
|
733 CXnProperty* bottomMargin = aNode.MarginBottomL(); |
|
734 if ( bottomMargin ) |
|
735 { |
|
736 if ( IsPropertyAutoL( *bottomMargin ) ) |
|
737 { |
|
738 // both margins set to AUTO, values equal |
|
739 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
740 if ( remainingHeight < 0 ) |
|
741 { |
|
742 remainingHeight = 0; |
|
743 } |
|
744 contentRect.Move( 0, remainingHeight / 2 ); |
|
745 marginRect.Resize( 0, remainingHeight ); |
|
746 borderRect.Move( 0, ( remainingHeight / 2 ) ); |
|
747 normalFlowBorderRect.Move( |
|
748 0, ( remainingHeight / 2 ) ); |
|
749 paddingRect.Move( 0, remainingHeight / 2 ); |
|
750 verticalMarginProcessed = ETrue; |
|
751 size = TSize( size.iWidth, |
|
752 size.iHeight + remainingHeight ); |
|
753 } |
|
754 else |
|
755 { |
|
756 // only top margin set to AUTO |
|
757 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
758 if ( remainingHeight < 0 ) |
|
759 { |
|
760 remainingHeight = 0; |
|
761 } |
|
762 marginRect.Resize( 0, remainingHeight ); |
|
763 marginRect.Move( 0, -remainingHeight ); |
|
764 verticalMarginProcessed = ETrue; |
|
765 size = TSize( size.iWidth, |
|
766 size.iHeight + remainingHeight ); |
|
767 } |
|
768 } |
|
769 } |
|
770 } |
|
771 if ( attributeName == |
|
772 XnPropertyNames::style::common::KMarginBottom ) |
|
773 { |
|
774 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
775 { |
|
776 // is top margin also set to AUTO? |
|
777 CXnProperty* topMargin = aNode.MarginTopL(); |
|
778 if ( topMargin ) |
|
779 { |
|
780 if ( IsPropertyAutoL( *topMargin ) ) |
|
781 { |
|
782 // both margins set to AUTO, values equal |
|
783 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
784 if ( remainingHeight < 0 ) |
|
785 { |
|
786 remainingHeight = 0; |
|
787 } |
|
788 contentRect.Move( 0, -( remainingHeight / 2 ) ); |
|
789 marginRect.Resize( 0, remainingHeight ); |
|
790 marginRect.Move( 0, -remainingHeight ); |
|
791 borderRect.Move( 0, -( remainingHeight / 2 ) ); |
|
792 normalFlowBorderRect.Move( |
|
793 0, -( remainingHeight / 2 ) ); |
|
794 paddingRect.Move( 0, -( remainingHeight / 2 ) ); |
|
795 verticalMarginProcessed = ETrue; |
|
796 size = TSize( size.iWidth, |
|
797 size.iHeight + remainingHeight ); |
|
798 } |
|
799 else |
|
800 { |
|
801 // only bottom margin set to AUTO |
|
802 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
803 if ( remainingHeight < 0 ) |
|
804 { |
|
805 remainingHeight = 0; |
|
806 } |
|
807 contentRect.Move( 0, -remainingHeight ); |
|
808 marginRect.Resize( 0, remainingHeight ); |
|
809 marginRect.Move( 0, -remainingHeight ); |
|
810 borderRect.Move( 0, -remainingHeight ); |
|
811 normalFlowBorderRect.Move( |
|
812 0, -remainingHeight ); |
|
813 paddingRect.Move( 0, -remainingHeight ); |
|
814 verticalMarginProcessed = ETrue; |
|
815 size = TSize( size.iWidth, |
|
816 size.iHeight + remainingHeight ); |
|
817 } |
|
818 } |
|
819 } |
|
820 } |
|
821 } |
|
822 } |
|
823 aNode.SetRect( contentRect ); |
|
824 aNode.SetPaddingRect( paddingRect ); |
|
825 aNode.SetBorderRect( borderRect ); |
|
826 aNode.SetMarginRect( marginRect ); |
|
827 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
828 return contentRect.Size(); |
|
829 } |
|
830 |
|
831 // ----------------------------------------------------------------------------- |
|
832 // AutoStaticLRL() |
|
833 // Calculate properties set to AUTO when positioning is static, |
|
834 // layout horizontal |
|
835 // and direction left-to-right |
|
836 // ----------------------------------------------------------------------------- |
|
837 // |
|
838 static TSize AutoStaticLRL( CXnNode& aNode, TInt aWidthToFit, TInt aHeightToFit, |
|
839 RArray< TPtrC8 >& aAutoProperties, TRect& aParentRect, |
|
840 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
841 TReal aVerticalUnitInPixels ) |
|
842 { |
|
843 // Static positioning, horizontal, left to right |
|
844 TBool horizontalMarginProcessed = EFalse; |
|
845 TBool verticalMarginProcessed = EFalse; |
|
846 TBool allVerticalValuesProcessed = EFalse; |
|
847 TBool allHorizontalValuesProcessed = EFalse; |
|
848 |
|
849 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
850 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
851 CXnProperty* minHeightProperty = aNode.MinHeightL(); |
|
852 CXnProperty* minWidthProperty = aNode.MinWidthL(); |
|
853 |
|
854 TRect contentRect = aNode.Rect(); |
|
855 TRect paddingRect = aNode.PaddingRect(); |
|
856 TRect borderRect = aNode.BorderRect(); |
|
857 TRect marginRect = aNode.MarginRect(); |
|
858 TRect normalFlowBorderRect = aNode.NormalFlowBorderRect(); |
|
859 TSize size = CalculateTotalDimensionsL( aNode, EFalse, ETrue, aParentRect, |
|
860 aGraphicsDevice, aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
861 |
|
862 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
863 { |
|
864 // search for width property |
|
865 const TDesC8& attributeName = aAutoProperties[i]; |
|
866 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
867 { |
|
868 // width was AUTO, all other vertical auto values are 0 |
|
869 TInt newWidth = aWidthToFit - size.iWidth; |
|
870 |
|
871 // Calculate the difference so that it can be returned |
|
872 TRect paddingRectDiff( SubtractRect( paddingRect, contentRect ) ); |
|
873 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
874 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
875 TRect normalFlowBorderRectDiff( SubtractRect( normalFlowBorderRect, |
|
876 contentRect ) ); |
|
877 |
|
878 // grow width to fill the void |
|
879 contentRect.SetWidth( newWidth ); |
|
880 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
881 borderRect = AddRect( contentRect, borderRectDiff ); |
|
882 normalFlowBorderRect = AddRect( |
|
883 contentRect, normalFlowBorderRectDiff ); |
|
884 marginRect = AddRect( contentRect, marginRectDiff ); |
|
885 |
|
886 size = TSize( aWidthToFit, size.iHeight ); |
|
887 allHorizontalValuesProcessed = ETrue; |
|
888 } |
|
889 } |
|
890 |
|
891 // if exactly one value is AUTO, value is computed to make equality true |
|
892 if ( aAutoProperties.Count() == 1 ) |
|
893 { |
|
894 if ( !allHorizontalValuesProcessed ) |
|
895 { |
|
896 const TDesC8& attributeName = aAutoProperties[0]; |
|
897 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
898 { |
|
899 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
900 if ( remainingHeight < 0 ) |
|
901 { |
|
902 remainingHeight = 0; |
|
903 } |
|
904 // Calculate the difference so that it can be returned |
|
905 TRect paddingRectDiff( SubtractRect( |
|
906 paddingRect, contentRect ) ); |
|
907 TRect borderRectDiff( SubtractRect( |
|
908 borderRect, contentRect ) ); |
|
909 TRect marginRectDiff( SubtractRect( |
|
910 marginRect, contentRect ) ); |
|
911 TRect normalFlowBorderRectDiff( SubtractRect( |
|
912 normalFlowBorderRect, contentRect ) ); |
|
913 |
|
914 // grow height to fill the void |
|
915 contentRect.SetHeight( remainingHeight ); |
|
916 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
917 borderRect = AddRect( contentRect, borderRectDiff ); |
|
918 normalFlowBorderRect = AddRect( |
|
919 contentRect, normalFlowBorderRectDiff ); |
|
920 marginRect = AddRect( contentRect, marginRectDiff ); |
|
921 size = TSize( size.iWidth, aHeightToFit ); |
|
922 } |
|
923 |
|
924 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
925 { |
|
926 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
927 if ( remainingWidth < 0 ) |
|
928 { |
|
929 remainingWidth = 0; |
|
930 } |
|
931 // move rect right to fill the void |
|
932 contentRect.Move( remainingWidth, 0 ); |
|
933 paddingRect.Move( remainingWidth, 0 ); |
|
934 borderRect.Move( remainingWidth, 0 ); |
|
935 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
936 marginRect.Resize( remainingWidth, 0 ); |
|
937 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
938 } |
|
939 |
|
940 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
941 { |
|
942 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
943 marginRect.Resize( remainingWidth, 0 ); |
|
944 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
945 } |
|
946 |
|
947 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
948 { |
|
949 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
950 // move rect right to fill the void |
|
951 contentRect.Move( 0, remainingHeight / 2 ); |
|
952 paddingRect.Move( 0, remainingHeight / 2 ); |
|
953 borderRect.Move( 0, remainingHeight / 2 ); |
|
954 normalFlowBorderRect.Move( 0, remainingHeight / 2 ); |
|
955 marginRect.Resize( 0, remainingHeight ); |
|
956 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
957 } |
|
958 |
|
959 if ( attributeName == |
|
960 XnPropertyNames::style::common::KMarginBottom ) |
|
961 { |
|
962 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
963 if ( remainingHeight < 0 ) |
|
964 { |
|
965 remainingHeight = 0; |
|
966 } |
|
967 marginRect.Resize( 0, remainingHeight ); |
|
968 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
969 } |
|
970 } |
|
971 } |
|
972 else |
|
973 { |
|
974 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
975 { |
|
976 const TDesC8& attributeName = aAutoProperties[i]; |
|
977 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
978 { |
|
979 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
980 if ( remainingHeight < 0 ) |
|
981 { |
|
982 remainingHeight = 0; |
|
983 } |
|
984 // Calculate the difference so that it can be returned |
|
985 TRect paddingRectDiff( SubtractRect( |
|
986 paddingRect, contentRect ) ); |
|
987 TRect borderRectDiff( SubtractRect( |
|
988 borderRect, contentRect ) ); |
|
989 TRect marginRectDiff( SubtractRect( |
|
990 marginRect, contentRect ) ); |
|
991 TRect normalFlowBorderRectDiff( SubtractRect( |
|
992 normalFlowBorderRect, contentRect ) ); |
|
993 |
|
994 // grow height to fill the void |
|
995 contentRect.SetHeight( remainingHeight ); |
|
996 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
997 borderRect = AddRect( contentRect, borderRectDiff ); |
|
998 normalFlowBorderRect = AddRect( |
|
999 contentRect, normalFlowBorderRectDiff ); |
|
1000 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1001 size = TSize( size.iWidth, aHeightToFit ); |
|
1002 } |
|
1003 |
|
1004 // several auto properties |
|
1005 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
1006 { |
|
1007 if ( !horizontalMarginProcessed ) |
|
1008 { |
|
1009 // is right margin also set to AUTO? |
|
1010 CXnProperty* rightMargin = aNode.MarginRightL(); |
|
1011 if ( rightMargin ) |
|
1012 { |
|
1013 if ( IsPropertyAutoL( *rightMargin ) ) |
|
1014 { |
|
1015 // both margins set to AUTO, values equal |
|
1016 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1017 if ( remainingWidth < 0 ) |
|
1018 { |
|
1019 remainingWidth = 0; |
|
1020 } |
|
1021 // move rect right to fill the void |
|
1022 contentRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1023 horizontalMarginProcessed = ETrue; |
|
1024 marginRect.Resize( ( remainingWidth ), 0 ); |
|
1025 borderRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1026 normalFlowBorderRect.Move( ( |
|
1027 remainingWidth / 2 ), 0 ); |
|
1028 paddingRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1029 size = TSize( size.iWidth + remainingWidth, |
|
1030 size.iHeight ); |
|
1031 } |
|
1032 else |
|
1033 { |
|
1034 // only left margin set to AUTO |
|
1035 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1036 if ( remainingWidth < 0 ) |
|
1037 { |
|
1038 remainingWidth = 0; |
|
1039 } |
|
1040 // move rect right to fill the void |
|
1041 contentRect.Move( remainingWidth, 0 ); |
|
1042 horizontalMarginProcessed = ETrue; |
|
1043 marginRect.Move( remainingWidth, 0 ); |
|
1044 borderRect.Move( remainingWidth, 0 ); |
|
1045 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
1046 paddingRect.Move( remainingWidth, 0 ); |
|
1047 size = TSize( size.iWidth + remainingWidth, |
|
1048 size.iHeight ); |
|
1049 } |
|
1050 } |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
1055 { |
|
1056 if ( !horizontalMarginProcessed ) |
|
1057 { |
|
1058 // is left margin also set to AUTO? |
|
1059 CXnProperty* leftMargin = aNode.MarginLeftL(); |
|
1060 if ( leftMargin ) |
|
1061 { |
|
1062 if ( IsPropertyAutoL( *leftMargin ) ) |
|
1063 { |
|
1064 // both margins set to AUTO, values equal |
|
1065 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1066 if ( remainingWidth < 0 ) |
|
1067 { |
|
1068 remainingWidth = 0; |
|
1069 } |
|
1070 // move rect right to fill the void |
|
1071 contentRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1072 horizontalMarginProcessed = ETrue; |
|
1073 marginRect.Resize( ( remainingWidth ), 0 ); |
|
1074 borderRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1075 normalFlowBorderRect.Move( ( |
|
1076 remainingWidth / 2 ), 0 ); |
|
1077 paddingRect.Move( ( remainingWidth / 2 ), 0 ); |
|
1078 size = TSize( size.iWidth + remainingWidth, |
|
1079 size.iHeight ); |
|
1080 } |
|
1081 else |
|
1082 { |
|
1083 // only right margin set to AUTO |
|
1084 horizontalMarginProcessed = ETrue; |
|
1085 } |
|
1086 } |
|
1087 } |
|
1088 } |
|
1089 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
1090 { |
|
1091 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1092 { |
|
1093 // is bottom margin also set to AUTO? |
|
1094 CXnProperty* bottomMargin = aNode.MarginBottomL(); |
|
1095 if ( bottomMargin ) |
|
1096 { |
|
1097 if ( IsPropertyAutoL( *bottomMargin ) ) |
|
1098 { |
|
1099 // both margins set to AUTO, values equal |
|
1100 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1101 if ( remainingHeight < 0 ) |
|
1102 { |
|
1103 remainingHeight = 0; |
|
1104 } |
|
1105 // move rect right to fill the void |
|
1106 contentRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1107 verticalMarginProcessed = ETrue; |
|
1108 marginRect.Resize( 0, remainingHeight ); |
|
1109 borderRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1110 normalFlowBorderRect.Move( |
|
1111 0, ( remainingHeight / 2 ) ); |
|
1112 paddingRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1113 size = TSize( size.iWidth, |
|
1114 size.iHeight + remainingHeight ); |
|
1115 } |
|
1116 else |
|
1117 { |
|
1118 // only top margin set to AUTO |
|
1119 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1120 if ( remainingHeight < 0 ) |
|
1121 { |
|
1122 remainingHeight = 0; |
|
1123 } |
|
1124 // move rect right to fill the void |
|
1125 contentRect.Move( 0, remainingHeight ); |
|
1126 verticalMarginProcessed = ETrue; |
|
1127 marginRect.Resize( 0, remainingHeight ); |
|
1128 borderRect.Move( 0, remainingHeight ); |
|
1129 normalFlowBorderRect.Move( 0, remainingHeight ); |
|
1130 paddingRect.Move( 0, remainingHeight ); |
|
1131 size = TSize( size.iWidth, |
|
1132 size.iHeight + remainingHeight ); |
|
1133 } |
|
1134 } |
|
1135 } |
|
1136 } |
|
1137 |
|
1138 if ( attributeName == |
|
1139 XnPropertyNames::style::common::KMarginBottom ) |
|
1140 { |
|
1141 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1142 { |
|
1143 // is top margin also set to AUTO? |
|
1144 CXnProperty* topMargin = aNode.MarginTopL(); |
|
1145 if ( topMargin ) |
|
1146 { |
|
1147 if ( IsPropertyAutoL( *topMargin ) ) |
|
1148 { |
|
1149 // both margins set to AUTO, values equal |
|
1150 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1151 if ( remainingHeight < 0 ) |
|
1152 { |
|
1153 remainingHeight = 0; |
|
1154 } |
|
1155 // move rect right to fill the void |
|
1156 contentRect.Move( 0, remainingHeight / 2 ); |
|
1157 verticalMarginProcessed = ETrue; |
|
1158 marginRect.Resize( 0, remainingHeight ); |
|
1159 borderRect.Move( 0, remainingHeight / 2 ); |
|
1160 normalFlowBorderRect.Move( |
|
1161 0, remainingHeight / 2 ); |
|
1162 paddingRect.Move( 0, remainingHeight / 2 ); |
|
1163 size = TSize( size.iWidth, |
|
1164 size.iHeight + remainingHeight ); |
|
1165 } |
|
1166 else |
|
1167 { |
|
1168 // only bottom margin set to AUTO |
|
1169 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1170 if ( remainingHeight < 0 ) |
|
1171 { |
|
1172 remainingHeight = 0; |
|
1173 } |
|
1174 marginRect.Resize( 0, remainingHeight ); |
|
1175 verticalMarginProcessed = ETrue; |
|
1176 size = TSize( size.iWidth, |
|
1177 size.iHeight + remainingHeight ); |
|
1178 } |
|
1179 } |
|
1180 } |
|
1181 } |
|
1182 } |
|
1183 } |
|
1184 aNode.SetRect( contentRect ); |
|
1185 aNode.SetPaddingRect( paddingRect ); |
|
1186 aNode.SetBorderRect( borderRect ); |
|
1187 aNode.SetMarginRect( marginRect ); |
|
1188 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
1189 return contentRect.Size(); |
|
1190 } |
|
1191 |
|
1192 // ----------------------------------------------------------------------------- |
|
1193 // AutoStaticRLL() |
|
1194 // Calculate properties set to AUTO when positioning is static, |
|
1195 // layout horizontal |
|
1196 // and direction right-to-left. |
|
1197 // ----------------------------------------------------------------------------- |
|
1198 // |
|
1199 static TSize AutoStaticRLL( CXnNode& aNode, TInt aWidthToFit, |
|
1200 TInt aHeightToFit, RArray< TPtrC8 >& aAutoProperties, TRect& aParentRect, |
|
1201 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
1202 TReal aVerticalUnitInPixels ) |
|
1203 { |
|
1204 // Static positioning, horizontal, right to left |
|
1205 TBool horizontalMarginProcessed = EFalse; |
|
1206 TBool verticalMarginProcessed = EFalse; |
|
1207 TBool allVerticalValuesProcessed = EFalse; |
|
1208 TBool allHorizontalValuesProcessed = EFalse; |
|
1209 |
|
1210 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
1211 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
1212 CXnProperty* minHeightProperty = aNode.MinHeightL(); |
|
1213 CXnProperty* minWidthProperty = aNode.MinWidthL(); |
|
1214 |
|
1215 TRect contentRect( aNode.Rect() ); |
|
1216 TRect paddingRect( aNode.PaddingRect() ); |
|
1217 TRect borderRect( aNode.BorderRect() ); |
|
1218 TRect marginRect( aNode.MarginRect() ); |
|
1219 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
1220 |
|
1221 TSize size = CalculateTotalDimensionsL( aNode, EFalse, ETrue, aParentRect, |
|
1222 aGraphicsDevice, aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
1223 |
|
1224 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
1225 { |
|
1226 // search for height property |
|
1227 const TDesC8& attributeName = aAutoProperties[i]; |
|
1228 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
1229 { |
|
1230 TInt newWidth = aWidthToFit - size.iWidth; |
|
1231 |
|
1232 // Calculate the difference so that it can be returned |
|
1233 TRect paddingRectDiff( SubtractRect( paddingRect, contentRect ) ); |
|
1234 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1235 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1236 TRect normalFlowBorderRectDiff( SubtractRect( normalFlowBorderRect, |
|
1237 contentRect ) ); |
|
1238 |
|
1239 // grow width to fill the void |
|
1240 contentRect.SetWidth( newWidth ); |
|
1241 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1242 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1243 normalFlowBorderRect = AddRect( contentRect, |
|
1244 normalFlowBorderRectDiff ); |
|
1245 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1246 |
|
1247 size = TSize( aWidthToFit, size.iHeight ); |
|
1248 allHorizontalValuesProcessed = ETrue; |
|
1249 } |
|
1250 } |
|
1251 |
|
1252 // if exactly one value is AUTO, value is computed to make equality true |
|
1253 if ( aAutoProperties.Count() == 1 ) |
|
1254 { |
|
1255 if ( !allHorizontalValuesProcessed ) |
|
1256 { |
|
1257 const TDesC8& attributeName = aAutoProperties[0]; |
|
1258 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
1259 { |
|
1260 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1261 if ( remainingHeight < 0 ) |
|
1262 { |
|
1263 remainingHeight = 0; |
|
1264 } |
|
1265 // Calculate the difference so that it can be returned |
|
1266 TRect paddingRectDiff( SubtractRect( |
|
1267 paddingRect, contentRect ) ); |
|
1268 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1269 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1270 TRect normalFlowBorderRectDiff( SubtractRect( |
|
1271 normalFlowBorderRect, contentRect ) ); |
|
1272 |
|
1273 // grow height to fill the void |
|
1274 contentRect.SetHeight( remainingHeight ); |
|
1275 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1276 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1277 normalFlowBorderRect = AddRect( contentRect, |
|
1278 normalFlowBorderRectDiff ); |
|
1279 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1280 |
|
1281 size = TSize( size.iWidth, aHeightToFit ); |
|
1282 } |
|
1283 |
|
1284 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
1285 { |
|
1286 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1287 if ( remainingWidth < 0 ) |
|
1288 { |
|
1289 remainingWidth = 0; |
|
1290 } |
|
1291 // move rect right to fill the void |
|
1292 contentRect.Move( remainingWidth, 0 ); |
|
1293 paddingRect.Move( remainingWidth, 0 ); |
|
1294 borderRect.Move( remainingWidth, 0 ); |
|
1295 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
1296 marginRect.Resize( remainingWidth, 0 ); |
|
1297 marginRect.Move( -remainingWidth, 0 ); |
|
1298 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
1299 } |
|
1300 |
|
1301 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
1302 { |
|
1303 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1304 if ( remainingWidth < 0 ) |
|
1305 { |
|
1306 remainingWidth = 0; |
|
1307 } |
|
1308 contentRect.Move( -remainingWidth, 0 ); |
|
1309 paddingRect.Move( -remainingWidth, 0 ); |
|
1310 borderRect.Move( -remainingWidth, 0 ); |
|
1311 normalFlowBorderRect.Move( -remainingWidth, 0 ); |
|
1312 marginRect.Move( -remainingWidth, 0 ); |
|
1313 marginRect.Resize( remainingWidth, 0 ); |
|
1314 |
|
1315 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
1316 } |
|
1317 |
|
1318 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
1319 { |
|
1320 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1321 if ( remainingHeight < 0 ) |
|
1322 { |
|
1323 remainingHeight = 0; |
|
1324 } |
|
1325 // move rect right to fill the void |
|
1326 contentRect.Move( 0, remainingHeight / 2 ); |
|
1327 paddingRect.Move( 0, remainingHeight / 2 ); |
|
1328 borderRect.Move( 0, remainingHeight / 2 ); |
|
1329 normalFlowBorderRect.Move( 0, remainingHeight / 2 ); |
|
1330 marginRect.Resize( 0, remainingHeight ); |
|
1331 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
1332 } |
|
1333 |
|
1334 if ( attributeName == |
|
1335 XnPropertyNames::style::common::KMarginBottom ) |
|
1336 { |
|
1337 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1338 if ( remainingHeight < 0 ) |
|
1339 { |
|
1340 remainingHeight = 0; |
|
1341 } |
|
1342 marginRect.Resize( 0, remainingHeight ); |
|
1343 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
1344 } |
|
1345 } |
|
1346 } |
|
1347 else |
|
1348 { |
|
1349 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
1350 { |
|
1351 const TDesC8& attributeName = aAutoProperties[i]; |
|
1352 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
1353 { |
|
1354 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1355 if ( remainingHeight < 0 ) |
|
1356 { |
|
1357 remainingHeight = 0; |
|
1358 } |
|
1359 // Calculate the difference so that it can be returned |
|
1360 TRect paddingRectDiff( SubtractRect( |
|
1361 paddingRect, contentRect ) ); |
|
1362 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1363 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1364 TRect normalFlowBorderRectDiff( SubtractRect( |
|
1365 normalFlowBorderRect, contentRect ) ); |
|
1366 |
|
1367 // grow height to fill the void |
|
1368 contentRect.SetHeight( remainingHeight ); |
|
1369 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1370 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1371 normalFlowBorderRect = AddRect( contentRect, |
|
1372 normalFlowBorderRectDiff ); |
|
1373 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1374 |
|
1375 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
1376 } |
|
1377 |
|
1378 // several auto properties |
|
1379 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
1380 { |
|
1381 if ( !horizontalMarginProcessed ) |
|
1382 { |
|
1383 // is right margin also set to AUTO? |
|
1384 CXnProperty* rightMargin = aNode.MarginRightL(); |
|
1385 if ( rightMargin ) |
|
1386 { |
|
1387 if ( IsPropertyAutoL( *rightMargin ) ) |
|
1388 { |
|
1389 // both margins set to AUTO, values equal |
|
1390 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1391 if ( remainingWidth < 0 ) |
|
1392 { |
|
1393 remainingWidth = 0; |
|
1394 } |
|
1395 // move rect left |
|
1396 contentRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1397 marginRect.Resize( remainingWidth, 0 ); |
|
1398 marginRect.Move( -remainingWidth, 0 ); |
|
1399 borderRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1400 normalFlowBorderRect.Move( |
|
1401 -( remainingWidth / 2 ), 0 ); |
|
1402 paddingRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1403 horizontalMarginProcessed = ETrue; |
|
1404 size = TSize( size.iWidth + remainingWidth, |
|
1405 size.iHeight ); |
|
1406 } |
|
1407 else |
|
1408 { |
|
1409 // only left margin set to AUTO |
|
1410 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1411 if ( remainingWidth < 0 ) |
|
1412 { |
|
1413 remainingWidth = 0; |
|
1414 } |
|
1415 // move rect left |
|
1416 contentRect.Move( ( remainingWidth ), 0 ); |
|
1417 marginRect.Resize( remainingWidth, 0 ); |
|
1418 marginRect.Move( remainingWidth, 0 ); |
|
1419 horizontalMarginProcessed = ETrue; |
|
1420 size = TSize( size.iWidth + remainingWidth, |
|
1421 size.iHeight ); |
|
1422 } |
|
1423 } |
|
1424 } |
|
1425 } |
|
1426 |
|
1427 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
1428 { |
|
1429 if ( !horizontalMarginProcessed ) |
|
1430 { |
|
1431 // is left margin also set to AUTO? |
|
1432 CXnProperty* leftMargin = aNode.MarginLeftL(); |
|
1433 if ( leftMargin ) |
|
1434 { |
|
1435 if ( IsPropertyAutoL( *leftMargin ) ) |
|
1436 { |
|
1437 // both margins set to AUTO, values equal |
|
1438 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1439 if ( remainingWidth < 0 ) |
|
1440 { |
|
1441 remainingWidth = 0; |
|
1442 } |
|
1443 contentRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1444 marginRect.Resize( remainingWidth, 0 ); |
|
1445 marginRect.Move( -remainingWidth, 0 ); |
|
1446 borderRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1447 normalFlowBorderRect.Move( |
|
1448 -( remainingWidth / 2 ), 0 ); |
|
1449 paddingRect.Move( -( remainingWidth / 2 ), 0 ); |
|
1450 horizontalMarginProcessed = ETrue; |
|
1451 size = TSize( size.iWidth + remainingWidth, |
|
1452 size.iHeight ); |
|
1453 } |
|
1454 else |
|
1455 { |
|
1456 // only right margin set to AUTO |
|
1457 TInt usedWidth = size.iWidth; |
|
1458 TInt remainingWidth = aWidthToFit - usedWidth; |
|
1459 if ( remainingWidth < 0 ) |
|
1460 { |
|
1461 remainingWidth = 0; |
|
1462 } |
|
1463 contentRect.Move( -remainingWidth, 0 ); |
|
1464 marginRect.Resize( remainingWidth, 0 ); |
|
1465 marginRect.Move( -remainingWidth, 0 ); |
|
1466 borderRect.Move( -remainingWidth, 0 ); |
|
1467 normalFlowBorderRect.Move( -remainingWidth, 0 ); |
|
1468 paddingRect.Move( -remainingWidth, 0 ); |
|
1469 horizontalMarginProcessed = ETrue; |
|
1470 size = TSize( size.iWidth + remainingWidth, |
|
1471 size.iHeight ); |
|
1472 } |
|
1473 } |
|
1474 } |
|
1475 } |
|
1476 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
1477 { |
|
1478 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1479 { |
|
1480 // is bottom margin also set to AUTO? |
|
1481 CXnProperty* bottomMargin = aNode.MarginBottomL(); |
|
1482 if ( bottomMargin ) |
|
1483 { |
|
1484 if ( IsPropertyAutoL( *bottomMargin ) ) |
|
1485 { |
|
1486 // both margins set to AUTO, values equal |
|
1487 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1488 if ( remainingHeight < 0 ) |
|
1489 { |
|
1490 remainingHeight = 0; |
|
1491 } |
|
1492 contentRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1493 marginRect.Resize( 0, remainingHeight ); |
|
1494 borderRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1495 normalFlowBorderRect.Move( |
|
1496 0, ( remainingHeight / 2 ) ); |
|
1497 paddingRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1498 verticalMarginProcessed = ETrue; |
|
1499 size = TSize( size.iWidth, |
|
1500 size.iHeight + remainingHeight ); |
|
1501 } |
|
1502 else |
|
1503 { |
|
1504 // only top margin set to AUTO |
|
1505 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1506 if ( remainingHeight < 0 ) |
|
1507 { |
|
1508 remainingHeight = 0; |
|
1509 } |
|
1510 contentRect.Move( 0, remainingHeight ); |
|
1511 marginRect.Resize( 0, remainingHeight ); |
|
1512 borderRect.Move( 0, remainingHeight ); |
|
1513 normalFlowBorderRect.Move( 0, remainingHeight ); |
|
1514 paddingRect.Move( 0, remainingHeight ); |
|
1515 verticalMarginProcessed = ETrue; |
|
1516 size = TSize( size.iWidth, |
|
1517 size.iHeight + remainingHeight ); |
|
1518 } |
|
1519 } |
|
1520 } |
|
1521 } |
|
1522 |
|
1523 if ( attributeName == |
|
1524 XnPropertyNames::style::common::KMarginBottom ) |
|
1525 { |
|
1526 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1527 { |
|
1528 // is top margin also set to AUTO? |
|
1529 CXnProperty* topMargin = aNode.MarginTopL(); |
|
1530 if ( topMargin ) |
|
1531 { |
|
1532 if ( IsPropertyAutoL( *topMargin ) ) |
|
1533 { |
|
1534 // both margins set to AUTO, values equal |
|
1535 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1536 if ( remainingHeight < 0 ) |
|
1537 { |
|
1538 remainingHeight = 0; |
|
1539 } |
|
1540 // move rect right to fill the void |
|
1541 contentRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1542 marginRect.Resize( 0, remainingHeight ); |
|
1543 borderRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1544 normalFlowBorderRect.Move( |
|
1545 0, ( remainingHeight / 2 ) ); |
|
1546 paddingRect.Move( 0, ( remainingHeight / 2 ) ); |
|
1547 verticalMarginProcessed = ETrue; |
|
1548 size = TSize( size.iWidth, |
|
1549 size.iHeight + remainingHeight ); |
|
1550 } |
|
1551 else |
|
1552 { |
|
1553 // only bottom margin set to AUTO |
|
1554 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1555 if ( remainingHeight < 0 ) |
|
1556 { |
|
1557 remainingHeight = 0; |
|
1558 } |
|
1559 // move rect right to fill the void |
|
1560 marginRect.Resize( 0, remainingHeight ); |
|
1561 verticalMarginProcessed = ETrue; |
|
1562 size = TSize( size.iWidth, |
|
1563 size.iHeight + remainingHeight ); |
|
1564 } |
|
1565 } |
|
1566 } |
|
1567 } |
|
1568 } |
|
1569 } |
|
1570 aNode.SetRect( contentRect ); |
|
1571 aNode.SetPaddingRect( paddingRect ); |
|
1572 aNode.SetBorderRect( borderRect ); |
|
1573 aNode.SetMarginRect( marginRect ); |
|
1574 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
1575 return contentRect.Size(); |
|
1576 } |
|
1577 |
|
1578 // ----------------------------------------------------------------------------- |
|
1579 // SubtractRect() |
|
1580 // Calculate the difference of two rectangles and return it as |
|
1581 // ----------------------------------------------------------------------------- |
|
1582 // |
|
1583 static TRect SubtractRect( const TRect& aOriginal, const TRect& aSubtracter ) |
|
1584 { |
|
1585 return TRect( aOriginal.iTl.iX - aSubtracter.iTl.iX, |
|
1586 aOriginal.iTl.iY - aSubtracter.iTl.iY, |
|
1587 aOriginal.iBr.iX - aSubtracter.iBr.iX, |
|
1588 aOriginal.iBr.iY - aSubtracter.iBr.iY ); |
|
1589 } |
|
1590 |
|
1591 // ----------------------------------------------------------------------------- |
|
1592 // AddRect() |
|
1593 // Add two rectangles together and return the result |
|
1594 // ----------------------------------------------------------------------------- |
|
1595 // |
|
1596 static TRect AddRect( const TRect& aOriginal, const TRect& aAdded ) |
|
1597 { |
|
1598 return TRect( aOriginal.iTl.iX + aAdded.iTl.iX, |
|
1599 aOriginal.iTl.iY + aAdded.iTl.iY, |
|
1600 aOriginal.iBr.iX + aAdded.iBr.iX, |
|
1601 aOriginal.iBr.iY + aAdded.iBr.iY ); |
|
1602 } |
|
1603 |
|
1604 // ----------------------------------------------------------------------------- |
|
1605 // AutoStaticTBL() |
|
1606 // Calculate properties set to AUTO when positioning is static, layout vertical |
|
1607 // and direction left-to-right |
|
1608 // ----------------------------------------------------------------------------- |
|
1609 // |
|
1610 static TSize AutoStaticTBL( CXnNode& aNode, TInt aWidthToFit, TInt aHeightToFit, |
|
1611 RArray< TPtrC8 >& aAutoProperties, TRect& aParentRect, |
|
1612 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
1613 TReal aVerticalUnitInPixels ) |
|
1614 { |
|
1615 // Static positioning, vertical, left to right |
|
1616 TBool horizontalMarginProcessed( EFalse ); |
|
1617 TBool verticalMarginProcessed( EFalse ); |
|
1618 TBool allVerticalValuesProcessed( EFalse ); |
|
1619 |
|
1620 TRect contentRect( aNode.Rect() ); |
|
1621 TRect paddingRect( aNode.PaddingRect() ); |
|
1622 TRect borderRect( aNode.BorderRect() ); |
|
1623 TRect marginRect( aNode.MarginRect() ); |
|
1624 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
1625 |
|
1626 TSize size( CalculateTotalDimensionsL( aNode, EFalse, ETrue, aParentRect, |
|
1627 aGraphicsDevice, aHorizontalUnitInPixels, aVerticalUnitInPixels ) ); |
|
1628 |
|
1629 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
1630 { |
|
1631 // search for height property |
|
1632 const TDesC8& attributeName = aAutoProperties[i]; |
|
1633 if ( attributeName == XnPropertyNames::style::common::KHeight ) |
|
1634 { |
|
1635 // Calculate the difference so that it can be returned |
|
1636 TRect paddingRectDiff( SubtractRect( paddingRect, contentRect ) ); |
|
1637 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1638 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1639 TRect normalFlowBorderRectDiff( SubtractRect( normalFlowBorderRect, |
|
1640 contentRect ) ); |
|
1641 |
|
1642 // grow height to fill the void |
|
1643 contentRect.SetHeight( aHeightToFit - size.iHeight ); |
|
1644 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1645 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1646 normalFlowBorderRect = AddRect( |
|
1647 contentRect, normalFlowBorderRectDiff ); |
|
1648 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1649 size = TSize( size.iWidth, aHeightToFit ); |
|
1650 allVerticalValuesProcessed = ETrue; |
|
1651 } |
|
1652 } |
|
1653 |
|
1654 // if exactly one value is AUTO, value is computed to make equality true |
|
1655 if ( aAutoProperties.Count() == 1 ) |
|
1656 { |
|
1657 if ( !allVerticalValuesProcessed ) |
|
1658 { |
|
1659 const TDesC8& attributeName = aAutoProperties[0]; |
|
1660 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
1661 { |
|
1662 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1663 if ( remainingWidth < 0 ) |
|
1664 { |
|
1665 remainingWidth = 0; |
|
1666 } |
|
1667 // Calculate the difference so that it can be returned |
|
1668 TRect paddingRectDiff( SubtractRect( |
|
1669 paddingRect, contentRect ) ); |
|
1670 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1671 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1672 TRect normalFlowBorderRectDiff( SubtractRect( |
|
1673 normalFlowBorderRect, contentRect ) ); |
|
1674 |
|
1675 // grow width to fill the void |
|
1676 contentRect.SetWidth( remainingWidth ); |
|
1677 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1678 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1679 normalFlowBorderRect = AddRect( contentRect, |
|
1680 normalFlowBorderRectDiff ); |
|
1681 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1682 size = TSize( aWidthToFit, size.iHeight ); |
|
1683 } |
|
1684 |
|
1685 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
1686 { |
|
1687 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1688 if ( remainingWidth < 0 ) |
|
1689 { |
|
1690 remainingWidth = 0; |
|
1691 } |
|
1692 // move rect right to fill the void |
|
1693 contentRect.Move( remainingWidth, 0 ); |
|
1694 paddingRect.Move( remainingWidth, 0 ); |
|
1695 borderRect.Move( remainingWidth, 0 ); |
|
1696 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
1697 marginRect.Resize( remainingWidth, 0 ); |
|
1698 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
1699 } |
|
1700 |
|
1701 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
1702 { |
|
1703 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1704 if ( remainingWidth < 0 ) |
|
1705 { |
|
1706 remainingWidth = 0; |
|
1707 } |
|
1708 marginRect.Resize( remainingWidth, 0 ); |
|
1709 size = TSize( size.iWidth + remainingWidth, size.iHeight ); |
|
1710 } |
|
1711 |
|
1712 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
1713 { |
|
1714 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1715 if ( remainingHeight < 0 ) |
|
1716 { |
|
1717 remainingHeight = 0; |
|
1718 } |
|
1719 // move rect right to fill the void |
|
1720 contentRect.Move( 0, remainingHeight / 2 ); |
|
1721 paddingRect.Move( 0, remainingHeight / 2 ); |
|
1722 borderRect.Move( 0, remainingHeight / 2 ); |
|
1723 normalFlowBorderRect.Move( 0, remainingHeight / 2 ); |
|
1724 marginRect.Resize( 0, remainingHeight ); |
|
1725 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
1726 } |
|
1727 |
|
1728 if ( attributeName == |
|
1729 XnPropertyNames::style::common::KMarginBottom ) |
|
1730 { |
|
1731 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1732 if ( remainingHeight < 0 ) |
|
1733 { |
|
1734 remainingHeight = 0; |
|
1735 } |
|
1736 // set margin rect |
|
1737 marginRect.Resize( 0, remainingHeight ); |
|
1738 size = TSize( size.iWidth, size.iHeight + remainingHeight ); |
|
1739 } |
|
1740 } |
|
1741 } |
|
1742 else |
|
1743 { |
|
1744 for ( TInt i = 0; i < aAutoProperties.Count(); i++ ) |
|
1745 { |
|
1746 const TDesC8& attributeName = aAutoProperties[i]; |
|
1747 if ( attributeName == XnPropertyNames::style::common::KWidth ) |
|
1748 { |
|
1749 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1750 if ( remainingWidth < 0 ) |
|
1751 { |
|
1752 remainingWidth = 0; |
|
1753 } |
|
1754 // Calculate the difference so that it can be returned |
|
1755 TRect paddingRectDiff( SubtractRect( |
|
1756 paddingRect, contentRect ) ); |
|
1757 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
1758 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
1759 TRect normalFlowBorderRectDiff( SubtractRect( |
|
1760 normalFlowBorderRect, contentRect ) ); |
|
1761 |
|
1762 // grow width to fill the void |
|
1763 contentRect.SetWidth( remainingWidth ); |
|
1764 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
1765 borderRect = AddRect( contentRect, borderRectDiff ); |
|
1766 normalFlowBorderRect = AddRect( contentRect, |
|
1767 normalFlowBorderRectDiff ); |
|
1768 marginRect = AddRect( contentRect, marginRectDiff ); |
|
1769 size = TSize( aWidthToFit, size.iHeight ); |
|
1770 } |
|
1771 |
|
1772 // several auto properties |
|
1773 if ( attributeName == XnPropertyNames::style::common::KMarginLeft ) |
|
1774 { |
|
1775 if ( !horizontalMarginProcessed ) |
|
1776 { |
|
1777 // is right margin also set to AUTO? |
|
1778 CXnProperty* rightMargin = aNode.MarginRightL(); |
|
1779 if ( rightMargin ) |
|
1780 { |
|
1781 if ( IsPropertyAutoL( *rightMargin ) ) |
|
1782 { |
|
1783 // both margins set to AUTO, values equal |
|
1784 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1785 if ( remainingWidth < 0 ) |
|
1786 { |
|
1787 remainingWidth = 0; |
|
1788 } |
|
1789 // move rect right to fill the void |
|
1790 contentRect.Move(( remainingWidth / 2 ), 0 ); |
|
1791 marginRect.Resize( remainingWidth, 0 ); |
|
1792 borderRect.Move( remainingWidth / 2, 0 ); |
|
1793 normalFlowBorderRect.Move( remainingWidth / 2, 0 ); |
|
1794 paddingRect.Move( remainingWidth / 2, 0 ); |
|
1795 horizontalMarginProcessed = ETrue; |
|
1796 size = TSize( size.iWidth + remainingWidth, |
|
1797 size.iHeight ); |
|
1798 } |
|
1799 else |
|
1800 { |
|
1801 // only left margin set to AUTO |
|
1802 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1803 if ( remainingWidth < 0 ) |
|
1804 { |
|
1805 remainingWidth = 0; |
|
1806 } |
|
1807 // move rect right to fill the void |
|
1808 contentRect.Move( remainingWidth, 0 ); |
|
1809 marginRect.Resize( remainingWidth, 0 ); |
|
1810 borderRect.Move( remainingWidth, 0 ); |
|
1811 normalFlowBorderRect.Move( remainingWidth, 0 ); |
|
1812 paddingRect.Move( remainingWidth, 0 ); |
|
1813 horizontalMarginProcessed = ETrue; |
|
1814 size = TSize( size.iWidth + remainingWidth, |
|
1815 size.iHeight ); |
|
1816 } |
|
1817 } |
|
1818 } |
|
1819 } |
|
1820 |
|
1821 if ( attributeName == XnPropertyNames::style::common::KMarginRight ) |
|
1822 { |
|
1823 if ( !horizontalMarginProcessed ) |
|
1824 { |
|
1825 // is left margin also set to AUTO? |
|
1826 CXnProperty* leftMargin = aNode.MarginLeftL(); |
|
1827 if ( leftMargin ) |
|
1828 { |
|
1829 if ( IsPropertyAutoL (*leftMargin ) ) |
|
1830 { |
|
1831 // both margins set to AUTO, values equal |
|
1832 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1833 if ( remainingWidth < 0 ) |
|
1834 { |
|
1835 remainingWidth = 0; |
|
1836 } |
|
1837 // move rect right to fill the void |
|
1838 contentRect.Move( remainingWidth / 2, 0 ); |
|
1839 marginRect.Resize( remainingWidth, 0 ); |
|
1840 borderRect.Move( remainingWidth / 2, 0 ); |
|
1841 normalFlowBorderRect.Move( remainingWidth / 2, 0 ); |
|
1842 paddingRect.Move( remainingWidth / 2, 0 ); |
|
1843 horizontalMarginProcessed = ETrue; |
|
1844 size = TSize( size.iWidth + remainingWidth, |
|
1845 size.iHeight ); |
|
1846 } |
|
1847 else |
|
1848 { |
|
1849 // only right margin set to AUTO |
|
1850 TInt remainingWidth = aWidthToFit - size.iWidth; |
|
1851 if ( remainingWidth < 0 ) |
|
1852 { |
|
1853 remainingWidth = 0; |
|
1854 } |
|
1855 // move rect right to fill the void |
|
1856 marginRect.Resize( remainingWidth, 0 ); |
|
1857 horizontalMarginProcessed = ETrue; |
|
1858 size = TSize( size.iWidth + remainingWidth, |
|
1859 size.iHeight ); |
|
1860 } |
|
1861 } |
|
1862 } |
|
1863 } |
|
1864 |
|
1865 if ( attributeName == XnPropertyNames::style::common::KMarginTop ) |
|
1866 { |
|
1867 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1868 { |
|
1869 // is bottom margin also set to AUTO? |
|
1870 CXnProperty* bottomMargin = aNode.MarginBottomL(); |
|
1871 if ( bottomMargin ) |
|
1872 { |
|
1873 if ( IsPropertyAutoL( *bottomMargin ) ) |
|
1874 { |
|
1875 // both margins set to AUTO, values equal |
|
1876 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1877 if ( remainingHeight < 0 ) |
|
1878 { |
|
1879 remainingHeight = 0; |
|
1880 } |
|
1881 // move rect right to fill the void |
|
1882 contentRect.Move( 0, remainingHeight / 2 ); |
|
1883 marginRect.Resize( 0, remainingHeight ); |
|
1884 borderRect.Move( 0, remainingHeight / 2 ); |
|
1885 normalFlowBorderRect.Move( 0, remainingHeight / 2 ); |
|
1886 paddingRect.Move( 0, remainingHeight / 2 ); |
|
1887 verticalMarginProcessed = ETrue; |
|
1888 size = TSize( size.iWidth, |
|
1889 size.iHeight + remainingHeight ); |
|
1890 } |
|
1891 else |
|
1892 { |
|
1893 // only top margin set to AUTO |
|
1894 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1895 if ( remainingHeight < 0 ) |
|
1896 { |
|
1897 remainingHeight = 0; |
|
1898 } |
|
1899 // move rect right to fill the void |
|
1900 contentRect.Move( 0, remainingHeight ); |
|
1901 marginRect.Resize( 0, remainingHeight ); |
|
1902 borderRect.Move( 0, remainingHeight ); |
|
1903 normalFlowBorderRect.Move( 0, remainingHeight ); |
|
1904 paddingRect.Move( 0, remainingHeight ); |
|
1905 verticalMarginProcessed = ETrue; |
|
1906 size = TSize( size.iWidth, |
|
1907 size.iHeight + remainingHeight ); |
|
1908 } |
|
1909 } |
|
1910 } |
|
1911 } |
|
1912 |
|
1913 if ( attributeName == |
|
1914 XnPropertyNames::style::common::KMarginBottom ) |
|
1915 { |
|
1916 if ( !verticalMarginProcessed && !allVerticalValuesProcessed ) |
|
1917 { |
|
1918 // is top margin also set to AUTO? |
|
1919 CXnProperty* topMargin = aNode.MarginTopL(); |
|
1920 if ( topMargin ) |
|
1921 { |
|
1922 if ( IsPropertyAutoL( *topMargin ) ) |
|
1923 { |
|
1924 // both margins set to AUTO, values equal |
|
1925 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1926 if ( remainingHeight < 0 ) |
|
1927 { |
|
1928 remainingHeight = 0; |
|
1929 } |
|
1930 // move rect right to fill the void |
|
1931 TRect normalFlowBorderRect( |
|
1932 aNode.NormalFlowBorderRect() ); |
|
1933 contentRect.Move( 0, remainingHeight / 2 ); |
|
1934 marginRect.Resize( 0, remainingHeight ); |
|
1935 borderRect.Move( 0, remainingHeight / 2 ); |
|
1936 normalFlowBorderRect.Move( 0, remainingHeight / 2 ); |
|
1937 paddingRect.Move( 0, remainingHeight / 2 ); |
|
1938 verticalMarginProcessed = ETrue; |
|
1939 size = TSize( size.iWidth, |
|
1940 size.iHeight + remainingHeight ); |
|
1941 } |
|
1942 else |
|
1943 { |
|
1944 // only bottom margin set to AUTO |
|
1945 TInt remainingHeight = aHeightToFit - size.iHeight; |
|
1946 if ( remainingHeight < 0 ) |
|
1947 { |
|
1948 remainingHeight = 0; |
|
1949 } |
|
1950 // move rect right to fill the void |
|
1951 marginRect.Resize( 0, remainingHeight ); |
|
1952 verticalMarginProcessed = ETrue; |
|
1953 size = TSize( size.iWidth, |
|
1954 size.iHeight + remainingHeight ); |
|
1955 } |
|
1956 } |
|
1957 } |
|
1958 } |
|
1959 } |
|
1960 } |
|
1961 aNode.SetRect( contentRect ); |
|
1962 aNode.SetPaddingRect( paddingRect ); |
|
1963 aNode.SetBorderRect( borderRect ); |
|
1964 aNode.SetMarginRect( marginRect ); |
|
1965 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
1966 return contentRect.Size(); |
|
1967 } |
|
1968 |
|
1969 // ----------------------------------------------------------------------------- |
|
1970 // CalculateAbsolutePositionsL() |
|
1971 // Move the rect by it's absolute positioning. |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // |
|
1974 static void CalculateAbsolutePositionsL( CXnNode& aNode, TRect& aParentRect, |
|
1975 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
1976 TReal aVerticalUnitInPixels ) |
|
1977 { |
|
1978 CXnProperty* topProperty = aNode.TopL(); |
|
1979 CXnProperty* bottomProperty = aNode.BottomL(); |
|
1980 CXnProperty* leftProperty = aNode.LeftL(); |
|
1981 CXnProperty* rightProperty = aNode.RightL(); |
|
1982 |
|
1983 TBool verticalValuesProcessed = EFalse; |
|
1984 TBool horizontalValuesProcessed = EFalse; |
|
1985 |
|
1986 TInt top = 0; |
|
1987 TInt bottom = 0; |
|
1988 TInt left = 0; |
|
1989 TInt right = 0; |
|
1990 |
|
1991 TRect contentRect( aNode.Rect() ); |
|
1992 TRect paddingRect( aNode.PaddingRect() ); |
|
1993 TRect borderRect( aNode.BorderRect() ); |
|
1994 TRect marginRect( aNode.MarginRect() ); |
|
1995 |
|
1996 if ( HasNodeAutoValuesL( aNode ) ) |
|
1997 { |
|
1998 CXnProperty* marginTopProperty = aNode.MarginTopL(); |
|
1999 CXnProperty* marginBottomProperty = aNode.MarginBottomL(); |
|
2000 CXnProperty* marginLeftProperty = aNode.MarginLeftL(); |
|
2001 CXnProperty* marginRightProperty = aNode.MarginRightL(); |
|
2002 CXnProperty* heightProperty = aNode.HeightL(); |
|
2003 CXnProperty* widthProperty = aNode.WidthL(); |
|
2004 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
2005 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
2006 CXnProperty* minHeightProperty = aNode.MinHeightL(); |
|
2007 CXnProperty* minWidthProperty = aNode.MinWidthL(); |
|
2008 |
|
2009 // move auto value node to it's parent's top left corner |
|
2010 TInt offsetx = 0; |
|
2011 TInt offsety = 0; |
|
2012 |
|
2013 offsetx = aParentRect.iTl.iX - marginRect.iTl.iX; |
|
2014 offsety = aParentRect.iTl.iY - marginRect.iTl.iY; |
|
2015 |
|
2016 contentRect.Move( offsetx, offsety ); |
|
2017 paddingRect.Move( offsetx, offsety ); |
|
2018 borderRect.Move( offsetx, offsety ); |
|
2019 marginRect.Move( offsetx, offsety ); |
|
2020 |
|
2021 // get values |
|
2022 if ( topProperty && !IsPropertyAutoL( *topProperty ) && |
|
2023 !IsPropertyNone( *topProperty ) ) |
|
2024 { |
|
2025 top = VerticalPixelValueL( topProperty, aParentRect.Height(), |
|
2026 aGraphicsDevice, aVerticalUnitInPixels ); |
|
2027 } |
|
2028 if ( bottomProperty && !IsPropertyAutoL( *bottomProperty ) && |
|
2029 !IsPropertyNone( *bottomProperty ) ) |
|
2030 { |
|
2031 bottom = VerticalPixelValueL( bottomProperty, aParentRect.Height(), |
|
2032 aGraphicsDevice, aVerticalUnitInPixels ); |
|
2033 } |
|
2034 if ( leftProperty && !IsPropertyAutoL( *leftProperty ) && |
|
2035 !IsPropertyNone( *leftProperty ) ) |
|
2036 { |
|
2037 left = HorizontalPixelValueL( leftProperty, aParentRect.Width(), |
|
2038 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2039 } |
|
2040 if ( rightProperty && !IsPropertyAutoL( *rightProperty ) && |
|
2041 !IsPropertyNone( *rightProperty ) ) |
|
2042 { |
|
2043 right = HorizontalPixelValueL( rightProperty, aParentRect.Width(), |
|
2044 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2045 } |
|
2046 // node has auto values |
|
2047 TSize spaceUsed( CalculateTotalDimensionsL( aNode, EFalse, EFalse, |
|
2048 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
2049 aVerticalUnitInPixels ) ); |
|
2050 TInt heightToUse = |
|
2051 aParentRect.Height() - spaceUsed.iHeight - top - bottom; |
|
2052 TInt widthToUse = |
|
2053 aParentRect.Width() - spaceUsed.iWidth - left - right; |
|
2054 |
|
2055 if ( heightToUse < 0 ) |
|
2056 { |
|
2057 heightToUse = 0; |
|
2058 } |
|
2059 if ( widthToUse < 0 ) |
|
2060 { |
|
2061 widthToUse = 0; |
|
2062 } |
|
2063 // vertical auto values |
|
2064 // (margin top, margin bottom, height, top, bottom) |
|
2065 if ( IsPropertyAutoL( *heightProperty ) ) |
|
2066 { |
|
2067 contentRect.Resize( 0, heightToUse ); |
|
2068 paddingRect.Resize( 0, heightToUse ); |
|
2069 borderRect.Resize( 0, heightToUse ); |
|
2070 marginRect.Resize( 0, heightToUse ); |
|
2071 |
|
2072 if ( IsLargerThanMaxSizeL( aParentRect, aNode, aGraphicsDevice, |
|
2073 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
2074 { |
|
2075 if ( !IsPropertyNone( *maxHeightProperty ) ) |
|
2076 { |
|
2077 TInt maxheight = HorizontalPixelValueL( maxHeightProperty, |
|
2078 aParentRect.Height(), aGraphicsDevice, |
|
2079 aHorizontalUnitInPixels ); |
|
2080 if ( maxheight < contentRect.Height() ) |
|
2081 { |
|
2082 TInt excessheight = contentRect.Height() - maxheight; |
|
2083 contentRect.Resize( 0, -excessheight ); |
|
2084 paddingRect.Resize( 0, -excessheight ); |
|
2085 borderRect.Resize( 0, -excessheight ); |
|
2086 marginRect.Resize( 0, -excessheight ); |
|
2087 } |
|
2088 } |
|
2089 } |
|
2090 if ( IsSmallerThanMinSizeL( aParentRect, aNode, aGraphicsDevice, |
|
2091 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
2092 { |
|
2093 if ( !IsPropertyNone( *minHeightProperty ) ) |
|
2094 { |
|
2095 TInt minheight = HorizontalPixelValueL( minHeightProperty, |
|
2096 aParentRect.Height(), aGraphicsDevice, |
|
2097 aHorizontalUnitInPixels ); |
|
2098 if ( minheight > contentRect.Height() ) |
|
2099 { |
|
2100 TInt missingheight = minheight - contentRect.Height(); |
|
2101 contentRect.Resize( 0, missingheight ); |
|
2102 paddingRect.Resize( 0, missingheight ); |
|
2103 borderRect.Resize( 0, missingheight ); |
|
2104 marginRect.Resize( 0, missingheight ); |
|
2105 } |
|
2106 } |
|
2107 } |
|
2108 verticalValuesProcessed = ETrue; |
|
2109 } |
|
2110 |
|
2111 if ( !verticalValuesProcessed ) |
|
2112 { |
|
2113 if ( IsPropertyAutoL( *topProperty ) && |
|
2114 IsPropertyAutoL( *bottomProperty ) ) |
|
2115 { |
|
2116 // move the box down |
|
2117 contentRect.Move( 0, heightToUse / 2 ); |
|
2118 paddingRect.Move( 0, heightToUse / 2 ); |
|
2119 borderRect.Move( 0, heightToUse / 2 ); |
|
2120 marginRect.Move( 0, heightToUse / 2 ); |
|
2121 } |
|
2122 if ( IsPropertyAutoL( *topProperty ) && |
|
2123 !IsPropertyAutoL( *bottomProperty ) ) |
|
2124 { |
|
2125 // move the box down |
|
2126 contentRect.Move( 0, heightToUse ); |
|
2127 paddingRect.Move( 0, heightToUse ); |
|
2128 borderRect.Move( 0, heightToUse ); |
|
2129 marginRect.Move( 0, heightToUse ); |
|
2130 } |
|
2131 if ( IsPropertyAutoL( *marginTopProperty ) && |
|
2132 IsPropertyAutoL( *marginBottomProperty ) ) |
|
2133 { |
|
2134 // both margins auto, equal values |
|
2135 marginRect.Resize( 0, heightToUse ); |
|
2136 paddingRect.Move( 0, heightToUse / 2 ); |
|
2137 borderRect.Move( 0, heightToUse / 2 ); |
|
2138 contentRect.Move( 0, heightToUse / 2 ); |
|
2139 } |
|
2140 if ( !IsPropertyAutoL( *marginTopProperty ) && |
|
2141 IsPropertyAutoL( *marginBottomProperty ) ) |
|
2142 { |
|
2143 // only top margin auto |
|
2144 marginRect.Resize( 0, heightToUse ); |
|
2145 paddingRect.Move( 0, heightToUse ); |
|
2146 borderRect.Move( 0, heightToUse ); |
|
2147 contentRect.Move( 0, heightToUse ); |
|
2148 } |
|
2149 if ( IsPropertyAutoL( *marginTopProperty ) && |
|
2150 !IsPropertyAutoL( *marginBottomProperty ) ) |
|
2151 { |
|
2152 // only bottom margin auto |
|
2153 marginRect.Resize( 0, heightToUse ); |
|
2154 } |
|
2155 } |
|
2156 |
|
2157 // horizontal auto values |
|
2158 // (margin left, margin right, width) |
|
2159 if ( IsPropertyAutoL( *widthProperty ) ) |
|
2160 { |
|
2161 contentRect.Resize( widthToUse, 0 ); |
|
2162 paddingRect.Resize( widthToUse, 0 );; |
|
2163 borderRect.Resize( widthToUse, 0 ); |
|
2164 marginRect.Resize( widthToUse, 0 ); |
|
2165 if ( IsLargerThanMaxSizeL( aParentRect, aNode, aGraphicsDevice, |
|
2166 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
2167 { |
|
2168 if ( !IsPropertyNone( *maxWidthProperty ) ) |
|
2169 { |
|
2170 TInt maxwidth = HorizontalPixelValueL( maxWidthProperty, |
|
2171 aParentRect.Width(), aGraphicsDevice, |
|
2172 aHorizontalUnitInPixels ); |
|
2173 if ( maxwidth < contentRect.Width() ) |
|
2174 { |
|
2175 TInt excesswidth = contentRect.Width() - maxwidth; |
|
2176 contentRect.Resize( -excesswidth, 0 ); |
|
2177 paddingRect.Resize( -excesswidth, 0 ); |
|
2178 borderRect.Resize( -excesswidth, 0 ); |
|
2179 marginRect.Resize( -excesswidth, 0 ); |
|
2180 } |
|
2181 } |
|
2182 } |
|
2183 if ( IsSmallerThanMinSizeL( aParentRect, aNode, aGraphicsDevice, |
|
2184 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
2185 { |
|
2186 if ( !IsPropertyNone( *minWidthProperty ) ) |
|
2187 { |
|
2188 TInt minwidth = HorizontalPixelValueL( minWidthProperty, |
|
2189 aParentRect.Width(), aGraphicsDevice, |
|
2190 aHorizontalUnitInPixels ); |
|
2191 if ( minwidth > contentRect.Width() ) |
|
2192 { |
|
2193 TInt missingwidth = minwidth - contentRect.Width(); |
|
2194 contentRect.Resize( missingwidth, 0 ); |
|
2195 paddingRect.Resize( missingwidth, 0 ); |
|
2196 borderRect.Resize( missingwidth, 0 ); |
|
2197 marginRect.Resize( missingwidth, 0 ); |
|
2198 } |
|
2199 } |
|
2200 } |
|
2201 horizontalValuesProcessed = ETrue; |
|
2202 } |
|
2203 if ( !horizontalValuesProcessed ) |
|
2204 { |
|
2205 if ( IsPropertyAutoL( *leftProperty ) && |
|
2206 IsPropertyAutoL( *rightProperty ) ) |
|
2207 { |
|
2208 // move the box left |
|
2209 contentRect.Move( widthToUse / 2, 0 ); |
|
2210 paddingRect.Move( widthToUse / 2, 0 ); |
|
2211 borderRect.Move( widthToUse / 2, 0 ); |
|
2212 marginRect.Move( widthToUse / 2, 0 ); |
|
2213 } |
|
2214 if ( IsPropertyAutoL( *leftProperty ) && |
|
2215 !IsPropertyAutoL( *rightProperty ) ) |
|
2216 { |
|
2217 // move the box left |
|
2218 contentRect.Move( widthToUse, 0 ); |
|
2219 paddingRect.Move( widthToUse, 0 ); |
|
2220 borderRect.Move( widthToUse, 0 ); |
|
2221 marginRect.Move( widthToUse, 0 ); |
|
2222 } |
|
2223 if ( IsPropertyAutoL( *marginLeftProperty ) && |
|
2224 IsPropertyAutoL( *marginRightProperty ) ) |
|
2225 { |
|
2226 // both margins auto, equal values |
|
2227 marginRect.Resize( widthToUse, 0 ); |
|
2228 paddingRect.Move( widthToUse / 2, 0 ); |
|
2229 borderRect.Move( widthToUse / 2, 0 ); |
|
2230 contentRect.Move( widthToUse / 2, 0 ); |
|
2231 } |
|
2232 if ( !IsPropertyAutoL( *marginLeftProperty ) && |
|
2233 IsPropertyAutoL( *marginRightProperty ) ) |
|
2234 { |
|
2235 // only right margin auto |
|
2236 marginRect.Resize( widthToUse, 0 ); |
|
2237 paddingRect.Move( widthToUse, 0 ); |
|
2238 borderRect.Move( widthToUse, 0 ); |
|
2239 contentRect.Move( widthToUse, 0 ); |
|
2240 } |
|
2241 if ( IsPropertyAutoL( *marginLeftProperty ) && |
|
2242 !IsPropertyAutoL( *marginRightProperty ) ) |
|
2243 { |
|
2244 // only left margin auto |
|
2245 marginRect.Resize( widthToUse, 0 ); |
|
2246 } |
|
2247 } |
|
2248 } |
|
2249 |
|
2250 // Move the rect to desired position |
|
2251 if ( topProperty ) |
|
2252 { |
|
2253 if ( !IsPropertyAutoL( *topProperty ) && |
|
2254 !IsPropertyNone( *topProperty ) ) |
|
2255 { |
|
2256 TInt y = VerticalPixelValueL( topProperty, aParentRect.Height(), |
|
2257 aGraphicsDevice, aVerticalUnitInPixels ); |
|
2258 contentRect.Move( 0, y ); |
|
2259 paddingRect.Move( 0, y ); |
|
2260 borderRect.Move( 0, y ); |
|
2261 marginRect.Move( 0, y ); |
|
2262 } |
|
2263 } |
|
2264 if ( leftProperty ) |
|
2265 { |
|
2266 if ( !IsPropertyAutoL( *leftProperty ) && |
|
2267 !IsPropertyNone( *leftProperty ) ) |
|
2268 { |
|
2269 TInt x = HorizontalPixelValueL( leftProperty, aParentRect.Width(), |
|
2270 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2271 contentRect.Move( x, 0 ); |
|
2272 paddingRect.Move( x, 0 ); |
|
2273 borderRect.Move( x, 0 ); |
|
2274 marginRect.Move( x, 0 ); |
|
2275 } |
|
2276 } |
|
2277 if ( bottomProperty ) |
|
2278 { |
|
2279 if ( !IsPropertyAutoL( *bottomProperty ) && |
|
2280 !IsPropertyNone( *bottomProperty ) ) |
|
2281 { |
|
2282 TInt py = VerticalPixelValueL( bottomProperty, |
|
2283 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ); |
|
2284 contentRect.Move( 0, -py ); |
|
2285 paddingRect.Move( 0, -py ); |
|
2286 borderRect.Move( 0, -py ); |
|
2287 marginRect.Move( 0, -py ); |
|
2288 } |
|
2289 } |
|
2290 if ( rightProperty ) |
|
2291 { |
|
2292 if ( !IsPropertyAutoL( *rightProperty ) && |
|
2293 !IsPropertyNone( *rightProperty ) ) |
|
2294 { |
|
2295 TInt px = HorizontalPixelValueL( rightProperty, |
|
2296 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2297 contentRect.Move( -px, 0 ); |
|
2298 paddingRect.Move( -px, 0 ); |
|
2299 borderRect.Move( -px, 0 ); |
|
2300 marginRect.Move( -px, 0 ); |
|
2301 } |
|
2302 } |
|
2303 |
|
2304 aNode.SetRect( contentRect ); |
|
2305 aNode.SetPaddingRect( paddingRect ); |
|
2306 aNode.SetBorderRect( borderRect ); |
|
2307 aNode.SetMarginRect( marginRect ); |
|
2308 |
|
2309 DropExceedingRectL( aParentRect, aNode ); |
|
2310 } |
|
2311 |
|
2312 // ----------------------------------------------------------------------------- |
|
2313 // CalculateBorderL() |
|
2314 // Move the rect by adding the border. |
|
2315 // ----------------------------------------------------------------------------- |
|
2316 // |
|
2317 static void CalculateBorderL( CXnNode& aNode, TRect& aParentRect, |
|
2318 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
2319 TReal aVerticalUnitInPixels ) |
|
2320 { |
|
2321 TInt offsetx = 0; |
|
2322 TInt offsety = 0; |
|
2323 |
|
2324 TInt borderleft = 0; |
|
2325 TInt borderright = 0; |
|
2326 TInt bordertop = 0; |
|
2327 TInt borderbottom = 0; |
|
2328 |
|
2329 CXnProperty* commonBorderStyle = aNode.BorderStyleL(); |
|
2330 CXnProperty* borderImage = aNode.BorderImageL(); |
|
2331 CXnProperty* borderStyle = aNode.BorderLeftStyleL(); |
|
2332 CXnProperty* borderproperty = aNode.BorderLeftL(); |
|
2333 |
|
2334 // if border width is defined |
|
2335 CXnProperty* borderwidthproperty = aNode.BorderWidthL(); |
|
2336 if ( !borderproperty ) |
|
2337 { |
|
2338 borderproperty = borderwidthproperty; |
|
2339 } |
|
2340 |
|
2341 if ( borderwidthproperty && ( ( commonBorderStyle && |
|
2342 !IsPropertyNone( *commonBorderStyle ) ) || |
|
2343 ( borderImage && !IsPropertyNone( *borderImage ) ) ) ) |
|
2344 { |
|
2345 TInt bordervertical = 0; |
|
2346 TInt borderhorizontal = 0; |
|
2347 |
|
2348 DetermineBorderWidthsL( borderwidthproperty, bordervertical, |
|
2349 borderhorizontal, aParentRect, aGraphicsDevice, |
|
2350 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
2351 |
|
2352 borderleft = borderhorizontal; |
|
2353 borderright = borderhorizontal; |
|
2354 bordertop = bordervertical; |
|
2355 borderbottom = bordervertical; |
|
2356 } |
|
2357 |
|
2358 TInt ignore; |
|
2359 // use border width only if there is valid border style or border image |
|
2360 if ( borderproperty && ( ( borderStyle && |
|
2361 !IsPropertyNone( *borderStyle ) ) || |
|
2362 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) || |
|
2363 ( borderImage && !IsPropertyNone( *borderImage ) ) ) ) |
|
2364 { |
|
2365 DetermineBorderWidthsL( borderproperty, ignore, borderleft, |
|
2366 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
2367 aVerticalUnitInPixels ); |
|
2368 } |
|
2369 borderStyle = aNode.BorderRightStyleL(); |
|
2370 borderproperty = aNode.BorderRightL(); |
|
2371 if ( !borderproperty ) |
|
2372 { |
|
2373 borderproperty = borderwidthproperty; |
|
2374 } |
|
2375 if ( borderproperty && ( ( borderStyle && |
|
2376 !IsPropertyNone( *borderStyle ) ) || |
|
2377 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) || |
|
2378 ( borderImage && !IsPropertyNone( *borderImage ) ) ) ) |
|
2379 { |
|
2380 DetermineBorderWidthsL( borderproperty, ignore, borderright, |
|
2381 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
2382 aVerticalUnitInPixels ); |
|
2383 } |
|
2384 borderStyle = aNode.BorderTopStyleL(); |
|
2385 borderproperty = aNode.BorderTopL(); |
|
2386 if ( !borderproperty ) |
|
2387 { |
|
2388 borderproperty = borderwidthproperty; |
|
2389 } |
|
2390 if ( borderproperty && ( ( borderStyle && |
|
2391 !IsPropertyNone( *borderStyle ) ) || |
|
2392 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) || |
|
2393 ( borderImage && !IsPropertyNone( *borderImage ) ) ) ) |
|
2394 { |
|
2395 DetermineBorderWidthsL( borderproperty, bordertop, ignore, |
|
2396 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
2397 aVerticalUnitInPixels ); |
|
2398 } |
|
2399 borderStyle = aNode.BorderBottomStyleL(); |
|
2400 borderproperty = aNode.BorderBottomL(); |
|
2401 if ( !borderproperty ) |
|
2402 { |
|
2403 borderproperty = borderwidthproperty; |
|
2404 } |
|
2405 if ( borderproperty && ( ( borderStyle && |
|
2406 !IsPropertyNone( *borderStyle ) ) || |
|
2407 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) || |
|
2408 ( borderImage && !IsPropertyNone( *borderImage ) ) ) ) |
|
2409 { |
|
2410 DetermineBorderWidthsL( borderproperty, borderbottom, ignore, |
|
2411 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
2412 aVerticalUnitInPixels ); |
|
2413 } |
|
2414 |
|
2415 offsetx = borderleft; // move the client rect of the element this much right |
|
2416 offsety = bordertop; // move the client rect of the element this much down |
|
2417 |
|
2418 TRect newrect( aNode.Rect() ); |
|
2419 newrect.Move( offsetx, offsety ); |
|
2420 aNode.SetRect( newrect ); |
|
2421 // and move the padding rect also, Ari 5.8.2005 |
|
2422 TRect paddingrect = aNode.PaddingRect(); |
|
2423 TPoint origin( paddingrect.iTl ); |
|
2424 paddingrect.Move( offsetx, offsety ); |
|
2425 aNode.SetPaddingRect( paddingrect ); |
|
2426 |
|
2427 TRect borderrect( origin, TSize( |
|
2428 borderleft + borderright + paddingrect.Width(), |
|
2429 bordertop + borderbottom + paddingrect.Height() ) ); |
|
2430 TRect normalFlowBorderRect( origin, TSize( |
|
2431 borderleft + borderright + paddingrect.Width(), |
|
2432 bordertop + borderbottom + paddingrect.Height() ) ); |
|
2433 aNode.SetBorderRect( borderrect ); |
|
2434 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
2435 } |
|
2436 |
|
2437 // ----------------------------------------------------------------------------- |
|
2438 // CalculateAbsoluteMarginL() |
|
2439 // Place child areas to parent rect and calculate margins. |
|
2440 // ----------------------------------------------------------------------------- |
|
2441 // |
|
2442 static void CalculateAbsoluteMarginL( CXnNode& aParent, CXnNode& aNode, |
|
2443 CXnNode* aPreviousSibling, const TDesC8& aParentBlockProgression, |
|
2444 const TDesC8& aParentDirection, TRect& aParentRect, |
|
2445 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
2446 TReal aVerticalUnitInPixels ) |
|
2447 { |
|
2448 TInt previousPosition = 0; |
|
2449 CXnProperty* marginProperty = NULL; |
|
2450 TInt marginLeft = 0; |
|
2451 TInt marginRight = 0; |
|
2452 TInt marginTop = 0; |
|
2453 TInt marginBottom = 0; |
|
2454 |
|
2455 marginProperty = aNode.MarginLeftL(); |
|
2456 |
|
2457 if ( marginProperty ) |
|
2458 { |
|
2459 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2460 { |
|
2461 marginLeft = HorizontalPixelValueL( marginProperty, |
|
2462 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2463 } |
|
2464 } |
|
2465 |
|
2466 marginProperty = aNode.MarginRightL(); |
|
2467 |
|
2468 if ( marginProperty ) |
|
2469 { |
|
2470 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2471 { |
|
2472 marginRight = HorizontalPixelValueL( marginProperty, |
|
2473 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2474 } |
|
2475 } |
|
2476 |
|
2477 marginProperty = aNode.MarginTopL(); |
|
2478 |
|
2479 if ( marginProperty ) |
|
2480 { |
|
2481 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2482 { |
|
2483 marginTop = VerticalPixelValueL( marginProperty, |
|
2484 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ); |
|
2485 } |
|
2486 } |
|
2487 |
|
2488 marginProperty = aNode.MarginBottomL(); |
|
2489 |
|
2490 if ( marginProperty ) |
|
2491 { |
|
2492 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2493 { |
|
2494 marginBottom = VerticalPixelValueL( marginProperty, |
|
2495 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ); |
|
2496 } |
|
2497 } |
|
2498 |
|
2499 TInt offsetx = 0; |
|
2500 TInt offsety = 0; |
|
2501 |
|
2502 if ( &aParent == &aNode ) |
|
2503 { |
|
2504 aParentRect.Move( -aParentRect.iTl.iX, -aParentRect.iTl.iY ); |
|
2505 } |
|
2506 |
|
2507 // if all properties are defined and block progression is LR, margin right |
|
2508 // is ignored and replaced by remaining |
|
2509 // if block progression is RL, same thing to margin left |
|
2510 |
|
2511 // previous sibling was found, get it's margin and previous coordinate to |
|
2512 // define next child's position |
|
2513 previousPosition = ( aPreviousSibling != NULL ) ? |
|
2514 GetPositionL( *aPreviousSibling, aParentBlockProgression, |
|
2515 aParentDirection ) : 0; |
|
2516 |
|
2517 // Move the rect considering previous child |
|
2518 // Margins are collapsed, larger is used |
|
2519 if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR ) |
|
2520 { |
|
2521 if ( aParentBlockProgression == |
|
2522 XnPropertyNames::style::common::block_progression::KLR || |
|
2523 aParentBlockProgression == |
|
2524 XnPropertyNames::style::common::block_progression::KRL ) |
|
2525 { |
|
2526 // offset to parent rect's top left corner |
|
2527 if ( !aPreviousSibling ) |
|
2528 { |
|
2529 offsetx = aParentRect.iTl.iX; |
|
2530 } |
|
2531 |
|
2532 offsety = aParentRect.iTl.iY + marginTop; |
|
2533 TInt prevMarginRight = 0; |
|
2534 |
|
2535 if ( aPreviousSibling ) |
|
2536 { |
|
2537 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2538 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2539 prevMarginRight = |
|
2540 previousMarginRect.iBr.iX - previousBorderRect.iBr.iX; |
|
2541 } |
|
2542 |
|
2543 if ( prevMarginRight > marginLeft ) |
|
2544 { |
|
2545 offsetx += previousPosition + prevMarginRight; |
|
2546 } |
|
2547 else |
|
2548 { |
|
2549 offsetx += previousPosition + marginLeft; |
|
2550 } |
|
2551 } |
|
2552 else // TB or BT |
|
2553 { |
|
2554 // offset to parent rect's top left corner |
|
2555 offsetx = aParentRect.iTl.iX + marginLeft; |
|
2556 |
|
2557 if ( !aPreviousSibling ) |
|
2558 { |
|
2559 offsety = aParentRect.iTl.iY; |
|
2560 } |
|
2561 |
|
2562 TInt prevMarginBottom = 0; |
|
2563 |
|
2564 if ( aPreviousSibling ) |
|
2565 { |
|
2566 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2567 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2568 prevMarginBottom = |
|
2569 previousMarginRect.iBr.iY - previousBorderRect.iBr.iY; |
|
2570 } |
|
2571 |
|
2572 if ( prevMarginBottom > marginTop ) |
|
2573 { |
|
2574 offsety += previousPosition + prevMarginBottom; |
|
2575 } |
|
2576 else |
|
2577 { |
|
2578 offsety += previousPosition + marginTop; |
|
2579 } |
|
2580 } |
|
2581 } |
|
2582 else // RTL |
|
2583 { |
|
2584 if ( aParentBlockProgression == |
|
2585 XnPropertyNames::style::common::block_progression::KLR || |
|
2586 aParentBlockProgression == |
|
2587 XnPropertyNames::style::common::block_progression::KRL ) |
|
2588 { |
|
2589 // offset to parent rect's top right corner |
|
2590 if ( !aPreviousSibling ) |
|
2591 { |
|
2592 offsetx = aParentRect.Width() - aNode.BorderRect().Width() + |
|
2593 aParentRect.iTl.iX; |
|
2594 } |
|
2595 else |
|
2596 { |
|
2597 offsetx = previousPosition - aNode.BorderRect().Width(); |
|
2598 } |
|
2599 |
|
2600 offsety = aParentRect.iTl.iY + marginTop; |
|
2601 |
|
2602 TInt prevMarginLeft = 0; |
|
2603 |
|
2604 if ( aPreviousSibling ) |
|
2605 { |
|
2606 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2607 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2608 prevMarginLeft = |
|
2609 previousBorderRect.iTl.iX - previousMarginRect.iTl.iX; |
|
2610 } |
|
2611 |
|
2612 if ( prevMarginLeft > marginRight ) |
|
2613 { |
|
2614 offsetx -= prevMarginLeft; |
|
2615 } |
|
2616 else |
|
2617 { |
|
2618 offsetx -= marginRight; |
|
2619 } |
|
2620 } |
|
2621 else // TB or BT |
|
2622 { |
|
2623 // offset to parent rect's bottom left corner |
|
2624 offsetx += aParentRect.iTl.iX + marginRight; |
|
2625 |
|
2626 if ( !aPreviousSibling ) |
|
2627 { |
|
2628 // start from bottom of parent rect |
|
2629 offsety = aParentRect.Height() - aNode.BorderRect().Height(); |
|
2630 } |
|
2631 else |
|
2632 { |
|
2633 offsety = previousPosition - aNode.BorderRect().Height(); |
|
2634 } |
|
2635 |
|
2636 TInt prevMarginTop = 0; |
|
2637 |
|
2638 if ( aPreviousSibling ) |
|
2639 { |
|
2640 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2641 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2642 prevMarginTop = |
|
2643 previousBorderRect.iTl.iY - previousMarginRect.iTl.iY; |
|
2644 } |
|
2645 |
|
2646 // collapse margins |
|
2647 if ( prevMarginTop > marginBottom ) |
|
2648 { |
|
2649 offsety -= prevMarginTop; |
|
2650 } |
|
2651 else |
|
2652 { |
|
2653 offsety -= marginBottom; |
|
2654 } |
|
2655 } |
|
2656 } |
|
2657 |
|
2658 TRect borderRect = TRect( aNode.BorderRect() ); |
|
2659 TRect normalFlowBorderRect = TRect( aNode.NormalFlowBorderRect() ); |
|
2660 // this is the top left corner of margin rect |
|
2661 TPoint origin( borderRect.iTl - TPoint( marginLeft, marginTop ) ); |
|
2662 |
|
2663 if ( &aParent != &aNode ) |
|
2664 { |
|
2665 // set content rect |
|
2666 TRect newRect( aNode.Rect() ); |
|
2667 newRect.Move( offsetx, offsety ); |
|
2668 aNode.SetRect( newRect ); |
|
2669 |
|
2670 // set padding rect |
|
2671 TRect paddingRect( aNode.PaddingRect() ); |
|
2672 paddingRect.Move( offsetx, offsety ); |
|
2673 aNode.SetPaddingRect( paddingRect ); |
|
2674 |
|
2675 // set border rect |
|
2676 borderRect.Move( offsetx, offsety ); |
|
2677 normalFlowBorderRect.Move( offsetx, offsety ); |
|
2678 // this is the top left corner of margin rect |
|
2679 origin = TPoint( borderRect.iTl - TPoint( marginLeft, marginTop ) ); |
|
2680 aNode.SetBorderRect( borderRect ); |
|
2681 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
2682 } |
|
2683 |
|
2684 TRect marginRect( origin, |
|
2685 TSize( marginLeft + marginRight + borderRect.Width(), |
|
2686 marginTop + marginBottom + borderRect.Height() ) ); |
|
2687 |
|
2688 aNode.SetMarginRect( marginRect ); |
|
2689 |
|
2690 // Within this function, the rects are adjusted if the display-priority is 0 |
|
2691 // and margin rect exceeds parent's content rect. |
|
2692 DropExceedingRectL( aParentRect, aNode ); |
|
2693 |
|
2694 if( IsNodeTooltip( aNode ) || aNode.Type()->Type() == KWidgetExtensionNodeName || |
|
2695 aNode.Type()->Type() == KPopUpNodeName ) |
|
2696 { |
|
2697 // because tooltip has it's own window, move margin rect to 0,0 |
|
2698 // and all other rects as much up left |
|
2699 TRect marginRect = aNode.MarginRect(); |
|
2700 |
|
2701 TRect borderRect = aNode.BorderRect(); |
|
2702 TRect paddingRect = aNode.PaddingRect(); |
|
2703 TRect contentRect = aNode.Rect(); |
|
2704 TInt x = marginRect.iTl.iX; |
|
2705 TInt y = marginRect.iTl.iY; |
|
2706 marginRect.Move( -x, -y ); |
|
2707 |
|
2708 borderRect.Move( -x, -y ); |
|
2709 paddingRect.Move( -x, -y ); |
|
2710 contentRect.Move( -x, -y ); |
|
2711 |
|
2712 aNode.SetMarginRect( marginRect ); |
|
2713 |
|
2714 aNode.SetBorderRect( borderRect ); |
|
2715 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
2716 aNode.SetPaddingRect( paddingRect ); |
|
2717 aNode.SetRect( contentRect ); |
|
2718 } |
|
2719 } |
|
2720 |
|
2721 // ----------------------------------------------------------------------------- |
|
2722 // CalculateAbsoluteMarginL() |
|
2723 // Place child areas to parent rect and calculate margins. |
|
2724 // ----------------------------------------------------------------------------- |
|
2725 // |
|
2726 static void CalculateMarginL( CXnNode& aParent, CXnNode& aNode, |
|
2727 CXnNode* aPreviousSibling, const TDesC8& aParentBlockProgression, |
|
2728 const TDesC8& aParentDirection, TRect& aParentRect, |
|
2729 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
2730 TReal aVerticalUnitInPixels, TInt& aColumnWidth, TInt& aColumnMargin ) |
|
2731 { |
|
2732 if( aParent.Control() && aParent.Control()->OwnsWindow() ) |
|
2733 { |
|
2734 aParentRect = TRect( aParentRect.iTl - aParent.MarginRect().iTl, aParentRect.Size() ); |
|
2735 } |
|
2736 |
|
2737 CXnProperty* marginProperty = NULL; |
|
2738 TInt marginLeft = 0; |
|
2739 TInt marginRight = 0; |
|
2740 TInt marginTop = 0; |
|
2741 TInt marginBottom = 0; |
|
2742 |
|
2743 marginProperty = aNode.MarginLeftL(); |
|
2744 if ( marginProperty ) |
|
2745 { |
|
2746 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2747 { |
|
2748 marginLeft = HorizontalPixelValueL( |
|
2749 marginProperty, aParentRect.Width(), |
|
2750 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2751 } |
|
2752 } |
|
2753 |
|
2754 marginProperty = aNode.MarginRightL(); |
|
2755 if ( marginProperty ) |
|
2756 { |
|
2757 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2758 { |
|
2759 marginRight = HorizontalPixelValueL( |
|
2760 marginProperty, aParentRect.Width(), |
|
2761 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
2762 } |
|
2763 } |
|
2764 |
|
2765 marginProperty = aNode.MarginTopL(); |
|
2766 if ( marginProperty ) |
|
2767 { |
|
2768 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2769 { |
|
2770 marginTop = VerticalPixelValueL( |
|
2771 marginProperty, aParentRect.Height(), |
|
2772 aGraphicsDevice, aVerticalUnitInPixels ); |
|
2773 } |
|
2774 } |
|
2775 |
|
2776 marginProperty = aNode.MarginBottomL(); |
|
2777 if ( marginProperty ) |
|
2778 { |
|
2779 if ( !IsPropertyAutoL( *marginProperty ) ) |
|
2780 { |
|
2781 marginBottom = VerticalPixelValueL( |
|
2782 marginProperty, aParentRect.Height(), |
|
2783 aGraphicsDevice, aVerticalUnitInPixels ); |
|
2784 } |
|
2785 } |
|
2786 |
|
2787 TInt offsetx = 0; |
|
2788 TInt offsety = 0; |
|
2789 |
|
2790 //What's this??? |
|
2791 if ( &aParent == &aNode ) |
|
2792 { |
|
2793 aParentRect.Move( -aParentRect.iTl.iX, -aParentRect.iTl.iY ); |
|
2794 } |
|
2795 |
|
2796 // Move the rect considering previous child |
|
2797 // Margins are collapsed, larger is used |
|
2798 if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR ) |
|
2799 { |
|
2800 // LTR , TB |
|
2801 // ********* |
|
2802 // | 1 | 4 | |
|
2803 // | 2 | 5 | |
|
2804 // | 3 | 6 | |
|
2805 // ********* |
|
2806 if ( aParentBlockProgression == |
|
2807 XnPropertyNames::style::common::block_progression::KTB ) |
|
2808 { |
|
2809 // First we need to know where to layout next sibling |
|
2810 // Try first under the previous sibling... |
|
2811 if ( aPreviousSibling ) |
|
2812 { |
|
2813 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2814 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2815 TBool layoutUnderPrevious( EFalse ); |
|
2816 TInt height = aNode.MarginRect().Height(); |
|
2817 TInt prevMarginBottom = |
|
2818 previousMarginRect.iBr.iY - previousBorderRect.iBr.iY; |
|
2819 if ( prevMarginBottom < marginTop ) |
|
2820 { |
|
2821 height -= prevMarginBottom; |
|
2822 } |
|
2823 else |
|
2824 { |
|
2825 height -= marginTop; |
|
2826 } |
|
2827 if(height <= aParentRect.iBr.iY - previousMarginRect.iBr.iY || IsSrollableBox(aNode)) |
|
2828 { |
|
2829 layoutUnderPrevious = ETrue; |
|
2830 } |
|
2831 |
|
2832 // ...then to the next column |
|
2833 if ( !layoutUnderPrevious ) |
|
2834 { |
|
2835 TInt width = |
|
2836 aNode.BorderRect().Width() + marginLeft + marginRight; |
|
2837 if ( aColumnMargin < marginLeft ) |
|
2838 { |
|
2839 width -= aColumnMargin; |
|
2840 } |
|
2841 else |
|
2842 { |
|
2843 width -= marginLeft; |
|
2844 } |
|
2845 if ( width + aColumnWidth <= aParentRect.Width() ) |
|
2846 { |
|
2847 offsety = aParentRect.iTl.iY + marginTop; |
|
2848 if ( aColumnMargin < marginLeft ) |
|
2849 { |
|
2850 offsetx = aParentRect.iTl.iX + aColumnWidth - |
|
2851 aColumnMargin + marginLeft; |
|
2852 } |
|
2853 else |
|
2854 { |
|
2855 offsetx = aParentRect.iTl.iX + aColumnWidth; |
|
2856 } |
|
2857 } |
|
2858 else |
|
2859 { |
|
2860 layoutUnderPrevious = ETrue; |
|
2861 } |
|
2862 } |
|
2863 if ( layoutUnderPrevious ) |
|
2864 { |
|
2865 offsetx = |
|
2866 aPreviousSibling->MarginRect().iTl.iX + marginLeft; |
|
2867 if ( prevMarginBottom > marginTop ) |
|
2868 { |
|
2869 // margin of this node is collapsed |
|
2870 offsety = previousMarginRect.iBr.iY; |
|
2871 } |
|
2872 else |
|
2873 { |
|
2874 // margin of the previous node is collapsed |
|
2875 offsety = previousBorderRect.iBr.iY + marginTop; |
|
2876 } |
|
2877 } |
|
2878 } |
|
2879 else |
|
2880 { |
|
2881 // offset to parent rect's top left corner |
|
2882 offsetx = aParentRect.iTl.iX + marginLeft; |
|
2883 offsety = aParentRect.iTl.iY + marginTop; |
|
2884 } |
|
2885 } |
|
2886 |
|
2887 // LTR , BT |
|
2888 // ********* |
|
2889 // | 3 | 6 | |
|
2890 // | 2 | 5 | |
|
2891 // | 1 | 4 | |
|
2892 // ********* |
|
2893 else if ( aParentBlockProgression == |
|
2894 XnPropertyNames::style::common::block_progression::KBT ) |
|
2895 { |
|
2896 // First we need to know where to layout next sibling |
|
2897 // Try first above the previous sibling... |
|
2898 if ( aPreviousSibling ) |
|
2899 { |
|
2900 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2901 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2902 TBool layoutAbovePrevious( EFalse ); |
|
2903 TInt height = |
|
2904 aNode.BorderRect().Height() + marginTop + marginBottom; |
|
2905 TInt prevMarginTop = |
|
2906 previousBorderRect.iTl.iY - previousMarginRect.iTl.iY; |
|
2907 if ( prevMarginTop < marginBottom ) |
|
2908 { |
|
2909 height -= prevMarginTop; |
|
2910 } |
|
2911 else |
|
2912 { |
|
2913 height -= marginBottom; |
|
2914 } |
|
2915 if ( height <= previousMarginRect.iTl.iY - aParentRect.iTl.iY ) |
|
2916 { |
|
2917 layoutAbovePrevious = ETrue; |
|
2918 } |
|
2919 |
|
2920 // ...then to the next column |
|
2921 if ( !layoutAbovePrevious ) |
|
2922 { |
|
2923 TInt width = |
|
2924 aNode.BorderRect().Width() + marginLeft + marginRight; |
|
2925 if ( aColumnMargin < marginLeft ) |
|
2926 { |
|
2927 width -= aColumnMargin; |
|
2928 } |
|
2929 else |
|
2930 { |
|
2931 width -= marginLeft; |
|
2932 } |
|
2933 if ( width + aColumnWidth <= aParentRect.Width() ) |
|
2934 { |
|
2935 offsety = aParentRect.iBr.iY - marginBottom - |
|
2936 aNode.BorderRect().Height(); |
|
2937 if ( aColumnMargin < marginLeft ) |
|
2938 { |
|
2939 offsetx = aParentRect.iTl.iX + aColumnWidth - |
|
2940 aColumnMargin + marginLeft; |
|
2941 } |
|
2942 else |
|
2943 { |
|
2944 offsetx = aParentRect.iTl.iX + aColumnWidth; |
|
2945 } |
|
2946 } |
|
2947 else |
|
2948 { |
|
2949 layoutAbovePrevious = ETrue; |
|
2950 } |
|
2951 } |
|
2952 if ( layoutAbovePrevious ) |
|
2953 { |
|
2954 offsetx = |
|
2955 aPreviousSibling->MarginRect().iTl.iX + marginLeft; |
|
2956 if ( prevMarginTop > marginBottom ) |
|
2957 { |
|
2958 // margin of this node is collapsed |
|
2959 offsety = previousMarginRect.iTl.iY - |
|
2960 aNode.BorderRect().Height(); |
|
2961 } |
|
2962 else |
|
2963 { |
|
2964 // margin of the previous node is collapsed |
|
2965 offsety = previousBorderRect.iTl.iY - marginBottom - |
|
2966 aNode.BorderRect().Height(); |
|
2967 } |
|
2968 } |
|
2969 } |
|
2970 else |
|
2971 { |
|
2972 offsetx = aParentRect.iTl.iX + marginLeft; |
|
2973 offsety = aParentRect.iBr.iY - marginBottom - |
|
2974 aNode.BorderRect().Height(); |
|
2975 } |
|
2976 } |
|
2977 |
|
2978 // LTR , LR |
|
2979 // ********* |
|
2980 // | 5 | 6 | |
|
2981 // | 3 | 4 | |
|
2982 // | 1 | 2 | |
|
2983 // ********* |
|
2984 else if ( aParentBlockProgression == |
|
2985 XnPropertyNames::style::common::block_progression::KLR ) |
|
2986 { |
|
2987 if ( aPreviousSibling ) |
|
2988 { |
|
2989 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
2990 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
2991 TBool layoutNextToPrevious( EFalse ); |
|
2992 TInt width = |
|
2993 aNode.BorderRect().Width() + marginRight + marginLeft; |
|
2994 TInt prevMarginRight = |
|
2995 previousMarginRect.iBr.iX - previousBorderRect.iBr.iX; |
|
2996 if ( prevMarginRight < marginLeft ) |
|
2997 { |
|
2998 width -= prevMarginRight; |
|
2999 } |
|
3000 else |
|
3001 { |
|
3002 width -= marginLeft; |
|
3003 } |
|
3004 if ( width <= aParentRect.iBr.iX - previousMarginRect.iBr.iX ) |
|
3005 { |
|
3006 layoutNextToPrevious = ETrue; |
|
3007 } |
|
3008 |
|
3009 if ( !layoutNextToPrevious ) |
|
3010 { |
|
3011 TInt height = aNode.BorderRect().Height() + marginTop + |
|
3012 marginBottom; |
|
3013 if ( aColumnMargin < marginBottom ) |
|
3014 { |
|
3015 height -= aColumnMargin; |
|
3016 } |
|
3017 else |
|
3018 { |
|
3019 height -= marginBottom; |
|
3020 } |
|
3021 if ( height + aColumnWidth <= aParentRect.Height() ) |
|
3022 { |
|
3023 offsetx = aParentRect.iTl.iX + marginLeft; |
|
3024 if ( aColumnMargin < marginTop ) |
|
3025 { |
|
3026 offsety = aParentRect.iBr.iY - aColumnWidth + |
|
3027 aColumnMargin - aNode.BorderRect().Height() - |
|
3028 marginBottom; |
|
3029 } |
|
3030 else |
|
3031 { |
|
3032 offsety = aParentRect.iBr.iY - aColumnWidth - |
|
3033 aNode.BorderRect().Height(); |
|
3034 } |
|
3035 } |
|
3036 else |
|
3037 { |
|
3038 layoutNextToPrevious = ETrue; |
|
3039 } |
|
3040 } |
|
3041 if ( layoutNextToPrevious ) |
|
3042 { |
|
3043 offsety = aPreviousSibling->MarginRect().iBr.iY - |
|
3044 aNode.BorderRect().Height() - marginBottom; |
|
3045 if ( prevMarginRight > marginLeft ) |
|
3046 { |
|
3047 // margin of this node is collapsed |
|
3048 offsetx = previousMarginRect.iBr.iX; |
|
3049 } |
|
3050 else |
|
3051 { |
|
3052 // margin of the previous node is collapsed |
|
3053 offsetx = previousBorderRect.iBr.iX + marginLeft; |
|
3054 } |
|
3055 } |
|
3056 } |
|
3057 else |
|
3058 { |
|
3059 offsetx = aParentRect.iTl.iX + marginLeft; |
|
3060 offsety = aParentRect.iBr.iY - aNode.BorderRect().Height() - |
|
3061 marginBottom; |
|
3062 } |
|
3063 } |
|
3064 |
|
3065 // LTR , RL |
|
3066 // ********* |
|
3067 // | 1 | 2 | |
|
3068 // | 3 | 4 | |
|
3069 // | 5 | 6 | |
|
3070 // ********* |
|
3071 |
|
3072 else if ( aParentBlockProgression == |
|
3073 XnPropertyNames::style::common::block_progression::KRL ) |
|
3074 { |
|
3075 if ( aPreviousSibling ) |
|
3076 { |
|
3077 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
3078 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
3079 TBool layoutNextToPrevious( EFalse ); |
|
3080 TInt width = |
|
3081 aNode.BorderRect().Width() + marginRight + marginLeft; |
|
3082 TInt prevMarginRight = |
|
3083 previousMarginRect.iBr.iX - previousBorderRect.iBr.iX; |
|
3084 if ( prevMarginRight < marginLeft ) |
|
3085 { |
|
3086 width -= prevMarginRight; |
|
3087 } |
|
3088 else |
|
3089 { |
|
3090 width -= marginLeft; |
|
3091 } |
|
3092 if ( width <= aParentRect.iBr.iX - previousMarginRect.iBr.iX ) |
|
3093 { |
|
3094 layoutNextToPrevious = ETrue; |
|
3095 } |
|
3096 |
|
3097 if ( !layoutNextToPrevious ) |
|
3098 { |
|
3099 TInt height = |
|
3100 aNode.BorderRect().Height() + marginTop + marginBottom; |
|
3101 if ( aColumnMargin < marginTop ) |
|
3102 { |
|
3103 height -= aColumnMargin; |
|
3104 } |
|
3105 else |
|
3106 { |
|
3107 height -= marginTop; |
|
3108 } |
|
3109 if ( height + aColumnWidth <= aParentRect.Height() ) |
|
3110 { |
|
3111 offsetx = aParentRect.iTl.iX + marginLeft; |
|
3112 if ( aColumnMargin < marginTop ) |
|
3113 { |
|
3114 offsety = aParentRect.iTl.iY + aColumnWidth - |
|
3115 aColumnMargin + marginTop; |
|
3116 } |
|
3117 else |
|
3118 { |
|
3119 offsety = aParentRect.iTl.iY + aColumnWidth; |
|
3120 } |
|
3121 } |
|
3122 else |
|
3123 { |
|
3124 layoutNextToPrevious = ETrue; |
|
3125 } |
|
3126 } |
|
3127 if ( layoutNextToPrevious ) |
|
3128 { |
|
3129 offsety = aPreviousSibling->MarginRect().iTl.iY + marginTop; |
|
3130 if ( prevMarginRight > marginLeft ) |
|
3131 { |
|
3132 // margin of this node is collapsed |
|
3133 offsetx = previousMarginRect.iBr.iX; |
|
3134 } |
|
3135 else |
|
3136 { |
|
3137 // margin of the previous node is collapsed |
|
3138 offsetx = previousBorderRect.iBr.iX + marginLeft; |
|
3139 } |
|
3140 } |
|
3141 } |
|
3142 else |
|
3143 { |
|
3144 offsetx = aParentRect.iTl.iX + marginLeft; |
|
3145 offsety = aParentRect.iTl.iY + marginTop; |
|
3146 } |
|
3147 } |
|
3148 } |
|
3149 |
|
3150 else |
|
3151 { |
|
3152 // RTL , TB |
|
3153 // ********* |
|
3154 // | 4 | 1 | |
|
3155 // | 5 | 2 | |
|
3156 // | 6 | 3 | |
|
3157 // ********* |
|
3158 if ( aParentBlockProgression == |
|
3159 XnPropertyNames::style::common::block_progression::KTB ) |
|
3160 { |
|
3161 if ( aPreviousSibling ) |
|
3162 { |
|
3163 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
3164 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
3165 TBool layoutUnderPrevious( EFalse ); |
|
3166 TInt height = aNode.MarginRect().Height(); |
|
3167 TInt prevMarginBottom = |
|
3168 previousMarginRect.iBr.iY - previousBorderRect.iBr.iY; |
|
3169 if ( prevMarginBottom < marginTop ) |
|
3170 { |
|
3171 height -= prevMarginBottom; |
|
3172 } |
|
3173 else |
|
3174 { |
|
3175 height -= marginTop; |
|
3176 } |
|
3177 if ( height <= aParentRect.iBr.iY - previousMarginRect.iBr.iY ) |
|
3178 { |
|
3179 layoutUnderPrevious = ETrue; |
|
3180 } |
|
3181 |
|
3182 if ( !layoutUnderPrevious ) |
|
3183 { |
|
3184 TInt width = |
|
3185 aNode.BorderRect().Width() + marginLeft + marginRight; |
|
3186 if ( aColumnMargin < marginLeft ) |
|
3187 { |
|
3188 width -= aColumnMargin; |
|
3189 } |
|
3190 else |
|
3191 { |
|
3192 width -= marginLeft; |
|
3193 } |
|
3194 if ( width + aColumnWidth <= aParentRect.Width() ) |
|
3195 { |
|
3196 offsety = aParentRect.iTl.iY + marginTop; |
|
3197 if ( aColumnMargin < marginLeft ) |
|
3198 { |
|
3199 offsetx = aParentRect.iBr.iX - aColumnWidth + |
|
3200 aColumnMargin - marginRight - |
|
3201 aNode.BorderRect().Width(); |
|
3202 } |
|
3203 else |
|
3204 { |
|
3205 offsetx = aParentRect.iBr.iX - aColumnWidth - |
|
3206 aNode.BorderRect().Width(); |
|
3207 } |
|
3208 } |
|
3209 else |
|
3210 { |
|
3211 layoutUnderPrevious = ETrue; |
|
3212 } |
|
3213 } |
|
3214 if ( layoutUnderPrevious ) |
|
3215 { |
|
3216 offsetx = aPreviousSibling->MarginRect().iBr.iX - |
|
3217 marginRight - aNode.BorderRect().Width(); |
|
3218 if ( prevMarginBottom > marginTop ) |
|
3219 { |
|
3220 offsety = previousMarginRect.iBr.iY; |
|
3221 } |
|
3222 else |
|
3223 { |
|
3224 offsety = previousBorderRect.iBr.iY + marginTop; |
|
3225 } |
|
3226 } |
|
3227 } |
|
3228 else |
|
3229 { |
|
3230 offsetx = aParentRect.iBr.iX - marginRight - |
|
3231 aNode.BorderRect().Width(); |
|
3232 offsety = aParentRect.iTl.iY + marginTop; |
|
3233 } |
|
3234 } |
|
3235 |
|
3236 // RTL , BT |
|
3237 // ********* |
|
3238 // | 6 | 3 | |
|
3239 // | 5 | 2 | |
|
3240 // | 4 | 1 | |
|
3241 // ********* |
|
3242 else if ( aParentBlockProgression == |
|
3243 XnPropertyNames::style::common::block_progression::KBT ) |
|
3244 { |
|
3245 if ( aPreviousSibling ) |
|
3246 { |
|
3247 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
3248 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
3249 TBool layoutAbovePrevious( EFalse ); |
|
3250 TInt height = |
|
3251 aNode.BorderRect().Height() + marginTop + marginBottom; |
|
3252 TInt prevMarginTop = |
|
3253 previousBorderRect.iTl.iY - previousMarginRect.iTl.iY; |
|
3254 if ( prevMarginTop < marginBottom ) |
|
3255 { |
|
3256 height -= prevMarginTop; |
|
3257 } |
|
3258 else |
|
3259 { |
|
3260 height -= marginBottom; |
|
3261 } |
|
3262 if ( height <= previousMarginRect.iTl.iY - aParentRect.iTl.iY ) |
|
3263 { |
|
3264 layoutAbovePrevious = ETrue; |
|
3265 } |
|
3266 |
|
3267 if ( !layoutAbovePrevious ) |
|
3268 { |
|
3269 TInt width = |
|
3270 aNode.BorderRect().Width() + marginLeft + marginRight; |
|
3271 if ( aColumnMargin < marginRight ) |
|
3272 { |
|
3273 width -= aColumnMargin; |
|
3274 } |
|
3275 else |
|
3276 { |
|
3277 width -= marginRight; |
|
3278 } |
|
3279 if ( width + aColumnWidth <= aParentRect.Width() ) |
|
3280 { |
|
3281 offsety = aParentRect.iBr.iY - marginBottom - |
|
3282 aNode.BorderRect().Height(); |
|
3283 if ( aColumnMargin < marginLeft ) |
|
3284 { |
|
3285 offsetx = aParentRect.iBr.iX - aColumnWidth + |
|
3286 aColumnMargin - marginRight - |
|
3287 aNode.BorderRect().Width(); |
|
3288 } |
|
3289 else |
|
3290 { |
|
3291 offsetx = aParentRect.iBr.iX - aColumnWidth - |
|
3292 aNode.BorderRect().Width(); |
|
3293 } |
|
3294 } |
|
3295 else |
|
3296 { |
|
3297 layoutAbovePrevious = ETrue; |
|
3298 } |
|
3299 } |
|
3300 if ( layoutAbovePrevious ) |
|
3301 { |
|
3302 offsetx = aPreviousSibling->MarginRect().iBr.iX - |
|
3303 marginRight - aNode.BorderRect().Width(); |
|
3304 if ( prevMarginTop > marginBottom ) |
|
3305 { |
|
3306 // margin of this node is collapsed |
|
3307 offsety = previousMarginRect.iTl.iY - |
|
3308 aNode.BorderRect().Height(); |
|
3309 } |
|
3310 else |
|
3311 { |
|
3312 // margin of the previous node is collapsed |
|
3313 offsety = previousBorderRect.iTl.iY - marginBottom - |
|
3314 aNode.BorderRect().Height(); |
|
3315 } |
|
3316 } |
|
3317 } |
|
3318 else |
|
3319 { |
|
3320 offsetx = aParentRect.iBr.iX - marginRight - |
|
3321 aNode.BorderRect().Width(); |
|
3322 offsety = aParentRect.iBr.iY - marginBottom - |
|
3323 aNode.BorderRect().Height(); |
|
3324 } |
|
3325 } |
|
3326 |
|
3327 // RTL , LR |
|
3328 // ********* |
|
3329 // | 6 | 5 | |
|
3330 // | 4 | 3 | |
|
3331 // | 2 | 1 | |
|
3332 // ********* |
|
3333 else if ( aParentBlockProgression == |
|
3334 XnPropertyNames::style::common::block_progression::KLR ) |
|
3335 { |
|
3336 if ( aPreviousSibling ) |
|
3337 { |
|
3338 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
3339 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
3340 TBool layoutNextToPrevious( EFalse ); |
|
3341 TInt width = |
|
3342 aNode.BorderRect().Width() + marginRight + marginLeft; |
|
3343 TInt prevMarginLeft = |
|
3344 previousBorderRect.iTl.iX - previousMarginRect.iTl.iX; |
|
3345 if ( prevMarginLeft < marginRight ) |
|
3346 { |
|
3347 width -= prevMarginLeft; |
|
3348 } |
|
3349 else |
|
3350 { |
|
3351 width -= marginRight; |
|
3352 } |
|
3353 if ( width <= previousMarginRect.iTl.iX - aParentRect.iTl.iX ) |
|
3354 { |
|
3355 layoutNextToPrevious = ETrue; |
|
3356 } |
|
3357 |
|
3358 if ( !layoutNextToPrevious ) |
|
3359 { |
|
3360 TInt height = |
|
3361 aNode.BorderRect().Height() + marginTop + marginBottom; |
|
3362 if ( aColumnMargin < marginBottom ) |
|
3363 { |
|
3364 height -= aColumnMargin; |
|
3365 } |
|
3366 else |
|
3367 { |
|
3368 height -= marginBottom; |
|
3369 } |
|
3370 if ( height + aColumnWidth <= aParentRect.Height() ) |
|
3371 { |
|
3372 offsetx = aParentRect.iBr.iX - marginRight - |
|
3373 aNode.BorderRect().Width(); |
|
3374 if ( aColumnMargin < marginTop ) |
|
3375 { |
|
3376 offsety = aParentRect.iBr.iY - aColumnWidth + |
|
3377 aColumnMargin - aNode.BorderRect().Height() - |
|
3378 marginBottom; |
|
3379 } |
|
3380 else |
|
3381 { |
|
3382 offsety = aParentRect.iBr.iY - aColumnWidth - |
|
3383 aNode.BorderRect().Height(); |
|
3384 } |
|
3385 } |
|
3386 else |
|
3387 { |
|
3388 layoutNextToPrevious = ETrue; |
|
3389 } |
|
3390 } |
|
3391 if ( layoutNextToPrevious ) |
|
3392 { |
|
3393 offsety = aPreviousSibling->MarginRect().iBr.iY - |
|
3394 aNode.BorderRect().Height() - marginBottom; |
|
3395 if ( prevMarginLeft > marginRight ) |
|
3396 { |
|
3397 offsetx = previousMarginRect.iTl.iX - |
|
3398 aNode.BorderRect().Width(); |
|
3399 } |
|
3400 else |
|
3401 { |
|
3402 offsetx = previousBorderRect.iTl.iX - marginRight - |
|
3403 aNode.BorderRect().Width(); |
|
3404 } |
|
3405 } |
|
3406 } |
|
3407 else |
|
3408 { |
|
3409 offsetx = aParentRect.iBr.iX - marginRight - |
|
3410 aNode.BorderRect().Width(); |
|
3411 offsety = aParentRect.iBr.iY - marginBottom - |
|
3412 aNode.BorderRect().Height(); |
|
3413 } |
|
3414 } |
|
3415 |
|
3416 // RTL , RL |
|
3417 // ********* |
|
3418 // | 2 | 1 | |
|
3419 // | 4 | 3 | |
|
3420 // | 6 | 5 | |
|
3421 // ********* |
|
3422 else if ( aParentBlockProgression == |
|
3423 XnPropertyNames::style::common::block_progression::KRL ) |
|
3424 { |
|
3425 if ( aPreviousSibling ) |
|
3426 { |
|
3427 TRect previousMarginRect = aPreviousSibling->MarginRect(); |
|
3428 TRect previousBorderRect = aPreviousSibling->BorderRect(); |
|
3429 TBool layoutNextToPrevious( EFalse ); |
|
3430 TInt width = |
|
3431 aNode.BorderRect().Width() + marginRight + marginLeft; |
|
3432 TInt prevMarginLeft = |
|
3433 previousBorderRect.iTl.iX - previousMarginRect.iTl.iX; |
|
3434 if ( prevMarginLeft < marginRight ) |
|
3435 { |
|
3436 width -= prevMarginLeft; |
|
3437 } |
|
3438 else |
|
3439 { |
|
3440 width -= marginRight; |
|
3441 } |
|
3442 if ( width <= previousMarginRect.iTl.iX - aParentRect.iTl.iX ) |
|
3443 { |
|
3444 layoutNextToPrevious = ETrue; |
|
3445 } |
|
3446 if ( !layoutNextToPrevious ) |
|
3447 { |
|
3448 TInt height = |
|
3449 aNode.BorderRect().Height() + marginTop + marginBottom; |
|
3450 if ( aColumnMargin < marginTop ) |
|
3451 { |
|
3452 height -= aColumnMargin; |
|
3453 } |
|
3454 else |
|
3455 { |
|
3456 height -= marginTop; |
|
3457 } |
|
3458 if ( height + aColumnWidth <= aParentRect.Height() ) |
|
3459 { |
|
3460 offsetx = aParentRect.iBr.iX - marginRight - |
|
3461 aNode.BorderRect().Width(); |
|
3462 if ( aColumnMargin < marginTop ) |
|
3463 { |
|
3464 offsety = aParentRect.iTl.iY + aColumnWidth - |
|
3465 aColumnMargin + marginTop; |
|
3466 } |
|
3467 else |
|
3468 { |
|
3469 offsety = aParentRect.iTl.iY + aColumnWidth; |
|
3470 } |
|
3471 } |
|
3472 else |
|
3473 { |
|
3474 layoutNextToPrevious = ETrue; |
|
3475 } |
|
3476 } |
|
3477 if ( layoutNextToPrevious ) |
|
3478 { |
|
3479 offsety = aPreviousSibling->MarginRect().iTl.iY + marginTop; |
|
3480 if ( prevMarginLeft > marginRight ) |
|
3481 { |
|
3482 offsetx = previousMarginRect.iTl.iX - |
|
3483 aNode.BorderRect().Width(); |
|
3484 } |
|
3485 else |
|
3486 { |
|
3487 offsetx = previousBorderRect.iTl.iX - marginRight - |
|
3488 aNode.BorderRect().Width(); |
|
3489 } |
|
3490 } |
|
3491 } |
|
3492 else |
|
3493 { |
|
3494 offsetx = aParentRect.iBr.iX - marginRight - |
|
3495 aNode.BorderRect().Width(); |
|
3496 offsety = aParentRect.iTl.iY + marginTop; |
|
3497 } |
|
3498 } |
|
3499 } |
|
3500 |
|
3501 TRect borderRect = TRect( aNode.BorderRect() ); |
|
3502 TRect normalFlowBorderRect = TRect( aNode.NormalFlowBorderRect() ); |
|
3503 // this is the top left corner of margin rect |
|
3504 TPoint origin( borderRect.iTl - TPoint( marginLeft, marginTop ) ); |
|
3505 |
|
3506 if ( &aParent != &aNode ) |
|
3507 { |
|
3508 // set content rect |
|
3509 TRect newRect( aNode.Rect() ); |
|
3510 newRect.Move( offsetx, offsety ); |
|
3511 aNode.SetRect( newRect ); |
|
3512 |
|
3513 // set padding rect |
|
3514 TRect paddingRect( aNode.PaddingRect() ); |
|
3515 paddingRect.Move( offsetx, offsety ); |
|
3516 aNode.SetPaddingRect( paddingRect ); |
|
3517 |
|
3518 // set border rect |
|
3519 borderRect.Move( offsetx, offsety ); |
|
3520 normalFlowBorderRect.Move( offsetx, offsety ); |
|
3521 // this is the top left corner of margin rect |
|
3522 origin = TPoint( borderRect.iTl - TPoint( marginLeft, marginTop ) ); |
|
3523 aNode.SetBorderRect( borderRect ); |
|
3524 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
3525 } |
|
3526 |
|
3527 TRect marginRect( origin, |
|
3528 TSize( marginLeft + marginRight + borderRect.Width(), |
|
3529 marginTop + marginBottom + borderRect.Height() ) ); |
|
3530 |
|
3531 aNode.SetMarginRect( marginRect ); |
|
3532 |
|
3533 // Within this function, the rects are adjusted if the display-priority is |
|
3534 // 0 and margin rect exceeds parent's content rect. |
|
3535 DropExceedingRectL( aParentRect, aNode ); |
|
3536 |
|
3537 // Update column width & column margin width according to block |
|
3538 // progression & direction. |
|
3539 if ( aParentBlockProgression == |
|
3540 XnPropertyNames::style::common::block_progression::KRL ) |
|
3541 { |
|
3542 TInt newColumnWidth = marginRect.iBr.iY - aParentRect.iTl.iY; |
|
3543 if ( newColumnWidth > aColumnWidth ) |
|
3544 { |
|
3545 aColumnWidth = newColumnWidth; |
|
3546 aColumnMargin = marginRect.iBr.iY - borderRect.iBr.iY; |
|
3547 } |
|
3548 } |
|
3549 else if ( aParentBlockProgression == |
|
3550 XnPropertyNames::style::common::block_progression::KLR ) |
|
3551 { |
|
3552 TInt newColumnWidth = aParentRect.iBr.iY - marginRect.iTl.iY; |
|
3553 if ( newColumnWidth > aColumnWidth ) |
|
3554 { |
|
3555 aColumnWidth = newColumnWidth; |
|
3556 aColumnMargin = borderRect.iTl.iY - marginRect.iTl.iY; |
|
3557 } |
|
3558 } |
|
3559 else if ( aParentDirection == |
|
3560 XnPropertyNames::style::common::direction::KLTR ) |
|
3561 { |
|
3562 // same for tb and bt |
|
3563 TInt newColumnWidth = marginRect.iBr.iX - aParentRect.iTl.iX; |
|
3564 if ( newColumnWidth > aColumnWidth ) |
|
3565 { |
|
3566 aColumnWidth = newColumnWidth; |
|
3567 aColumnMargin = marginRect.iBr.iX - borderRect.iBr.iX; |
|
3568 } |
|
3569 } |
|
3570 else if ( aParentDirection == |
|
3571 XnPropertyNames::style::common::direction::KRTL ) |
|
3572 { |
|
3573 // same for tb and bt |
|
3574 TInt newColumnWidth = aParentRect.iBr.iX - marginRect.iTl.iX; |
|
3575 if ( newColumnWidth > aColumnWidth ) |
|
3576 { |
|
3577 aColumnWidth = newColumnWidth; |
|
3578 aColumnMargin = borderRect.iTl.iX - marginRect.iTl.iX; |
|
3579 } |
|
3580 } |
|
3581 |
|
3582 if ( IsNodeTooltip( aNode ) ) |
|
3583 { |
|
3584 // because tooltip has it's own window, move margin rect to 0,0 |
|
3585 // and all other rects as much up left |
|
3586 TRect marginRect = aNode.MarginRect(); |
|
3587 TRect borderRect = aNode.BorderRect(); |
|
3588 TRect paddingRect = aNode.PaddingRect(); |
|
3589 TRect contentRect = aNode.Rect(); |
|
3590 TInt x = marginRect.iTl.iX; |
|
3591 TInt y = marginRect.iTl.iY; |
|
3592 marginRect.Move( -x, -y ); |
|
3593 borderRect.Move( -x, -y ); |
|
3594 paddingRect.Move( -x, -y ); |
|
3595 contentRect.Move( -x, -y ); |
|
3596 aNode.SetMarginRect( marginRect ); |
|
3597 aNode.SetBorderRect( borderRect ); |
|
3598 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
3599 aNode.SetPaddingRect( paddingRect ); |
|
3600 aNode.SetRect( contentRect ); |
|
3601 } |
|
3602 } |
|
3603 |
|
3604 // ----------------------------------------------------------------------------- |
|
3605 // CalculatePaddingL() |
|
3606 // Move the rect by adding the padding. |
|
3607 // ----------------------------------------------------------------------------- |
|
3608 // |
|
3609 static void CalculatePaddingL( const TRect& aParentRect, CXnNode& aNode, |
|
3610 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
3611 TReal aVerticalUnitInPixels ) |
|
3612 { |
|
3613 TInt offsetx = 0; |
|
3614 TInt offsety = 0; |
|
3615 |
|
3616 TInt paddingleft = 0; |
|
3617 TInt paddingright = 0; |
|
3618 TInt paddingtop = 0; |
|
3619 TInt paddingbottom = 0; |
|
3620 TRect parentRect = aParentRect; |
|
3621 |
|
3622 CXnProperty* paddingproperty = aNode.PaddingLeftL(); |
|
3623 |
|
3624 if ( paddingproperty ) |
|
3625 { |
|
3626 TRAPD( error, paddingleft = HorizontalPixelValueL( paddingproperty, |
|
3627 parentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ) ); |
|
3628 |
|
3629 if ( error != KErrNone ) |
|
3630 { |
|
3631 paddingleft = 0; |
|
3632 } |
|
3633 } |
|
3634 |
|
3635 paddingproperty = aNode.PaddingRightL(); |
|
3636 |
|
3637 if ( paddingproperty ) |
|
3638 { |
|
3639 TRAPD( error, paddingright = HorizontalPixelValueL( paddingproperty, |
|
3640 parentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ) ); |
|
3641 |
|
3642 if ( error != KErrNone ) |
|
3643 { |
|
3644 paddingright = 0; |
|
3645 } |
|
3646 } |
|
3647 |
|
3648 paddingproperty = aNode.PaddingTopL(); |
|
3649 |
|
3650 if ( paddingproperty ) |
|
3651 { |
|
3652 TRAPD( error, paddingtop = VerticalPixelValueL( paddingproperty, |
|
3653 parentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3654 |
|
3655 if ( error != KErrNone ) |
|
3656 { |
|
3657 paddingtop = 0; |
|
3658 } |
|
3659 } |
|
3660 |
|
3661 paddingproperty = aNode.PaddingBottomL(); |
|
3662 |
|
3663 if ( paddingproperty ) |
|
3664 { |
|
3665 TRAPD( error, paddingbottom = VerticalPixelValueL( paddingproperty, |
|
3666 parentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3667 |
|
3668 if ( error != KErrNone ) |
|
3669 { |
|
3670 paddingbottom = 0; |
|
3671 } |
|
3672 } |
|
3673 |
|
3674 // move the client rect of the element this much right |
|
3675 offsetx = paddingleft; |
|
3676 // move the client rect of the element this much down |
|
3677 offsety = paddingtop; |
|
3678 |
|
3679 TRect newrect( aNode.Rect() ); |
|
3680 TPoint origin( newrect.iTl ); |
|
3681 newrect.Move( offsetx, offsety ); |
|
3682 aNode.SetRect( newrect ); |
|
3683 |
|
3684 // set padding rect |
|
3685 TRect paddingrect( origin, TSize( paddingleft + paddingright + |
|
3686 newrect.Width(), paddingtop + paddingbottom + newrect.Height() ) ); |
|
3687 |
|
3688 aNode.SetPaddingRect( paddingrect ); |
|
3689 } |
|
3690 |
|
3691 // ----------------------------------------------------------------------------- |
|
3692 // CalculateRectL() |
|
3693 // Creates rect for CXnComponent. |
|
3694 // ----------------------------------------------------------------------------- |
|
3695 // |
|
3696 static void CalculateRectL( CXnNode& aNode, CXnNode& aParent, |
|
3697 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
3698 TReal aVerticalUnitInPixels ) |
|
3699 { |
|
3700 TInt width = 0; |
|
3701 TInt height = 0; |
|
3702 TRect parentRect = aParent.Rect(); |
|
3703 CXnProperty* widthproperty = aNode.WidthL(); |
|
3704 |
|
3705 if ( widthproperty ) |
|
3706 { |
|
3707 // if width is auto, it is set to 0 at this point and calculated later |
|
3708 if ( IsPropertyAutoL( *widthproperty ) ) |
|
3709 { |
|
3710 width = 0; |
|
3711 } |
|
3712 else |
|
3713 { |
|
3714 width = HorizontalPixelValueL( widthproperty, parentRect.Width(), |
|
3715 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
3716 } |
|
3717 } |
|
3718 |
|
3719 CXnProperty* heightproperty = aNode.HeightL(); |
|
3720 |
|
3721 if ( heightproperty ) |
|
3722 { |
|
3723 // if height is auto, height is set to 0 at this point |
|
3724 // and calculated later |
|
3725 if ( IsPropertyAutoL( *heightproperty ) ) |
|
3726 { |
|
3727 height = 0; |
|
3728 } |
|
3729 else |
|
3730 { |
|
3731 height = VerticalPixelValueL( heightproperty, parentRect.Height(), |
|
3732 aGraphicsDevice, aVerticalUnitInPixels ); |
|
3733 } |
|
3734 } |
|
3735 |
|
3736 // check that rect sizes are in max and min bounds |
|
3737 CXnProperty* maxheightproperty = aNode.MaxHeightL(); |
|
3738 CXnProperty* minheightproperty = aNode.MinHeightL(); |
|
3739 CXnProperty* maxwidthproperty = aNode.MaxWidthL(); |
|
3740 CXnProperty* minwidthproperty = aNode.MinWidthL(); |
|
3741 |
|
3742 if ( maxwidthproperty ) |
|
3743 { |
|
3744 if ( !IsPropertyNone( *maxwidthproperty ) ) |
|
3745 { |
|
3746 TInt maxwidth = HorizontalPixelValueL( |
|
3747 maxwidthproperty, parentRect.Width(), |
|
3748 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
3749 |
|
3750 if ( width > maxwidth ) |
|
3751 { |
|
3752 width = maxwidth; |
|
3753 } |
|
3754 } |
|
3755 } |
|
3756 |
|
3757 if ( minwidthproperty ) |
|
3758 { |
|
3759 if ( !IsPropertyNone( *minwidthproperty ) ) |
|
3760 { |
|
3761 TInt minwidth = HorizontalPixelValueL( |
|
3762 minwidthproperty, parentRect.Width(), |
|
3763 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
3764 |
|
3765 if ( width < minwidth ) |
|
3766 { |
|
3767 width = minwidth; |
|
3768 } |
|
3769 } |
|
3770 } |
|
3771 |
|
3772 if ( maxheightproperty ) |
|
3773 { |
|
3774 if ( !IsPropertyNone( *maxheightproperty ) ) |
|
3775 { |
|
3776 TInt maxheight = VerticalPixelValueL( |
|
3777 maxheightproperty, parentRect.Height(), |
|
3778 aGraphicsDevice, aVerticalUnitInPixels ); |
|
3779 |
|
3780 if ( height > maxheight ) |
|
3781 { |
|
3782 height = maxheight; |
|
3783 } |
|
3784 } |
|
3785 } |
|
3786 |
|
3787 if ( minheightproperty ) |
|
3788 { |
|
3789 if ( !IsPropertyNone( *minheightproperty ) ) |
|
3790 { |
|
3791 TInt minheight = VerticalPixelValueL( |
|
3792 minheightproperty, parentRect.Height(), |
|
3793 aGraphicsDevice, aVerticalUnitInPixels ); |
|
3794 |
|
3795 if ( height < minheight ) |
|
3796 { |
|
3797 height = minheight; |
|
3798 } |
|
3799 } |
|
3800 } |
|
3801 |
|
3802 if ( aNode.ViewNodeImpl() && height != 0 && width != 0 ) |
|
3803 { |
|
3804 TRect rect( 0, 0, width, height ); |
|
3805 TRect paddingrect( 0, 0, width, height ); |
|
3806 TRect borderrect( 0, 0, width, height ); |
|
3807 TRect normalFlowBorderRect( 0, 0, width, height ); |
|
3808 TRect marginrect( 0, 0, width, height ); |
|
3809 |
|
3810 aNode.SetRect( rect ); |
|
3811 aNode.SetPaddingRect( paddingrect ); |
|
3812 aNode.SetBorderRect( borderrect ); |
|
3813 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
3814 aNode.SetMarginRect( marginrect ); |
|
3815 } |
|
3816 else if ( !aNode.ViewNodeImpl() ) |
|
3817 { |
|
3818 TInt adaptive( aNode.IsAdaptive() ); |
|
3819 |
|
3820 if ( adaptive && ( IsNodeTooltip( aNode ) || IsAbsoluteL( aNode ) ) ) |
|
3821 { |
|
3822 CXnUiEngine* engine( aNode.UiEngine() ); |
|
3823 |
|
3824 TSize maxSize( engine->ClientRect().Size() ); |
|
3825 |
|
3826 if ( adaptive & XnAdaptive::EHeight ) |
|
3827 { |
|
3828 height = maxSize.iHeight; |
|
3829 } |
|
3830 if ( adaptive & XnAdaptive::EWidth ) |
|
3831 { |
|
3832 width = maxSize.iWidth; |
|
3833 } |
|
3834 } |
|
3835 |
|
3836 TRect rect( 0, 0, width, height ); |
|
3837 TRect paddingrect( 0, 0, width, height ); |
|
3838 TRect borderrect( 0, 0, width, height ); |
|
3839 TRect normalFlowBorderRect( 0, 0, width, height ); |
|
3840 TRect marginrect( 0, 0, width, height ); |
|
3841 |
|
3842 aNode.SetRect( rect ); |
|
3843 aNode.SetPaddingRect( paddingrect ); |
|
3844 aNode.SetBorderRect( borderrect ); |
|
3845 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
3846 aNode.SetMarginRect( marginrect ); |
|
3847 } |
|
3848 } |
|
3849 |
|
3850 // ----------------------------------------------------------------------------- |
|
3851 // CalculateRelativePositionL() |
|
3852 // Move the rect by it's relative position. |
|
3853 // ----------------------------------------------------------------------------- |
|
3854 // |
|
3855 static void CalculateRelativePositionsL( const TRect& aParentRect, |
|
3856 CXnNode& aNode, CGraphicsDevice& aGraphicsDevice, |
|
3857 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ) |
|
3858 { |
|
3859 CXnProperty* top = aNode.TopL(); |
|
3860 CXnProperty* bottom = aNode.BottomL(); |
|
3861 CXnProperty* left = aNode.LeftL(); |
|
3862 CXnProperty* right = aNode.RightL(); |
|
3863 |
|
3864 // Move rect by offset |
|
3865 TRect newRect( aNode.Rect() ); |
|
3866 TRect paddingRect( aNode.PaddingRect() ); |
|
3867 TRect borderRect( aNode.BorderRect() ); |
|
3868 TRect marginRect( aNode.MarginRect() ); |
|
3869 |
|
3870 TRect parentRect = aParentRect; |
|
3871 |
|
3872 if ( top && !IsPropertyAutoL( *top ) ) |
|
3873 { |
|
3874 newRect.Move( 0, VerticalPixelValueL( top, parentRect.Height(), |
|
3875 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3876 paddingRect.Move( 0, VerticalPixelValueL( top, parentRect.Height(), |
|
3877 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3878 borderRect.Move( 0, VerticalPixelValueL( top, parentRect.Height(), |
|
3879 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3880 marginRect.Move( 0, VerticalPixelValueL( top, parentRect.Height(), |
|
3881 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3882 } |
|
3883 if ( bottom && !IsPropertyAutoL( *bottom ) ) |
|
3884 { |
|
3885 newRect.Move( 0, -VerticalPixelValueL( bottom, parentRect.Height(), |
|
3886 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3887 paddingRect.Move( 0, -VerticalPixelValueL( bottom, parentRect.Height(), |
|
3888 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3889 borderRect.Move( 0, -VerticalPixelValueL( bottom, parentRect.Height(), |
|
3890 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3891 marginRect.Move( 0, -VerticalPixelValueL( bottom, parentRect.Height(), |
|
3892 aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
3893 } |
|
3894 if ( left && !IsPropertyAutoL( *left ) ) |
|
3895 { |
|
3896 newRect.Move( HorizontalPixelValueL( left, parentRect.Width(), |
|
3897 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3898 paddingRect.Move( HorizontalPixelValueL( left, parentRect.Width(), |
|
3899 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3900 borderRect.Move( HorizontalPixelValueL( left, parentRect.Width(), |
|
3901 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3902 marginRect.Move( HorizontalPixelValueL( left, parentRect.Width(), |
|
3903 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3904 } |
|
3905 if ( right && !IsPropertyAutoL( *right ) ) |
|
3906 { |
|
3907 newRect.Move( -HorizontalPixelValueL( right, parentRect.Width(), |
|
3908 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3909 paddingRect.Move( -HorizontalPixelValueL( right, parentRect.Width(), |
|
3910 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3911 borderRect.Move( -HorizontalPixelValueL( right, parentRect.Width(), |
|
3912 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3913 marginRect.Move( -HorizontalPixelValueL( right, parentRect.Width(), |
|
3914 aGraphicsDevice, aHorizontalUnitInPixels ), 0 ); |
|
3915 } |
|
3916 |
|
3917 aNode.SetRect( newRect ); |
|
3918 aNode.SetPaddingRect( paddingRect ); |
|
3919 aNode.SetBorderRect( borderRect ); |
|
3920 aNode.SetMarginRect( marginRect ); |
|
3921 |
|
3922 DropExceedingRectL( parentRect, aNode, ETrue ); |
|
3923 } |
|
3924 |
|
3925 // ----------------------------------------------------------------------------- |
|
3926 // CalculateSpaceUsedByChildrenL() |
|
3927 // Return space used by node's children. |
|
3928 // ----------------------------------------------------------------------------- |
|
3929 // |
|
3930 static TSize CalculateSpaceUsedByChildrenL( RPointerArray< CXnNode >& aChildren, |
|
3931 CXnNode& aNode, const TDesC8& aParentBlockProgression, |
|
3932 const TDesC8& aParentDirection, CGraphicsDevice& aScreenDevice, |
|
3933 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ) |
|
3934 { |
|
3935 TInt usedSiblingHeight( 0 ); |
|
3936 TInt usedSiblingWidth( 0 ); |
|
3937 |
|
3938 TRect rect( aNode.Rect() ); |
|
3939 |
|
3940 TSize largestSize( 0, 0 ); |
|
3941 |
|
3942 for ( TInt i = 0; i < aChildren.Count(); i++ ) |
|
3943 { |
|
3944 CXnNode* node( aChildren[i] ); |
|
3945 |
|
3946 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
3947 !IsAbsoluteL( *node ) && !IsNodeTooltip( *node ) ) |
|
3948 { |
|
3949 TSize siblingSize = CalculateTotalDimensionsL( *node, ETrue, |
|
3950 EFalse, rect, aScreenDevice, aHorizontalUnitInPixels, |
|
3951 aVerticalUnitInPixels ); |
|
3952 |
|
3953 if ( node->IsAdaptive() ) |
|
3954 { |
|
3955 RPointerArray< CXnNode >& children( node->Children() ); |
|
3956 |
|
3957 CXnProperty* blockProgressionProperty( |
|
3958 node->BlockProgressionL() ); |
|
3959 CXnProperty* directionProperty( node->DirectionL() ); |
|
3960 |
|
3961 const TDesC8* blockProgression( |
|
3962 &XnPropertyNames::style::common::block_progression::KTB() ); |
|
3963 const TDesC8* direction( |
|
3964 &XnPropertyNames::style::common::direction::KLTR() ); |
|
3965 |
|
3966 if ( directionProperty ) |
|
3967 { |
|
3968 direction = &directionProperty->StringValue(); |
|
3969 } |
|
3970 |
|
3971 if ( blockProgressionProperty ) |
|
3972 { |
|
3973 blockProgression = &blockProgressionProperty->StringValue(); |
|
3974 } |
|
3975 |
|
3976 siblingSize += CalculateSpaceUsedByChildrenL( children, aNode, |
|
3977 *blockProgression, *direction, |
|
3978 aScreenDevice, aHorizontalUnitInPixels, |
|
3979 aVerticalUnitInPixels ); |
|
3980 } |
|
3981 |
|
3982 if ( siblingSize.iWidth > largestSize.iWidth ) |
|
3983 { |
|
3984 largestSize.iWidth = siblingSize.iWidth; |
|
3985 } |
|
3986 if ( siblingSize.iHeight > largestSize.iHeight ) |
|
3987 { |
|
3988 largestSize.iHeight = siblingSize.iHeight; |
|
3989 } |
|
3990 |
|
3991 if ( aParentBlockProgression == |
|
3992 XnPropertyNames::style::common::block_progression::KTB ) |
|
3993 { |
|
3994 usedSiblingHeight += siblingSize.iHeight; |
|
3995 usedSiblingWidth = largestSize.iWidth; |
|
3996 } |
|
3997 |
|
3998 if ( aParentBlockProgression == |
|
3999 XnPropertyNames::style::common::block_progression::KLR || |
|
4000 aParentBlockProgression == |
|
4001 XnPropertyNames::style::common::block_progression::KRL ) |
|
4002 { |
|
4003 usedSiblingWidth += siblingSize.iWidth; |
|
4004 usedSiblingHeight = largestSize.iHeight; |
|
4005 } |
|
4006 |
|
4007 // collapse margins |
|
4008 if ( aChildren.Count() < i ) |
|
4009 { |
|
4010 CXnNode* next( aChildren[i + 1] ); |
|
4011 |
|
4012 if ( ( aParentBlockProgression == |
|
4013 XnPropertyNames::style::common::block_progression::KLR || |
|
4014 aParentBlockProgression == |
|
4015 XnPropertyNames::style::common:: |
|
4016 block_progression::KRL ) && aParentDirection == |
|
4017 XnPropertyNames::style::common::direction::KLTR ) |
|
4018 { |
|
4019 TInt thisSiblingsRightMargin = |
|
4020 node->MarginRect().iBr.iX - node->BorderRect().iBr.iX; |
|
4021 TInt nextSiblingsLeftMargin = |
|
4022 next->BorderRect().iTl.iX - next->MarginRect().iTl.iX; |
|
4023 |
|
4024 if ( nextSiblingsLeftMargin > thisSiblingsRightMargin ) |
|
4025 { |
|
4026 usedSiblingWidth -= thisSiblingsRightMargin; |
|
4027 } |
|
4028 } |
|
4029 |
|
4030 if ( ( aParentBlockProgression == |
|
4031 XnPropertyNames::style::common::block_progression::KRL || |
|
4032 aParentBlockProgression == |
|
4033 XnPropertyNames::style::common |
|
4034 ::block_progression::KLR ) && aParentDirection == |
|
4035 XnPropertyNames::style::common::direction::KRTL ) |
|
4036 { |
|
4037 TInt thisSiblingsLeftMargin = |
|
4038 node->MarginRect().iTl.iX - node->BorderRect().iTl.iX; |
|
4039 TInt nextSiblingsRightMargin = |
|
4040 next->BorderRect().iBr.iX - next->MarginRect().iBr.iX; |
|
4041 |
|
4042 if ( nextSiblingsRightMargin > thisSiblingsLeftMargin ) |
|
4043 { |
|
4044 usedSiblingWidth =- thisSiblingsLeftMargin; |
|
4045 } |
|
4046 } |
|
4047 |
|
4048 if ( ( aParentBlockProgression == |
|
4049 XnPropertyNames::style::common::block_progression::KTB || |
|
4050 aParentBlockProgression == |
|
4051 XnPropertyNames::style::common:: |
|
4052 block_progression::KBT ) && aParentDirection == |
|
4053 XnPropertyNames::style::common::direction::KLTR ) |
|
4054 { |
|
4055 TInt thisSiblingsBottomMargin = |
|
4056 node->MarginRect().iBr.iY - node->BorderRect().iBr.iY; |
|
4057 TInt nextSiblingsTopMargin = |
|
4058 next->BorderRect().iTl.iY - next->MarginRect().iTl.iY; |
|
4059 |
|
4060 if ( nextSiblingsTopMargin > thisSiblingsBottomMargin ) |
|
4061 { |
|
4062 usedSiblingHeight -= thisSiblingsBottomMargin; |
|
4063 } |
|
4064 } |
|
4065 |
|
4066 if ( ( aParentBlockProgression == |
|
4067 XnPropertyNames::style::common::block_progression::KTB || |
|
4068 aParentBlockProgression == |
|
4069 XnPropertyNames::style::common:: |
|
4070 block_progression::KBT ) && aParentDirection == |
|
4071 XnPropertyNames::style::common::direction::KRTL ) |
|
4072 { |
|
4073 TInt thisSiblingsTopMargin = |
|
4074 node->MarginRect().iTl.iY - node->BorderRect().iTl.iY; |
|
4075 TInt nextSiblingsBottomMargin = |
|
4076 next->BorderRect().iBr.iY - next->MarginRect().iBr.iY; |
|
4077 |
|
4078 if ( nextSiblingsBottomMargin > thisSiblingsTopMargin ) |
|
4079 { |
|
4080 usedSiblingHeight -= thisSiblingsTopMargin; |
|
4081 } |
|
4082 } |
|
4083 } |
|
4084 } |
|
4085 } |
|
4086 |
|
4087 return TSize( usedSiblingWidth, usedSiblingHeight ); |
|
4088 } |
|
4089 |
|
4090 // ----------------------------------------------------------------------------- |
|
4091 // CalculateTotalDimensionsL() |
|
4092 // Scale dimensions for areas that have properties set to AUTO. |
|
4093 // ----------------------------------------------------------------------------- |
|
4094 // |
|
4095 static TSize CalculateTotalDimensionsL( CXnNode& aNode, TBool aIgnoreAutoValues, |
|
4096 TBool aIgnoreMinSizes, TRect& aParentRect, |
|
4097 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
4098 TReal aVerticalUnitInPixels ) |
|
4099 { |
|
4100 // AUTO areas return their defined dimensions if not ignored |
|
4101 // if ignored, 0 is returned as area dimensions |
|
4102 CXnProperty* width( aNode.WidthL() ); |
|
4103 CXnProperty* height( aNode.HeightL() ); |
|
4104 TInt adaptive( aNode.IsAdaptive() ); |
|
4105 TBool autoNotFound( EFalse ); |
|
4106 |
|
4107 if ( adaptive ) |
|
4108 { |
|
4109 // Force to measure adaptive size |
|
4110 aIgnoreAutoValues = EFalse; |
|
4111 autoNotFound = ETrue; |
|
4112 } |
|
4113 if ( aIgnoreAutoValues ) |
|
4114 { |
|
4115 TInt horizontalAuto( HasNodeHorizontalAutoValuesL( aNode ) ); |
|
4116 TInt verticalAuto( HasNodeVerticalAutoValuesL( aNode ) ); |
|
4117 if ( horizontalAuto && verticalAuto ) |
|
4118 { |
|
4119 return TSize( 0, 0 ); |
|
4120 } |
|
4121 else if ( horizontalAuto ) |
|
4122 { |
|
4123 TInt h = VerticalPixelValueL( height, aParentRect.Height(), |
|
4124 aGraphicsDevice, aVerticalUnitInPixels ); |
|
4125 return TSize( 0, h ); |
|
4126 } |
|
4127 else if ( verticalAuto ) |
|
4128 { |
|
4129 TInt w = HorizontalPixelValueL( width, aParentRect.Width(), |
|
4130 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
4131 return TSize( w, 0 ); |
|
4132 } |
|
4133 autoNotFound = ETrue; |
|
4134 } |
|
4135 |
|
4136 TInt x( 0 ); |
|
4137 TInt y( 0 ); |
|
4138 |
|
4139 if ( !aIgnoreMinSizes ) |
|
4140 { |
|
4141 if ( !autoNotFound && HasNodeAutoValuesL( aNode ) ) |
|
4142 { |
|
4143 // if auto values, check minimum sizes |
|
4144 if ( height ) |
|
4145 { |
|
4146 if ( IsPropertyAutoL( *height ) ) |
|
4147 { |
|
4148 CXnProperty* minheight( aNode.MinHeightL() ); |
|
4149 if ( minheight ) |
|
4150 { |
|
4151 if ( !IsPropertyNone( *minheight ) ) |
|
4152 { |
|
4153 y += VerticalPixelValueL( minheight, |
|
4154 aParentRect.Height(), aGraphicsDevice, |
|
4155 aVerticalUnitInPixels ); |
|
4156 } |
|
4157 } |
|
4158 } |
|
4159 } |
|
4160 if ( width ) |
|
4161 { |
|
4162 if ( IsPropertyAutoL( *width ) ) |
|
4163 { |
|
4164 CXnProperty* minwidth( aNode.MinWidthL() ); |
|
4165 if ( minwidth ) |
|
4166 { |
|
4167 if ( !IsPropertyNone( *minwidth ) ) |
|
4168 { |
|
4169 x += HorizontalPixelValueL( minwidth, |
|
4170 aParentRect.Width(), aGraphicsDevice, |
|
4171 aHorizontalUnitInPixels ); |
|
4172 } |
|
4173 } |
|
4174 } |
|
4175 } |
|
4176 } |
|
4177 } |
|
4178 |
|
4179 CXnProperty* marginLeft = aNode.MarginLeftL(); |
|
4180 CXnProperty* marginRight = aNode.MarginRightL(); |
|
4181 CXnProperty* borderLeft = aNode.BorderLeftL(); |
|
4182 CXnProperty* borderRight = aNode.BorderRightL(); |
|
4183 CXnProperty* paddingLeft = aNode.PaddingLeftL(); |
|
4184 CXnProperty* paddingRight = aNode.PaddingRightL(); |
|
4185 CXnProperty* marginTop = aNode.MarginTopL(); |
|
4186 CXnProperty* marginBottom = aNode.MarginBottomL(); |
|
4187 CXnProperty* borderTop = aNode.BorderTopL(); |
|
4188 CXnProperty* borderBottom = aNode.BorderBottomL(); |
|
4189 CXnProperty* paddingTop = aNode.PaddingTopL(); |
|
4190 CXnProperty* paddingBottom = aNode.PaddingBottomL(); |
|
4191 CXnProperty* borderWidth = aNode.BorderWidthL(); |
|
4192 CXnProperty* borderStyle = aNode.BorderStyleL(); |
|
4193 CXnProperty* borderImage = aNode.BorderImageL(); |
|
4194 CXnProperty* borderLeftStyle = aNode.BorderLeftStyleL(); |
|
4195 CXnProperty* borderRightStyle = aNode.BorderRightStyleL(); |
|
4196 CXnProperty* borderTopStyle = aNode.BorderTopStyleL(); |
|
4197 CXnProperty* borderBottomStyle = aNode.BorderBottomStyleL(); |
|
4198 |
|
4199 TInt borderWidthValue( 0 ); |
|
4200 TInt borderHeightValue( 0 ); |
|
4201 TInt ignore; |
|
4202 |
|
4203 if ( marginLeft ) |
|
4204 { |
|
4205 if ( autoNotFound || !IsPropertyAutoL( *marginLeft ) ) |
|
4206 { |
|
4207 x += HorizontalPixelValueL( marginLeft, aParentRect.Width(), |
|
4208 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
4209 } |
|
4210 } |
|
4211 if ( marginRight ) |
|
4212 { |
|
4213 if ( autoNotFound || !IsPropertyAutoL( *marginRight ) ) |
|
4214 { |
|
4215 x += HorizontalPixelValueL( marginRight, aParentRect.Width(), |
|
4216 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
4217 } |
|
4218 } |
|
4219 if ( paddingLeft ) |
|
4220 { |
|
4221 TRAP_IGNORE( x += HorizontalPixelValueL( paddingLeft, |
|
4222 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ) ); |
|
4223 } |
|
4224 if ( paddingRight ) |
|
4225 { |
|
4226 TRAP_IGNORE( x += HorizontalPixelValueL( paddingRight, |
|
4227 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ) ); |
|
4228 } |
|
4229 if ( marginTop ) |
|
4230 { |
|
4231 if ( autoNotFound || !IsPropertyAutoL( *marginTop ) ) |
|
4232 { |
|
4233 y += VerticalPixelValueL( marginTop, aParentRect.Height(), |
|
4234 aGraphicsDevice, aVerticalUnitInPixels ); |
|
4235 } |
|
4236 } |
|
4237 if ( marginBottom ) |
|
4238 { |
|
4239 if ( autoNotFound || !IsPropertyAutoL( *marginBottom ) ) |
|
4240 { |
|
4241 y += VerticalPixelValueL( marginBottom, aParentRect.Height(), |
|
4242 aGraphicsDevice, aVerticalUnitInPixels ); |
|
4243 } |
|
4244 } |
|
4245 if ( paddingTop ) |
|
4246 { |
|
4247 TRAP_IGNORE( y += VerticalPixelValueL( paddingTop, |
|
4248 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
4249 } |
|
4250 if ( paddingBottom ) |
|
4251 { |
|
4252 TRAP_IGNORE( y += VerticalPixelValueL( paddingBottom, |
|
4253 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ) ); |
|
4254 } |
|
4255 // is border image or border style defined? |
|
4256 // if not, borders are ignored |
|
4257 if ( borderWidth ) |
|
4258 { |
|
4259 if ( borderImage || borderStyle ) |
|
4260 { |
|
4261 DetermineBorderWidthsL( borderWidth, borderWidthValue, |
|
4262 borderHeightValue, aParentRect, aGraphicsDevice, |
|
4263 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
4264 x += ( borderWidthValue * 2 ); |
|
4265 y += ( borderHeightValue * 2 ); |
|
4266 } |
|
4267 } |
|
4268 if ( borderLeft ) |
|
4269 { |
|
4270 if ( borderImage || borderStyle || borderLeftStyle ) |
|
4271 { |
|
4272 x -= borderWidthValue; |
|
4273 TInt borderLeftValue( 0 ); |
|
4274 DetermineBorderWidthsL( borderLeft, ignore, borderLeftValue, |
|
4275 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
4276 aVerticalUnitInPixels ); |
|
4277 x += borderLeftValue; |
|
4278 } |
|
4279 } |
|
4280 if ( borderRight ) |
|
4281 { |
|
4282 if ( borderImage || borderStyle || borderRightStyle ) |
|
4283 { |
|
4284 x -= borderWidthValue; |
|
4285 TInt borderRightValue( 0 ); |
|
4286 DetermineBorderWidthsL( borderRight, ignore, borderRightValue, |
|
4287 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
4288 aVerticalUnitInPixels ); |
|
4289 x += borderRightValue; |
|
4290 } |
|
4291 } |
|
4292 if ( borderTop ) |
|
4293 { |
|
4294 if ( borderImage || borderStyle || borderTopStyle ) |
|
4295 { |
|
4296 y -= borderHeightValue; |
|
4297 TInt borderTopValue( 0 ); |
|
4298 DetermineBorderWidthsL( borderTop, borderTopValue, ignore, |
|
4299 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
4300 aVerticalUnitInPixels ); |
|
4301 y += borderTopValue; |
|
4302 } |
|
4303 } |
|
4304 if ( borderBottom ) |
|
4305 { |
|
4306 if ( borderImage || borderStyle || borderBottomStyle ) |
|
4307 { |
|
4308 y -= borderHeightValue; |
|
4309 TInt borderBottomValue( 0 ); |
|
4310 DetermineBorderWidthsL( borderBottom, borderBottomValue, ignore, |
|
4311 aParentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
4312 aVerticalUnitInPixels ); |
|
4313 y += borderBottomValue; |
|
4314 } |
|
4315 } |
|
4316 |
|
4317 TInt maxHeight( 0 ); |
|
4318 TInt maxWidth( 0 ); |
|
4319 TInt minHeight( 0 ); |
|
4320 TInt minWidth( 0 ); |
|
4321 |
|
4322 if ( HasNodeMinSizesL( aNode ) ) |
|
4323 { |
|
4324 CXnProperty* heightproperty( aNode.HeightL() ); |
|
4325 CXnProperty* widthproperty( aNode.WidthL() ); |
|
4326 if ( heightproperty ) |
|
4327 { |
|
4328 CXnProperty* minheightproperty( aNode.MinHeightL() ); |
|
4329 if ( minheightproperty ) |
|
4330 { |
|
4331 if ( !IsPropertyNone( *minheightproperty ) ) |
|
4332 { |
|
4333 minHeight = VerticalPixelValueL( minheightproperty, |
|
4334 aParentRect.Height(), aGraphicsDevice, |
|
4335 aVerticalUnitInPixels ); |
|
4336 } |
|
4337 } |
|
4338 } |
|
4339 if ( widthproperty ) |
|
4340 { |
|
4341 CXnProperty* minwidthproperty( aNode.MinWidthL() ); |
|
4342 if ( minwidthproperty ) |
|
4343 { |
|
4344 if (!IsPropertyNone( *minwidthproperty ) ) |
|
4345 { |
|
4346 minWidth = HorizontalPixelValueL( minwidthproperty, |
|
4347 aParentRect.Width(), aGraphicsDevice, |
|
4348 aHorizontalUnitInPixels ); |
|
4349 } |
|
4350 } |
|
4351 } |
|
4352 } |
|
4353 if ( HasNodeMaxSizesL( aNode ) ) |
|
4354 { |
|
4355 CXnProperty* heightProperty( aNode.HeightL() ); |
|
4356 CXnProperty* widthProperty( aNode.WidthL() ); |
|
4357 if ( heightProperty ) |
|
4358 { |
|
4359 CXnProperty* maxHeightProperty( aNode.MaxHeightL() ); |
|
4360 if ( maxHeightProperty ) |
|
4361 { |
|
4362 if ( !IsPropertyNone( *maxHeightProperty ) ) |
|
4363 { |
|
4364 maxHeight = VerticalPixelValueL( maxHeightProperty, |
|
4365 aParentRect.Height(), aGraphicsDevice, |
|
4366 aVerticalUnitInPixels ); |
|
4367 } |
|
4368 } |
|
4369 } |
|
4370 if ( widthProperty ) |
|
4371 { |
|
4372 CXnProperty* maxWidthProperty( aNode.MaxWidthL() ); |
|
4373 if ( maxWidthProperty ) |
|
4374 { |
|
4375 if ( !IsPropertyNone( *maxWidthProperty ) ) |
|
4376 { |
|
4377 maxWidth = HorizontalPixelValueL( maxWidthProperty, |
|
4378 aParentRect.Width(), aGraphicsDevice, |
|
4379 aHorizontalUnitInPixels ); |
|
4380 } |
|
4381 } |
|
4382 } |
|
4383 } |
|
4384 if ( width && height ) |
|
4385 { |
|
4386 if ( ( adaptive & XnAdaptive::EWidth ) && |
|
4387 ( adaptive & XnAdaptive::EHeight ) ) |
|
4388 { |
|
4389 TSize available( aParentRect.Size() - TSize( x, y ) ); |
|
4390 if ( available.iWidth > 0 ) |
|
4391 { |
|
4392 if ( available.iWidth > maxWidth && maxWidth > 0 ) |
|
4393 { |
|
4394 available.iWidth = maxWidth; |
|
4395 } |
|
4396 } |
|
4397 if ( available.iHeight > 0 ) |
|
4398 { |
|
4399 if ( available.iHeight > maxHeight && maxHeight > 0 ) |
|
4400 { |
|
4401 available.iHeight = maxHeight; |
|
4402 } |
|
4403 } |
|
4404 TSize size( aNode.MeasureAdaptiveContentL( available ) ); |
|
4405 x += size.iWidth; |
|
4406 y += size.iHeight; |
|
4407 if ( minWidth > x ) |
|
4408 { |
|
4409 x = minWidth; |
|
4410 } |
|
4411 if ( minHeight > y ) |
|
4412 { |
|
4413 y = minHeight; |
|
4414 } |
|
4415 return TSize( x, y ); |
|
4416 } |
|
4417 } |
|
4418 if ( width ) |
|
4419 { |
|
4420 if ( adaptive & XnAdaptive::EWidth ) |
|
4421 { |
|
4422 TSize available( aParentRect.Size() - TSize( x, y ) ); |
|
4423 if ( available.iWidth > 0 ) |
|
4424 { |
|
4425 if ( available.iWidth > maxWidth && maxWidth > 0 ) |
|
4426 { |
|
4427 available.iWidth = maxWidth; |
|
4428 } |
|
4429 x += aNode.MeasureAdaptiveContentL( available ).iWidth; |
|
4430 if ( minWidth > x ) |
|
4431 { |
|
4432 x = minWidth; |
|
4433 } |
|
4434 } |
|
4435 } |
|
4436 else if ( autoNotFound || !IsPropertyAutoL( *width ) ) |
|
4437 { |
|
4438 x += HorizontalPixelValueL( width, aParentRect.Width(), |
|
4439 aGraphicsDevice, aHorizontalUnitInPixels ); |
|
4440 } |
|
4441 } |
|
4442 if ( height ) |
|
4443 { |
|
4444 if ( adaptive & XnAdaptive::EHeight ) |
|
4445 { |
|
4446 TSize available( aParentRect.Size() - TSize( x, y ) ); |
|
4447 if ( available.iHeight > 0 ) |
|
4448 { |
|
4449 if ( available.iHeight > maxHeight && maxHeight > 0 ) |
|
4450 { |
|
4451 available.iHeight = maxHeight; |
|
4452 } |
|
4453 y += aNode.MeasureAdaptiveContentL( available ).iHeight; |
|
4454 if ( minHeight > y ) |
|
4455 { |
|
4456 y = minHeight; |
|
4457 } |
|
4458 } |
|
4459 } |
|
4460 else if ( autoNotFound || !IsPropertyAutoL( *height ) ) |
|
4461 { |
|
4462 y += VerticalPixelValueL( height, aParentRect.Height(), |
|
4463 aGraphicsDevice, aVerticalUnitInPixels ); |
|
4464 } |
|
4465 } |
|
4466 return TSize( x, y ); |
|
4467 } |
|
4468 |
|
4469 // ----------------------------------------------------------------------------- |
|
4470 // CutOnePixelFromPercentChildNodeL() |
|
4471 // If node has a child node with percentace defined sizes, |
|
4472 // one pixel may be cut off from it to fix possible rounding problem. |
|
4473 // ----------------------------------------------------------------------------- |
|
4474 // |
|
4475 static TBool CutOnePixelFromPercentChildNodeL( CXnNode& aNode, |
|
4476 const TDesC8& aParentBlockProgression ) |
|
4477 { |
|
4478 RPointerArray< CXnNode >& children = aNode.Children(); |
|
4479 // find the last percent value node |
|
4480 // possible percent values: |
|
4481 // width |
|
4482 // height |
|
4483 // paddings |
|
4484 // margins |
|
4485 // borders |
|
4486 for ( TInt i = children.Count() -1; i < -1 ; --i ) |
|
4487 { |
|
4488 CXnNode* currentNode = children[i]; |
|
4489 |
|
4490 TInt x = 0; |
|
4491 TInt y = 0; |
|
4492 |
|
4493 CXnProperty* widthHeight; |
|
4494 CXnProperty* paddingTopLeft; |
|
4495 CXnProperty* paddingBottomRight; |
|
4496 CXnProperty* borderTopLeft; |
|
4497 CXnProperty* borderBottomRight; |
|
4498 CXnProperty* marginTopLeft; |
|
4499 CXnProperty* marginBottomRight; |
|
4500 |
|
4501 if ( ( aParentBlockProgression == |
|
4502 XnPropertyNames::style::common::block_progression::KLR ) || |
|
4503 aParentBlockProgression == |
|
4504 XnPropertyNames::style::common::block_progression::KRL ) |
|
4505 { |
|
4506 x = -1; |
|
4507 y = 0; |
|
4508 widthHeight = currentNode->WidthL(); |
|
4509 paddingTopLeft = currentNode->PaddingLeftL(); |
|
4510 paddingBottomRight = currentNode->PaddingRightL(); |
|
4511 borderTopLeft = currentNode->BorderLeftL(); |
|
4512 borderBottomRight = currentNode->BorderRightL(); |
|
4513 marginTopLeft = currentNode->MarginLeftL(); |
|
4514 marginBottomRight = currentNode->MarginRightL(); |
|
4515 } |
|
4516 else |
|
4517 { |
|
4518 y = -1; |
|
4519 x = 0; |
|
4520 widthHeight = currentNode->HeightL(); |
|
4521 paddingTopLeft = currentNode->PaddingTopL(); |
|
4522 paddingBottomRight = currentNode->PaddingBottomL(); |
|
4523 borderTopLeft = currentNode->BorderTopL(); |
|
4524 borderBottomRight = currentNode->BorderBottomL(); |
|
4525 marginTopLeft = currentNode->MarginTopL(); |
|
4526 marginBottomRight = currentNode->MarginBottomL(); |
|
4527 } |
|
4528 if ( widthHeight ) |
|
4529 { |
|
4530 if ( IsValuePercentageL( *widthHeight ) ) |
|
4531 { |
|
4532 // shrink width one pixel |
|
4533 TRect rect( currentNode->Rect() ); |
|
4534 rect.Resize( x, y ); |
|
4535 currentNode->SetRect( rect ); |
|
4536 TRect paddingRect( currentNode->PaddingRect() ); |
|
4537 paddingRect.Resize( x, y ); |
|
4538 currentNode->SetPaddingRect( paddingRect ); |
|
4539 TRect borderRect( currentNode->BorderRect() ); |
|
4540 borderRect.Resize( x, y ); |
|
4541 TRect marginRect( currentNode->MarginRect() ); |
|
4542 |
|
4543 marginRect.Resize( x, y ); |
|
4544 |
|
4545 currentNode->SetMarginRect( marginRect ); |
|
4546 |
|
4547 return ETrue; |
|
4548 } |
|
4549 } |
|
4550 if ( paddingTopLeft ) |
|
4551 { |
|
4552 if ( IsValuePercentageL( *paddingTopLeft ) ) |
|
4553 { |
|
4554 // shrink left padding one pixel |
|
4555 TRect rect( currentNode->Rect() ); |
|
4556 rect.Move( x, y ); |
|
4557 currentNode->SetRect( rect ); |
|
4558 TRect paddingRect( currentNode->PaddingRect() ); |
|
4559 paddingRect.Resize( x, y ); |
|
4560 currentNode->SetPaddingRect( paddingRect ); |
|
4561 TRect borderRect( currentNode->BorderRect() ); |
|
4562 TRect normalFlowBorderRect( |
|
4563 currentNode->NormalFlowBorderRect() ); |
|
4564 borderRect.Resize( x, y ); |
|
4565 normalFlowBorderRect.Resize( x, y ); |
|
4566 currentNode->SetBorderRect( borderRect ); |
|
4567 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
4568 TRect marginRect( currentNode->MarginRect() ); |
|
4569 |
|
4570 marginRect.Resize( x, y ); |
|
4571 |
|
4572 currentNode->SetMarginRect( marginRect ); |
|
4573 |
|
4574 return ETrue; |
|
4575 } |
|
4576 } |
|
4577 if ( paddingBottomRight ) |
|
4578 { |
|
4579 if ( IsValuePercentageL( *paddingBottomRight ) ) |
|
4580 { |
|
4581 // shrink right padding one pixel |
|
4582 TRect paddingRect( currentNode->PaddingRect() ); |
|
4583 paddingRect.Resize( x, y ); |
|
4584 currentNode->SetPaddingRect( paddingRect ); |
|
4585 TRect borderRect( currentNode->BorderRect() ); |
|
4586 TRect normalFlowBorderRect( |
|
4587 currentNode->NormalFlowBorderRect() ); |
|
4588 borderRect.Resize( x, y ); |
|
4589 normalFlowBorderRect.Resize( x, y ); |
|
4590 currentNode->SetBorderRect( borderRect ); |
|
4591 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
4592 TRect marginRect( currentNode->MarginRect() ); |
|
4593 |
|
4594 marginRect.Resize( x, y ); |
|
4595 |
|
4596 currentNode->SetMarginRect( marginRect ); |
|
4597 |
|
4598 return ETrue; |
|
4599 } |
|
4600 } |
|
4601 if ( borderTopLeft ) |
|
4602 { |
|
4603 if ( IsValuePercentageL( *borderTopLeft ) ) |
|
4604 { |
|
4605 TRect rect( currentNode->Rect() ); |
|
4606 rect.Move( x, y ); |
|
4607 currentNode->SetRect( rect ); |
|
4608 TRect paddingRect( currentNode->PaddingRect() ); |
|
4609 paddingRect.Move( x, y ); |
|
4610 currentNode->SetPaddingRect( paddingRect ); |
|
4611 TRect borderRect( currentNode->BorderRect() ); |
|
4612 TRect normalFlowBorderRect( |
|
4613 currentNode->NormalFlowBorderRect() ); |
|
4614 borderRect.Resize( x, y ); |
|
4615 normalFlowBorderRect.Resize( x, y ); |
|
4616 currentNode->SetBorderRect( borderRect ); |
|
4617 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
4618 TRect marginRect( currentNode->MarginRect() ); |
|
4619 |
|
4620 marginRect.Resize( x, y ); |
|
4621 |
|
4622 currentNode->SetMarginRect( marginRect ); |
|
4623 |
|
4624 return ETrue; |
|
4625 } |
|
4626 } |
|
4627 if ( borderBottomRight ) |
|
4628 { |
|
4629 if ( IsValuePercentageL( *borderBottomRight ) ) |
|
4630 { |
|
4631 TRect borderRect( currentNode->BorderRect() ); |
|
4632 TRect normalFlowBorderRect( currentNode->BorderRect() ); |
|
4633 borderRect.Resize( x, y ); |
|
4634 normalFlowBorderRect.Resize( x, y ); |
|
4635 currentNode->SetBorderRect( borderRect ); |
|
4636 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
4637 TRect marginRect( currentNode->MarginRect() ); |
|
4638 |
|
4639 marginRect.Resize( x, y ); |
|
4640 |
|
4641 currentNode->SetMarginRect( marginRect ); |
|
4642 |
|
4643 return ETrue; |
|
4644 } |
|
4645 } |
|
4646 if ( marginTopLeft ) |
|
4647 { |
|
4648 if ( IsValuePercentageL( *marginTopLeft ) ) |
|
4649 { |
|
4650 TRect rect( currentNode->Rect() ); |
|
4651 rect.Move( x, y ); |
|
4652 currentNode->SetRect( rect ); |
|
4653 TRect paddingRect( currentNode->PaddingRect() ); |
|
4654 paddingRect.Move( x, y ); |
|
4655 currentNode->SetPaddingRect( paddingRect ); |
|
4656 TRect borderRect( currentNode->BorderRect() ); |
|
4657 TRect normalFlowBorderRect( |
|
4658 currentNode->NormalFlowBorderRect() ); |
|
4659 borderRect.Move( x, y ); |
|
4660 normalFlowBorderRect.Move( x, y ); |
|
4661 currentNode->SetBorderRect( borderRect ); |
|
4662 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
4663 TRect marginRect( currentNode->MarginRect() ); |
|
4664 |
|
4665 marginRect.Resize( x, y ); |
|
4666 |
|
4667 currentNode->SetMarginRect( marginRect ); |
|
4668 |
|
4669 return ETrue; |
|
4670 } |
|
4671 } |
|
4672 if ( marginBottomRight ) |
|
4673 { |
|
4674 if ( IsValuePercentageL( *marginBottomRight ) ) |
|
4675 { |
|
4676 TRect marginRect( currentNode->MarginRect() ); |
|
4677 |
|
4678 marginRect.Resize( x, y ); |
|
4679 |
|
4680 currentNode->SetMarginRect( marginRect ); |
|
4681 |
|
4682 return ETrue; |
|
4683 } |
|
4684 } |
|
4685 } |
|
4686 |
|
4687 return EFalse; |
|
4688 } |
|
4689 |
|
4690 // ----------------------------------------------------------------------------- |
|
4691 // DetermineBorderWidthsL() |
|
4692 // Determine border widths. |
|
4693 // ----------------------------------------------------------------------------- |
|
4694 // |
|
4695 static void DetermineBorderWidthsL( CXnProperty* aBorderWidthProperty, |
|
4696 TInt& aBordervertical, TInt& aBorderhorizontal, TRect& aParentRect, |
|
4697 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
4698 TReal aVerticalUnitInPixels ) |
|
4699 { |
|
4700 CXnDomList& propertyValueList = |
|
4701 aBorderWidthProperty->Property()->PropertyValueList(); |
|
4702 for ( TInt i = propertyValueList.Length() - 1; i >= 0; --i ) |
|
4703 { |
|
4704 CXnDomPropertyValue* value = |
|
4705 static_cast< CXnDomPropertyValue* >( propertyValueList.Item( i ) ); |
|
4706 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
4707 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
4708 { |
|
4709 // border width was defined as string |
|
4710 const TDesC8& borderwidth = aBorderWidthProperty->StringValue(); |
|
4711 if ( borderwidth == |
|
4712 XnPropertyNames::style::common::border_width::KThin ) |
|
4713 { |
|
4714 aBordervertical = KXnBorderThin; |
|
4715 aBorderhorizontal = KXnBorderThin; |
|
4716 } |
|
4717 else if ( borderwidth == |
|
4718 XnPropertyNames::style::common::border_width::KMedium ) |
|
4719 { |
|
4720 aBordervertical = KXnBorderMedium; |
|
4721 aBorderhorizontal = KXnBorderMedium; |
|
4722 } |
|
4723 else |
|
4724 { |
|
4725 aBordervertical = KXnBorderThick; |
|
4726 aBorderhorizontal = KXnBorderThick; |
|
4727 } |
|
4728 } |
|
4729 else |
|
4730 { |
|
4731 // border width was defined as int |
|
4732 aBordervertical = VerticalPixelValueL( aBorderWidthProperty, |
|
4733 aParentRect.Height(), aGraphicsDevice, aVerticalUnitInPixels ); |
|
4734 aBorderhorizontal = HorizontalPixelValueL( aBorderWidthProperty, |
|
4735 aParentRect.Width(), aGraphicsDevice, aHorizontalUnitInPixels ); |
|
4736 } |
|
4737 } |
|
4738 } |
|
4739 |
|
4740 // ----------------------------------------------------------------------------- |
|
4741 // DisplayedChildrenCountL() |
|
4742 // Return number of node's displayed children. |
|
4743 // ----------------------------------------------------------------------------- |
|
4744 // |
|
4745 static TInt DisplayedChildrenCountL( CXnNode& aNode, |
|
4746 RPointerArray< CXnNode >* aDisplayedChildren ) |
|
4747 { |
|
4748 RPointerArray< CXnNode >& children = aNode.Children(); |
|
4749 TInt displayedCount( 0 ); |
|
4750 |
|
4751 for ( TInt i = 0; i < children.Count(); i++ ) |
|
4752 { |
|
4753 CXnNode* node( children[i] ); |
|
4754 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
4755 !IsAbsoluteL( *node ) && !IsNodeTooltip( *node ) ) |
|
4756 { |
|
4757 if ( aDisplayedChildren ) |
|
4758 { |
|
4759 aDisplayedChildren->AppendL( node ); |
|
4760 } |
|
4761 displayedCount++; |
|
4762 } |
|
4763 } |
|
4764 |
|
4765 return displayedCount; |
|
4766 } |
|
4767 |
|
4768 // ----------------------------------------------------------------------------- |
|
4769 // DisplayedParentL() |
|
4770 // Return node's displayed parent. |
|
4771 // ----------------------------------------------------------------------------- |
|
4772 // |
|
4773 static CXnNode* DisplayedParentL( CXnNode& aNode ) |
|
4774 { |
|
4775 if ( aNode.ViewNodeImpl() ) |
|
4776 { |
|
4777 return &aNode; |
|
4778 } |
|
4779 CXnNode* parent = aNode.Parent(); |
|
4780 return parent; |
|
4781 } |
|
4782 |
|
4783 // ----------------------------------------------------------------------------- |
|
4784 // DomPropertyValueFromProperty() |
|
4785 // Return DOM property value from property. |
|
4786 // ----------------------------------------------------------------------------- |
|
4787 // |
|
4788 static CXnDomPropertyValue* DomPropertyValueFromProperty( |
|
4789 CXnProperty* aProperty ) |
|
4790 { |
|
4791 if ( !aProperty ) |
|
4792 { |
|
4793 return NULL; |
|
4794 } |
|
4795 CXnDomProperty* domProperty = aProperty->Property(); |
|
4796 if ( !domProperty ) |
|
4797 { |
|
4798 return NULL; |
|
4799 } |
|
4800 return static_cast< |
|
4801 CXnDomPropertyValue* >( domProperty->PropertyValueList().Item( 0 ) ); |
|
4802 } |
|
4803 |
|
4804 // ----------------------------------------------------------------------------- |
|
4805 // DomPropertyValueFromProperty() |
|
4806 // Return DOM property value from property. |
|
4807 // ----------------------------------------------------------------------------- |
|
4808 // |
|
4809 static TBool IsChildOfScrollableControl( CXnNode& aNode ) |
|
4810 { |
|
4811 CXnNode* parent = &aNode; |
|
4812 while( parent ) |
|
4813 { |
|
4814 if( IsSrollableBox( *parent ) ) |
|
4815 { |
|
4816 return ETrue; |
|
4817 } |
|
4818 parent = parent->Parent(); |
|
4819 } |
|
4820 return EFalse; |
|
4821 } |
|
4822 |
|
4823 // ----------------------------------------------------------------------------- |
|
4824 // DropExceedingRectL() |
|
4825 // Drop node if node's margin rect exceeds it's parent's content rect. |
|
4826 // ----------------------------------------------------------------------------- |
|
4827 // |
|
4828 static void DropExceedingRectL( const TRect& aParentRect, CXnNode& aNode, |
|
4829 TBool aDropRelativeNode ) |
|
4830 { |
|
4831 if( IsChildOfScrollableControl( aNode ) ) |
|
4832 { |
|
4833 return; |
|
4834 } |
|
4835 |
|
4836 if ( IsNodeTooltip( aNode ) ) |
|
4837 { |
|
4838 // tooltip never dropped |
|
4839 return; |
|
4840 } |
|
4841 |
|
4842 CXnProperty* positionProp( aNode.PositionL() ); |
|
4843 |
|
4844 if ( positionProp ) |
|
4845 { |
|
4846 const TDesC8& value( positionProp->StringValue() ); |
|
4847 if ( value == XnPropertyNames::style::common::position::KFloating ) |
|
4848 { |
|
4849 // Don't change floating positioned box dimensions |
|
4850 return; |
|
4851 } |
|
4852 } |
|
4853 |
|
4854 TRect parentRect( aParentRect ); |
|
4855 TRect marginRect( aNode.MarginRect() ); |
|
4856 |
|
4857 // does the margin rect fit in its parent? |
|
4858 TInt parentLeft = parentRect.iTl.iX; |
|
4859 TInt parentRight = parentRect.iBr.iX; |
|
4860 TInt parentTop = parentRect.iTl.iY; |
|
4861 TInt parentBottom = parentRect.iBr.iY; |
|
4862 |
|
4863 TInt rectLeft = marginRect.iTl.iX; |
|
4864 TInt rectRight = marginRect.iBr.iX; |
|
4865 TInt rectTop = marginRect.iTl.iY; |
|
4866 TInt rectBottom = marginRect.iBr.iY; |
|
4867 |
|
4868 TInt priority = 0; |
|
4869 CXnProperty* priorityProperty = aNode.DisplayPriorityL(); |
|
4870 |
|
4871 if ( priorityProperty ) |
|
4872 { |
|
4873 TRAPD( error, priority = priorityProperty->FloatValueL() ); |
|
4874 if ( error != KErrNone ) |
|
4875 { |
|
4876 priority = 0; |
|
4877 } |
|
4878 } |
|
4879 |
|
4880 TInt leftOffset( 0 ); |
|
4881 TInt rightOffset( 0 ); |
|
4882 TInt topOffset( 0 ); |
|
4883 TInt bottomOffset( 0 ); |
|
4884 |
|
4885 if ( priority != 0 ) |
|
4886 { |
|
4887 TBool drop = CalculateExceedingArea( *aNode.Parent(), aNode, |
|
4888 leftOffset, rightOffset, topOffset, bottomOffset ); |
|
4889 if ( drop ) |
|
4890 { |
|
4891 aNode.UiEngine()->SetNodeDroppedL( aNode, XnNodeLayout::EDropped ); |
|
4892 } |
|
4893 } |
|
4894 // If display priority is 0 as much as possible must be shown, but |
|
4895 // parent's content rect must not be exceeded. |
|
4896 else |
|
4897 { |
|
4898 // This must not be done for tracster. It is a special component, |
|
4899 // which takes care |
|
4900 // of its final layout and therefore its children can exceed |
|
4901 // the parent's rect. |
|
4902 CXnNode* parent = aNode.Parent(); |
|
4903 |
|
4904 // If the node is relatively positioned, and this is not called from |
|
4905 // CalculateRelativePositionsL(), then must not be cropped!! |
|
4906 |
|
4907 // Default is static |
|
4908 const TDesC8* value( |
|
4909 &XnPropertyNames::style::common::position::KStatic() ); |
|
4910 |
|
4911 if ( positionProp && positionProp->StringValue() != KNullDesC8 ) |
|
4912 { |
|
4913 value = &positionProp->StringValue(); |
|
4914 } |
|
4915 if ( !aDropRelativeNode && |
|
4916 XnPropertyNames::style::common::position::KRelative() == *value ) |
|
4917 // relative nodes must not be adjusted, if this is not called |
|
4918 // from CalculateRelativePositionsL(). |
|
4919 { |
|
4920 return; |
|
4921 } |
|
4922 if ( rectLeft < parentLeft ) |
|
4923 { |
|
4924 leftOffset = parentLeft - rectLeft; |
|
4925 } |
|
4926 if ( rectRight > parentRight ) |
|
4927 { |
|
4928 rightOffset = rectRight - parentRight; |
|
4929 } |
|
4930 if ( rectTop < parentTop ) |
|
4931 { |
|
4932 topOffset = parentTop - rectTop; |
|
4933 } |
|
4934 if ( rectBottom > parentBottom ) |
|
4935 { |
|
4936 bottomOffset = rectBottom - parentBottom; |
|
4937 } |
|
4938 AdjustRectsL( aNode, leftOffset, rightOffset, topOffset, bottomOffset ); |
|
4939 } |
|
4940 } |
|
4941 |
|
4942 // ----------------------------------------------------------------------------- |
|
4943 // CalculateExceedingArea() |
|
4944 // Calculates how much a dropped node affects to the area of its parent |
|
4945 // that is content based node. |
|
4946 // Returns whether a child's margin rect exceeds its parents content |
|
4947 // rect or not. |
|
4948 // ----------------------------------------------------------------------------- |
|
4949 // |
|
4950 static TBool CalculateExceedingArea( CXnNode& aParent, CXnNode& aChild, |
|
4951 TInt& aLeftOffset, TInt& aRightOffset, TInt& aTopOffset, |
|
4952 TInt& aBottomOffset ) |
|
4953 { |
|
4954 TBool ret( EFalse ); |
|
4955 |
|
4956 TRect parentRect( aParent.Rect() ); |
|
4957 TInt parentLeft = parentRect.iTl.iX; |
|
4958 TInt parentRight = parentRect.iBr.iX; |
|
4959 TInt parentTop = parentRect.iTl.iY; |
|
4960 TInt parentBottom = parentRect.iBr.iY; |
|
4961 |
|
4962 TRect marginRect( aChild.MarginRect() ); |
|
4963 TInt rectLeft = marginRect.iTl.iX; |
|
4964 TInt rectRight = marginRect.iBr.iX; |
|
4965 TInt rectTop = marginRect.iTl.iY; |
|
4966 TInt rectBottom = marginRect.iBr.iY; |
|
4967 |
|
4968 TInt adaptive( aParent.IsAdaptive() ); |
|
4969 |
|
4970 if ( rectLeft < parentLeft ) |
|
4971 { |
|
4972 if ( adaptive & XnAdaptive::EWidth ) |
|
4973 { |
|
4974 aLeftOffset = rectRight - parentLeft; |
|
4975 if ( aLeftOffset < 0 ) |
|
4976 { |
|
4977 aLeftOffset = 0; |
|
4978 } |
|
4979 } |
|
4980 ret = ETrue; |
|
4981 } |
|
4982 if ( rectRight > parentRight ) |
|
4983 { |
|
4984 if ( adaptive & XnAdaptive::EWidth ) |
|
4985 { |
|
4986 aRightOffset = parentRight - rectLeft; |
|
4987 if ( aRightOffset < 0 ) |
|
4988 { |
|
4989 aRightOffset = 0; |
|
4990 } |
|
4991 } |
|
4992 ret = ETrue; |
|
4993 } |
|
4994 if ( rectTop < parentTop ) |
|
4995 { |
|
4996 if ( adaptive & XnAdaptive::EHeight ) |
|
4997 { |
|
4998 aTopOffset = rectBottom - parentTop; |
|
4999 if ( aTopOffset < 0 ) |
|
5000 { |
|
5001 aTopOffset = 0; |
|
5002 } |
|
5003 } |
|
5004 ret = ETrue; |
|
5005 } |
|
5006 if ( rectBottom > parentBottom ) |
|
5007 { |
|
5008 if ( adaptive & XnAdaptive::EHeight ) |
|
5009 { |
|
5010 aBottomOffset = parentBottom - rectTop; |
|
5011 if ( aBottomOffset < 0 ) |
|
5012 { |
|
5013 aBottomOffset = 0; |
|
5014 } |
|
5015 } |
|
5016 ret = ETrue; |
|
5017 } |
|
5018 return ret; |
|
5019 } |
|
5020 |
|
5021 // ----------------------------------------------------------------------------- |
|
5022 // AdjustRectsL() |
|
5023 // Adjust all the rects according to the given offsets. |
|
5024 // ----------------------------------------------------------------------------- |
|
5025 // |
|
5026 static void AdjustRectsL( CXnNode& aNode, TInt aLeftOffset, TInt aRightOffset, |
|
5027 TInt aTopOffset, TInt aBottomOffset ) |
|
5028 { |
|
5029 if ( aLeftOffset || aRightOffset || aTopOffset || aBottomOffset ) |
|
5030 { |
|
5031 #ifdef _XN3_DEBUG_ |
|
5032 CXnProperty* id( aNode.IdL() ); |
|
5033 |
|
5034 if ( id ) |
|
5035 { |
|
5036 TBuf8< 256 > debug; |
|
5037 debug.Append( _L8( "Node id: " ) ); |
|
5038 debug.Append( id->StringValue() ); |
|
5039 debug.Append( _L8( "doesn't fit to parent and will be adjusted" ) ); |
|
5040 |
|
5041 RDebug::RawPrint( debug ); |
|
5042 } |
|
5043 #endif |
|
5044 |
|
5045 // Adjust margin rect |
|
5046 TRect marginRect( aNode.MarginRect() ); |
|
5047 TRect newRect = TRect( marginRect.iTl.iX + aLeftOffset, |
|
5048 marginRect.iTl.iY + aTopOffset, marginRect.iBr.iX - aRightOffset, |
|
5049 marginRect.iBr.iY - aBottomOffset ); |
|
5050 aNode.SetMarginRect( newRect ); |
|
5051 |
|
5052 // Adjust border rect |
|
5053 TRect borderRect( aNode.BorderRect() ); |
|
5054 newRect = TRect( borderRect.iTl.iX + aLeftOffset, |
|
5055 borderRect.iTl.iY + aTopOffset, borderRect.iBr.iX - aRightOffset, |
|
5056 borderRect.iBr.iY - aBottomOffset ); |
|
5057 aNode.SetBorderRect( newRect ); |
|
5058 |
|
5059 // Adjust normal flow border rect |
|
5060 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
5061 newRect = TRect( normalFlowBorderRect.iTl.iX + aLeftOffset, |
|
5062 normalFlowBorderRect.iTl.iY + aTopOffset, |
|
5063 normalFlowBorderRect.iBr.iX - aRightOffset, |
|
5064 normalFlowBorderRect.iBr.iY - aBottomOffset ); |
|
5065 aNode.SetNormalFlowBorderRect( newRect ); |
|
5066 |
|
5067 // Adjust padding rect |
|
5068 TRect paddingRect( aNode.PaddingRect() ); |
|
5069 newRect = TRect( paddingRect.iTl.iX + aLeftOffset, |
|
5070 paddingRect.iTl.iY + aTopOffset, paddingRect.iBr.iX - aRightOffset, |
|
5071 paddingRect.iBr.iY - aBottomOffset ); |
|
5072 aNode.SetPaddingRect( newRect ); |
|
5073 |
|
5074 // Adjust content rect |
|
5075 TRect contentRect( aNode.Rect() ); |
|
5076 newRect = TRect( contentRect.iTl.iX + aLeftOffset, |
|
5077 contentRect.iTl.iY + aTopOffset, contentRect.iBr.iX - aRightOffset, |
|
5078 contentRect.iBr.iY - aBottomOffset ); |
|
5079 aNode.SetRect( newRect ); |
|
5080 } |
|
5081 } |
|
5082 |
|
5083 // ----------------------------------------------------------------------------- |
|
5084 // ClearRects() |
|
5085 // Sets sizes of the rects to 0. |
|
5086 // ----------------------------------------------------------------------------- |
|
5087 // |
|
5088 static void ClearRects( CXnNode& aNode, TBool aRecurse ) |
|
5089 { |
|
5090 TRect empty; |
|
5091 |
|
5092 aNode.SetRect( empty ); |
|
5093 aNode.SetPaddingRect( empty ); |
|
5094 aNode.SetBorderRect( empty ); |
|
5095 aNode.SetNormalFlowBorderRect( empty ); |
|
5096 aNode.SetMarginRect( empty ); |
|
5097 |
|
5098 CCoeControl* control( aNode.Control() ); |
|
5099 |
|
5100 if ( control ) |
|
5101 { |
|
5102 control->SetRect( empty ); |
|
5103 } |
|
5104 |
|
5105 if ( aRecurse ) |
|
5106 { |
|
5107 RPointerArray< CXnNode >& children( aNode.Children() ); |
|
5108 for ( TInt i = 0; i < children.Count(); i++ ) |
|
5109 { |
|
5110 ClearRects( *children[i], aRecurse ); |
|
5111 } |
|
5112 } |
|
5113 } |
|
5114 |
|
5115 // ----------------------------------------------------------------------------- |
|
5116 // FitChildrenIntoParentL() |
|
5117 // Drop child nodes until they fit into the parent. Also, if node has |
|
5118 // a child node with percentace defined sizes, one pixel may be cut off from it |
|
5119 // to fix possible rounding problem. |
|
5120 // ----------------------------------------------------------------------------- |
|
5121 // |
|
5122 static void FitChildrenIntoParentL( CXnNode& aNode, |
|
5123 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
5124 TReal aVerticalUnitInPixels ) |
|
5125 { |
|
5126 if( IsSrollableBox( aNode ) ) |
|
5127 { |
|
5128 return; |
|
5129 } |
|
5130 RPointerArray< CXnNode >& children( aNode.Children() ); |
|
5131 |
|
5132 if ( children.Count() == 0 ) |
|
5133 { |
|
5134 return; |
|
5135 } |
|
5136 |
|
5137 CXnProperty* blockProgressionProperty( aNode.BlockProgressionL() ); |
|
5138 CXnProperty* directionProperty( aNode.DirectionL() ); |
|
5139 |
|
5140 const TDesC8* blockProgression = NULL; |
|
5141 |
|
5142 if ( !blockProgressionProperty ) |
|
5143 { |
|
5144 // using default |
|
5145 blockProgression = |
|
5146 &XnPropertyNames::style::common::block_progression::KTB(); |
|
5147 } |
|
5148 else |
|
5149 { |
|
5150 blockProgression = &blockProgressionProperty->StringValue(); |
|
5151 } |
|
5152 |
|
5153 const TDesC8* direction( NULL ); |
|
5154 |
|
5155 if ( !directionProperty ) |
|
5156 { |
|
5157 // use default |
|
5158 direction = &XnPropertyNames::style::common::direction::KLTR(); |
|
5159 } |
|
5160 else |
|
5161 { |
|
5162 direction = &directionProperty->StringValue(); |
|
5163 } |
|
5164 |
|
5165 TSize space = CalculateSpaceUsedByChildrenL( children, aNode, |
|
5166 *blockProgression, *direction, aGraphicsDevice, |
|
5167 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
5168 TSize parentSize( aNode.Rect().Size() ); |
|
5169 |
|
5170 while( ( ( parentSize.iHeight < space.iHeight ) && |
|
5171 ( parentSize.iHeight > 0 ) ) || |
|
5172 ( ( parentSize.iWidth < space.iWidth ) && |
|
5173 ( parentSize.iWidth > 0 ) ) ) |
|
5174 { |
|
5175 // if areas go over just one pixel, |
|
5176 // cut the pixel from a percent sized node |
|
5177 if ( ( parentSize.iHeight == space.iHeight - 1 ) || |
|
5178 ( parentSize.iWidth == space.iWidth - 1 ) ) |
|
5179 { |
|
5180 CutOnePixelFromPercentChildNodeL( aNode, *blockProgression ); |
|
5181 // Childs are now in parent size |
|
5182 return; |
|
5183 } |
|
5184 |
|
5185 TInt childCount( DisplayedChildrenCountL( aNode ) ); |
|
5186 |
|
5187 PriorizeChildrenL( aNode ); |
|
5188 |
|
5189 if ( DisplayedChildrenCountL( aNode ) == childCount ) |
|
5190 { |
|
5191 // cannot drop any more children, but they still don't fit |
|
5192 return; |
|
5193 } |
|
5194 |
|
5195 space = CalculateSpaceUsedByChildrenL( children, aNode, |
|
5196 *blockProgression, *direction, aGraphicsDevice, |
|
5197 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
5198 } |
|
5199 |
|
5200 return; |
|
5201 } |
|
5202 |
|
5203 // ----------------------------------------------------------------------------- |
|
5204 // GetPositionL() |
|
5205 // Return position coordinate of a CXnComponent. Returned position depends on |
|
5206 // given block progression. |
|
5207 // ----------------------------------------------------------------------------- |
|
5208 // |
|
5209 static TInt GetPositionL( CXnNode& aNode, const TDesC8& aParentBlockProgression, |
|
5210 const TDesC8& aParentDirection ) |
|
5211 { |
|
5212 TInt returnValue = 0; |
|
5213 if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR ) |
|
5214 { |
|
5215 if ( aParentBlockProgression == |
|
5216 XnPropertyNames::style::common::block_progression::KTB || |
|
5217 aParentBlockProgression == |
|
5218 XnPropertyNames::style::common::block_progression::KBT ) |
|
5219 { |
|
5220 returnValue = aNode.NormalFlowBorderRect().iBr.iY; |
|
5221 } |
|
5222 else // LR or RL |
|
5223 { |
|
5224 returnValue = aNode.NormalFlowBorderRect().iBr.iX; |
|
5225 } |
|
5226 } |
|
5227 else // RTL |
|
5228 { |
|
5229 if ( aParentBlockProgression == |
|
5230 XnPropertyNames::style::common::block_progression::KTB || |
|
5231 aParentBlockProgression == |
|
5232 XnPropertyNames::style::common::block_progression::KBT ) |
|
5233 { |
|
5234 returnValue = aNode.NormalFlowBorderRect().iTl.iY; |
|
5235 } |
|
5236 else // LR or RL |
|
5237 { |
|
5238 returnValue = aNode.NormalFlowBorderRect().iTl.iX; |
|
5239 } |
|
5240 } |
|
5241 return returnValue; |
|
5242 } |
|
5243 |
|
5244 // ----------------------------------------------------------------------------- |
|
5245 // HasNodeAutoValues() |
|
5246 // Check if node has properties set to AUTO. |
|
5247 // ----------------------------------------------------------------------------- |
|
5248 // |
|
5249 static TInt HasNodeAutoValuesL( CXnNode& aNode ) |
|
5250 { |
|
5251 return HasNodeHorizontalAutoValuesL( aNode ) || |
|
5252 HasNodeVerticalAutoValuesL( aNode ); |
|
5253 } |
|
5254 |
|
5255 // ----------------------------------------------------------------------------- |
|
5256 // HasNodeHorizontalValues() |
|
5257 // Check if node has properties set to AUTO. |
|
5258 // ----------------------------------------------------------------------------- |
|
5259 // |
|
5260 static TInt HasNodeHorizontalAutoValuesL( CXnNode& aNode ) |
|
5261 { |
|
5262 TInt autoCount = 0; |
|
5263 |
|
5264 CXnProperty* width = aNode.WidthL(); |
|
5265 |
|
5266 if ( width ) |
|
5267 { |
|
5268 if ( IsPropertyAutoL( *width ) ) |
|
5269 { |
|
5270 autoCount++; |
|
5271 } |
|
5272 } |
|
5273 else |
|
5274 { |
|
5275 // width is auto as default |
|
5276 autoCount++; |
|
5277 } |
|
5278 |
|
5279 CXnProperty* marginleft = aNode.MarginLeftL(); |
|
5280 |
|
5281 if ( marginleft ) |
|
5282 { |
|
5283 if ( IsPropertyAutoL( *marginleft ) ) |
|
5284 { |
|
5285 autoCount++; |
|
5286 } |
|
5287 } |
|
5288 |
|
5289 CXnProperty* marginright = aNode.MarginRightL(); |
|
5290 |
|
5291 if ( marginright ) |
|
5292 { |
|
5293 if ( IsPropertyAutoL( *marginright ) ) |
|
5294 { |
|
5295 autoCount++; |
|
5296 } |
|
5297 } |
|
5298 |
|
5299 if ( !IsAbsoluteL( aNode ) && !IsRelativeL( aNode ) ) |
|
5300 { |
|
5301 return autoCount; |
|
5302 } |
|
5303 |
|
5304 CXnProperty* left = aNode.LeftL(); |
|
5305 |
|
5306 if ( left ) |
|
5307 { |
|
5308 if ( IsPropertyAutoL( *left ) ) |
|
5309 { |
|
5310 autoCount++; |
|
5311 } |
|
5312 } |
|
5313 |
|
5314 CXnProperty* right = aNode.RightL(); |
|
5315 |
|
5316 if ( right ) |
|
5317 { |
|
5318 if ( IsPropertyAutoL( *right ) ) |
|
5319 { |
|
5320 autoCount++; |
|
5321 } |
|
5322 } |
|
5323 |
|
5324 return autoCount; |
|
5325 } |
|
5326 |
|
5327 // ----------------------------------------------------------------------------- |
|
5328 // HasNodeVerticalAutoValues() |
|
5329 // Check if node has properties set to AUTO. |
|
5330 // ----------------------------------------------------------------------------- |
|
5331 // |
|
5332 static TInt HasNodeVerticalAutoValuesL( CXnNode& aNode ) |
|
5333 { |
|
5334 TInt autoCount = 0; |
|
5335 |
|
5336 CXnProperty* height = aNode.HeightL(); |
|
5337 |
|
5338 if ( height ) |
|
5339 { |
|
5340 if ( IsPropertyAutoL( *height ) ) |
|
5341 { |
|
5342 autoCount++; |
|
5343 } |
|
5344 } |
|
5345 else |
|
5346 { |
|
5347 // height is auto as default |
|
5348 autoCount++; |
|
5349 } |
|
5350 |
|
5351 CXnProperty* margintop = aNode.MarginTopL(); |
|
5352 |
|
5353 if ( margintop ) |
|
5354 { |
|
5355 if ( IsPropertyAutoL( *margintop ) ) |
|
5356 { |
|
5357 autoCount++; |
|
5358 } |
|
5359 } |
|
5360 |
|
5361 CXnProperty* marginbottom = aNode.MarginBottomL(); |
|
5362 |
|
5363 if ( marginbottom ) |
|
5364 { |
|
5365 if ( IsPropertyAutoL( *marginbottom ) ) |
|
5366 { |
|
5367 autoCount++; |
|
5368 } |
|
5369 } |
|
5370 |
|
5371 if ( !IsAbsoluteL( aNode ) && !IsRelativeL( aNode ) ) |
|
5372 { |
|
5373 return autoCount; |
|
5374 } |
|
5375 |
|
5376 CXnProperty* top = aNode.TopL(); |
|
5377 |
|
5378 if ( top ) |
|
5379 { |
|
5380 if ( IsPropertyAutoL( *top ) ) |
|
5381 { |
|
5382 autoCount++; |
|
5383 } |
|
5384 } |
|
5385 |
|
5386 CXnProperty* bottom = aNode.BottomL(); |
|
5387 |
|
5388 if ( bottom ) |
|
5389 { |
|
5390 if ( IsPropertyAutoL( *bottom ) ) |
|
5391 { |
|
5392 autoCount++; |
|
5393 } |
|
5394 } |
|
5395 |
|
5396 return autoCount; |
|
5397 } |
|
5398 |
|
5399 // ----------------------------------------------------------------------------- |
|
5400 // HasNodeMinSizesL() |
|
5401 // Check if node has minimum size values. |
|
5402 // ----------------------------------------------------------------------------- |
|
5403 // |
|
5404 static TBool HasNodeMinSizesL( CXnNode& aNode ) |
|
5405 { |
|
5406 CXnProperty* minWidth = aNode.MinWidthL(); |
|
5407 |
|
5408 if ( minWidth ) |
|
5409 { |
|
5410 if ( !IsPropertyNone( *minWidth ) ) |
|
5411 { |
|
5412 return ETrue; |
|
5413 } |
|
5414 } |
|
5415 |
|
5416 CXnProperty* minHeight = aNode.MinHeightL(); |
|
5417 |
|
5418 if ( minHeight ) |
|
5419 { |
|
5420 if ( !IsPropertyNone( *minHeight ) ) |
|
5421 { |
|
5422 return ETrue; |
|
5423 } |
|
5424 } |
|
5425 |
|
5426 return EFalse; |
|
5427 } |
|
5428 |
|
5429 // ----------------------------------------------------------------------------- |
|
5430 // HasNodeMaxSizesL() |
|
5431 // Check if node has maximum size values. |
|
5432 // ----------------------------------------------------------------------------- |
|
5433 // |
|
5434 static TBool HasNodeMaxSizesL( CXnNode& aNode ) |
|
5435 { |
|
5436 CXnProperty* maxWidth = aNode.MaxWidthL(); |
|
5437 |
|
5438 if ( maxWidth ) |
|
5439 { |
|
5440 if ( !IsPropertyNone( *maxWidth ) ) |
|
5441 { |
|
5442 return ETrue; |
|
5443 } |
|
5444 } |
|
5445 |
|
5446 CXnProperty* maxHeight = aNode.MaxHeightL(); |
|
5447 |
|
5448 if ( maxHeight ) |
|
5449 { |
|
5450 if ( !IsPropertyNone( *maxHeight ) ) |
|
5451 { |
|
5452 return ETrue; |
|
5453 } |
|
5454 } |
|
5455 |
|
5456 return EFalse; |
|
5457 } |
|
5458 |
|
5459 // ----------------------------------------------------------------------------- |
|
5460 // HorizontalCentimetersToPixelsL() |
|
5461 // Convert horizontal centimeter value to pixel value. |
|
5462 // ----------------------------------------------------------------------------- |
|
5463 // |
|
5464 static TInt HorizontalCentimetersToPixelsL( TReal& aCentimeters, |
|
5465 CGraphicsDevice& aScreenDevice ) |
|
5466 { |
|
5467 TReal twips = aCentimeters * KCentimetersAsTwips; |
|
5468 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
5469 return aScreenDevice.HorizontalTwipsToPixels( intTwips ); |
|
5470 } |
|
5471 |
|
5472 // ----------------------------------------------------------------------------- |
|
5473 // HorizontalInchesToPixelsL() |
|
5474 // Convert horizontal inch value to pixel value. |
|
5475 // ----------------------------------------------------------------------------- |
|
5476 // |
|
5477 static TInt HorizontalInchesToPixelsL( TReal& aInches, |
|
5478 CGraphicsDevice& aScreenDevice ) |
|
5479 { |
|
5480 TReal twips = aInches * KInchesAsTwips; |
|
5481 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
5482 return aScreenDevice.HorizontalTwipsToPixels( intTwips ); |
|
5483 } |
|
5484 |
|
5485 // ----------------------------------------------------------------------------- |
|
5486 // HorizontalMillimetersToPixelsL() |
|
5487 // Convert horizontal millimeter value to pixel value. |
|
5488 // ----------------------------------------------------------------------------- |
|
5489 // |
|
5490 static TInt HorizontalMillimetersToPixelsL( TReal& aMillimeters, |
|
5491 CGraphicsDevice& aScreenDevice ) |
|
5492 { |
|
5493 TReal twips = aMillimeters * KMillimetersAsTwips; |
|
5494 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
5495 return aScreenDevice.HorizontalTwipsToPixels( intTwips ); |
|
5496 } |
|
5497 |
|
5498 // ----------------------------------------------------------------------------- |
|
5499 // HorizontalPicasToPixelsL() |
|
5500 // Convert horizontal pica value to pixel value. |
|
5501 // ----------------------------------------------------------------------------- |
|
5502 // |
|
5503 static TInt HorizontalPicasToPixelsL( TReal& aPicas, |
|
5504 CGraphicsDevice& aScreenDevice ) |
|
5505 { |
|
5506 TReal twips = aPicas * KPicasAsTwips; |
|
5507 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
5508 return aScreenDevice.HorizontalTwipsToPixels( intTwips ); |
|
5509 } |
|
5510 |
|
5511 // ----------------------------------------------------------------------------- |
|
5512 // HorizontalPixelValueL() |
|
5513 // Convert horizontal property to pixel value. |
|
5514 // ----------------------------------------------------------------------------- |
|
5515 // |
|
5516 static TInt HorizontalPixelValueL( CXnProperty* aValue, TInt aReferenceValue, |
|
5517 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels ) |
|
5518 { |
|
5519 return HorizontalValueToPixelsL( DomPropertyValueFromProperty( aValue ), |
|
5520 static_cast< TReal >( aReferenceValue ), aScreenDevice, |
|
5521 aHorizontalUnitInPixels ); |
|
5522 } |
|
5523 |
|
5524 // ----------------------------------------------------------------------------- |
|
5525 // HorizontalPointsToPixelsL() |
|
5526 // Convert horizontal point value to pixel value. |
|
5527 // ----------------------------------------------------------------------------- |
|
5528 // |
|
5529 static TInt HorizontalPointsToPixelsL( TReal& aPoints, |
|
5530 CGraphicsDevice& aScreenDevice ) |
|
5531 { |
|
5532 TReal twips = aPoints * KPointsAsTwips; |
|
5533 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
5534 return aScreenDevice.HorizontalTwipsToPixels( intTwips ); |
|
5535 } |
|
5536 |
|
5537 // ----------------------------------------------------------------------------- |
|
5538 // HorizontalUnitsToPixelsL() |
|
5539 // Convert horizontal unit value to pixel value. |
|
5540 // ----------------------------------------------------------------------------- |
|
5541 // |
|
5542 static TInt HorizontalUnitsToPixelsL( TReal aUnits, TReal aUnitInPixels ) |
|
5543 { |
|
5544 TInt pixels = aUnits * aUnitInPixels; |
|
5545 return pixels; |
|
5546 } |
|
5547 |
|
5548 // ----------------------------------------------------------------------------- |
|
5549 // VerticalUnitsToPixelsL() |
|
5550 // Convert vertical unit value to pixel value. |
|
5551 // ----------------------------------------------------------------------------- |
|
5552 // |
|
5553 static TInt VerticalUnitsToPixelsL( TReal aUnits, TReal aUnitInPixels ) |
|
5554 { |
|
5555 TInt pixels = aUnits * aUnitInPixels; |
|
5556 return pixels; |
|
5557 } |
|
5558 |
|
5559 // ----------------------------------------------------------------------------- |
|
5560 // HorizontalValueToPixelsL() |
|
5561 // Convert horizontal property value to pixel value. |
|
5562 // ----------------------------------------------------------------------------- |
|
5563 // |
|
5564 static TInt HorizontalValueToPixelsL( CXnDomPropertyValue* aValue, |
|
5565 TReal aReferenceValue, CGraphicsDevice& aScreenDevice, TReal aUnitInPixels ) |
|
5566 { |
|
5567 if ( !aValue ) |
|
5568 { |
|
5569 User::Leave( KXnErrHorizontalValueNULL ); |
|
5570 } |
|
5571 CXnDomPropertyValue::TPrimitiveValueType valueType = |
|
5572 aValue->PrimitiveValueType(); |
|
5573 // Handle error cases first, inherit is handled elsewhere, none returns 0 |
|
5574 switch ( valueType ) |
|
5575 { |
|
5576 case CXnDomPropertyValue::EUnknown: |
|
5577 case CXnDomPropertyValue::EEms: |
|
5578 case CXnDomPropertyValue::EExs: |
|
5579 case CXnDomPropertyValue::EDeg: |
|
5580 case CXnDomPropertyValue::ERad: |
|
5581 case CXnDomPropertyValue::EGrad: |
|
5582 case CXnDomPropertyValue::EMs: |
|
5583 case CXnDomPropertyValue::ES: |
|
5584 case CXnDomPropertyValue::EHz: |
|
5585 case CXnDomPropertyValue::EKHz: |
|
5586 case CXnDomPropertyValue::EDimension: |
|
5587 case CXnDomPropertyValue::EString: |
|
5588 case CXnDomPropertyValue::EUri: |
|
5589 case CXnDomPropertyValue::EIdent: |
|
5590 case CXnDomPropertyValue::EAttr: |
|
5591 case CXnDomPropertyValue::ECounter: |
|
5592 case CXnDomPropertyValue::ERect: |
|
5593 case CXnDomPropertyValue::ERgbColor: |
|
5594 case CXnDomPropertyValue::ERgbaColor: |
|
5595 case CXnDomPropertyValue::EFunction: |
|
5596 break; |
|
5597 default: |
|
5598 { |
|
5599 TReal value = aValue->FloatValueL(); |
|
5600 if ( valueType == CXnDomPropertyValue::ENumber || |
|
5601 valueType == CXnDomPropertyValue::EPx ) |
|
5602 { |
|
5603 return static_cast< TInt >( value ); |
|
5604 } |
|
5605 else if ( valueType == CXnDomPropertyValue::EPercentage ) |
|
5606 { |
|
5607 return PercentageToPixelsL( value, aReferenceValue ); |
|
5608 } |
|
5609 else if ( valueType == CXnDomPropertyValue::EIn ) |
|
5610 { |
|
5611 return HorizontalInchesToPixelsL( value, aScreenDevice ); |
|
5612 } |
|
5613 else if ( valueType == CXnDomPropertyValue::ECm ) |
|
5614 { |
|
5615 return HorizontalCentimetersToPixelsL( value, aScreenDevice ); |
|
5616 } |
|
5617 else if ( valueType == CXnDomPropertyValue::EMm ) |
|
5618 { |
|
5619 return HorizontalMillimetersToPixelsL( value, aScreenDevice ); |
|
5620 } |
|
5621 else if ( valueType == CXnDomPropertyValue::EPt ) |
|
5622 { |
|
5623 return HorizontalPointsToPixelsL( value, aScreenDevice ); |
|
5624 } |
|
5625 else if ( valueType == CXnDomPropertyValue::EPc ) |
|
5626 { |
|
5627 return HorizontalPicasToPixelsL( value, aScreenDevice ); |
|
5628 } |
|
5629 else if ( valueType == CXnDomPropertyValue::EUnitValue ) |
|
5630 { |
|
5631 return HorizontalUnitsToPixelsL( value, aUnitInPixels ); |
|
5632 } |
|
5633 } |
|
5634 break; |
|
5635 } |
|
5636 |
|
5637 return 0; |
|
5638 } |
|
5639 |
|
5640 // ----------------------------------------------------------------------------- |
|
5641 // IsAbsoluteL() |
|
5642 // Check if node's positioning is absolute. |
|
5643 // ----------------------------------------------------------------------------- |
|
5644 // |
|
5645 static TBool IsAbsoluteL( CXnNode& aNode ) |
|
5646 { |
|
5647 CXnProperty* prop( aNode.PositionL() ); |
|
5648 |
|
5649 if ( prop ) |
|
5650 { |
|
5651 const TDesC8& value( prop->StringValue() ); |
|
5652 if ( value == XnPropertyNames::style::common::position::KAbsolute || |
|
5653 value == XnPropertyNames::style::common::position::KFloating ) |
|
5654 { |
|
5655 return ETrue; |
|
5656 } |
|
5657 } |
|
5658 |
|
5659 return EFalse; |
|
5660 } |
|
5661 |
|
5662 // ----------------------------------------------------------------------------- |
|
5663 // IsLargerThanMaxSizeL() |
|
5664 // Check if node rect size exceeds it's max sizes. |
|
5665 // ----------------------------------------------------------------------------- |
|
5666 // |
|
5667 static TBool IsLargerThanMaxSizeL( const TRect& aParentRect, CXnNode& aNode, |
|
5668 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
5669 TReal aVerticalUnitInPixels ) |
|
5670 { |
|
5671 TRect parentRect = aParentRect; |
|
5672 CXnProperty* heightProperty = aNode.HeightL(); |
|
5673 CXnProperty* widthProperty = aNode.WidthL(); |
|
5674 |
|
5675 if ( heightProperty ) |
|
5676 { |
|
5677 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
5678 if ( maxHeightProperty ) |
|
5679 { |
|
5680 if ( !IsPropertyNone( *maxHeightProperty ) ) |
|
5681 { |
|
5682 TInt maxHeight = VerticalPixelValueL( maxHeightProperty, |
|
5683 parentRect.Height(), aScreenDevice, aVerticalUnitInPixels ); |
|
5684 TInt height = aNode.Rect().Height(); |
|
5685 if ( height > maxHeight ) |
|
5686 { |
|
5687 // height larger than max |
|
5688 return ETrue; |
|
5689 } |
|
5690 } |
|
5691 } |
|
5692 } |
|
5693 |
|
5694 if ( widthProperty ) |
|
5695 { |
|
5696 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
5697 if ( maxWidthProperty ) |
|
5698 { |
|
5699 if ( !IsPropertyNone( *maxWidthProperty ) ) |
|
5700 { |
|
5701 TInt maxWidth = HorizontalPixelValueL( maxWidthProperty, |
|
5702 parentRect.Width(), aScreenDevice, aHorizontalUnitInPixels ); |
|
5703 TInt width = aNode.Rect().Width(); |
|
5704 if ( width > maxWidth ) |
|
5705 { |
|
5706 // width larger than max |
|
5707 return ETrue; |
|
5708 } |
|
5709 } |
|
5710 } |
|
5711 } |
|
5712 |
|
5713 // width and height within limits |
|
5714 return EFalse; |
|
5715 } |
|
5716 |
|
5717 // ----------------------------------------------------------------------------- |
|
5718 // IsNodeDisplayedL() |
|
5719 // Check if node is able to be displayed. |
|
5720 // ----------------------------------------------------------------------------- |
|
5721 // |
|
5722 static TBool IsNodeDisplayedL( CXnNode& aNode ) |
|
5723 { |
|
5724 if ( !aNode.IsLayoutCapable() ) |
|
5725 { |
|
5726 return EFalse; |
|
5727 } |
|
5728 |
|
5729 // Am I displayed? |
|
5730 CXnProperty* displayProp( aNode.DisplayL() ); |
|
5731 |
|
5732 if ( displayProp ) |
|
5733 { |
|
5734 const TDesC8& display( displayProp->StringValue() ); |
|
5735 |
|
5736 if ( display != XnPropertyNames::style::common::display::KBlock ) |
|
5737 { |
|
5738 return EFalse; |
|
5739 } |
|
5740 } |
|
5741 |
|
5742 CXnNode* parent( aNode.Parent() ); |
|
5743 |
|
5744 // Is my parent displayed? |
|
5745 for ( ; parent; parent = parent->Parent() ) |
|
5746 { |
|
5747 CXnProperty* displayProp( parent->DisplayL() ); |
|
5748 |
|
5749 if ( displayProp ) |
|
5750 { |
|
5751 const TDesC8& display( displayProp->StringValue() ); |
|
5752 |
|
5753 if ( display != XnPropertyNames::style::common::display::KBlock ) |
|
5754 { |
|
5755 return EFalse; |
|
5756 } |
|
5757 } |
|
5758 } |
|
5759 |
|
5760 return ETrue; |
|
5761 } |
|
5762 |
|
5763 // ----------------------------------------------------------------------------- |
|
5764 // IsNodeTooltip() |
|
5765 // Check if node is a tooltip. |
|
5766 // ----------------------------------------------------------------------------- |
|
5767 // |
|
5768 static TBool IsNodeTooltip( CXnNode& aNode ) |
|
5769 { |
|
5770 _LIT8( tooltip, "tooltip" ); |
|
5771 |
|
5772 if ( aNode.Type()->Type() == tooltip ) |
|
5773 { |
|
5774 return ETrue; |
|
5775 } |
|
5776 return EFalse; |
|
5777 } |
|
5778 |
|
5779 // ----------------------------------------------------------------------------- |
|
5780 // IsPropertyAutoL() |
|
5781 // Check if property is set to AUTO. |
|
5782 // ----------------------------------------------------------------------------- |
|
5783 // |
|
5784 static TBool IsPropertyAutoL( CXnProperty& aProperty ) |
|
5785 { |
|
5786 if ( &aProperty ) |
|
5787 { |
|
5788 TBool returnValue; |
|
5789 TInt index = 0; |
|
5790 CXnDomProperty* domProperty = aProperty.Property(); |
|
5791 CXnDomPropertyValue* domPropertyValue = |
|
5792 static_cast< CXnDomPropertyValue* >( |
|
5793 domProperty->PropertyValueList().Item( index ) ); |
|
5794 returnValue = domPropertyValue->IsAutoIdent(); |
|
5795 if ( !returnValue ) |
|
5796 { |
|
5797 // if return value is string and not auto or none, |
|
5798 // return ETrue because auto is used as default value |
|
5799 if ( IsStringValueL( aProperty ) && !IsPropertyNone( aProperty ) ) |
|
5800 { |
|
5801 return ETrue; |
|
5802 } |
|
5803 } |
|
5804 return returnValue; |
|
5805 } |
|
5806 return EFalse; |
|
5807 } |
|
5808 |
|
5809 // ----------------------------------------------------------------------------- |
|
5810 // IsPropertyNone() |
|
5811 // Check if property is set to NONE. |
|
5812 // ----------------------------------------------------------------------------- |
|
5813 // |
|
5814 static TBool IsPropertyNone( CXnProperty& aProperty ) |
|
5815 { |
|
5816 if ( &aProperty ) |
|
5817 { |
|
5818 TInt index = 0; |
|
5819 CXnDomProperty* domProperty = aProperty.Property(); |
|
5820 CXnDomPropertyValue* domPropertyValue = |
|
5821 static_cast< CXnDomPropertyValue* >( |
|
5822 domProperty->PropertyValueList().Item( index ) ); |
|
5823 return domPropertyValue->IsNoneIdent(); |
|
5824 } |
|
5825 return EFalse; |
|
5826 } |
|
5827 |
|
5828 // ----------------------------------------------------------------------------- |
|
5829 // IsRelativeL() |
|
5830 // Check if node's positioning is absolute. |
|
5831 // ----------------------------------------------------------------------------- |
|
5832 // |
|
5833 static TBool IsRelativeL( CXnNode& aNode ) |
|
5834 { |
|
5835 CXnProperty* positioningProperty = aNode.PositionL(); |
|
5836 if ( positioningProperty ) |
|
5837 { |
|
5838 const TDesC8& positioning = positioningProperty->StringValue(); |
|
5839 if ( positioning == XnPropertyNames::style::common::position::KRelative ) |
|
5840 { |
|
5841 return ETrue; |
|
5842 } |
|
5843 } |
|
5844 return EFalse; |
|
5845 } |
|
5846 |
|
5847 // ----------------------------------------------------------------------------- |
|
5848 // IsSmallerThanMinSizeL() |
|
5849 // Check if node rect size is smaller than it's min sizes. |
|
5850 // ----------------------------------------------------------------------------- |
|
5851 // |
|
5852 static TBool IsSmallerThanMinSizeL( const TRect& aParentRect, CXnNode& aNode, |
|
5853 CGraphicsDevice& aScreenDevice, TReal aHorizontalUnitInPixels, |
|
5854 TReal aVerticalUnitInPixels ) |
|
5855 { |
|
5856 TRect parentRect = aParentRect; |
|
5857 CXnProperty* heightproperty = aNode.HeightL(); |
|
5858 CXnProperty* widthproperty = aNode.WidthL(); |
|
5859 |
|
5860 if ( heightproperty ) |
|
5861 { |
|
5862 CXnProperty* minheightproperty = aNode.MinHeightL(); |
|
5863 if ( minheightproperty ) |
|
5864 { |
|
5865 if ( !IsPropertyNone( *minheightproperty ) ) |
|
5866 { |
|
5867 TInt minheight = VerticalPixelValueL( minheightproperty, |
|
5868 parentRect.Height(), aScreenDevice, aVerticalUnitInPixels ); |
|
5869 TInt height = aNode.Rect().Height(); |
|
5870 if ( height < minheight ) |
|
5871 { |
|
5872 // height smaller than minimum |
|
5873 return ETrue; |
|
5874 } |
|
5875 } |
|
5876 } |
|
5877 } |
|
5878 if ( widthproperty ) |
|
5879 { |
|
5880 CXnProperty* minwidthproperty = aNode.MinWidthL(); |
|
5881 if ( minwidthproperty ) |
|
5882 { |
|
5883 if ( !IsPropertyNone( *minwidthproperty ) ) |
|
5884 { |
|
5885 TInt minwidth = HorizontalPixelValueL( minwidthproperty, |
|
5886 parentRect.Width(), aScreenDevice, aHorizontalUnitInPixels ); |
|
5887 TInt width = aNode.Rect().Width(); |
|
5888 if ( width < minwidth ) |
|
5889 { |
|
5890 // width smaller than minimum |
|
5891 return ETrue; |
|
5892 } |
|
5893 } |
|
5894 } |
|
5895 } |
|
5896 // width and height within limits |
|
5897 return EFalse; |
|
5898 } |
|
5899 |
|
5900 // ----------------------------------------------------------------------------- |
|
5901 // IsStringValueL() |
|
5902 // Check if property value is string. |
|
5903 // ----------------------------------------------------------------------------- |
|
5904 // |
|
5905 static TBool IsStringValueL( CXnProperty& aProperty ) |
|
5906 { |
|
5907 CXnDomList& propertyValueList = aProperty.Property()->PropertyValueList(); |
|
5908 CXnDomPropertyValue* value = |
|
5909 static_cast< CXnDomPropertyValue* >( propertyValueList.Item( 0 ) ); |
|
5910 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
5911 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
5912 { |
|
5913 return ETrue; |
|
5914 } |
|
5915 return EFalse; |
|
5916 } |
|
5917 |
|
5918 // ----------------------------------------------------------------------------- |
|
5919 // IsValuePercentageL() |
|
5920 // Check if property value is percentage. |
|
5921 // ----------------------------------------------------------------------------- |
|
5922 // |
|
5923 static TBool IsValuePercentageL( CXnProperty& aProperty ) |
|
5924 { |
|
5925 CXnDomProperty* domProperty = aProperty.Property(); |
|
5926 CXnDomPropertyValue* domPropertyValue = static_cast< |
|
5927 CXnDomPropertyValue* >( domProperty->PropertyValueList().Item( 0 ) ); |
|
5928 if ( !domPropertyValue ) |
|
5929 { |
|
5930 User::Leave( KXnErrDomPropertyValueNULL ); |
|
5931 } |
|
5932 CXnDomPropertyValue::TPrimitiveValueType valueType = |
|
5933 domPropertyValue->PrimitiveValueType(); |
|
5934 if ( valueType == CXnDomPropertyValue::EPercentage ) |
|
5935 { |
|
5936 return ETrue; |
|
5937 } |
|
5938 return EFalse; |
|
5939 } |
|
5940 |
|
5941 // ----------------------------------------------------------------------------- |
|
5942 // PercentageToPixelsL() |
|
5943 // Convert percentage value to pixel value. |
|
5944 // ----------------------------------------------------------------------------- |
|
5945 // |
|
5946 static TInt PercentageToPixelsL( TReal& aPercentage, TReal aReferenceValue ) |
|
5947 { |
|
5948 TReal value = aReferenceValue * aPercentage * KIntPercentageConstant; |
|
5949 return static_cast< TInt >( value + KIntConversionConstant ); |
|
5950 } |
|
5951 |
|
5952 // ----------------------------------------------------------------------------- |
|
5953 // GetPreviousNodeL() |
|
5954 // ----------------------------------------------------------------------------- |
|
5955 // |
|
5956 static CXnNode* GetPreviousNodeL( CXnNode& aNode ) |
|
5957 { |
|
5958 CXnNode* returnValue = NULL; |
|
5959 CXnNode* parent = aNode.Parent(); |
|
5960 |
|
5961 if ( !parent ) |
|
5962 { |
|
5963 return returnValue; |
|
5964 } |
|
5965 |
|
5966 RPointerArray< CXnNode >& nodes = parent->Children(); |
|
5967 |
|
5968 for ( TInt currentIndex = 0; currentIndex < nodes.Count(); currentIndex++ ) |
|
5969 { |
|
5970 CXnNode* checkNode = nodes[currentIndex]; |
|
5971 if ( &aNode == checkNode && currentIndex > 0 ) |
|
5972 { |
|
5973 for ( TInt candidateIndex = |
|
5974 currentIndex - 1; candidateIndex >= 0; candidateIndex-- ) |
|
5975 { |
|
5976 checkNode = nodes[candidateIndex]; |
|
5977 if ( IsNodeDisplayedL( *checkNode ) && |
|
5978 !checkNode->IsDropped() && !IsAbsoluteL( *checkNode ) && |
|
5979 !IsNodeTooltip( *checkNode ) ) |
|
5980 { |
|
5981 returnValue = nodes[candidateIndex]; |
|
5982 break; |
|
5983 } |
|
5984 } |
|
5985 } |
|
5986 } |
|
5987 |
|
5988 return returnValue; |
|
5989 } |
|
5990 |
|
5991 // ----------------------------------------------------------------------------- |
|
5992 // PlaceAreasL() |
|
5993 // Move the area rects to their places. All positioning is done here. |
|
5994 // ----------------------------------------------------------------------------- |
|
5995 // |
|
5996 static void PlaceAreasL( CXnNode& aNode, RPointerArray< CXnNode >& aLaidOutList, |
|
5997 TInt aLayoutPhase, CGraphicsDevice& aGraphicsDevice, |
|
5998 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ) |
|
5999 { |
|
6000 CXnNodeBreadthFirstIterator< CXnNode >* iterator = |
|
6001 CXnNodeBreadthFirstIterator< CXnNode >::NewL( aNode ); |
|
6002 CleanupStack::PushL( iterator ); |
|
6003 |
|
6004 RPointerArray< CXnNode > absoluteNodes; |
|
6005 CleanupClosePushL( absoluteNodes ); |
|
6006 |
|
6007 RPointerArray< CXnNode > relativeNodes; |
|
6008 CleanupClosePushL( relativeNodes ); |
|
6009 |
|
6010 RPointerArray< CXnNode > autoNodes; |
|
6011 CleanupClosePushL( autoNodes ); |
|
6012 |
|
6013 RPointerArray< CXnNode > adaptiveNodes; |
|
6014 CleanupClosePushL( adaptiveNodes ); |
|
6015 |
|
6016 CXnProperty* parentBlockProgressionProperty( NULL ); |
|
6017 CXnProperty* parentDirectionProperty( NULL ); |
|
6018 const TDesC8* parentBlockProgression( NULL ); |
|
6019 const TDesC8* parentDirection( NULL ); |
|
6020 |
|
6021 CXnUiEngine* engine( aNode.UiEngine() ); |
|
6022 TSize maxAvailableSize( engine->ClientRect().Size() ); |
|
6023 |
|
6024 // Start to go through the tree |
|
6025 CXnNode* previous( NULL ); |
|
6026 |
|
6027 CXnNode* parent( NULL ); |
|
6028 TInt columnWidth; |
|
6029 TInt columnMargin; |
|
6030 TRect parentRect; |
|
6031 |
|
6032 #ifdef _XN3_DEBUG_ |
|
6033 RDebug::Print( _L("Xuikon: Layout:") ); |
|
6034 TBuf8< 256 > debug; |
|
6035 #endif |
|
6036 |
|
6037 // Place areas according their parents and positioning |
|
6038 for( CXnNode* node = iterator->Value(); node; node = iterator->NextL() ) |
|
6039 { |
|
6040 #ifdef _XN3_DEBUG_ |
|
6041 debug = node->Type()->Type(); |
|
6042 CXnProperty* id( node->IdL() ); |
|
6043 if ( id ) |
|
6044 { |
|
6045 debug.Append( _L8( ", id: " ) ); |
|
6046 debug.Append( id->StringValue() ); |
|
6047 } |
|
6048 #endif |
|
6049 |
|
6050 if ( node->IsLaidOut() ) |
|
6051 { |
|
6052 #ifdef _XN3_DEBUG_ |
|
6053 debug.Append( _L8( ", already laidout" ) ); |
|
6054 RDebug::RawPrint( debug ); |
|
6055 #endif |
|
6056 |
|
6057 continue; |
|
6058 } |
|
6059 |
|
6060 if ( !IsNodeDisplayedL( *node ) || node->IsDropped() ) |
|
6061 { |
|
6062 #ifdef _XN3_DEBUG_ |
|
6063 debug.Append( _L8( ", not displayed or dropped" ) ); |
|
6064 RDebug::RawPrint( debug ); |
|
6065 #endif |
|
6066 continue; |
|
6067 } |
|
6068 |
|
6069 #ifdef _XN3_DEBUG_ |
|
6070 RDebug::RawPrint( debug ); |
|
6071 #endif |
|
6072 |
|
6073 switch ( aLayoutPhase ) |
|
6074 { |
|
6075 case XnLayoutPhase::ELayout: |
|
6076 if ( aLaidOutList.Find( node ) == KErrNotFound ) |
|
6077 { |
|
6078 aLaidOutList.AppendL( node ); |
|
6079 } |
|
6080 /* flow through */ |
|
6081 case XnLayoutPhase::EMeasure: |
|
6082 if ( node->ViewNodeImpl() ) |
|
6083 { |
|
6084 // check that view's children fit into it |
|
6085 FitChildrenIntoParentL( *node, aGraphicsDevice, |
|
6086 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6087 continue; |
|
6088 } |
|
6089 engine->CheckAdaptiveContentL( *node, maxAvailableSize ); |
|
6090 if ( node->IsDropped() ) |
|
6091 { |
|
6092 // Adaptive content check dropped this node |
|
6093 continue; |
|
6094 } |
|
6095 break; |
|
6096 default: |
|
6097 // Should not happen |
|
6098 continue; |
|
6099 } |
|
6100 |
|
6101 if( node->Type()->Type() == KScrollableBoxNodeName ) |
|
6102 { |
|
6103 CXnScrollableControlAdapter* cntrl = node->ScrollableControl(); |
|
6104 if( cntrl ) |
|
6105 { |
|
6106 cntrl->ResetState(); |
|
6107 } |
|
6108 } |
|
6109 |
|
6110 CXnNode* tmpParent( DisplayedParentL( *node ) ); |
|
6111 |
|
6112 // Is parent changed? |
|
6113 if ( tmpParent != parent ) |
|
6114 { |
|
6115 columnWidth = 0; |
|
6116 columnMargin = 0; |
|
6117 if ( parent ) |
|
6118 { |
|
6119 // Process auto areas |
|
6120 ProcessAutoAreasL( *parent, &autoNodes, *parentBlockProgression, |
|
6121 *parentDirection, aGraphicsDevice, aHorizontalUnitInPixels, |
|
6122 aVerticalUnitInPixels ); |
|
6123 autoNodes.Reset(); |
|
6124 // Pocess relative areas |
|
6125 for ( TInt i = 0; i < relativeNodes.Count(); i++ ) |
|
6126 { |
|
6127 CalculateRelativePositionsL( parentRect, *relativeNodes[i], |
|
6128 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6129 aVerticalUnitInPixels ); |
|
6130 } |
|
6131 relativeNodes.Reset(); |
|
6132 // Process absolute areas |
|
6133 for ( TInt i = 0; i < absoluteNodes.Count(); i++ ) |
|
6134 { |
|
6135 CalculatePaddingL( parentRect, *absoluteNodes[i], |
|
6136 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6137 aVerticalUnitInPixels ); |
|
6138 CalculateBorderL( *absoluteNodes[i], parentRect, |
|
6139 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6140 aVerticalUnitInPixels ); |
|
6141 CalculateAbsoluteMarginL( *parent, *absoluteNodes[i], NULL, |
|
6142 *parentBlockProgression, *parentDirection, parentRect, |
|
6143 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6144 aVerticalUnitInPixels ); |
|
6145 CalculateAbsolutePositionsL( *absoluteNodes[i], parentRect, |
|
6146 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6147 aVerticalUnitInPixels ); |
|
6148 } |
|
6149 absoluteNodes.Reset(); |
|
6150 previous = NULL; |
|
6151 } |
|
6152 // Get new parent properties |
|
6153 parent = tmpParent; |
|
6154 parentBlockProgressionProperty = parent->BlockProgressionL(); |
|
6155 parentDirectionProperty = parent->DirectionL(); |
|
6156 if ( !parentBlockProgressionProperty ) |
|
6157 { |
|
6158 // block progression default is tb |
|
6159 parentBlockProgression = |
|
6160 &XnPropertyNames::style::common::block_progression::KTB(); |
|
6161 } |
|
6162 else |
|
6163 { |
|
6164 parentBlockProgression = |
|
6165 &parentBlockProgressionProperty->StringValue(); |
|
6166 } |
|
6167 if ( !parentDirectionProperty ) |
|
6168 { |
|
6169 // direction default is ltr |
|
6170 parentDirection = |
|
6171 &XnPropertyNames::style::common::direction::KLTR(); |
|
6172 } |
|
6173 else |
|
6174 { |
|
6175 parentDirection = &parentDirectionProperty->StringValue(); |
|
6176 } |
|
6177 } |
|
6178 |
|
6179 parentRect = parent->Rect(); |
|
6180 |
|
6181 CalculateRectL( *node, *parent, aGraphicsDevice, |
|
6182 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6183 |
|
6184 // Which positioning is used? |
|
6185 CXnProperty* positioningProp( node->PositionL() ); |
|
6186 // Static is the default |
|
6187 const TDesC8* positioning( |
|
6188 &XnPropertyNames::style::common::position::KStatic() ); |
|
6189 |
|
6190 if ( positioningProp ) |
|
6191 { |
|
6192 const TDesC8& value( positioningProp->StringValue() ); |
|
6193 if ( value != KNullDesC8 ) |
|
6194 { |
|
6195 positioning = &value; |
|
6196 } |
|
6197 } |
|
6198 // Adaptive nodes' _must_ be collected here |
|
6199 if ( node->IsAdaptive() && adaptiveNodes.Find( node ) == KErrNotFound ) |
|
6200 { |
|
6201 // Postpone adaptive area processing |
|
6202 adaptiveNodes.AppendL( node ); |
|
6203 } |
|
6204 // Tooltips are processed as absolute areas |
|
6205 TBool absolute( IsAbsoluteL( *node ) || IsNodeTooltip( *node ) ); |
|
6206 if ( !node->ViewNodeImpl() && HasNodeAutoValuesL( *node ) && !absolute ) |
|
6207 { |
|
6208 // if area has auto values, process it later |
|
6209 autoNodes.AppendL( node ); |
|
6210 } |
|
6211 if ( absolute ) |
|
6212 { |
|
6213 // Absolute positioning area found, take it out of normal flow |
|
6214 // Because of that, previous node is not set |
|
6215 // Absolute area is put to a array to be processed later |
|
6216 absoluteNodes.AppendL( node ); |
|
6217 continue; |
|
6218 } |
|
6219 // static or relative positioning |
|
6220 CalculatePaddingL( parentRect, *node, aGraphicsDevice, |
|
6221 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6222 CalculateBorderL( *node, parentRect, aGraphicsDevice, |
|
6223 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6224 previous = GetPreviousNodeL( *node ); |
|
6225 CalculateMarginL( *parent, *node, previous, *parentBlockProgression, |
|
6226 *parentDirection, parentRect, aGraphicsDevice, |
|
6227 aHorizontalUnitInPixels, aVerticalUnitInPixels, columnWidth, |
|
6228 columnMargin ); |
|
6229 FitChildrenIntoParentL( *node, aGraphicsDevice, aHorizontalUnitInPixels, |
|
6230 aVerticalUnitInPixels ); |
|
6231 if ( XnPropertyNames::style::common::position::KRelative() == |
|
6232 *positioning ) |
|
6233 { |
|
6234 // Relative positioning area found, add it's offset later |
|
6235 relativeNodes.AppendL( node ); |
|
6236 } |
|
6237 previous = node; |
|
6238 } |
|
6239 |
|
6240 if ( parent ) |
|
6241 { |
|
6242 // Are there auto nodes left? |
|
6243 ProcessAutoAreasL( *parent, &autoNodes, *parentBlockProgression, |
|
6244 *parentDirection, aGraphicsDevice, aHorizontalUnitInPixels, |
|
6245 aVerticalUnitInPixels ); |
|
6246 // Are there relative nodes left? |
|
6247 for ( TInt i = 0; i < relativeNodes.Count(); i++ ) |
|
6248 { |
|
6249 CalculateRelativePositionsL( parentRect, *relativeNodes[i], |
|
6250 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6251 aVerticalUnitInPixels ); |
|
6252 } |
|
6253 // Are there absolute nodes left? |
|
6254 for ( TInt i = 0; i < absoluteNodes.Count(); i++ ) |
|
6255 { |
|
6256 CalculatePaddingL( parentRect, *absoluteNodes[i], aGraphicsDevice, |
|
6257 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6258 CalculateBorderL( *absoluteNodes[i], parentRect, aGraphicsDevice, |
|
6259 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6260 CalculateAbsoluteMarginL( *parent, *absoluteNodes[i], NULL, |
|
6261 *parentBlockProgression, *parentDirection, parentRect, |
|
6262 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6263 aVerticalUnitInPixels ); |
|
6264 FitChildrenIntoParentL( *absoluteNodes[i], aGraphicsDevice, |
|
6265 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6266 CalculateAbsolutePositionsL( *absoluteNodes[i], parentRect, |
|
6267 aGraphicsDevice, aHorizontalUnitInPixels, |
|
6268 aVerticalUnitInPixels ); |
|
6269 } |
|
6270 } |
|
6271 |
|
6272 for ( TInt i = 0; i < adaptiveNodes.Count(); i++ ) |
|
6273 { |
|
6274 // Fix parent size to its childs content size |
|
6275 ProcessAdaptiveAreasL( *adaptiveNodes[i], aGraphicsDevice, |
|
6276 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6277 } |
|
6278 |
|
6279 // close node arrays and destroy iterator |
|
6280 CleanupStack::PopAndDestroy( 5, iterator ); |
|
6281 } |
|
6282 |
|
6283 // ----------------------------------------------------------------------------- |
|
6284 // PriorizeChildrenL() |
|
6285 // Find a child node with highest priority value and drop all |
|
6286 // child nodes with highest priority. |
|
6287 // ----------------------------------------------------------------------------- |
|
6288 // |
|
6289 static void PriorizeChildrenL( CXnNode& aNode ) |
|
6290 { |
|
6291 RPointerArray< CXnNode >& children( aNode.Children() ); |
|
6292 |
|
6293 CXnNode* candidate( NULL ); |
|
6294 TInt highest( 0 ); |
|
6295 |
|
6296 // Find the highest priority value among the children |
|
6297 for ( TInt i = 0; i < children.Count(); i++ ) |
|
6298 { |
|
6299 CXnNode* node( children[i] ); |
|
6300 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
6301 !IsAbsoluteL( *node ) && !IsNodeTooltip( *node ) ) |
|
6302 { |
|
6303 CXnProperty* priorityProperty( node->DisplayPriorityL() ); |
|
6304 if ( priorityProperty ) |
|
6305 { |
|
6306 TInt priority( priorityProperty->FloatValueL() ); |
|
6307 if ( priority > highest ) |
|
6308 { |
|
6309 // highest found, set new top priority |
|
6310 highest = priority; |
|
6311 candidate = node; |
|
6312 } |
|
6313 } |
|
6314 } |
|
6315 } |
|
6316 if ( candidate ) |
|
6317 { |
|
6318 aNode.UiEngine()->SetNodeDroppedL( |
|
6319 *candidate, XnNodeLayout::EDropped ); |
|
6320 } |
|
6321 } |
|
6322 |
|
6323 // ----------------------------------------------------------------------------- |
|
6324 // CalculateAutoPropertiesOfNodesL() |
|
6325 // |
|
6326 // ----------------------------------------------------------------------------- |
|
6327 // |
|
6328 static void CalculateAutoPropertiesOfNodesL( |
|
6329 RPointerArray< CXnNode >* aAutoNodeArray, TInt& aWidthAutoCount, |
|
6330 TInt& aHeightAutoCount ) |
|
6331 { |
|
6332 aWidthAutoCount = 0; |
|
6333 aHeightAutoCount = 0; |
|
6334 |
|
6335 // calculate the number of auto properties in each direction |
|
6336 for ( TInt i = 0; i < aAutoNodeArray->Count(); ++i ) |
|
6337 { |
|
6338 CXnNode* tmp = ( *aAutoNodeArray )[i]; |
|
6339 if ( !tmp->IsDropped() ) |
|
6340 { |
|
6341 if ( HasNodeVerticalAutoValuesL( *tmp ) ) |
|
6342 { |
|
6343 ++aHeightAutoCount; |
|
6344 } |
|
6345 if ( HasNodeHorizontalAutoValuesL( *tmp ) ) |
|
6346 { |
|
6347 ++aWidthAutoCount; |
|
6348 } |
|
6349 } |
|
6350 } |
|
6351 if ( aWidthAutoCount == 0 ) |
|
6352 { |
|
6353 aWidthAutoCount = 1; |
|
6354 } |
|
6355 if ( aHeightAutoCount == 0 ) |
|
6356 { |
|
6357 aHeightAutoCount = 1; |
|
6358 } |
|
6359 } |
|
6360 |
|
6361 // ----------------------------------------------------------------------------- |
|
6362 // ProcessAutoAreasL() |
|
6363 // Process nodes with layout properties defined as auto. |
|
6364 // ----------------------------------------------------------------------------- |
|
6365 // |
|
6366 static void ProcessAutoAreasL( CXnNode& aParent, |
|
6367 RPointerArray< CXnNode >* aAutoNodeArray, |
|
6368 const TDesC8& aParentBlockProgression, const TDesC8& aParentDirection, |
|
6369 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
6370 TReal aVerticalUnitInPixels ) |
|
6371 { |
|
6372 TInt autoCount( aAutoNodeArray->Count() ); |
|
6373 |
|
6374 if ( autoCount == 0 ) |
|
6375 { |
|
6376 return; |
|
6377 } |
|
6378 |
|
6379 // Just to be sure, drop others first if needed |
|
6380 FitChildrenIntoParentL( aParent, aGraphicsDevice, aHorizontalUnitInPixels, |
|
6381 aVerticalUnitInPixels ); |
|
6382 |
|
6383 TInt originalHeightAutoCount( 0 ); |
|
6384 TInt originalWidthAutoCount( 0 ); |
|
6385 |
|
6386 CalculateAutoPropertiesOfNodesL( aAutoNodeArray, originalWidthAutoCount, |
|
6387 originalHeightAutoCount ); |
|
6388 |
|
6389 TInt heightAutoCount( originalHeightAutoCount ); |
|
6390 TInt widthAutoCount( originalWidthAutoCount ); |
|
6391 |
|
6392 // calculate space to use (parent height and width - placed areas) |
|
6393 CXnNode* parent( &aParent ); |
|
6394 TRect parentRect( parent->Rect() ); |
|
6395 |
|
6396 if( parent->Control() && parent->Control()->OwnsWindow() ) |
|
6397 { |
|
6398 parentRect = TRect( parentRect.iTl - parent->MarginRect().iTl, parentRect.Size() ); |
|
6399 } |
|
6400 |
|
6401 TInt parentWidth( parentRect.Width() ); |
|
6402 TInt parentHeight( parentRect.Height() ); |
|
6403 |
|
6404 RPointerArray< CXnNode >& children( parent->Children() ); |
|
6405 |
|
6406 RPointerArray< CXnNode > layoutedAutoNodes; |
|
6407 CleanupClosePushL( layoutedAutoNodes ); |
|
6408 |
|
6409 TBool layoutedAutoNodesAdded( EFalse ); |
|
6410 TBool layoutingHeight( EFalse ); |
|
6411 TBool layoutingWidth( EFalse ); |
|
6412 |
|
6413 TInt displayedChildCount( DisplayedChildrenCountL( aParent ) ); |
|
6414 |
|
6415 do |
|
6416 { |
|
6417 layoutedAutoNodesAdded = EFalse; |
|
6418 |
|
6419 // count the size used by the non auto nodes and |
|
6420 // auto nodes which have been calculated |
|
6421 TSize calculatedAutosize = CalculateSpaceUsedByAutoChildrenL( |
|
6422 *aAutoNodeArray, layoutedAutoNodes, *parent, |
|
6423 aParentBlockProgression, aParentDirection, aGraphicsDevice ); |
|
6424 |
|
6425 TInt usedSiblingHeight( calculatedAutosize.iHeight ); |
|
6426 TInt usedSiblingWidth( calculatedAutosize.iWidth ); |
|
6427 |
|
6428 if ( aParentBlockProgression == |
|
6429 XnPropertyNames::style::common::block_progression::KTB || |
|
6430 aParentBlockProgression == |
|
6431 XnPropertyNames::style::common::block_progression::KBT ) |
|
6432 { |
|
6433 // calculate space for each auto area |
|
6434 parentHeight = parentRect.Height() - usedSiblingHeight; |
|
6435 parentHeight = parentHeight / heightAutoCount; |
|
6436 layoutingHeight = ETrue; |
|
6437 } |
|
6438 else // assume that block progression is LR or RL |
|
6439 { |
|
6440 // calculate space for each auto area |
|
6441 parentWidth = parentRect.Width() - usedSiblingWidth; |
|
6442 parentWidth = parentWidth / widthAutoCount; |
|
6443 layoutingWidth = ETrue; |
|
6444 } |
|
6445 for ( TInt i = 0; i < autoCount; i++ ) |
|
6446 { |
|
6447 CXnNode* node( ( *aAutoNodeArray )[i] ); |
|
6448 if ( layoutedAutoNodes.Find( node ) != KErrNotFound ) |
|
6449 { |
|
6450 // The size has already been calculated and fixed |
|
6451 continue; |
|
6452 } |
|
6453 if ( node->IsDropped() ) |
|
6454 { |
|
6455 // The node is dropped, no need to recalculate |
|
6456 continue; |
|
6457 } |
|
6458 CXnProperty* heightProperty = node->HeightL(); |
|
6459 CXnProperty* widthProperty = node->WidthL(); |
|
6460 CXnProperty* marginLeft = node->MarginLeftL(); |
|
6461 CXnProperty* marginRight = node->MarginRightL(); |
|
6462 CXnProperty* marginTop = node->MarginTopL(); |
|
6463 CXnProperty* marginBottom = node->MarginBottomL(); |
|
6464 TInt freeHeight = parentHeight; |
|
6465 TInt freeWidth = parentWidth; |
|
6466 TBool verticalValuesAuto = IsPropertyAutoL( *heightProperty ) || |
|
6467 IsPropertyAutoL( *marginTop ) || |
|
6468 IsPropertyAutoL( *marginBottom ); |
|
6469 if ( !verticalValuesAuto == !heightProperty ) |
|
6470 { |
|
6471 verticalValuesAuto = ETrue; |
|
6472 } |
|
6473 TBool horizontalValuesAuto = IsPropertyAutoL( *widthProperty ) || |
|
6474 IsPropertyAutoL( *marginLeft ) || |
|
6475 IsPropertyAutoL( *marginRight ); |
|
6476 if ( !horizontalValuesAuto == !widthProperty ) |
|
6477 { |
|
6478 horizontalValuesAuto = ETrue; |
|
6479 } |
|
6480 TInt adaptive( node->IsAdaptive() ); |
|
6481 // I have childs share the available space between them |
|
6482 if ( adaptive & XnAdaptive::EHeight ) |
|
6483 { |
|
6484 // Give all available height to the adaptive node's children |
|
6485 freeHeight = parentRect.Height() - usedSiblingHeight; |
|
6486 } |
|
6487 if ( adaptive & XnAdaptive::EWidth ) |
|
6488 { |
|
6489 // Give all available width to the adaptive node's children |
|
6490 freeWidth = parentRect.Width() - usedSiblingWidth; |
|
6491 } |
|
6492 ScaleAutoAreaL( *node, freeWidth, freeHeight, |
|
6493 aParentBlockProgression, aParentDirection, |
|
6494 parentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
6495 aVerticalUnitInPixels ); |
|
6496 FitChildrenIntoParentL( *node, aGraphicsDevice, |
|
6497 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
6498 // handle autonodes which had auto width or height, |
|
6499 // but also min or max limit |
|
6500 if ( aParentBlockProgression == |
|
6501 XnPropertyNames::style::common::block_progression::KTB || |
|
6502 aParentBlockProgression == |
|
6503 XnPropertyNames::style::common::block_progression::KBT ) |
|
6504 { |
|
6505 if ( IsPropertyAutoL( *heightProperty ) && |
|
6506 ( freeHeight != node->MarginRect().Height() ) ) |
|
6507 { |
|
6508 if ( layoutedAutoNodes.Find( node ) == KErrNotFound ) |
|
6509 { |
|
6510 // The height has been callculated already |
|
6511 // and it doesn't depend on the expected |
|
6512 // auto size anymore, mark the node as layouted |
|
6513 // and reduce the parent free size |
|
6514 layoutedAutoNodes.AppendL( node ); |
|
6515 heightAutoCount--; |
|
6516 layoutedAutoNodesAdded = ETrue; |
|
6517 } |
|
6518 } |
|
6519 } |
|
6520 if ( aParentBlockProgression == |
|
6521 XnPropertyNames::style::common::block_progression::KLR || |
|
6522 aParentBlockProgression == |
|
6523 XnPropertyNames::style::common::block_progression::KRL ) |
|
6524 { |
|
6525 if ( IsPropertyAutoL( *widthProperty ) && |
|
6526 ( freeWidth != node->MarginRect().Width() ) ) |
|
6527 { |
|
6528 if ( layoutedAutoNodes.Find ( node ) == KErrNotFound ) |
|
6529 { |
|
6530 // The width has been callculated already |
|
6531 // and it doesn't depend on the expected |
|
6532 // auto size anymore, mark the node as layouted |
|
6533 // and reduce the parent free size |
|
6534 layoutedAutoNodes.AppendL( node ); |
|
6535 widthAutoCount--; |
|
6536 layoutedAutoNodesAdded = ETrue; |
|
6537 } |
|
6538 } |
|
6539 } |
|
6540 } |
|
6541 |
|
6542 // drop areas if children don't fit |
|
6543 FitAutoChildrenIntoParentL( *aAutoNodeArray, layoutedAutoNodes, |
|
6544 *parent, aParentBlockProgression, aParentDirection, |
|
6545 aGraphicsDevice ); |
|
6546 |
|
6547 // if something was dropped, reset the layouted auto nodes array |
|
6548 TInt newDisplayedChildCount = DisplayedChildrenCountL( aParent ); |
|
6549 |
|
6550 if ( displayedChildCount != newDisplayedChildCount ) |
|
6551 { |
|
6552 // if nodes with auto values are dropped |
|
6553 // recalculate the auto counts |
|
6554 CalculateAutoPropertiesOfNodesL( aAutoNodeArray, |
|
6555 originalWidthAutoCount, originalHeightAutoCount ); |
|
6556 |
|
6557 // recalculate everything again because something was dropped |
|
6558 layoutedAutoNodes.Reset(); |
|
6559 displayedChildCount = newDisplayedChildCount; |
|
6560 heightAutoCount = originalHeightAutoCount; |
|
6561 widthAutoCount = originalWidthAutoCount; |
|
6562 layoutedAutoNodesAdded = ETrue; |
|
6563 } |
|
6564 |
|
6565 } |
|
6566 while( layoutedAutoNodesAdded && ( ( heightAutoCount && layoutingHeight ) || |
|
6567 ( widthAutoCount && layoutingWidth ) ) ); |
|
6568 |
|
6569 MoveAutoAreaL( parentRect, children, aParentBlockProgression, |
|
6570 aParentDirection ); |
|
6571 |
|
6572 CleanupStack::PopAndDestroy( &layoutedAutoNodes ); |
|
6573 } |
|
6574 |
|
6575 // ----------------------------------------------------------------------------- |
|
6576 // CalculateCollapseMarginsL() |
|
6577 // Return the amount the margins should be collapsed in two list. The list |
|
6578 // element contains the amount of margins collapsed in pixels to the previous |
|
6579 // layoutable, nondropped, static and nontooltip node. |
|
6580 // When calculating the movement of the node, this value should be decreased |
|
6581 // from the movement. |
|
6582 // When calculating the total size of the auto proerety nodes, this value |
|
6583 // should be decreased from the size taken. |
|
6584 // If the children list contains one of the above mentioned type of nodes, |
|
6585 // then the value for those are always 0. |
|
6586 // For example, if there are three children and the middle one has been |
|
6587 // dropped, the the returned list contains two elemnts, first is 0 and |
|
6588 // the second one is the amount of collapsed margins between the first and the |
|
6589 // last node. |
|
6590 // The caller is responsible of releasing the returned arrays. |
|
6591 // ----------------------------------------------------------------------------- |
|
6592 // |
|
6593 static void CalculateCollapseMarginsL( RPointerArray< CXnNode >& aChildren, |
|
6594 RArray< TInt >& aCollapsedMarginsWidth, |
|
6595 RArray< TInt >& aCollapsedMarginsHeight, |
|
6596 const TDesC8& aParentBlockProgression, |
|
6597 const TDesC8& aParentDirection ) |
|
6598 { |
|
6599 aCollapsedMarginsWidth.Reset(); |
|
6600 aCollapsedMarginsHeight.Reset(); |
|
6601 |
|
6602 // Find first node which needs to be taken into account |
|
6603 CXnNode* previousNode = NULL; |
|
6604 TInt startIndex = aChildren.Count(); |
|
6605 for ( TInt i = 0; !previousNode && i < aChildren.Count(); i++ ) |
|
6606 { |
|
6607 if ( IsNodeDisplayedL( *aChildren[i] ) && |
|
6608 !aChildren[i]->IsDropped() && |
|
6609 !IsAbsoluteL(*aChildren[i]) && |
|
6610 !IsNodeTooltip(*aChildren[i]) && |
|
6611 aChildren[i]->IsLayoutCapable()) |
|
6612 { |
|
6613 previousNode = aChildren[i]; |
|
6614 startIndex = aChildren.Find( previousNode ) + 1; |
|
6615 } |
|
6616 } |
|
6617 |
|
6618 // Add needed amount of collapsed margins as 0 |
|
6619 for ( TInt i = 1; i < startIndex; i++ ) |
|
6620 { |
|
6621 User::LeaveIfError( aCollapsedMarginsWidth.Append( 0 ) ); |
|
6622 User::LeaveIfError( aCollapsedMarginsHeight.Append( 0 ) ); |
|
6623 } |
|
6624 |
|
6625 // Calculate collapsed for the rest of the nodes, 0 if not needed |
|
6626 for ( TInt i = startIndex; i < aChildren.Count() && previousNode; i++ ) |
|
6627 { |
|
6628 CXnNode* node = aChildren[i]; |
|
6629 TInt collapsedWidth = 0; |
|
6630 TInt collapsedHeight = 0; |
|
6631 |
|
6632 if ( IsNodeDisplayedL( *node ) && |
|
6633 !node->IsDropped() && |
|
6634 !IsAbsoluteL( *node ) && |
|
6635 !IsNodeTooltip( *node ) && |
|
6636 node->IsLayoutCapable() ) |
|
6637 { |
|
6638 if ( ( aParentBlockProgression == |
|
6639 XnPropertyNames::style::common::block_progression::KLR || |
|
6640 aParentBlockProgression == |
|
6641 XnPropertyNames::style::common::block_progression::KRL ) && |
|
6642 aParentDirection == |
|
6643 XnPropertyNames::style::common::direction::KLTR ) |
|
6644 { |
|
6645 TInt previousRightMargin = Abs( previousNode-> |
|
6646 MarginRect().iBr.iX - previousNode->BorderRect().iBr.iX ); |
|
6647 TInt nodeLeftMargin = Abs( node->BorderRect().iTl.iX - |
|
6648 node->MarginRect().iTl.iX ); |
|
6649 |
|
6650 collapsedWidth = -( previousRightMargin > nodeLeftMargin ) ? |
|
6651 nodeLeftMargin : previousRightMargin; |
|
6652 } |
|
6653 |
|
6654 if ( ( aParentBlockProgression == |
|
6655 XnPropertyNames::style::common::block_progression::KRL || |
|
6656 aParentBlockProgression == |
|
6657 XnPropertyNames::style::common::block_progression::KLR ) && |
|
6658 aParentDirection == |
|
6659 XnPropertyNames::style::common::direction::KRTL ) |
|
6660 { |
|
6661 TInt previousLeftMargin = Abs( previousNode-> |
|
6662 MarginRect().iTl.iX - previousNode->BorderRect().iTl.iX ); |
|
6663 TInt nodeRightMargin = Abs( node->BorderRect().iBr.iX - |
|
6664 node->MarginRect().iBr.iX ); |
|
6665 |
|
6666 collapsedWidth = ( previousLeftMargin > nodeRightMargin ) ? |
|
6667 nodeRightMargin : previousLeftMargin; |
|
6668 } |
|
6669 |
|
6670 if ( ( aParentBlockProgression == |
|
6671 XnPropertyNames::style::common::block_progression::KTB || |
|
6672 aParentBlockProgression == |
|
6673 XnPropertyNames::style::common::block_progression::KBT ) && |
|
6674 aParentDirection == |
|
6675 XnPropertyNames::style::common::direction::KLTR ) |
|
6676 { |
|
6677 TInt previousBottomMargin = Abs( previousNode-> |
|
6678 MarginRect().iBr.iY - previousNode->BorderRect().iBr.iY ); |
|
6679 TInt nodeTopMargin = Abs( node->BorderRect().iTl.iY - |
|
6680 node->MarginRect().iTl.iY ); |
|
6681 |
|
6682 collapsedHeight = ( previousBottomMargin > nodeTopMargin ) ? |
|
6683 nodeTopMargin : previousBottomMargin; |
|
6684 } |
|
6685 |
|
6686 if ( ( aParentBlockProgression == |
|
6687 XnPropertyNames::style::common::block_progression::KTB || |
|
6688 aParentBlockProgression == |
|
6689 XnPropertyNames::style::common::block_progression::KBT ) && |
|
6690 aParentDirection == |
|
6691 XnPropertyNames::style::common::direction::KRTL ) |
|
6692 { |
|
6693 TInt previousTopMargin = Abs( previousNode->\ |
|
6694 MarginRect().iTl.iY - previousNode->BorderRect().iTl.iY ); |
|
6695 TInt nodeBottomMargin = Abs( node->BorderRect().iBr.iY - |
|
6696 node->MarginRect().iBr.iY ); |
|
6697 |
|
6698 collapsedHeight = -( ( previousTopMargin > nodeBottomMargin ) ? |
|
6699 nodeBottomMargin : previousTopMargin ); |
|
6700 } |
|
6701 } |
|
6702 User::LeaveIfError( aCollapsedMarginsWidth.Append( collapsedWidth ) ); |
|
6703 User::LeaveIfError( aCollapsedMarginsHeight.Append( collapsedHeight ) ); |
|
6704 previousNode = node; |
|
6705 } |
|
6706 } |
|
6707 |
|
6708 // ----------------------------------------------------------------------------- |
|
6709 // CalculateSpaceUsedByAutoChildrenL() |
|
6710 // Return space used by node's children including auto nodes which have |
|
6711 // been calculated. |
|
6712 // ----------------------------------------------------------------------------- |
|
6713 // |
|
6714 static TSize CalculateSpaceUsedByAutoChildrenL( |
|
6715 RPointerArray< CXnNode >& aAutoChildren, |
|
6716 RPointerArray< CXnNode >& aCalculatedAutoChildren, |
|
6717 CXnNode& aParent, const TDesC8& aParentBlockProgression, |
|
6718 const TDesC8& aParentDirection, CGraphicsDevice& /*aScreenDevice*/ ) |
|
6719 { |
|
6720 TInt usedSiblingHeight( 0 ); |
|
6721 TInt usedSiblingWidth( 0 ); |
|
6722 |
|
6723 TSize largestSize( 0, 0 ); |
|
6724 |
|
6725 // Calculate collapsed margins |
|
6726 RArray< TInt > collapsedMarginsWidth; |
|
6727 RArray< TInt > collapsedMarginsHeight; |
|
6728 |
|
6729 CleanupClosePushL( collapsedMarginsWidth ); |
|
6730 CleanupClosePushL( collapsedMarginsHeight ); |
|
6731 |
|
6732 RPointerArray< CXnNode >& children( aParent.Children() ); |
|
6733 |
|
6734 CalculateCollapseMarginsL( children, |
|
6735 collapsedMarginsWidth, |
|
6736 collapsedMarginsHeight, |
|
6737 aParentBlockProgression, |
|
6738 aParentDirection ); |
|
6739 |
|
6740 for ( TInt i = 0; i < children.Count(); i++ ) |
|
6741 { |
|
6742 CXnNode* node( children[i] ); |
|
6743 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
6744 !IsAbsoluteL( *node ) && !IsNodeTooltip( *node ) ) |
|
6745 { |
|
6746 // Calculate how much does the node takes space, |
|
6747 // 0 is used for auto nodes which have not been calculated |
|
6748 TSize siblingSize( node->MarginRect().Size() ); |
|
6749 if ( aAutoChildren.Find( node ) != KErrNotFound && |
|
6750 aCalculatedAutoChildren.Find( node ) == KErrNotFound ) |
|
6751 { |
|
6752 // Node is auto node and its values have not been fixed yet |
|
6753 // The node may have auto in either direction |
|
6754 // so that must be checked |
|
6755 if ( HasNodeVerticalAutoValuesL( *node ) ) |
|
6756 { |
|
6757 siblingSize.iHeight = 0; |
|
6758 } |
|
6759 if ( HasNodeHorizontalAutoValuesL( *node ) ) |
|
6760 { |
|
6761 siblingSize.iWidth = 0; |
|
6762 } |
|
6763 } |
|
6764 // Update the largets found node rect |
|
6765 if ( siblingSize.iWidth > largestSize.iWidth ) |
|
6766 { |
|
6767 largestSize.iWidth = siblingSize.iWidth; |
|
6768 } |
|
6769 if ( siblingSize.iHeight > largestSize.iHeight ) |
|
6770 { |
|
6771 largestSize.iHeight = siblingSize.iHeight; |
|
6772 } |
|
6773 // Add the used area |
|
6774 if ( aParentBlockProgression == |
|
6775 XnPropertyNames::style::common::block_progression::KTB || |
|
6776 aParentBlockProgression == |
|
6777 XnPropertyNames::style::common::block_progression::KBT ) |
|
6778 { |
|
6779 usedSiblingHeight += siblingSize.iHeight; |
|
6780 usedSiblingWidth = largestSize.iWidth; |
|
6781 } |
|
6782 if ( aParentBlockProgression == |
|
6783 XnPropertyNames::style::common::block_progression::KLR || |
|
6784 aParentBlockProgression == |
|
6785 XnPropertyNames::style::common::block_progression::KRL ) |
|
6786 { |
|
6787 usedSiblingWidth += siblingSize.iWidth; |
|
6788 usedSiblingHeight = largestSize.iHeight; |
|
6789 } |
|
6790 // Find the children index from all children |
|
6791 TInt childrenIndex( children.Find( node ) ); |
|
6792 // No collapsing for just one node |
|
6793 if ( childrenIndex > 0 ) |
|
6794 { |
|
6795 // Take the collapsed margins into account |
|
6796 // (the value is 0 if not collapsed) |
|
6797 usedSiblingWidth -= collapsedMarginsWidth[childrenIndex - 1]; |
|
6798 usedSiblingHeight -= collapsedMarginsHeight[childrenIndex - 1]; |
|
6799 } |
|
6800 } |
|
6801 } |
|
6802 // Collapsed arrays |
|
6803 CleanupStack::PopAndDestroy( 2 ); |
|
6804 |
|
6805 return TSize( usedSiblingWidth, usedSiblingHeight ); |
|
6806 } |
|
6807 |
|
6808 // ----------------------------------------------------------------------------- |
|
6809 // MoveAutoAreaL() |
|
6810 // Move nodes after all auto properties have been handled. |
|
6811 // ----------------------------------------------------------------------------- |
|
6812 // |
|
6813 static void MoveAutoAreaL( TRect& parentRect, |
|
6814 RPointerArray< CXnNode >& aChildren, const TDesC8& aParentBlockProgression, |
|
6815 const TDesC8& aParentDirection ) |
|
6816 { |
|
6817 // Calculate collapsed margins |
|
6818 RArray< TInt > collapsedMarginsWidth; |
|
6819 RArray< TInt > collapsedMarginsHeight; |
|
6820 |
|
6821 CleanupClosePushL( collapsedMarginsWidth ); |
|
6822 CleanupClosePushL( collapsedMarginsHeight ); |
|
6823 |
|
6824 CalculateCollapseMarginsL( aChildren, collapsedMarginsWidth, |
|
6825 collapsedMarginsHeight, aParentBlockProgression, |
|
6826 aParentDirection ); |
|
6827 |
|
6828 CXnNode* previousNode( NULL ); |
|
6829 TInt startIndex( aChildren.Count() ); |
|
6830 |
|
6831 for ( TInt i = 0; !previousNode && i < aChildren.Count(); i++ ) |
|
6832 { |
|
6833 CXnNode* node( aChildren[i] ); |
|
6834 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
6835 !IsAbsoluteL (*node ) && !IsNodeTooltip( *node ) ) |
|
6836 { |
|
6837 previousNode = node; |
|
6838 startIndex = i + 1; |
|
6839 } |
|
6840 } |
|
6841 if ( !previousNode ) |
|
6842 { |
|
6843 // Collapsed arrays |
|
6844 CleanupStack::PopAndDestroy( 2 ); |
|
6845 return; |
|
6846 } |
|
6847 |
|
6848 // Which way are the boxes layouted? |
|
6849 // |
|
6850 // 1) ltr, tb: 2) ltr, bt: 3) ltr, rl: 4) ltr, lr: |
|
6851 // 1 4 3 6 1 2 3 4 5 6 |
|
6852 // 2 5 2 5 4 5 6 1 2 3 |
|
6853 // 3 6 1 4 |
|
6854 // |
|
6855 // 5) rtl, tb: 6) rtl, bt: 7) rtl, rl: 8) rtl, lr: |
|
6856 // 4 1 6 3 3 2 1 6 5 4 |
|
6857 // 5 2 5 2 6 5 4 3 2 1 |
|
6858 // 6 3 4 1 |
|
6859 // |
|
6860 |
|
6861 TInt layoutType( 0 ); |
|
6862 if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR ) |
|
6863 { |
|
6864 if ( aParentBlockProgression == |
|
6865 XnPropertyNames::style::common::block_progression::KTB ) |
|
6866 { |
|
6867 layoutType = 1; |
|
6868 } |
|
6869 else if ( aParentBlockProgression == |
|
6870 XnPropertyNames::style::common::block_progression::KBT ) |
|
6871 { |
|
6872 layoutType = 2; |
|
6873 } |
|
6874 else if ( aParentBlockProgression == |
|
6875 XnPropertyNames::style::common::block_progression::KRL ) |
|
6876 { |
|
6877 layoutType = 3; |
|
6878 } |
|
6879 else if ( aParentBlockProgression == |
|
6880 XnPropertyNames::style::common::block_progression::KLR ) |
|
6881 { |
|
6882 layoutType = 4; |
|
6883 } |
|
6884 } |
|
6885 else if ( aParentDirection == |
|
6886 XnPropertyNames::style::common::direction::KRTL ) |
|
6887 { |
|
6888 if ( aParentBlockProgression == |
|
6889 XnPropertyNames::style::common::block_progression::KTB ) |
|
6890 { |
|
6891 layoutType = 5; |
|
6892 } |
|
6893 else if ( aParentBlockProgression == |
|
6894 XnPropertyNames::style::common::block_progression::KBT ) |
|
6895 { |
|
6896 layoutType = 6; |
|
6897 } |
|
6898 else if ( aParentBlockProgression == |
|
6899 XnPropertyNames::style::common::block_progression::KRL ) |
|
6900 { |
|
6901 layoutType = 7; |
|
6902 } |
|
6903 else if ( aParentBlockProgression == |
|
6904 XnPropertyNames::style::common::block_progression::KLR ) |
|
6905 { |
|
6906 layoutType = 8; |
|
6907 } |
|
6908 } |
|
6909 TRect previousContentRect( previousNode->Rect() ); |
|
6910 TRect previousPaddingRect( previousNode->PaddingRect() ); |
|
6911 TRect previousBorderRect( previousNode->BorderRect() ); |
|
6912 TRect previousMarginRect( previousNode->MarginRect() ); |
|
6913 TRect previousNormalFlowBorderRect( previousNode->NormalFlowBorderRect() ); |
|
6914 TInt widthToMove = 0; |
|
6915 TInt heightToMove = 0; |
|
6916 |
|
6917 // Move the first node to the correct place |
|
6918 switch ( layoutType ) |
|
6919 { |
|
6920 case 1: |
|
6921 { |
|
6922 // Top to parent top |
|
6923 heightToMove = parentRect.iTl.iY - previousMarginRect.iTl.iY; |
|
6924 } |
|
6925 break; |
|
6926 case 2: |
|
6927 { |
|
6928 // Bottom to parent bottom |
|
6929 heightToMove = parentRect.iBr.iY - previousMarginRect.iBr.iY; |
|
6930 } |
|
6931 break; |
|
6932 case 3: |
|
6933 { |
|
6934 // Left to parent left |
|
6935 widthToMove = parentRect.iTl.iX - previousMarginRect.iTl.iX; |
|
6936 } |
|
6937 break; |
|
6938 case 4: |
|
6939 { |
|
6940 heightToMove = parentRect.iBr.iY - previousMarginRect.iBr.iY; |
|
6941 widthToMove = parentRect.iTl.iX - previousMarginRect.iTl.iX; |
|
6942 } |
|
6943 break; |
|
6944 case 5: // flow through |
|
6945 case 7: |
|
6946 { |
|
6947 heightToMove = parentRect.iTl.iY - previousMarginRect.iTl.iY; |
|
6948 widthToMove = parentRect.iBr.iX - previousMarginRect.iBr.iX; |
|
6949 } |
|
6950 break; |
|
6951 case 6: // flow through |
|
6952 case 8: |
|
6953 { |
|
6954 heightToMove = parentRect.iBr.iY - previousMarginRect.iBr.iY; |
|
6955 widthToMove = parentRect.iBr.iX - previousMarginRect.iBr.iX; |
|
6956 } |
|
6957 break; |
|
6958 } |
|
6959 |
|
6960 // Move rects |
|
6961 previousContentRect.Move( widthToMove, heightToMove ); |
|
6962 previousPaddingRect.Move( widthToMove, heightToMove ); |
|
6963 previousBorderRect.Move( widthToMove, heightToMove ); |
|
6964 previousMarginRect.Move( widthToMove, heightToMove ); |
|
6965 previousNormalFlowBorderRect.Move( widthToMove, heightToMove ); |
|
6966 |
|
6967 // Set rects |
|
6968 previousNode->SetRect( previousContentRect ); |
|
6969 previousNode->SetPaddingRect( previousPaddingRect ); |
|
6970 previousNode->SetBorderRect( previousBorderRect ); |
|
6971 previousNode->SetMarginRect( previousMarginRect ); |
|
6972 previousNode->SetNormalFlowBorderRect( previousNormalFlowBorderRect ); |
|
6973 |
|
6974 for ( TInt i = startIndex; i < aChildren.Count() && previousNode; i++ ) |
|
6975 { |
|
6976 CXnNode* node( aChildren[i] ); |
|
6977 |
|
6978 if ( IsNodeDisplayedL( *node ) && !node->IsDropped() && |
|
6979 !IsAbsoluteL( *node ) && !IsNodeTooltip( *node ) ) |
|
6980 { |
|
6981 // Get rects |
|
6982 TRect contentRect( node->Rect() ); |
|
6983 TRect paddingRect( node->PaddingRect() ); |
|
6984 TRect borderRect( node->BorderRect() ); |
|
6985 TRect marginRect( node->MarginRect() ); |
|
6986 TRect normalFlowBorderRect( node->NormalFlowBorderRect() ); |
|
6987 previousMarginRect = previousNode->MarginRect(); |
|
6988 |
|
6989 widthToMove = 0; |
|
6990 heightToMove = 0; |
|
6991 |
|
6992 // Count movements |
|
6993 switch ( layoutType ) |
|
6994 { |
|
6995 case 1: |
|
6996 { |
|
6997 // Move node top to the previous bottom |
|
6998 heightToMove = previousMarginRect.iBr.iY - marginRect.iTl.iY; |
|
6999 heightToMove -= collapsedMarginsHeight[i - 1]; |
|
7000 } |
|
7001 break; |
|
7002 case 2: |
|
7003 { |
|
7004 // Move node bottom to the previous top |
|
7005 heightToMove = previousMarginRect.iTl.iY - marginRect.iBr.iY; |
|
7006 heightToMove += collapsedMarginsHeight[i - 1]; |
|
7007 } |
|
7008 break; |
|
7009 case 3: |
|
7010 { |
|
7011 // Move node left to the previous right |
|
7012 widthToMove = previousMarginRect.iBr.iX - marginRect.iTl.iX; |
|
7013 widthToMove -= collapsedMarginsWidth[i - 1]; |
|
7014 } |
|
7015 break; |
|
7016 case 4: |
|
7017 { |
|
7018 heightToMove = previousMarginRect.iTl.iY - marginRect.iTl.iY; |
|
7019 widthToMove = previousMarginRect.iBr.iX - marginRect.iTl.iX; |
|
7020 widthToMove -= collapsedMarginsWidth[i - 1]; |
|
7021 } |
|
7022 break; |
|
7023 case 5: |
|
7024 { |
|
7025 // Move node top to the previous bottom |
|
7026 heightToMove = previousMarginRect.iBr.iY - marginRect.iTl.iY; |
|
7027 heightToMove -= collapsedMarginsHeight[i - 1]; |
|
7028 widthToMove = previousMarginRect.iTl.iX - marginRect.iTl.iX; |
|
7029 } |
|
7030 break; |
|
7031 case 6: |
|
7032 { |
|
7033 // Move node bottom to the previous top |
|
7034 heightToMove = previousMarginRect.iTl.iY - marginRect.iBr.iY; |
|
7035 heightToMove += collapsedMarginsHeight[i - 1]; |
|
7036 widthToMove = previousMarginRect.iTl.iX - marginRect.iTl.iX; |
|
7037 } |
|
7038 break; |
|
7039 case 7: |
|
7040 { |
|
7041 // Move node left to the previous right |
|
7042 widthToMove = previousMarginRect.iTl.iX - marginRect.iBr.iX; |
|
7043 widthToMove += collapsedMarginsWidth[i - 1]; |
|
7044 } |
|
7045 break; |
|
7046 case 8: |
|
7047 { |
|
7048 heightToMove = previousMarginRect.iTl.iY - marginRect.iTl.iY; |
|
7049 widthToMove = previousMarginRect.iTl.iX - marginRect.iBr.iX; |
|
7050 widthToMove += collapsedMarginsWidth[i - 1]; |
|
7051 } |
|
7052 break; |
|
7053 } |
|
7054 |
|
7055 // Move rects |
|
7056 contentRect.Move( widthToMove, heightToMove ); |
|
7057 paddingRect.Move( widthToMove, heightToMove ); |
|
7058 borderRect.Move( widthToMove, heightToMove ); |
|
7059 marginRect.Move( widthToMove, heightToMove ); |
|
7060 normalFlowBorderRect.Move( widthToMove, heightToMove ); |
|
7061 |
|
7062 // Set rects |
|
7063 node->SetRect( contentRect ); |
|
7064 node->SetPaddingRect( paddingRect ); |
|
7065 node->SetBorderRect( borderRect ); |
|
7066 node->SetMarginRect( marginRect ); |
|
7067 node->SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
7068 |
|
7069 previousNode = node; |
|
7070 } |
|
7071 } |
|
7072 |
|
7073 // Collapsed arrays |
|
7074 CleanupStack::PopAndDestroy( 2 ); |
|
7075 } |
|
7076 |
|
7077 // ----------------------------------------------------------------------------- |
|
7078 // ScaleAutoAreaL() |
|
7079 // Scale dimensions for areas that have properties set to AUTO. |
|
7080 // ----------------------------------------------------------------------------- |
|
7081 // |
|
7082 static TSize ScaleAutoAreaL( CXnNode& aNode, TInt aWidthToFit, |
|
7083 TInt aHeightToFit, const TDesC8& aParentBlockProgression, |
|
7084 const TDesC8& aParentDirection, TRect& aParentRect, |
|
7085 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
7086 TReal aVerticalUnitInPixels ) |
|
7087 { |
|
7088 // if only one value is auto, it is computed from equality |
|
7089 // if width is set to AUTO, all other values become 0 |
|
7090 // if both margin left and right are set to AUTO, their computed |
|
7091 // values are equal |
|
7092 TSize sizeOfAutoArea( 0, 0 ); |
|
7093 |
|
7094 RArray< TPtrC8 > autoArray; |
|
7095 CleanupClosePushL( autoArray ); |
|
7096 |
|
7097 CXnProperty* top = aNode.TopL(); |
|
7098 if ( IsPropertyAutoL( *top ) ) |
|
7099 { |
|
7100 TPtrC8 propertyName = top->Property()->Name(); |
|
7101 autoArray.Append( propertyName ); |
|
7102 } |
|
7103 CXnProperty* bottom = aNode.BottomL(); |
|
7104 if ( IsPropertyAutoL( *bottom ) ) |
|
7105 { |
|
7106 TPtrC8 propertyName = bottom->Property()->Name(); |
|
7107 autoArray.Append( propertyName ); |
|
7108 } |
|
7109 CXnProperty* left = aNode.LeftL(); |
|
7110 if ( IsPropertyAutoL( *left ) ) |
|
7111 { |
|
7112 TPtrC8 propertyName = left->Property()->Name(); |
|
7113 autoArray.Append( propertyName ); |
|
7114 } |
|
7115 CXnProperty* right = aNode.RightL(); |
|
7116 if ( IsPropertyAutoL( *right ) ) |
|
7117 { |
|
7118 TPtrC8 propertyName = right->Property()->Name(); |
|
7119 autoArray.Append( propertyName ); |
|
7120 } |
|
7121 CXnProperty* width = aNode.WidthL(); |
|
7122 if ( IsPropertyAutoL( *width ) ) |
|
7123 { |
|
7124 TPtrC8 propertyName = width->Property()->Name(); |
|
7125 autoArray.Append( propertyName ); |
|
7126 } |
|
7127 if ( !width ) |
|
7128 { |
|
7129 TPtrC8 propertyName = XnPropertyNames::style::common::KWidth(); |
|
7130 autoArray.Append( propertyName ); |
|
7131 } |
|
7132 CXnProperty* height = aNode.HeightL(); |
|
7133 if ( IsPropertyAutoL( *height ) ) |
|
7134 { |
|
7135 TPtrC8 propertyName = height->Property()->Name(); |
|
7136 autoArray.Append( propertyName ); |
|
7137 } |
|
7138 if ( !height ) |
|
7139 { |
|
7140 TPtrC8 propertyName = XnPropertyNames::style::common::KHeight(); |
|
7141 autoArray.Append( propertyName ); |
|
7142 } |
|
7143 CXnProperty* marginTop = aNode.MarginTopL(); |
|
7144 if ( IsPropertyAutoL( *marginTop ) ) |
|
7145 { |
|
7146 TPtrC8 propertyName = marginTop->Property()->Name(); |
|
7147 autoArray.Append( propertyName ); |
|
7148 } |
|
7149 CXnProperty* marginBottom = aNode.MarginBottomL(); |
|
7150 if ( IsPropertyAutoL( *marginBottom ) ) |
|
7151 { |
|
7152 TPtrC8 propertyName = marginBottom->Property()->Name(); |
|
7153 autoArray.Append( propertyName ); |
|
7154 } |
|
7155 CXnProperty* marginLeft = aNode.MarginLeftL(); |
|
7156 if ( IsPropertyAutoL( *marginLeft ) ) |
|
7157 { |
|
7158 TPtrC8 propertyName = marginLeft->Property()->Name(); |
|
7159 autoArray.Append( propertyName ); |
|
7160 } |
|
7161 CXnProperty* marginRight = aNode.MarginRightL(); |
|
7162 if ( IsPropertyAutoL( *marginRight ) ) |
|
7163 { |
|
7164 TPtrC8 propertyName = marginRight->Property()->Name(); |
|
7165 autoArray.Append( propertyName ); |
|
7166 } |
|
7167 |
|
7168 if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR ) |
|
7169 { |
|
7170 if ( aParentBlockProgression == |
|
7171 XnPropertyNames::style::common::block_progression::KTB || |
|
7172 aParentBlockProgression == |
|
7173 XnPropertyNames::style::common::block_progression::KBT ) |
|
7174 { |
|
7175 sizeOfAutoArea = TSize( AutoStaticTBL( aNode, aWidthToFit, |
|
7176 aHeightToFit, autoArray, aParentRect, aGraphicsDevice, |
|
7177 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ); |
|
7178 } |
|
7179 else // block progression LR |
|
7180 { |
|
7181 sizeOfAutoArea = TSize( AutoStaticLRL( aNode, aWidthToFit, |
|
7182 aHeightToFit, autoArray, aParentRect, aGraphicsDevice, |
|
7183 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ); |
|
7184 } |
|
7185 } |
|
7186 else // direction RTL |
|
7187 { |
|
7188 if ( aParentBlockProgression == |
|
7189 XnPropertyNames::style::common::block_progression::KTB || |
|
7190 aParentBlockProgression == |
|
7191 XnPropertyNames::style::common::block_progression::KBT ) |
|
7192 { |
|
7193 sizeOfAutoArea = TSize( AutoStaticBTL( aNode, aWidthToFit, |
|
7194 aHeightToFit, autoArray, aParentRect, aGraphicsDevice, |
|
7195 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ); |
|
7196 } |
|
7197 else // block progression RL |
|
7198 { |
|
7199 sizeOfAutoArea = TSize( AutoStaticRLL( aNode, aWidthToFit, |
|
7200 aHeightToFit, autoArray, aParentRect, aGraphicsDevice, |
|
7201 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ); |
|
7202 } |
|
7203 } |
|
7204 |
|
7205 // if size not within min&max size limits, resize |
|
7206 // (min-size) |
|
7207 if ( HasNodeMinSizesL( aNode ) ) |
|
7208 { |
|
7209 if ( IsSmallerThanMinSizeL( aParentRect, aNode, aGraphicsDevice, |
|
7210 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
7211 { |
|
7212 GrowToMinSizeL( aNode, aParentRect, aGraphicsDevice, |
|
7213 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
7214 } |
|
7215 } |
|
7216 |
|
7217 if ( HasNodeMaxSizesL( aNode ) ) |
|
7218 { |
|
7219 if ( IsLargerThanMaxSizeL( aParentRect, aNode, aGraphicsDevice, |
|
7220 aHorizontalUnitInPixels, aVerticalUnitInPixels ) ) |
|
7221 { |
|
7222 ShrinkToMaxSizeL( aNode, aParentRect, aGraphicsDevice, |
|
7223 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
7224 } |
|
7225 } |
|
7226 |
|
7227 CleanupStack::PopAndDestroy( &autoArray ); |
|
7228 |
|
7229 // Return the context rect size because the min-max |
|
7230 // test might have changed the size of autoarea |
|
7231 return aNode.Rect().Size(); |
|
7232 } |
|
7233 |
|
7234 // ----------------------------------------------------------------------------- |
|
7235 // GrowToMinSizeL() |
|
7236 // |
|
7237 // ----------------------------------------------------------------------------- |
|
7238 // |
|
7239 static void GrowToMinSizeL( CXnNode& aNode, TRect& aParentRect, |
|
7240 CGraphicsDevice& aScreenDevice, |
|
7241 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ) |
|
7242 { |
|
7243 // grow to min size |
|
7244 CXnProperty* minWidthProperty = aNode.MinWidthL(); |
|
7245 CXnProperty* minHeightProperty = aNode.MinHeightL(); |
|
7246 |
|
7247 TRect contentRect( aNode.Rect() ); |
|
7248 TRect paddingRect( aNode.PaddingRect() ); |
|
7249 TRect borderRect( aNode.BorderRect() ); |
|
7250 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
7251 TRect marginRect( aNode.MarginRect() ); |
|
7252 |
|
7253 if ( minWidthProperty ) |
|
7254 { |
|
7255 if ( !IsPropertyNone( *minWidthProperty ) ) |
|
7256 { |
|
7257 TInt minWidth = HorizontalPixelValueL( minWidthProperty, |
|
7258 aParentRect.Width(), aScreenDevice, aHorizontalUnitInPixels ); |
|
7259 if ( contentRect.Width() < minWidth ) |
|
7260 { |
|
7261 TInt widthToGrow = minWidth - contentRect.Width(); |
|
7262 contentRect.Resize( widthToGrow, 0 ); |
|
7263 paddingRect.Resize( widthToGrow, 0 ); |
|
7264 borderRect.Resize( widthToGrow, 0 ); |
|
7265 normalFlowBorderRect.Resize( widthToGrow, 0 ); |
|
7266 marginRect.Resize( widthToGrow, 0 ); |
|
7267 } |
|
7268 } |
|
7269 } |
|
7270 |
|
7271 if ( minHeightProperty ) |
|
7272 { |
|
7273 if ( !IsPropertyNone( *minHeightProperty ) ) |
|
7274 { |
|
7275 TInt minHeight = VerticalPixelValueL( minHeightProperty, |
|
7276 aParentRect.Height(), aScreenDevice, aVerticalUnitInPixels ); |
|
7277 if ( contentRect.Height() < minHeight ) |
|
7278 { |
|
7279 TInt heightToGrow = minHeight - contentRect.Height(); |
|
7280 contentRect.Resize( 0, heightToGrow ); |
|
7281 paddingRect.Resize( 0, heightToGrow ); |
|
7282 borderRect.Resize( 0, heightToGrow ); |
|
7283 normalFlowBorderRect.Resize( 0, heightToGrow ); |
|
7284 marginRect.Resize( 0, heightToGrow ); |
|
7285 } |
|
7286 } |
|
7287 } |
|
7288 |
|
7289 aNode.SetRect( contentRect ); |
|
7290 aNode.SetPaddingRect( paddingRect ); |
|
7291 aNode.SetBorderRect( borderRect ); |
|
7292 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
7293 aNode.SetMarginRect( marginRect ); |
|
7294 } |
|
7295 |
|
7296 // ----------------------------------------------------------------------------- |
|
7297 // ShrinkToMaxSizeL() |
|
7298 // ----------------------------------------------------------------------------- |
|
7299 // |
|
7300 static void ShrinkToMaxSizeL( CXnNode& aNode, TRect& aParentRect, |
|
7301 CGraphicsDevice& aScreenDevice, |
|
7302 TReal aHorizontalUnitInPixels, TReal aVerticalUnitInPixels ) |
|
7303 { |
|
7304 // grow to min size |
|
7305 CXnProperty* maxWidthProperty = aNode.MaxWidthL(); |
|
7306 CXnProperty* maxHeightProperty = aNode.MaxHeightL(); |
|
7307 |
|
7308 TRect contentRect( aNode.Rect() ); |
|
7309 TRect paddingRect( aNode.PaddingRect() ); |
|
7310 TRect borderRect( aNode.BorderRect() ); |
|
7311 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
7312 TRect marginRect( aNode.MarginRect() ); |
|
7313 |
|
7314 if ( maxWidthProperty ) |
|
7315 { |
|
7316 if ( !IsPropertyNone( *maxWidthProperty ) ) |
|
7317 { |
|
7318 TInt maxWidth = HorizontalPixelValueL( maxWidthProperty, |
|
7319 aParentRect.Width(), aScreenDevice, aHorizontalUnitInPixels ); |
|
7320 if ( contentRect.Width() > maxWidth ) |
|
7321 { |
|
7322 TInt widthToShrink = contentRect.Width() - maxWidth; |
|
7323 contentRect.Resize( -widthToShrink, 0 ); |
|
7324 paddingRect.Resize( -widthToShrink, 0 ); |
|
7325 borderRect.Resize( -widthToShrink, 0 ); |
|
7326 normalFlowBorderRect.Resize( -widthToShrink, 0 ); |
|
7327 marginRect.Resize( -widthToShrink, 0 ); |
|
7328 } |
|
7329 } |
|
7330 } |
|
7331 |
|
7332 if ( maxHeightProperty ) |
|
7333 { |
|
7334 if ( !IsPropertyNone( *maxHeightProperty ) ) |
|
7335 { |
|
7336 TInt maxHeight = VerticalPixelValueL( maxHeightProperty, |
|
7337 aParentRect.Height(), aScreenDevice, aVerticalUnitInPixels ); |
|
7338 if ( contentRect.Height() > maxHeight ) |
|
7339 { |
|
7340 TInt heightToShrink = contentRect.Height() - maxHeight; |
|
7341 contentRect.Resize( 0, -heightToShrink ); |
|
7342 paddingRect.Resize( 0, -heightToShrink ); |
|
7343 borderRect.Resize( 0, -heightToShrink ); |
|
7344 normalFlowBorderRect.Resize( 0, -heightToShrink ); |
|
7345 marginRect.Resize( 0, -heightToShrink ); |
|
7346 } |
|
7347 } |
|
7348 } |
|
7349 |
|
7350 aNode.SetRect( contentRect ); |
|
7351 aNode.SetPaddingRect( paddingRect ); |
|
7352 aNode.SetBorderRect( borderRect ); |
|
7353 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
7354 aNode.SetMarginRect( marginRect ); |
|
7355 } |
|
7356 |
|
7357 // ----------------------------------------------------------------------------- |
|
7358 // FitAutoChildrenIntoParentL() |
|
7359 // |
|
7360 // ----------------------------------------------------------------------------- |
|
7361 // |
|
7362 static void FitAutoChildrenIntoParentL( RPointerArray< CXnNode >& aAutoChildren, |
|
7363 RPointerArray< CXnNode >& aCalculatedAutoChildren, CXnNode& aParent, |
|
7364 const TDesC8& aParentBlockProgression, const TDesC8& aParentDirection, |
|
7365 CGraphicsDevice& aGraphicsDevice ) |
|
7366 { |
|
7367 if( IsSrollableBox( aParent ) ) |
|
7368 { |
|
7369 return; |
|
7370 } |
|
7371 |
|
7372 TSize space = CalculateSpaceUsedByAutoChildrenL( aAutoChildren, |
|
7373 aCalculatedAutoChildren, aParent, aParentBlockProgression, |
|
7374 aParentDirection, aGraphicsDevice ); |
|
7375 |
|
7376 TSize parentSize( aParent.Rect().Size() ); |
|
7377 |
|
7378 while( ( ( parentSize.iHeight < space.iHeight ) && |
|
7379 ( parentSize.iHeight > 0 ) ) || |
|
7380 ( ( parentSize.iWidth < space.iWidth ) && |
|
7381 ( parentSize.iWidth > 0 ) ) ) |
|
7382 { |
|
7383 // if areas go over just one pixel, cut the pixel |
|
7384 // from a percent sized node |
|
7385 if ( ( parentSize.iHeight == space.iHeight - 1 ) || |
|
7386 ( parentSize.iWidth == space.iWidth - 1 ) ) |
|
7387 { |
|
7388 CutOnePixelFromPercentChildNodeL( aParent, aParentBlockProgression ); |
|
7389 return; |
|
7390 } |
|
7391 |
|
7392 TInt childCount( DisplayedChildrenCountL( aParent ) ); |
|
7393 |
|
7394 PriorizeChildrenL( aParent ); |
|
7395 |
|
7396 if ( DisplayedChildrenCountL( aParent ) == childCount ) |
|
7397 { |
|
7398 // cannot drop any more children, but they still don't fit |
|
7399 return; |
|
7400 } |
|
7401 |
|
7402 space = CalculateSpaceUsedByAutoChildrenL( aAutoChildren, |
|
7403 aCalculatedAutoChildren, aParent, aParentBlockProgression, |
|
7404 aParentDirection, aGraphicsDevice ); |
|
7405 } |
|
7406 } |
|
7407 |
|
7408 // ----------------------------------------------------------------------------- |
|
7409 // VerticalCentimetersToPixelsL() |
|
7410 // Convert vertical centimeter value to pixel value. |
|
7411 // ----------------------------------------------------------------------------- |
|
7412 // |
|
7413 static TInt VerticalCentimetersToPixelsL( TReal& aCentimeters, |
|
7414 CGraphicsDevice& aScreenDevice ) |
|
7415 { |
|
7416 TReal twips = aCentimeters * KCentimetersAsTwips; |
|
7417 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
7418 return aScreenDevice.VerticalTwipsToPixels( intTwips ); |
|
7419 } |
|
7420 |
|
7421 // ----------------------------------------------------------------------------- |
|
7422 // VerticalInchesToPixelsL() |
|
7423 // Convert vertical inch value to pixel value. |
|
7424 // ----------------------------------------------------------------------------- |
|
7425 // |
|
7426 static TInt VerticalInchesToPixelsL( TReal& aInches, |
|
7427 CGraphicsDevice& aScreenDevice ) |
|
7428 { |
|
7429 TReal twips = aInches * KInchesAsTwips; |
|
7430 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
7431 return aScreenDevice.VerticalTwipsToPixels( intTwips ); |
|
7432 } |
|
7433 |
|
7434 // ----------------------------------------------------------------------------- |
|
7435 // VerticalMillimetersToPixelsL() |
|
7436 // Convert vertical millimeter value to pixel value. |
|
7437 // ----------------------------------------------------------------------------- |
|
7438 // |
|
7439 static TInt VerticalMillimetersToPixelsL( TReal& aMillimeters, |
|
7440 CGraphicsDevice& aScreenDevice ) |
|
7441 { |
|
7442 TReal twips = aMillimeters * KMillimetersAsTwips; |
|
7443 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
7444 return aScreenDevice.VerticalTwipsToPixels( intTwips ); |
|
7445 } |
|
7446 |
|
7447 // ----------------------------------------------------------------------------- |
|
7448 // VerticalPicasToPixelsL() |
|
7449 // Convert vertical pica value to pixel value. |
|
7450 // ----------------------------------------------------------------------------- |
|
7451 // |
|
7452 static TInt VerticalPicasToPixelsL( TReal& aPicas, |
|
7453 CGraphicsDevice& aScreenDevice ) |
|
7454 { |
|
7455 TReal twips = aPicas * KPicasAsTwips; |
|
7456 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
7457 return aScreenDevice.VerticalTwipsToPixels( intTwips ); |
|
7458 } |
|
7459 |
|
7460 // ----------------------------------------------------------------------------- |
|
7461 // VerticalPixelValueL() |
|
7462 // Convert vertical property to pixel value. |
|
7463 // ----------------------------------------------------------------------------- |
|
7464 // |
|
7465 static TInt VerticalPixelValueL( CXnProperty* aValue, TInt aReferenceValue, |
|
7466 CGraphicsDevice& aScreenDevice, TReal aVerticalUnitInPixels ) |
|
7467 { |
|
7468 return VerticalValueToPixelsL( DomPropertyValueFromProperty( aValue ), |
|
7469 static_cast< TReal >( aReferenceValue ), aScreenDevice, |
|
7470 aVerticalUnitInPixels ); |
|
7471 } |
|
7472 |
|
7473 // ----------------------------------------------------------------------------- |
|
7474 // VerticalPointsToPixelsL() |
|
7475 // Convert vertical point value to pixel value. |
|
7476 // ----------------------------------------------------------------------------- |
|
7477 // |
|
7478 static TInt VerticalPointsToPixelsL( TReal& aPoints, |
|
7479 CGraphicsDevice& aScreenDevice ) |
|
7480 { |
|
7481 TReal twips = aPoints * KPointsAsTwips; |
|
7482 TInt intTwips = static_cast< TInt >( twips + KIntConversionConstant ); |
|
7483 return aScreenDevice.VerticalTwipsToPixels( intTwips ); |
|
7484 } |
|
7485 |
|
7486 // ----------------------------------------------------------------------------- |
|
7487 // VerticalValueToPixelsL() |
|
7488 // Convert vertical property value to pixel value. |
|
7489 // ----------------------------------------------------------------------------- |
|
7490 // |
|
7491 static TInt VerticalValueToPixelsL( CXnDomPropertyValue* aValue, |
|
7492 TReal aReferenceValue, CGraphicsDevice& aScreenDevice, |
|
7493 TReal aVerticalUnitInPixels ) |
|
7494 { |
|
7495 if ( !aValue ) |
|
7496 { |
|
7497 User::Leave( KXnErrDomPropertyValueNULL ); |
|
7498 } |
|
7499 CXnDomPropertyValue::TPrimitiveValueType valueType = |
|
7500 aValue->PrimitiveValueType(); |
|
7501 // Handle error cases first, inherit is handled elsewhere, none returns 0 |
|
7502 switch ( valueType ) |
|
7503 { |
|
7504 case CXnDomPropertyValue::EUnknown: |
|
7505 case CXnDomPropertyValue::EEms: |
|
7506 case CXnDomPropertyValue::EExs: |
|
7507 case CXnDomPropertyValue::EDeg: |
|
7508 case CXnDomPropertyValue::ERad: |
|
7509 case CXnDomPropertyValue::EGrad: |
|
7510 case CXnDomPropertyValue::EMs: |
|
7511 case CXnDomPropertyValue::ES: |
|
7512 case CXnDomPropertyValue::EHz: |
|
7513 case CXnDomPropertyValue::EKHz: |
|
7514 case CXnDomPropertyValue::EDimension: |
|
7515 case CXnDomPropertyValue::EString: |
|
7516 case CXnDomPropertyValue::EUri: |
|
7517 case CXnDomPropertyValue::EIdent: |
|
7518 case CXnDomPropertyValue::EAttr: |
|
7519 case CXnDomPropertyValue::ECounter: |
|
7520 case CXnDomPropertyValue::ERect: |
|
7521 case CXnDomPropertyValue::ERgbColor: |
|
7522 case CXnDomPropertyValue::ERgbaColor: |
|
7523 case CXnDomPropertyValue::EFunction: |
|
7524 break; |
|
7525 default: |
|
7526 { |
|
7527 TReal value = aValue->FloatValueL(); |
|
7528 if ( valueType == CXnDomPropertyValue::ENumber || |
|
7529 valueType == CXnDomPropertyValue::EPx ) |
|
7530 { |
|
7531 return static_cast< TInt >( value ); |
|
7532 } |
|
7533 else if ( valueType == CXnDomPropertyValue::EPercentage ) |
|
7534 { |
|
7535 return PercentageToPixelsL( value, aReferenceValue ); |
|
7536 } |
|
7537 else if ( valueType == CXnDomPropertyValue::EIn ) |
|
7538 { |
|
7539 return VerticalInchesToPixelsL( value, aScreenDevice ); |
|
7540 } |
|
7541 else if ( valueType == CXnDomPropertyValue::ECm ) |
|
7542 { |
|
7543 return VerticalCentimetersToPixelsL( value, aScreenDevice ); |
|
7544 } |
|
7545 else if ( valueType == CXnDomPropertyValue::EMm ) |
|
7546 { |
|
7547 return VerticalMillimetersToPixelsL( value, aScreenDevice ); |
|
7548 } |
|
7549 else if ( valueType == CXnDomPropertyValue::EPt ) |
|
7550 { |
|
7551 return VerticalPointsToPixelsL( value, aScreenDevice ); |
|
7552 } |
|
7553 else if ( valueType == CXnDomPropertyValue::EPc ) |
|
7554 { |
|
7555 return VerticalPicasToPixelsL( value, aScreenDevice ); |
|
7556 } |
|
7557 else if ( valueType == CXnDomPropertyValue::EUnitValue ) |
|
7558 { |
|
7559 return VerticalUnitsToPixelsL( value, aVerticalUnitInPixels ); |
|
7560 } |
|
7561 } |
|
7562 break; |
|
7563 } |
|
7564 |
|
7565 return 0; |
|
7566 } |
|
7567 |
|
7568 // ----------------------------------------------------------------------------- |
|
7569 // ProcessAdaptiveAreasL() |
|
7570 // Process adaptive areas |
|
7571 // ----------------------------------------------------------------------------- |
|
7572 // |
|
7573 static void ProcessAdaptiveAreasL( CXnNode& aParent, |
|
7574 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
7575 TReal aVerticalUnitInPixels ) |
|
7576 { |
|
7577 CXnProperty* blockProgressionProperty( aParent.BlockProgressionL() ); |
|
7578 CXnProperty* directionProperty( aParent.DirectionL() ); |
|
7579 const TDesC8* blockProgression( |
|
7580 &XnPropertyNames::style::common::block_progression::KTB() ); |
|
7581 const TDesC8* direction( |
|
7582 &XnPropertyNames::style::common::direction::KLTR() ); |
|
7583 |
|
7584 if ( directionProperty ) |
|
7585 { |
|
7586 direction = &directionProperty->StringValue(); |
|
7587 } |
|
7588 |
|
7589 if ( blockProgressionProperty ) |
|
7590 { |
|
7591 blockProgression = &blockProgressionProperty->StringValue(); |
|
7592 } |
|
7593 |
|
7594 CalculateAdaptiveSizeL( aParent, *blockProgression, *direction, |
|
7595 aGraphicsDevice, aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
7596 } |
|
7597 |
|
7598 // ----------------------------------------------------------------------------- |
|
7599 // CalculateAdaptiveSizeL() |
|
7600 // Fixes the adaptive node size to its layouted children size |
|
7601 // ----------------------------------------------------------------------------- |
|
7602 // |
|
7603 static void CalculateAdaptiveSizeL( CXnNode& aNode, |
|
7604 const TDesC8& aParentBlockProgression, const TDesC8& /*aParentDirection*/, |
|
7605 CGraphicsDevice& aGraphicsDevice, TReal aHorizontalUnitInPixels, |
|
7606 TReal aVerticalUnitInPixels ) |
|
7607 { |
|
7608 TInt adaptive( aNode.IsAdaptive() ); |
|
7609 CXnNode* parent( aNode.Parent() ); |
|
7610 |
|
7611 if ( !adaptive || !parent ) |
|
7612 { |
|
7613 return; |
|
7614 } |
|
7615 |
|
7616 TInt adaptiveHeight( 0 ); |
|
7617 TInt adaptiveWidth( 0 ); |
|
7618 |
|
7619 RPointerArray< CXnNode > children; |
|
7620 CleanupClosePushL( children ); |
|
7621 |
|
7622 TInt count( DisplayedChildrenCountL( aNode, &children ) ); |
|
7623 |
|
7624 TSize size; |
|
7625 |
|
7626 if ( count == 0 ) |
|
7627 { |
|
7628 TRect parentRect( parent->Rect() ); |
|
7629 if( parent->Control() && parent->Control()->OwnsWindow() ) |
|
7630 { |
|
7631 parentRect = TRect( parentRect.iTl - parent->MarginRect().iTl, parentRect.Size() ); |
|
7632 } |
|
7633 // I don't have any displayed childrens, fix my own size |
|
7634 size = CalculateTotalDimensionsL( aNode, ETrue, EFalse, |
|
7635 parentRect, aGraphicsDevice, aHorizontalUnitInPixels, |
|
7636 aVerticalUnitInPixels ); |
|
7637 adaptiveHeight = size.iHeight; |
|
7638 adaptiveWidth = size.iWidth; |
|
7639 } |
|
7640 else |
|
7641 { |
|
7642 TBool autoHeight( EFalse ); |
|
7643 TBool autoWidth( EFalse ); |
|
7644 TBool sizeKnown( EFalse ); |
|
7645 for ( TInt i = 0; i < children.Count(); i++ ) |
|
7646 { |
|
7647 CXnNode* node( children[i] ); |
|
7648 if ( !IsNodeDisplayedL( *node ) ) |
|
7649 { |
|
7650 continue; |
|
7651 } |
|
7652 CXnProperty* heightProperty( node->HeightL() ); |
|
7653 if ( !( node->IsAdaptive() & XnAdaptive::EHeight ) && |
|
7654 ( adaptive & XnAdaptive::EHeight ) && |
|
7655 IsPropertyAutoL( *heightProperty ) ) |
|
7656 { |
|
7657 adaptiveHeight = node->MarginRect().Size().iHeight; |
|
7658 autoHeight = ETrue; |
|
7659 if ( !( adaptive & XnAdaptive::EWidth ) ) |
|
7660 { |
|
7661 // Height is now known and width is not adaptive |
|
7662 // -> size is now known |
|
7663 sizeKnown = ETrue; |
|
7664 } |
|
7665 } |
|
7666 CXnProperty* widthProperty( node->WidthL() ); |
|
7667 if ( !( node->IsAdaptive() & XnAdaptive::EWidth ) && |
|
7668 ( adaptive & XnAdaptive::EWidth ) && |
|
7669 IsPropertyAutoL( *widthProperty ) ) |
|
7670 { |
|
7671 adaptiveWidth = node->MarginRect().Size().iWidth; |
|
7672 autoWidth = ETrue; |
|
7673 if ( !( adaptive & XnAdaptive::EHeight ) ) |
|
7674 { |
|
7675 // Width is now known and height is not adaptive |
|
7676 // -> size is now known |
|
7677 sizeKnown = ETrue; |
|
7678 } |
|
7679 } |
|
7680 if ( autoWidth && autoHeight ) |
|
7681 { |
|
7682 // Both auto -> size is now known |
|
7683 sizeKnown = ETrue; |
|
7684 } |
|
7685 if ( !sizeKnown ) |
|
7686 { |
|
7687 // Fix adaptive sized child's size first |
|
7688 ProcessAdaptiveAreasL( *node, aGraphicsDevice, |
|
7689 aHorizontalUnitInPixels, aVerticalUnitInPixels ); |
|
7690 TSize marginSize( node->MarginRect().Size() ); |
|
7691 if ( aParentBlockProgression == |
|
7692 XnPropertyNames::style::common::block_progression::KTB || |
|
7693 aParentBlockProgression == |
|
7694 XnPropertyNames::style::common::block_progression::KBT ) |
|
7695 { |
|
7696 if ( !autoHeight && ( adaptive & XnAdaptive::EHeight ) ) |
|
7697 { |
|
7698 adaptiveHeight += marginSize.iHeight; |
|
7699 } |
|
7700 if ( !autoWidth && ( adaptive & XnAdaptive::EWidth ) ) |
|
7701 { |
|
7702 if ( marginSize.iWidth > adaptiveWidth ) |
|
7703 { |
|
7704 adaptiveWidth = marginSize.iWidth; |
|
7705 } |
|
7706 } |
|
7707 } |
|
7708 else if ( aParentBlockProgression == |
|
7709 XnPropertyNames::style::common:: |
|
7710 block_progression::KLR || aParentBlockProgression == |
|
7711 XnPropertyNames::style::common:: |
|
7712 block_progression::KRL ) |
|
7713 { |
|
7714 if ( !autoHeight && ( adaptive & XnAdaptive::EHeight ) ) |
|
7715 { |
|
7716 if ( marginSize.iHeight > adaptiveHeight ) |
|
7717 { |
|
7718 adaptiveHeight = marginSize.iHeight; |
|
7719 } |
|
7720 } |
|
7721 if ( !autoWidth && ( adaptive & XnAdaptive::EWidth ) ) |
|
7722 { |
|
7723 adaptiveWidth += marginSize.iWidth; |
|
7724 } |
|
7725 } |
|
7726 } |
|
7727 } |
|
7728 } |
|
7729 |
|
7730 TRect contentRect( aNode.Rect() ); |
|
7731 TRect paddingRect( aNode.PaddingRect() ); |
|
7732 TRect borderRect( aNode.BorderRect() ); |
|
7733 TRect marginRect( aNode.MarginRect() ); |
|
7734 TRect normalFlowBorderRect( aNode.NormalFlowBorderRect() ); |
|
7735 |
|
7736 TRect paddingRectDiff( SubtractRect( paddingRect, contentRect ) ); |
|
7737 TRect borderRectDiff( SubtractRect( borderRect, contentRect ) ); |
|
7738 TRect marginRectDiff( SubtractRect( marginRect, contentRect ) ); |
|
7739 TRect normalFlowBorderRectDiff( SubtractRect( |
|
7740 normalFlowBorderRect, contentRect ) ); |
|
7741 |
|
7742 TInt dy( 0 ); |
|
7743 TInt dx( 0 ); |
|
7744 |
|
7745 if ( adaptive & XnAdaptive::EHeight ) |
|
7746 { |
|
7747 if ( adaptiveHeight <= 0 ) |
|
7748 { |
|
7749 adaptiveHeight = 0; |
|
7750 } |
|
7751 dy = contentRect.Size().iHeight - adaptiveHeight; |
|
7752 } |
|
7753 if ( adaptive & XnAdaptive::EWidth ) |
|
7754 { |
|
7755 if ( adaptiveWidth <= 0 ) |
|
7756 { |
|
7757 adaptiveWidth = 0; |
|
7758 } |
|
7759 dx = contentRect.Size().iWidth - adaptiveWidth; |
|
7760 } |
|
7761 |
|
7762 contentRect.Resize( -dx, -dy ); |
|
7763 |
|
7764 paddingRect = AddRect( contentRect, paddingRectDiff ); |
|
7765 borderRect = AddRect( contentRect, borderRectDiff ); |
|
7766 marginRect = AddRect( contentRect, marginRectDiff ); |
|
7767 normalFlowBorderRect = AddRect( contentRect, normalFlowBorderRectDiff ); |
|
7768 |
|
7769 aNode.SetRect( contentRect ); |
|
7770 aNode.SetPaddingRect( paddingRect ); |
|
7771 aNode.SetBorderRect( borderRect ); |
|
7772 aNode.SetMarginRect( marginRect ); |
|
7773 aNode.SetNormalFlowBorderRect( normalFlowBorderRect ); |
|
7774 |
|
7775 aNode.FixAdaptiveSizeL( contentRect.Size() ); |
|
7776 |
|
7777 aNode.UiEngine()->CheckAdaptiveContentL( aNode, contentRect.Size() ); |
|
7778 |
|
7779 CleanupStack::PopAndDestroy( &children ); |
|
7780 } |
|
7781 |
|
7782 // ----------------------------------------------------------------------------- |
|
7783 // BuildTriggerNodeLC |
|
7784 // Builds a trigger node |
|
7785 // ----------------------------------------------------------------------------- |
|
7786 // |
|
7787 static CXnNode* BuildTriggerNodeLC( CXnUiEngine& aUiEngine, |
|
7788 const TDesC8& aTriggerName ) |
|
7789 { |
|
7790 CXnNode* node = CXnNode::NewL(); |
|
7791 CleanupStack::PushL( node ); |
|
7792 |
|
7793 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
7794 CleanupStack::PushL( type ); |
|
7795 |
|
7796 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
7797 CleanupStack::Pop( type ); |
|
7798 |
|
7799 node->SetImpl( impl ); |
|
7800 node->SetUiEngine( aUiEngine ); |
|
7801 |
|
7802 CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL( |
|
7803 aUiEngine.ODT()->DomDocument().StringPool() ); |
|
7804 |
|
7805 CleanupStack::PushL( nameValue ); |
|
7806 |
|
7807 nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName ); |
|
7808 |
|
7809 CXnProperty* name = CXnProperty::NewL( |
|
7810 XnPropertyNames::action::trigger::KName, |
|
7811 nameValue, *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
7812 |
|
7813 CleanupStack::Pop( nameValue ); |
|
7814 |
|
7815 CleanupStack::PushL( name ); |
|
7816 |
|
7817 node->SetPropertyL( name ); |
|
7818 |
|
7819 CleanupStack::Pop( name ); |
|
7820 |
|
7821 //CleanupStack::Pop( node ); |
|
7822 |
|
7823 return node; |
|
7824 } |
|
7825 |
|
7826 // ----------------------------------------------------------------------------- |
|
7827 // UpdateInternalUnits |
|
7828 // Updates UiEngineImpl unit values |
|
7829 // ----------------------------------------------------------------------------- |
|
7830 // |
|
7831 static void UpdateInternalUnits( TReal& aHorizontalUnitInPixels, |
|
7832 TReal& aVerticalUnitInPixels, TRect aRect ) |
|
7833 { |
|
7834 TAknWindowComponentLayout referenceLayout = |
|
7835 AknLayoutScalable_Avkon::aid_value_unit2(); |
|
7836 TRect parent( aRect ); |
|
7837 |
|
7838 TAknLayoutRect rect; |
|
7839 |
|
7840 // TAknWindowLineLayout should go directly |
|
7841 //to LayoutRect/LayoutControl etc. methods |
|
7842 rect.LayoutRect( parent, referenceLayout.LayoutLine() ); |
|
7843 |
|
7844 TReal rectWidth = rect.Rect().Width(); |
|
7845 |
|
7846 if ( rectWidth == 0 ) |
|
7847 { |
|
7848 aHorizontalUnitInPixels = 0; |
|
7849 } |
|
7850 |
|
7851 aHorizontalUnitInPixels = rectWidth / 10; |
|
7852 |
|
7853 TReal rectHeight = rect.Rect().Height(); |
|
7854 |
|
7855 if ( rectHeight == 0 ) |
|
7856 { |
|
7857 aVerticalUnitInPixels = 0; |
|
7858 } |
|
7859 |
|
7860 aVerticalUnitInPixels = rectHeight / 10; |
|
7861 } |
|
7862 |
|
7863 // ----------------------------------------------------------------------------- |
|
7864 // BuildScreenDeviceChangeTriggerNodeLC |
|
7865 // Build trigger node for screen device change event |
|
7866 // ----------------------------------------------------------------------------- |
|
7867 // |
|
7868 static CXnNode* BuildScreenDeviceChangeTriggerNodeLC( CXnUiEngine& aUiEngine ) |
|
7869 { |
|
7870 CXnDomStringPool* sp( aUiEngine.ODT()->DomDocument().StringPool() ); |
|
7871 |
|
7872 CXnNode* node = CXnNode::NewL(); |
|
7873 CleanupStack::PushL( node ); |
|
7874 |
|
7875 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
7876 CleanupStack::PushL( type ); |
|
7877 |
|
7878 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
7879 CleanupStack::Pop( type ); |
|
7880 |
|
7881 node->SetImpl( impl ); |
|
7882 node->SetUiEngine( aUiEngine ); |
|
7883 |
|
7884 CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL( sp ); |
|
7885 CleanupStack::PushL( nameValue ); |
|
7886 |
|
7887 nameValue->SetStringValueL( CXnDomPropertyValue::EString, |
|
7888 XnPropertyNames::action::trigger::name::KScreenDeviceChange ); |
|
7889 |
|
7890 CXnProperty* name = CXnProperty::NewL( |
|
7891 XnPropertyNames::action::trigger::KName, nameValue, *sp ); |
|
7892 CleanupStack::Pop( nameValue ); |
|
7893 CleanupStack::PushL( name ); |
|
7894 |
|
7895 node->SetPropertyL( name ); |
|
7896 CleanupStack::Pop( name ); |
|
7897 |
|
7898 CXnDomPropertyValue* reasonValue = CXnDomPropertyValue::NewL( sp ); |
|
7899 CleanupStack::PushL( reasonValue ); |
|
7900 |
|
7901 const TDesC8* reasonString( NULL ); |
|
7902 |
|
7903 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
7904 { |
|
7905 reasonString = &XnPropertyNames::action::trigger::name:: |
|
7906 orientation::reason::KLandscape; |
|
7907 } |
|
7908 else |
|
7909 { |
|
7910 reasonString = &XnPropertyNames::action::trigger::name:: |
|
7911 orientation::reason::KPortrait; |
|
7912 } |
|
7913 |
|
7914 reasonValue->SetStringValueL( CXnDomPropertyValue::EString, *reasonString ); |
|
7915 |
|
7916 CXnProperty* reason = CXnProperty::NewL( XnPropertyNames::action::trigger:: |
|
7917 name::orientation::KReason, reasonValue, *sp ); |
|
7918 |
|
7919 CleanupStack::Pop( reasonValue ); |
|
7920 |
|
7921 CleanupStack::PushL( reason ); |
|
7922 |
|
7923 node->SetPropertyL( reason ); |
|
7924 |
|
7925 CleanupStack::Pop( reason ); |
|
7926 |
|
7927 return node; |
|
7928 } |
|
7929 |
|
7930 // ----------------------------------------------------------------------------- |
|
7931 // FillFocusCandidatesL |
|
7932 // ----------------------------------------------------------------------------- |
|
7933 // |
|
7934 static void FillFocusCandidatesL( CXnNode* aParent, |
|
7935 RPointerArray< CXnNode >& aArray ) |
|
7936 { |
|
7937 RPointerArray< CXnNode >& children( aParent->Children() ); |
|
7938 |
|
7939 aArray.AppendL( aParent ); |
|
7940 |
|
7941 for ( TInt i = 0; i < children.Count(); i++ ) |
|
7942 { |
|
7943 FillFocusCandidatesL( children[i], aArray ); |
|
7944 } |
|
7945 } |
|
7946 |
|
7947 // ----------------------------------------------------------------------------- |
|
7948 // SetAdaptivesL |
|
7949 // ----------------------------------------------------------------------------- |
|
7950 // |
|
7951 static TBool SetAdaptivesL( CXnNode& aNode ) |
|
7952 { |
|
7953 TBool retval( EFalse ); |
|
7954 |
|
7955 // Check if the node is adaptive |
|
7956 if ( aNode.IsAdaptive( ETrue ) && IsNodeDisplayedL( aNode ) ) |
|
7957 { |
|
7958 retval = ETrue; |
|
7959 // Mark adaptive node to be measured |
|
7960 aNode.SetAdaptiveL( XnAdaptive::EMeasure ); |
|
7961 } |
|
7962 |
|
7963 RPointerArray< CXnNode >& children( aNode.Children() ); |
|
7964 |
|
7965 for ( TInt i = 0; i < children.Count(); i++ ) |
|
7966 { |
|
7967 TBool ret( SetAdaptivesL( *children[i] ) ); |
|
7968 if ( ret ) |
|
7969 { |
|
7970 retval = ret; |
|
7971 } |
|
7972 } |
|
7973 |
|
7974 return retval; |
|
7975 } |
|
7976 |
|
7977 #ifdef _XN3_DEBUG_ |
|
7978 // ----------------------------------------------------------------------------- |
|
7979 // TraceTreeL |
|
7980 // ----------------------------------------------------------------------------- |
|
7981 // |
|
7982 static void TraceTreeL( CXnNode* aRootNode ) |
|
7983 { |
|
7984 CXnDepthFirstTreeIterator< CXnNode >* iterator = |
|
7985 CXnDepthFirstTreeIterator< CXnNode >::NewL( *aRootNode ); |
|
7986 CleanupStack::PushL( iterator ); |
|
7987 |
|
7988 RDebug::Print( _L("Xuikon: UI tree:") ); |
|
7989 |
|
7990 TBuf8< 256 > debug; |
|
7991 |
|
7992 TInt level( 0 ); |
|
7993 |
|
7994 for( CXnNode* node = iterator->Value(); node; |
|
7995 node = iterator->NextL() ) |
|
7996 { |
|
7997 debug = _L8( "Xuikon: " ); |
|
7998 |
|
7999 level = iterator->Level(); |
|
8000 |
|
8001 for ( TInt i = 0; i < level; i++ ) |
|
8002 { |
|
8003 debug.Append( ' ' ); |
|
8004 } |
|
8005 |
|
8006 debug.Append( node->Type()->Type() ); |
|
8007 |
|
8008 CXnProperty* id( node->IdL() ); |
|
8009 |
|
8010 if ( id ) |
|
8011 { |
|
8012 debug.Append( _L8( ", id: " ) ); |
|
8013 debug.Append( id->StringValue() ); |
|
8014 } |
|
8015 |
|
8016 debug.AppendFormat( _L8( ", laidout: %d" ), node->IsLaidOut() ); |
|
8017 debug.AppendFormat( _L8( ", displayed: %d" ), |
|
8018 IsNodeDisplayedL( *node ) ); |
|
8019 |
|
8020 CCoeControl* control( node->Control() ); |
|
8021 |
|
8022 if ( control ) |
|
8023 { |
|
8024 TBool visible( control->IsVisible() ); |
|
8025 TRect rect( control->Rect() ); |
|
8026 TPoint tl( rect.iTl ); |
|
8027 TPoint br( rect.iBr ); |
|
8028 debug.AppendFormat( _L8( ", visible %d:" ), visible ); |
|
8029 debug.AppendFormat( |
|
8030 _L8( ", Tl: %d %d, Br: %d %d" ), tl.iX, tl.iY, br.iX, br.iY ); |
|
8031 } |
|
8032 else |
|
8033 { |
|
8034 debug.Append( _L8( ", no control" ) ); |
|
8035 } |
|
8036 RDebug::RawPrint( debug ); |
|
8037 } |
|
8038 |
|
8039 CleanupStack::PopAndDestroy( iterator ); |
|
8040 } |
|
8041 #endif |
|
8042 |
|
8043 // ============================ MEMBER FUNCTIONS =============================== |
|
8044 |
|
8045 // ----------------------------------------------------------------------------- |
|
8046 // CXnUiEngineImpl::CXnUiEngineImpl() |
|
8047 // C++ default constructor can NOT contain any code, that |
|
8048 // might leave. |
|
8049 // ----------------------------------------------------------------------------- |
|
8050 // |
|
8051 CXnUiEngineImpl::CXnUiEngineImpl( CXnUiEngine& aUiEngine, |
|
8052 CXnAppUiAdapter& aAdapter ) |
|
8053 : iUiEngine( &aUiEngine ), iAppUiAdapter( aAdapter ), |
|
8054 iViewManager( aAdapter.ViewManager() ) |
|
8055 { |
|
8056 iAppUiAdapter.UiStateListener().AddObserver( *this ); |
|
8057 |
|
8058 iViewManager.AddObserver( *this ); |
|
8059 } |
|
8060 |
|
8061 // ----------------------------------------------------------------------------- |
|
8062 // CXnUiEngineImpl::ConstructL() |
|
8063 // Symbian 2nd phase constructor can leave. |
|
8064 // ----------------------------------------------------------------------------- |
|
8065 // |
|
8066 void CXnUiEngineImpl::ConstructL() |
|
8067 { |
|
8068 iEditMode = CXnEditMode::NewL( *iUiEngine ); |
|
8069 |
|
8070 iCurrentGraphicsDevice = CCoeEnv::Static()->ScreenDevice(); |
|
8071 |
|
8072 // Update the units here, even the refence client rect is only a quess. |
|
8073 // That is because we don't know the UI furniture yet. Units are |
|
8074 // needed in controls constructions |
|
8075 UpdateInternalUnits( |
|
8076 iHorizontalUnitInPixels, |
|
8077 iVerticalUnitInPixels, |
|
8078 iAppUiAdapter.ClientRect() ); |
|
8079 } |
|
8080 |
|
8081 // ----------------------------------------------------------------------------- |
|
8082 // CXnUiEngineImpl::NewL() |
|
8083 // Two-phased constructor. |
|
8084 // ----------------------------------------------------------------------------- |
|
8085 // |
|
8086 CXnUiEngineImpl* CXnUiEngineImpl::NewL( CXnUiEngine& aUiEngine, |
|
8087 CXnAppUiAdapter& aAdapter ) |
|
8088 { |
|
8089 return new ( ELeave ) CXnUiEngineImpl( aUiEngine, aAdapter ); |
|
8090 } |
|
8091 |
|
8092 // ----------------------------------------------------------------------------- |
|
8093 // CXnUiEngineImpl::~CXnUiEngineImpl() |
|
8094 // C++ default destructor. |
|
8095 // ----------------------------------------------------------------------------- |
|
8096 // |
|
8097 CXnUiEngineImpl::~CXnUiEngineImpl() |
|
8098 { |
|
8099 iAppUiAdapter.UiStateListener().RemoveObserver( *this ); |
|
8100 |
|
8101 iViewManager.RemoveObserver( *this ); |
|
8102 |
|
8103 delete iEditMode; |
|
8104 |
|
8105 iFocusCandidateList.Reset(); |
|
8106 |
|
8107 if ( iRedrawRegions.Count() ) |
|
8108 { |
|
8109 iRedrawRegions.ResetAndDestroy(); |
|
8110 } |
|
8111 |
|
8112 iDirtyList.Reset(); |
|
8113 } |
|
8114 |
|
8115 // ----------------------------------------------------------------------------- |
|
8116 // CXnUiEngineImpl::AppUiAdapter() |
|
8117 // ----------------------------------------------------------------------------- |
|
8118 // |
|
8119 CXnAppUiAdapter& CXnUiEngineImpl::AppUiAdapter() const |
|
8120 { |
|
8121 return iAppUiAdapter; |
|
8122 } |
|
8123 |
|
8124 // ----------------------------------------------------------------------------- |
|
8125 // CXnUiEngineImpl::LayoutUIL() |
|
8126 // ----------------------------------------------------------------------------- |
|
8127 // |
|
8128 void CXnUiEngineImpl::LayoutUIL( CXnNode* /*aNode*/ ) |
|
8129 { |
|
8130 if ( IsLayoutDisabled() ) |
|
8131 { |
|
8132 iLayoutControl |= XnLayoutControl::ELayoutUI; |
|
8133 return; |
|
8134 } |
|
8135 |
|
8136 iLayoutControl &= ~XnLayoutControl::ELayoutUI; |
|
8137 |
|
8138 if ( iDirtyList.Count() == 0 ) |
|
8139 { |
|
8140 // Nothing to do, layout is up-to-date |
|
8141 return; |
|
8142 } |
|
8143 |
|
8144 DisableRenderUiLC(); |
|
8145 CXnNode* candidate( StartLayoutFromL() ); |
|
8146 PrepareRunLayoutL(); |
|
8147 iDirtyList.Reset(); |
|
8148 |
|
8149 // Run layout until it is fully calculated |
|
8150 do |
|
8151 { |
|
8152 iLayoutPhase = RunLayoutL( candidate ); |
|
8153 } |
|
8154 while ( iLayoutPhase != XnLayoutPhase::ENone ); |
|
8155 |
|
8156 CXnNode* focused( FocusedNode() ); |
|
8157 |
|
8158 if ( focused && focused->IsDropped() ) |
|
8159 { |
|
8160 // The currently focused node is dropped, run losevisualization |
|
8161 CXnNode* loseVisualisation = |
|
8162 BuildTriggerNodeLC( *iUiEngine, |
|
8163 XnPropertyNames::action::trigger::name::KLoseVisualisation ); |
|
8164 |
|
8165 focused->ReportXuikonEventL( *loseVisualisation ); |
|
8166 CleanupStack::PopAndDestroy( loseVisualisation ); |
|
8167 |
|
8168 if ( FocusedNode() == focused ) |
|
8169 { |
|
8170 // Remove focus as losevisualization trigger didn't |
|
8171 // change focus from dropped node to another one |
|
8172 SetFocusedNodeL( NULL ); |
|
8173 } |
|
8174 } |
|
8175 |
|
8176 if ( !FocusedNode() && iAppUiAdapter.FocusShown() ) |
|
8177 { |
|
8178 // No focus, try if some of the focus candidates can be focused |
|
8179 RootNode()->RunFocusChangeL( iFocusCandidateList ); |
|
8180 } |
|
8181 |
|
8182 iFocusCandidateList.Reset(); |
|
8183 |
|
8184 iAppUiAdapter.EffectManager()->UiLayouted(); |
|
8185 |
|
8186 // Layout is now recalculated |
|
8187 CleanupStack::PopAndDestroy(); // anonymous |
|
8188 } |
|
8189 |
|
8190 // ----------------------------------------------------------------------------- |
|
8191 // PrepareRunLayoutL() |
|
8192 // Set dropped flags of all nodes in the tree to ENone. |
|
8193 // ----------------------------------------------------------------------------- |
|
8194 // |
|
8195 void CXnUiEngineImpl::PrepareRunLayoutL() |
|
8196 { |
|
8197 if ( iLayoutPhase == XnLayoutPhase::ENone ) |
|
8198 { |
|
8199 iLayoutPhase = XnLayoutPhase::ELayout; |
|
8200 |
|
8201 for ( TInt i = 0; i < iDirtyList.Count(); i++ ) |
|
8202 { |
|
8203 CXnNode* dirty( iDirtyList[i] ); |
|
8204 |
|
8205 // Clear dropped flags recursively |
|
8206 SetNodeDroppedL( *dirty, XnNodeLayout::ENone ); |
|
8207 |
|
8208 if ( SetAdaptivesL( *dirty ) ) |
|
8209 { |
|
8210 // Adaptive node causes measure phase |
|
8211 iLayoutPhase = XnLayoutPhase::EMeasure; |
|
8212 } |
|
8213 } |
|
8214 } |
|
8215 } |
|
8216 |
|
8217 // ----------------------------------------------------------------------------- |
|
8218 // CXnUiEngineImpl::RunLayoutL() |
|
8219 // ----------------------------------------------------------------------------- |
|
8220 // |
|
8221 TInt CXnUiEngineImpl::RunLayoutL( CXnNode* aNode ) |
|
8222 { |
|
8223 TRect clientRect( ClientRect() ); |
|
8224 // Move it to 0, 0 |
|
8225 clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY ); |
|
8226 |
|
8227 RPointerArray< CXnNode > laidOutList; |
|
8228 CleanupClosePushL( laidOutList ); |
|
8229 |
|
8230 if ( IsNodeDisplayedL( *aNode ) ) |
|
8231 { |
|
8232 if ( aNode->ViewNodeImpl() && !aNode ->IsLaidOut() ) |
|
8233 { |
|
8234 aNode->SetMarginRect( clientRect ); |
|
8235 aNode->SetBorderRect( clientRect ); |
|
8236 aNode->SetNormalFlowBorderRect( clientRect ); |
|
8237 aNode->SetPaddingRect( clientRect ); |
|
8238 aNode->SetRect( clientRect ); |
|
8239 } |
|
8240 |
|
8241 // Put areas to place |
|
8242 PlaceAreasL( *aNode, laidOutList, iLayoutPhase, |
|
8243 *iCurrentGraphicsDevice, iHorizontalUnitInPixels, |
|
8244 iVerticalUnitInPixels ); |
|
8245 } |
|
8246 |
|
8247 TInt nextPhase; |
|
8248 |
|
8249 switch ( iLayoutPhase ) |
|
8250 { |
|
8251 case XnLayoutPhase::EMeasure: |
|
8252 nextPhase = XnLayoutPhase::ELayout; |
|
8253 break; |
|
8254 case XnLayoutPhase::ELayout: |
|
8255 // Layout is now calculated |
|
8256 iCurrentView->SetLaidOutL(); |
|
8257 iLayoutControl &= ~XnLayoutControl::EViewDirty; |
|
8258 // Check nodes which dimensions are changed |
|
8259 for ( TInt i = 0; i < laidOutList.Count(); i++ ) |
|
8260 { |
|
8261 CXnNode* node( laidOutList[i] ); |
|
8262 if( IsSrollableBox( *node ) && node->ScrollableControl() ) |
|
8263 { |
|
8264 node->ScrollableControl()->LayoutChangedL(); |
|
8265 } |
|
8266 if ( /*IsNodeTooltip( *node ) ||*/ !node->IsLaidOut() ) |
|
8267 { |
|
8268 continue; |
|
8269 } |
|
8270 CXnControlAdapter* adapter( node->Control() ); |
|
8271 if ( adapter ) |
|
8272 { |
|
8273 TRect rect; |
|
8274 |
|
8275 if ( node->ViewNodeImpl() ) |
|
8276 { |
|
8277 rect = ClientRect(); |
|
8278 |
|
8279 // Move it to 0, 0 |
|
8280 //rect.Move( -rect.iTl.iX, -rect.iTl.iY ); |
|
8281 } |
|
8282 else |
|
8283 { |
|
8284 rect = node->BorderRect(); |
|
8285 } |
|
8286 |
|
8287 if ( adapter->Rect() != rect ) |
|
8288 { |
|
8289 AddToRedrawListL( node, rect ); |
|
8290 |
|
8291 adapter->SetRect( rect ); |
|
8292 |
|
8293 CXnProperty* prop = node->GetPropertyL( |
|
8294 XnPropertyNames::common::KSizeAware ); |
|
8295 if ( prop && prop->StringValue() == |
|
8296 XnPropertyNames::KTrue ) |
|
8297 { |
|
8298 CXnNode* sizeChanged = |
|
8299 BuildTriggerNodeLC( *iUiEngine, |
|
8300 XnPropertyNames::action::trigger::name:: |
|
8301 KSizeChanged ); |
|
8302 node->ReportXuikonEventL( *sizeChanged ); |
|
8303 CleanupStack::PopAndDestroy( sizeChanged ); |
|
8304 } |
|
8305 } |
|
8306 } |
|
8307 } |
|
8308 /* flow through */ |
|
8309 default: |
|
8310 nextPhase = XnLayoutPhase::ENone; |
|
8311 break; |
|
8312 } |
|
8313 CleanupStack::PopAndDestroy( &laidOutList ); |
|
8314 return nextPhase; |
|
8315 } |
|
8316 |
|
8317 // ----------------------------------------------------------------------------- |
|
8318 // CXnUiEngineImpl::RenderUIL() |
|
8319 // ----------------------------------------------------------------------------- |
|
8320 // |
|
8321 void CXnUiEngineImpl::RenderUIL( CXnNode* /*aNode*/ ) |
|
8322 { |
|
8323 if ( IsLayoutDisabled() ) |
|
8324 { |
|
8325 // Layout is not up-to-date |
|
8326 iLayoutControl |= XnLayoutControl::ERenderUI; |
|
8327 return; |
|
8328 } |
|
8329 |
|
8330 #ifdef _XN3_DEBUG_ |
|
8331 TraceTreeL(iCurrentView ); |
|
8332 #endif |
|
8333 |
|
8334 __PRINTS("*** CXnUiEngineImpl::RenderUIL ***"); |
|
8335 |
|
8336 for( TInt i=0; i<iRedrawRegions.Count(); i++) |
|
8337 { |
|
8338 CCoeControl* control = iRedrawRegions[i]->iControl; |
|
8339 RRegion& redrawRegion = iRedrawRegions[i]->iRegion; |
|
8340 |
|
8341 if( redrawRegion.CheckError() ) |
|
8342 { |
|
8343 // Mark tree rendered |
|
8344 iCurrentView->SetRenderedL(); |
|
8345 // Error occured during dirty set, redraw whole window |
|
8346 control->DrawNow(); |
|
8347 |
|
8348 __PRINTS("* CXnUiEngineImpl::RenderUIL - redraw region error -> full redraw ***"); |
|
8349 } |
|
8350 else |
|
8351 { |
|
8352 if( !redrawRegion.IsEmpty() ) |
|
8353 { |
|
8354 // Mark tree rendered |
|
8355 iCurrentView->SetRenderedL(); |
|
8356 |
|
8357 if ( iAppUiAdapter.EffectManager()->ControlEffectActive( control ) ) |
|
8358 { |
|
8359 // control effect is ongoing, no need to draw control yet |
|
8360 redrawRegion.Clear(); |
|
8361 continue; |
|
8362 } |
|
8363 |
|
8364 TInt count( redrawRegion.Count() ); |
|
8365 |
|
8366 if( count > 2 ) |
|
8367 { |
|
8368 // Make bounding rect over the dirty areas |
|
8369 TRect boundingRect( redrawRegion.BoundingRect() ); |
|
8370 |
|
8371 __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing bounding rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ), |
|
8372 boundingRect.iTl.iX, boundingRect.iTl.iY, boundingRect.iBr.iX, boundingRect.iBr.iY ); |
|
8373 |
|
8374 control->DrawNow( boundingRect ); |
|
8375 } |
|
8376 else |
|
8377 { |
|
8378 for( TInt i = 0; i < count; i++ ) |
|
8379 { |
|
8380 // Draw every dirty area separately |
|
8381 TRect redrawRect( redrawRegion[i] ); |
|
8382 |
|
8383 __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ), |
|
8384 redrawRect.iTl.iX, redrawRect.iTl.iY, redrawRect.iBr.iX, redrawRect.iBr.iY ); |
|
8385 |
|
8386 control->DrawNow( redrawRect ); |
|
8387 } |
|
8388 } |
|
8389 } |
|
8390 else |
|
8391 { |
|
8392 __PRINTS("* CXnUiEngineImpl::RenderUIL - nothing to redraw ***"); |
|
8393 } |
|
8394 } |
|
8395 |
|
8396 redrawRegion.Clear(); |
|
8397 } |
|
8398 |
|
8399 RefreshMenuL(); |
|
8400 |
|
8401 iLayoutControl &= ~XnLayoutControl::ERenderUI; |
|
8402 |
|
8403 iAppUiAdapter.EffectManager()->UiRendered(); |
|
8404 |
|
8405 __PRINTS("*** CXnUiEngineImpl::RenderUIL - done ***"); |
|
8406 } |
|
8407 |
|
8408 // ----------------------------------------------------------------------------- |
|
8409 // CXnUiEngineImpl::RootNode() |
|
8410 // ----------------------------------------------------------------------------- |
|
8411 // |
|
8412 CXnNode* CXnUiEngineImpl::RootNode() |
|
8413 { |
|
8414 return iViewManager.RootNode(); |
|
8415 } |
|
8416 |
|
8417 // ----------------------------------------------------------------------------- |
|
8418 // CXnUiEngineImpl::ODT() |
|
8419 // ----------------------------------------------------------------------------- |
|
8420 // |
|
8421 CXnODT* CXnUiEngineImpl::ODT() |
|
8422 { |
|
8423 return iViewManager.ODT(); |
|
8424 } |
|
8425 |
|
8426 // ----------------------------------------------------------------------------- |
|
8427 // CXnUiEngineImpl::FindNodeByIdL() |
|
8428 // ----------------------------------------------------------------------------- |
|
8429 // |
|
8430 CXnNode* CXnUiEngineImpl::FindNodeByIdL( const TDesC& aAreaId, |
|
8431 const TDesC& aNamespace ) |
|
8432 { |
|
8433 HBufC8* id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aAreaId ); |
|
8434 CleanupStack::PushL( id ); |
|
8435 |
|
8436 HBufC8* ns = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aNamespace ); |
|
8437 CleanupStack::PushL( ns ); |
|
8438 |
|
8439 CXnNode* returnValue( FindNodeByIdL( *id, *ns ) ); |
|
8440 |
|
8441 CleanupStack::PopAndDestroy( ns ); |
|
8442 CleanupStack::PopAndDestroy( id ); |
|
8443 |
|
8444 return returnValue; |
|
8445 } |
|
8446 |
|
8447 // ----------------------------------------------------------------------------- |
|
8448 // CXnUiEngineImpl::FindNodeByIdL() |
|
8449 // ----------------------------------------------------------------------------- |
|
8450 // |
|
8451 CXnNode* CXnUiEngineImpl::FindNodeByIdL( const TDesC8& aAreaId, |
|
8452 const TDesC8& aNamespace ) |
|
8453 { |
|
8454 // Find the namespace where to start node id look-up |
|
8455 CXnViewData& active( iViewManager.ActiveViewData() ); |
|
8456 |
|
8457 CXnPluginData* pluginData( active.Plugin( aNamespace ) ); |
|
8458 |
|
8459 if ( aNamespace != KNullDesC8 && !pluginData ) |
|
8460 { |
|
8461 RPointerArray< CXnPluginData >& views( |
|
8462 iViewManager.ActiveAppData().PluginData() ); |
|
8463 |
|
8464 for ( TInt i = 0; i < views.Count(); i++ ) |
|
8465 { |
|
8466 CXnViewData* view = static_cast< CXnViewData* >( views[i] ); |
|
8467 |
|
8468 if ( view != &active ) |
|
8469 { |
|
8470 pluginData = view->Plugin( aNamespace ); |
|
8471 |
|
8472 if ( pluginData ) |
|
8473 { |
|
8474 break; |
|
8475 } |
|
8476 } |
|
8477 } |
|
8478 } |
|
8479 |
|
8480 if ( !pluginData ) |
|
8481 { |
|
8482 return NULL; |
|
8483 } |
|
8484 |
|
8485 CXnNode* root( pluginData->Node()->LayoutNode() ); |
|
8486 |
|
8487 return ::FindNodeByIdL( root, aAreaId, aNamespace ); |
|
8488 } |
|
8489 |
|
8490 // ----------------------------------------------------------------------------- |
|
8491 // CXnUiEngineImpl::FindNodeByClassL() |
|
8492 // ----------------------------------------------------------------------------- |
|
8493 // |
|
8494 CXnPointerArray* CXnUiEngineImpl::FindNodeByClassL( |
|
8495 const TDesC& aClassId, const TDesC& aNamespace ) |
|
8496 { |
|
8497 HBufC8* classId = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aClassId ); |
|
8498 CleanupStack::PushL( classId ); |
|
8499 |
|
8500 HBufC8* ns = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aNamespace ); |
|
8501 CleanupStack::PushL( ns ); |
|
8502 |
|
8503 CXnPointerArray* returnValue( FindNodeByClassL( *classId, *ns ) ); |
|
8504 |
|
8505 CleanupStack::PopAndDestroy( ns ); |
|
8506 CleanupStack::PopAndDestroy( classId ); |
|
8507 |
|
8508 return returnValue; |
|
8509 } |
|
8510 |
|
8511 // ----------------------------------------------------------------------------- |
|
8512 // CXnUiEngineImpl::FindNodeByClassL() |
|
8513 // ----------------------------------------------------------------------------- |
|
8514 // |
|
8515 CXnPointerArray* CXnUiEngineImpl::FindNodeByClassL( |
|
8516 const TDesC8& aClassId, const TDesC8& aNamespace ) |
|
8517 { |
|
8518 // Find the namespace where to start node class look-up |
|
8519 CXnViewData& active( iViewManager.ActiveViewData() ); |
|
8520 |
|
8521 CXnPluginData* pluginData( active.Plugin( aNamespace ) ); |
|
8522 |
|
8523 if ( aNamespace != KNullDesC8 && !pluginData ) |
|
8524 { |
|
8525 RPointerArray< CXnPluginData >& views( |
|
8526 iViewManager.ActiveAppData().PluginData() ); |
|
8527 |
|
8528 for ( TInt i = 0; i < views.Count(); i++ ) |
|
8529 { |
|
8530 CXnViewData* view = static_cast< CXnViewData* >( views[i] ); |
|
8531 |
|
8532 if ( view != &active ) |
|
8533 { |
|
8534 pluginData = view->Plugin( aNamespace ); |
|
8535 |
|
8536 if ( pluginData ) |
|
8537 { |
|
8538 break; |
|
8539 } |
|
8540 } |
|
8541 } |
|
8542 } |
|
8543 |
|
8544 CXnPointerArray* array = CXnPointerArray::NewL(); |
|
8545 CleanupStack::PushL( array ); |
|
8546 |
|
8547 if ( pluginData ) |
|
8548 { |
|
8549 CXnNode* root( pluginData->Node()->LayoutNode() ); |
|
8550 ::FindNodeByClassL( root, aClassId, *array, aNamespace ); |
|
8551 } |
|
8552 |
|
8553 CleanupStack::Pop( array ); |
|
8554 |
|
8555 return array; |
|
8556 } |
|
8557 |
|
8558 // ----------------------------------------------------------------------------- |
|
8559 // CXnUiEngineImpl::FindContentSourceNodesL() |
|
8560 // ----------------------------------------------------------------------------- |
|
8561 // |
|
8562 CXnPointerArray* CXnUiEngineImpl::FindContentSourceNodesL( |
|
8563 const TDesC8& aNamespace ) |
|
8564 { |
|
8565 CXnViewData& active( iViewManager.ActiveViewData() ); |
|
8566 |
|
8567 CXnPluginData* pluginData( active.Plugin( aNamespace ) ); |
|
8568 |
|
8569 if ( aNamespace != KNullDesC8 && !pluginData ) |
|
8570 { |
|
8571 RPointerArray< CXnPluginData >& views( |
|
8572 iViewManager.ActiveAppData().PluginData() ); |
|
8573 |
|
8574 for ( TInt i = 0; i < views.Count(); i++ ) |
|
8575 { |
|
8576 CXnViewData* view = static_cast< CXnViewData* >( views[i] ); |
|
8577 |
|
8578 if ( view != &active ) |
|
8579 { |
|
8580 pluginData = view->Plugin( aNamespace ); |
|
8581 |
|
8582 if ( pluginData ) |
|
8583 { |
|
8584 break; |
|
8585 } |
|
8586 } |
|
8587 } |
|
8588 } |
|
8589 |
|
8590 CXnPointerArray* array = CXnPointerArray::NewL(); |
|
8591 CleanupStack::PushL( array ); |
|
8592 |
|
8593 if ( pluginData ) |
|
8594 { |
|
8595 RPointerArray< CXnNode > list; |
|
8596 CleanupClosePushL( list ); |
|
8597 |
|
8598 pluginData->ContentSourceNodesL( list ); |
|
8599 |
|
8600 const TInt count( list.Count() ); |
|
8601 |
|
8602 array->Container().ReserveL( count ); |
|
8603 |
|
8604 for ( TInt i = 0; i < count; i++ ) |
|
8605 { |
|
8606 array->Container().Append( list[i] ); |
|
8607 } |
|
8608 |
|
8609 CleanupStack::PopAndDestroy( &list ); |
|
8610 } |
|
8611 |
|
8612 CleanupStack::Pop( array ); |
|
8613 |
|
8614 return array; |
|
8615 } |
|
8616 |
|
8617 // ----------------------------------------------------------------------------- |
|
8618 // CXnUiEngineImpl::Resources() |
|
8619 // ----------------------------------------------------------------------------- |
|
8620 // |
|
8621 CArrayPtrSeg< CXnResource >& CXnUiEngineImpl::Resources() |
|
8622 { |
|
8623 return iViewManager.Resources(); |
|
8624 } |
|
8625 |
|
8626 // ----------------------------------------------------------------------------- |
|
8627 // CXnUiEngineImpl::SetFocusedNodeL() |
|
8628 // ----------------------------------------------------------------------------- |
|
8629 // |
|
8630 void CXnUiEngineImpl::SetFocusedNodeL( CXnNode* aFocusedNode, TInt aSource ) |
|
8631 { |
|
8632 if ( iKeyEventDispatcher ) |
|
8633 { |
|
8634 iKeyEventDispatcher->SetNodeL( aFocusedNode, aSource ); |
|
8635 } |
|
8636 } |
|
8637 |
|
8638 // ----------------------------------------------------------------------------- |
|
8639 // CXnUiEngine::FocusedNode |
|
8640 // Forwards the call to the ui engine implementation |
|
8641 // ----------------------------------------------------------------------------- |
|
8642 // |
|
8643 CXnNode* CXnUiEngineImpl::FocusedNode() |
|
8644 { |
|
8645 if ( iKeyEventDispatcher ) |
|
8646 { |
|
8647 return iKeyEventDispatcher->FocusedNode(); |
|
8648 } |
|
8649 |
|
8650 return NULL; |
|
8651 } |
|
8652 |
|
8653 // ----------------------------------------------------------------------------- |
|
8654 // CXnUiEngineImpl::IsEditMode |
|
8655 // Returns ETrue if the current mode is edit, otherwise EFalse. |
|
8656 // ----------------------------------------------------------------------------- |
|
8657 // |
|
8658 TBool CXnUiEngineImpl::IsEditMode() |
|
8659 { |
|
8660 return ( iEditMode->EditState() != CXnEditMode::ENone ); |
|
8661 } |
|
8662 |
|
8663 // ----------------------------------------------------------------------------- |
|
8664 // CXnUiEngineImpl::NotifyViewActivatedL() |
|
8665 // ----------------------------------------------------------------------------- |
|
8666 // |
|
8667 void CXnUiEngineImpl::NotifyViewActivatedL( const CXnViewData& /*aViewData*/ ) |
|
8668 { |
|
8669 iCurrentView = iViewManager.ViewNode(); |
|
8670 |
|
8671 iControlAdapterList = &iViewManager.Controls(); |
|
8672 iCurrentViewControlAdapter = iCurrentView->Control(); |
|
8673 |
|
8674 iDirtyList.Reset(); |
|
8675 |
|
8676 iRedrawRegions.ResetAndDestroy(); |
|
8677 |
|
8678 // Remove previous menubar and stylus popup node |
|
8679 iMenuNode = NULL; |
|
8680 iStylusPopupNode = NULL; |
|
8681 |
|
8682 if ( iKeyEventDispatcher ) |
|
8683 { |
|
8684 iKeyEventDispatcher->ResetMenuNodeL(); |
|
8685 } |
|
8686 |
|
8687 RPointerArray< CXnNode >& children( iCurrentView->Children() ); |
|
8688 |
|
8689 for ( TInt count = children.Count() - 1; count >= 0 ; --count ) |
|
8690 { |
|
8691 CXnNode* node( children[count] ); |
|
8692 |
|
8693 // Check that the given type of a control is parent |
|
8694 // (or ancestor) of this control |
|
8695 const TDesC8& type( node->Type()->Type() ); |
|
8696 |
|
8697 if ( type == KXnMenuBar ) |
|
8698 { |
|
8699 iMenuNode = node; |
|
8700 XnMenuInterface::MXnMenuInterface* menuIf( NULL ); |
|
8701 XnComponentInterface::MakeInterfaceL( menuIf, node->AppIfL() ); |
|
8702 if ( menuIf ) |
|
8703 { |
|
8704 menuIf->SetObserver( *this ); |
|
8705 } |
|
8706 } |
|
8707 else if ( type == _L8("styluspopup") ) |
|
8708 { |
|
8709 iStylusPopupNode = node; |
|
8710 |
|
8711 static_cast< CXnPopupControlAdapter* > |
|
8712 ( node->Control() )->SetObserver( *this ); |
|
8713 } |
|
8714 } |
|
8715 |
|
8716 ReportScreenDeviceChangeL(); |
|
8717 |
|
8718 SetClientRectL( iAppUiAdapter.ClientRect(), EFalse ); |
|
8719 |
|
8720 RootNode()->SetDirtyL(); |
|
8721 |
|
8722 ForceRenderUIL(); |
|
8723 |
|
8724 iLayoutControl &= ~XnLayoutControl::ERefreshMenu; |
|
8725 } |
|
8726 |
|
8727 // ----------------------------------------------------------------------------- |
|
8728 // CXnUiEngineImpl::NotifyWidgetAdditionL() |
|
8729 // ----------------------------------------------------------------------------- |
|
8730 // |
|
8731 void CXnUiEngineImpl::NotifyWidgetAdditionL( |
|
8732 const CXnPluginData& /*aPluginData*/ ) |
|
8733 { |
|
8734 } |
|
8735 |
|
8736 // ----------------------------------------------------------------------------- |
|
8737 // CXnUiEngineImpl::DynInitMenuItemL() |
|
8738 // ----------------------------------------------------------------------------- |
|
8739 // |
|
8740 TBool CXnUiEngineImpl::DynInitMenuItemL( CXnNodeAppIf& aMenuItem, |
|
8741 CXnNodeAppIf* aPlugin ) |
|
8742 { |
|
8743 // dynamic menuitem types reserved for HS internal use, |
|
8744 // internal menuitems' origin must be in active view namespace |
|
8745 _LIT( KAddWidget, "hs_add_widget" ); |
|
8746 _LIT( KRemoveWidget, "hs_remove_widget" ); |
|
8747 _LIT( KAddView, "hs_add_view" ); |
|
8748 _LIT( KRemoveView, "hs_remove_view" ); |
|
8749 _LIT( KOnline, "hs_online" ); |
|
8750 _LIT( KOffline, "hs_offline" ); |
|
8751 |
|
8752 CXnProperty* prop( |
|
8753 aMenuItem.GetPropertyL( XnPropertyNames::menu::KItemType ) ); |
|
8754 |
|
8755 TBool retval( EFalse ); |
|
8756 |
|
8757 if( !prop ) |
|
8758 { |
|
8759 // No type defined, declaration error |
|
8760 return retval; |
|
8761 } |
|
8762 |
|
8763 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
8764 |
|
8765 TInt viewAmount( iViewManager.ViewAmount() ); |
|
8766 |
|
8767 // Check if the menuitem is in view namespace |
|
8768 TBool internal( aMenuItem.Namespace() == ActiveView()->Namespace() ); |
|
8769 |
|
8770 HBufC* itemType( prop->StringValueL() ); |
|
8771 CleanupStack::PushL( itemType ); |
|
8772 |
|
8773 if ( internal ) |
|
8774 { |
|
8775 if ( *itemType == KAddWidget ) |
|
8776 { |
|
8777 if ( aPlugin && &aPlugin->Node() ) |
|
8778 { |
|
8779 CXnPluginData* data( viewData.Plugin( &aPlugin->Node() ) ); |
|
8780 |
|
8781 if ( data && !data->Occupied() ) |
|
8782 { |
|
8783 retval = ETrue; |
|
8784 } |
|
8785 } |
|
8786 } |
|
8787 else if ( *itemType == KRemoveWidget ) |
|
8788 { |
|
8789 CXnNode* node( ( aPlugin ) ? &aPlugin->Node() : FocusedNode() ); |
|
8790 |
|
8791 if ( node ) |
|
8792 { |
|
8793 CXnPluginData* data( viewData.Plugin( node ) ); |
|
8794 |
|
8795 if ( data && data->Removable() && data->Occupied() ) |
|
8796 { |
|
8797 retval = ETrue; |
|
8798 } |
|
8799 } |
|
8800 } |
|
8801 else if ( *itemType == KAddView ) |
|
8802 { |
|
8803 // checks Max pages value - from RootData |
|
8804 if ( viewAmount < iViewManager.MaxPages() ) |
|
8805 { |
|
8806 retval = ETrue; |
|
8807 } |
|
8808 } |
|
8809 else if ( *itemType == KRemoveView ) |
|
8810 { |
|
8811 if ( viewData.Removable() && viewAmount > 1 ) |
|
8812 { |
|
8813 retval = ETrue; |
|
8814 } |
|
8815 } |
|
8816 else if ( *itemType == KOnline || *itemType == KOffline ) |
|
8817 { |
|
8818 retval = iAppUiAdapter.DynInitMenuItemL( *itemType ); |
|
8819 } |
|
8820 } |
|
8821 else |
|
8822 { |
|
8823 const TDesC8& ns( aMenuItem.Namespace() ); |
|
8824 |
|
8825 CXnPluginData* data( viewData.Plugin( ns ) ); |
|
8826 |
|
8827 if ( data ) |
|
8828 { |
|
8829 RPointerArray< CXnNode > nodes; |
|
8830 CleanupClosePushL( nodes ); |
|
8831 |
|
8832 data->ContentSourceNodesL( nodes ); |
|
8833 |
|
8834 RPointerArray< CXnNodeAppIf > list; |
|
8835 CleanupClosePushL( list ); |
|
8836 |
|
8837 for ( TInt i = 0; i < nodes.Count(); i++ ) |
|
8838 { |
|
8839 list.AppendL( &nodes[i]->AppIfL() ); |
|
8840 } |
|
8841 |
|
8842 retval = iAppUiAdapter.DynInitMenuItemL( *itemType, &list ); |
|
8843 |
|
8844 CleanupStack::PopAndDestroy( 2, &nodes ); // list |
|
8845 } |
|
8846 } |
|
8847 |
|
8848 CleanupStack::PopAndDestroy( itemType ); |
|
8849 |
|
8850 return retval; |
|
8851 } |
|
8852 |
|
8853 // ----------------------------------------------------------------------------- |
|
8854 // CXnUiEngineImpl::VerticalPixelValueL() |
|
8855 // ----------------------------------------------------------------------------- |
|
8856 // |
|
8857 TInt CXnUiEngineImpl::VerticalPixelValueL( |
|
8858 CXnProperty* aValue, TInt aReferenceValue ) |
|
8859 { |
|
8860 return ::VerticalPixelValueL( aValue, aReferenceValue, |
|
8861 *iCurrentGraphicsDevice, iVerticalUnitInPixels ); |
|
8862 } |
|
8863 |
|
8864 // ----------------------------------------------------------------------------- |
|
8865 // CXnUiEngineImpl::HorizontalPixelValueL() |
|
8866 // ----------------------------------------------------------------------------- |
|
8867 // |
|
8868 TInt CXnUiEngineImpl::HorizontalPixelValueL( |
|
8869 CXnProperty* aValue, TInt aReferenceValue ) |
|
8870 { |
|
8871 return ::HorizontalPixelValueL( aValue, aReferenceValue, |
|
8872 *iCurrentGraphicsDevice, iHorizontalUnitInPixels ); |
|
8873 } |
|
8874 |
|
8875 // ----------------------------------------------------------------------------- |
|
8876 // CXnUiEngineImpl::VerticalTwipValueL() |
|
8877 // ----------------------------------------------------------------------------- |
|
8878 // |
|
8879 TInt CXnUiEngineImpl::VerticalTwipValueL( CXnProperty* aValue, |
|
8880 TInt aReferenceValue ) |
|
8881 { |
|
8882 return iCurrentGraphicsDevice->VerticalPixelsToTwips( |
|
8883 VerticalPixelValueL( aValue, aReferenceValue ) ); |
|
8884 } |
|
8885 |
|
8886 // ----------------------------------------------------------------------------- |
|
8887 // CXnUiEngineImpl::HorizontalTwipValueL() |
|
8888 // ----------------------------------------------------------------------------- |
|
8889 // |
|
8890 TInt CXnUiEngineImpl::HorizontalTwipValueL( CXnProperty* aValue, |
|
8891 TInt aReferenceValue ) |
|
8892 { |
|
8893 return iCurrentGraphicsDevice->HorizontalPixelsToTwips( |
|
8894 HorizontalPixelValueL( aValue, aReferenceValue ) ); |
|
8895 } |
|
8896 |
|
8897 // ----------------------------------------------------------------------------- |
|
8898 // CXnUiEngineImpl::ViewManager() |
|
8899 // ----------------------------------------------------------------------------- |
|
8900 // |
|
8901 CXnViewManager* CXnUiEngineImpl::ViewManager() |
|
8902 { |
|
8903 return &iViewManager; |
|
8904 } |
|
8905 |
|
8906 // ----------------------------------------------------------------------------- |
|
8907 // CXnUiEngineImpl::ActiveView() |
|
8908 // ----------------------------------------------------------------------------- |
|
8909 // |
|
8910 CXnNode* CXnUiEngineImpl::ActiveView() |
|
8911 { |
|
8912 return iViewManager.ViewNode(); |
|
8913 } |
|
8914 |
|
8915 // ----------------------------------------------------------------------------- |
|
8916 // CXnUiEngineImpl::RefreshMenuL |
|
8917 // Refresh current menu |
|
8918 // ----------------------------------------------------------------------------- |
|
8919 // |
|
8920 void CXnUiEngineImpl::RefreshMenuL() |
|
8921 { |
|
8922 if ( IsLayoutDisabled() ) |
|
8923 { |
|
8924 return; |
|
8925 } |
|
8926 |
|
8927 if ( iLayoutControl & XnLayoutControl::ERefreshMenu ) |
|
8928 { |
|
8929 if ( iKeyEventDispatcher ) |
|
8930 { |
|
8931 iLayoutControl &= ~XnLayoutControl::ERefreshMenu; |
|
8932 iKeyEventDispatcher->RefreshMenuL(); |
|
8933 } |
|
8934 } |
|
8935 } |
|
8936 |
|
8937 // ----------------------------------------------------------------------------- |
|
8938 // CXnUiEngineImpl::AddDirtyNodeL |
|
8939 // Add a dirty node. This method must be called via CXnNode SetDirtyL |
|
8940 // ----------------------------------------------------------------------------- |
|
8941 // |
|
8942 void CXnUiEngineImpl::AddDirtyNodeL( CXnNode* aNode, TInt aLevel ) |
|
8943 { |
|
8944 CXnViewData& data( iViewManager.ActiveViewData() ); |
|
8945 |
|
8946 if ( !aNode || ( aNode != RootNode() && !data.Plugin( aNode->Namespace() ) ) ) |
|
8947 { |
|
8948 // No node, or node doesn't belong to active view namespace |
|
8949 return; |
|
8950 } |
|
8951 |
|
8952 if ( aNode->Type()->Type() == KMenuBar ) |
|
8953 { |
|
8954 iLayoutControl |= XnLayoutControl::ERefreshMenu; |
|
8955 return; |
|
8956 } |
|
8957 |
|
8958 if ( iLayoutControl & XnLayoutControl::EViewDirty ) |
|
8959 { |
|
8960 // nothing to do |
|
8961 return; |
|
8962 } |
|
8963 |
|
8964 if ( aLevel == XnDirtyLevel::ERender ) |
|
8965 { |
|
8966 if( aNode == RootNode() ) |
|
8967 { |
|
8968 TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView ); |
|
8969 if( dirtyRegion ) |
|
8970 { |
|
8971 dirtyRegion->iRegion.Clear(); |
|
8972 } |
|
8973 aNode = iCurrentView; |
|
8974 } |
|
8975 |
|
8976 // Add to redraw list |
|
8977 AddToRedrawListL( aNode ); |
|
8978 } |
|
8979 else |
|
8980 { |
|
8981 // Add to dirty list for relayout and redraw |
|
8982 AddToDirtyListL( aNode ); |
|
8983 } |
|
8984 } |
|
8985 |
|
8986 // ----------------------------------------------------------------------------- |
|
8987 // CXnUiEngineImpl::ScreenDeviceSize |
|
8988 // Get the size of the current screen device |
|
8989 // ----------------------------------------------------------------------------- |
|
8990 // |
|
8991 TSize CXnUiEngineImpl::ScreenDeviceSize() const |
|
8992 { |
|
8993 if ( iCurrentGraphicsDevice ) |
|
8994 { |
|
8995 return iCurrentGraphicsDevice->SizeInPixels(); |
|
8996 } |
|
8997 |
|
8998 return TSize( 0, 0 ); |
|
8999 } |
|
9000 |
|
9001 // ----------------------------------------------------------------------------- |
|
9002 // CXnUiEngineImpl::IsDialogDisplaying |
|
9003 // Whether the dialog is displaying or not. |
|
9004 // ----------------------------------------------------------------------------- |
|
9005 // |
|
9006 TBool CXnUiEngineImpl::IsDialogDisplaying() |
|
9007 { |
|
9008 return iAppUiAdapter.IsDisplayingControlBetweenPriorities( |
|
9009 ECoeStackPriorityDialog - 1, KXnStackPriorityKeyEventDispatcher - 1 ); |
|
9010 } |
|
9011 |
|
9012 // ----------------------------------------------------------------------------- |
|
9013 // CXnUiEngineImpl::HandleResourceChangeL |
|
9014 // Handles a change to the control's resources of type aType |
|
9015 // ----------------------------------------------------------------------------- |
|
9016 // |
|
9017 void CXnUiEngineImpl::HandleResourceChangeL( TInt aType ) |
|
9018 { |
|
9019 if ( iMenuNode ) |
|
9020 { |
|
9021 CXnControlAdapter* adapter( iMenuNode->Control() ); |
|
9022 |
|
9023 if ( adapter ) |
|
9024 { |
|
9025 adapter->HandleResourceChange( aType ); |
|
9026 } |
|
9027 } |
|
9028 |
|
9029 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
9030 { |
|
9031 HandleDynamicLayoutVariantSwitchL(); |
|
9032 } |
|
9033 else if ( aType == KAknsMessageSkinChange ) |
|
9034 { |
|
9035 HandleSkinChangeL(); |
|
9036 } |
|
9037 else if( iCurrentViewControlAdapter ) |
|
9038 { |
|
9039 iCurrentViewControlAdapter->HandleResourceChange( aType ); |
|
9040 } |
|
9041 } |
|
9042 |
|
9043 // ----------------------------------------------------------------------------- |
|
9044 // CXnUiEngineImpl::HandleSkinChangeL |
|
9045 // Handles a skin change to the controls |
|
9046 // ----------------------------------------------------------------------------- |
|
9047 // |
|
9048 void CXnUiEngineImpl::HandleSkinChangeL() |
|
9049 { |
|
9050 // Force relayout |
|
9051 DisableRenderUiLC(); |
|
9052 |
|
9053 RootNode()->SetDirtyL(); |
|
9054 |
|
9055 for ( TInt i = 0; i < iControlAdapterList->Count(); i++ ) |
|
9056 { |
|
9057 CXnControlAdapter* adapter( ( *iControlAdapterList )[i] ); |
|
9058 adapter->SkinChanged(); |
|
9059 } |
|
9060 |
|
9061 ForceRenderUIL(); |
|
9062 |
|
9063 CleanupStack::PopAndDestroy(); |
|
9064 |
|
9065 // Handle inactive views |
|
9066 RPointerArray< CXnPluginData >& views( |
|
9067 iAppUiAdapter.ViewManager().ActiveAppData().PluginData() ); |
|
9068 |
|
9069 for ( TInt i = 0; i < views.Count(); i++ ) |
|
9070 { |
|
9071 CXnViewData* view = static_cast< CXnViewData* >( views[i] ); |
|
9072 if ( view && !view->Active() ) |
|
9073 { |
|
9074 RPointerArray< CXnControlAdapter > controls; |
|
9075 CleanupClosePushL( controls ); |
|
9076 view->ControlsL( controls ); |
|
9077 for ( TInt j = 0; j < controls.Count(); j++ ) |
|
9078 { |
|
9079 controls[j]->SkinChanged(); |
|
9080 } |
|
9081 CleanupStack::PopAndDestroy( &controls ); |
|
9082 } |
|
9083 } |
|
9084 } |
|
9085 |
|
9086 // ----------------------------------------------------------------------------- |
|
9087 // CXnUiEngineImpl::HandleDynamicLayoutVariantSwitchL |
|
9088 // Handles a KEikDynamicLayoutVariantSwitch resource change |
|
9089 // ----------------------------------------------------------------------------- |
|
9090 // |
|
9091 void CXnUiEngineImpl::HandleDynamicLayoutVariantSwitchL() |
|
9092 { |
|
9093 // Must return here if there is no current view or |
|
9094 // controladapterlist. This may occur when the phone |
|
9095 // is booted for the first time and the location/date |
|
9096 // query is visible. |
|
9097 if ( !ActiveView() ) |
|
9098 { |
|
9099 return; |
|
9100 } |
|
9101 |
|
9102 // remove focus |
|
9103 iAppUiAdapter.HideFocus(); |
|
9104 |
|
9105 // Update client rect |
|
9106 SetClientRectL( iAppUiAdapter.ClientRect(), EFalse ); |
|
9107 |
|
9108 // Update background rect |
|
9109 // Bg rect is always screen size. |
|
9110 TRect bgRect; |
|
9111 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect ); |
|
9112 iAppUiAdapter.ViewAdapter().BgManager().SetRect( bgRect ); |
|
9113 |
|
9114 iEditMode->HandleScreenDeviceChangedL(); |
|
9115 |
|
9116 // Force relayout |
|
9117 DisableRenderUiLC(); |
|
9118 |
|
9119 RootNode()->SetDirtyL(); |
|
9120 |
|
9121 ReportScreenDeviceChangeL(); |
|
9122 |
|
9123 iAppUiAdapter.EffectManager()->OrientationChanged(); |
|
9124 |
|
9125 if ( !iControlAdapterList ) |
|
9126 { |
|
9127 iControlAdapterList = &iViewManager.Controls(); |
|
9128 } |
|
9129 for ( TInt i = 0; i < iControlAdapterList->Count(); i++ ) |
|
9130 { |
|
9131 CXnControlAdapter* adapter( ( *iControlAdapterList )[i] ); |
|
9132 |
|
9133 adapter->HandleScreenDeviceChangedL(); |
|
9134 } |
|
9135 |
|
9136 ForceRenderUIL(); |
|
9137 |
|
9138 CleanupStack::PopAndDestroy(); |
|
9139 } |
|
9140 |
|
9141 // ----------------------------------------------------------------------------- |
|
9142 // CXnUiEngineImpl::IsMenuDisplaying |
|
9143 // Checks whether the menu is displaying or not. |
|
9144 // ----------------------------------------------------------------------------- |
|
9145 // |
|
9146 TBool CXnUiEngineImpl::IsMenuDisplaying() |
|
9147 { |
|
9148 if ( iKeyEventDispatcher ) |
|
9149 { |
|
9150 return iKeyEventDispatcher->IsMenuFocused(); |
|
9151 } |
|
9152 |
|
9153 return EFalse; |
|
9154 } |
|
9155 |
|
9156 // ----------------------------------------------------------------------------- |
|
9157 // CXnUiEngineImpl::MenubarNode |
|
9158 // Returns menubar node |
|
9159 // ----------------------------------------------------------------------------- |
|
9160 // |
|
9161 CXnNode* CXnUiEngineImpl::MenuBarNode() const |
|
9162 { |
|
9163 return iMenuNode; |
|
9164 } |
|
9165 |
|
9166 // ----------------------------------------------------------------------------- |
|
9167 // CXnUiEngineImpl::StylusPopupNode |
|
9168 // Returns stylus popup node |
|
9169 // ----------------------------------------------------------------------------- |
|
9170 // |
|
9171 CXnNode* CXnUiEngineImpl::StylusPopupNode() const |
|
9172 { |
|
9173 return iStylusPopupNode; |
|
9174 } |
|
9175 |
|
9176 // ----------------------------------------------------------------------------- |
|
9177 // CXnUiEngineImpl::AddPassiveFocusedNode |
|
9178 // ----------------------------------------------------------------------------- |
|
9179 // |
|
9180 void CXnUiEngineImpl::AddPassiveFocusedNodeL( CXnNode* aNode ) |
|
9181 { |
|
9182 if ( iKeyEventDispatcher ) |
|
9183 { |
|
9184 iKeyEventDispatcher->AddPassiveFocusedNodeL( aNode ); |
|
9185 } |
|
9186 } |
|
9187 |
|
9188 // ----------------------------------------------------------------------------- |
|
9189 // CXnUiEngineImpl::RemovePassiveFocusedNode |
|
9190 // ----------------------------------------------------------------------------- |
|
9191 // |
|
9192 void CXnUiEngineImpl::RemovePassiveFocusedNodeL( CXnNode* aNode ) |
|
9193 { |
|
9194 if ( iKeyEventDispatcher ) |
|
9195 { |
|
9196 iKeyEventDispatcher->RemovePassiveFocusedNodeL( aNode ); |
|
9197 } |
|
9198 } |
|
9199 |
|
9200 // ----------------------------------------------------------------------------- |
|
9201 // CXnUiEngineImpl::AddPassiveFocusedNode |
|
9202 // ----------------------------------------------------------------------------- |
|
9203 // |
|
9204 void CXnUiEngineImpl::ClearPassiveFocusedNodesL() |
|
9205 { |
|
9206 if ( iKeyEventDispatcher ) |
|
9207 { |
|
9208 iKeyEventDispatcher->ClearPassiveFocusedNodesL(); |
|
9209 } |
|
9210 } |
|
9211 |
|
9212 // ----------------------------------------------------------------------------- |
|
9213 // SetNodeDroppedL() |
|
9214 // Sets node's dropped state |
|
9215 // ----------------------------------------------------------------------------- |
|
9216 // |
|
9217 void CXnUiEngineImpl::SetNodeDroppedL( CXnNode& aNode, TInt aDropped ) const |
|
9218 { |
|
9219 if ( aDropped != XnNodeLayout::ENone ) |
|
9220 { |
|
9221 CXnNode* parent( aNode.Parent() ); |
|
9222 TInt parentAdaptive( parent->IsAdaptive( ETrue ) ); |
|
9223 |
|
9224 if ( iLayoutPhase == XnLayoutPhase::EMeasure ) |
|
9225 { |
|
9226 if ( !parentAdaptive ) |
|
9227 { |
|
9228 // Only adaptive childs can be dropped during measure phase |
|
9229 return; |
|
9230 } |
|
9231 } |
|
9232 |
|
9233 #ifdef _XN3_DEBUG_ |
|
9234 CXnProperty* id( aNode.IdL() ); |
|
9235 |
|
9236 if ( id ) |
|
9237 { |
|
9238 TBuf8< 256 > debug; |
|
9239 debug.Append( _L8( "Node id: " ) ); |
|
9240 debug.Append( id->StringValue() ); |
|
9241 debug.Append( _L8( " will be set to dropped" ) ); |
|
9242 RDebug::RawPrint( debug ); |
|
9243 } |
|
9244 #endif |
|
9245 |
|
9246 // Node will be dropped |
|
9247 aNode.SetDropped( aDropped ); |
|
9248 |
|
9249 // Get ride of its rects |
|
9250 ClearRects( aNode ); |
|
9251 |
|
9252 if ( parentAdaptive ) |
|
9253 { |
|
9254 // Is there adaptive content left after dropping? |
|
9255 CheckAdaptiveContentL( *parent, parent->Rect().Size() ); |
|
9256 } |
|
9257 } |
|
9258 else |
|
9259 { |
|
9260 // Node is no more dropped |
|
9261 aNode.SetDropped( aDropped ); |
|
9262 } |
|
9263 } |
|
9264 |
|
9265 // ----------------------------------------------------------------------------- |
|
9266 // CheckAdaptiveContentL() |
|
9267 // Checks if node is adaptive, but doesn't have any content |
|
9268 // ----------------------------------------------------------------------------- |
|
9269 // |
|
9270 void CXnUiEngineImpl::CheckAdaptiveContentL( |
|
9271 CXnNode& aNode, TSize aAvailableSize ) const |
|
9272 { |
|
9273 TInt adaptive( aNode.IsAdaptive( ETrue ) ); |
|
9274 TBool isEmpty( EFalse ); |
|
9275 |
|
9276 if ( adaptive ) |
|
9277 { |
|
9278 if ( aAvailableSize == TSize::EUninitialized ) |
|
9279 { |
|
9280 // Use max available size |
|
9281 aAvailableSize = ScreenDeviceSize(); |
|
9282 } |
|
9283 |
|
9284 const TDesC8& name( aNode.Type()->Type() ); |
|
9285 |
|
9286 if ( name == KBoxNodeName || name == KButtonNodeName ) |
|
9287 { |
|
9288 RPointerArray< CXnNode > displayedChildren; |
|
9289 CleanupClosePushL( displayedChildren ); |
|
9290 |
|
9291 TInt displayedCount( DisplayedChildrenCountL( |
|
9292 aNode, &displayedChildren ) ); |
|
9293 |
|
9294 if ( displayedCount == 0 ) |
|
9295 { |
|
9296 isEmpty = ETrue; |
|
9297 } |
|
9298 else |
|
9299 { |
|
9300 for ( TInt i = 0; i < displayedChildren.Count(); i++ ) |
|
9301 { |
|
9302 CheckAdaptiveContentL( *displayedChildren[i], |
|
9303 aAvailableSize ); |
|
9304 } |
|
9305 |
|
9306 if ( DisplayedChildrenCountL( aNode ) == 0 ) |
|
9307 { |
|
9308 isEmpty = ETrue; |
|
9309 } |
|
9310 } |
|
9311 |
|
9312 CleanupStack::PopAndDestroy( &displayedChildren ); |
|
9313 } |
|
9314 |
|
9315 if ( isEmpty ) |
|
9316 { |
|
9317 // No content available, drop adaptive node |
|
9318 SetNodeDroppedL( aNode, XnNodeLayout::EDropped ); |
|
9319 } |
|
9320 } |
|
9321 } |
|
9322 |
|
9323 // ----------------------------------------------------------------------------- |
|
9324 // CXnUiEngineImpl::AddFocusCandidateL |
|
9325 // ----------------------------------------------------------------------------- |
|
9326 // |
|
9327 void CXnUiEngineImpl::AddFocusCandidateL( CXnNode* aNode ) |
|
9328 { |
|
9329 if ( !aNode ) |
|
9330 { |
|
9331 return; |
|
9332 } |
|
9333 TInt index( iFocusCandidateList.Find( aNode ) ); |
|
9334 if ( index == KErrNotFound ) |
|
9335 { |
|
9336 iFocusCandidateList.AppendL( aNode ); |
|
9337 } |
|
9338 } |
|
9339 |
|
9340 // ----------------------------------------------------------------------------- |
|
9341 // CXnUiEngineImpl::IsLayoutDisabled |
|
9342 // ----------------------------------------------------------------------------- |
|
9343 // |
|
9344 TBool CXnUiEngineImpl::IsLayoutDisabled() |
|
9345 { |
|
9346 if ( !iCurrentView ) |
|
9347 { |
|
9348 return ETrue; |
|
9349 } |
|
9350 |
|
9351 TBool retval( EFalse ); |
|
9352 |
|
9353 if ( !( iLayoutControl & XnLayoutControl::EIgnoreState ) ) |
|
9354 { |
|
9355 if ( iDisableCount > 0 ) |
|
9356 { |
|
9357 retval = ETrue; |
|
9358 } |
|
9359 } |
|
9360 |
|
9361 return retval; |
|
9362 } |
|
9363 |
|
9364 // ----------------------------------------------------------------------------- |
|
9365 // AddToRedrawListL |
|
9366 // Mark Control's appearance to be redrawn |
|
9367 // ----------------------------------------------------------------------------- |
|
9368 // |
|
9369 void CXnUiEngineImpl::AddToRedrawListL( CXnNode* aNode, TRect aRect ) |
|
9370 { |
|
9371 CXnControlAdapter* aAdapter( aNode->Control() ); |
|
9372 |
|
9373 if( !aAdapter ) |
|
9374 { |
|
9375 return; |
|
9376 } |
|
9377 |
|
9378 if( aRect != TRect::EUninitialized ) |
|
9379 { |
|
9380 // This is the new rect which will be set by layout algo |
|
9381 AddRedrawRectL( aRect, *aNode ); |
|
9382 } |
|
9383 |
|
9384 TRect rect( aAdapter->Rect() ); |
|
9385 |
|
9386 if( rect == TRect::EUninitialized ) |
|
9387 { |
|
9388 // Don't add uninitialized rect |
|
9389 return; |
|
9390 } |
|
9391 |
|
9392 /* |
|
9393 if( aNode->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
9394 { |
|
9395 const TDesC8& name( aNode->DomNode()->Name() ); |
|
9396 |
|
9397 if( name == KPlugin ) |
|
9398 { |
|
9399 rect.Grow( KFocusGrowValue, KFocusGrowValue ); |
|
9400 } |
|
9401 else |
|
9402 { |
|
9403 TRect marginRect( aNode->MarginRect() ); |
|
9404 |
|
9405 CXnNode* parent( aNode->Parent() ); |
|
9406 |
|
9407 for( ; parent; parent = parent->Parent() ) |
|
9408 { |
|
9409 if( parent->DomNode()->Name() == KPlugin ) |
|
9410 { |
|
9411 if( parent->Rect() == marginRect ) |
|
9412 { |
|
9413 rect.Grow( KFocusGrowValue, KFocusGrowValue ); |
|
9414 } |
|
9415 |
|
9416 break; |
|
9417 } |
|
9418 } |
|
9419 } |
|
9420 } |
|
9421 */ |
|
9422 GrowIfNeeded(aNode, rect); |
|
9423 AddRedrawRectL( rect, *aNode ); |
|
9424 } |
|
9425 |
|
9426 // ----------------------------------------------------------------------------- |
|
9427 // AddToDirtyListL |
|
9428 // Mark node to dirty list for relayout |
|
9429 // ----------------------------------------------------------------------------- |
|
9430 // |
|
9431 void CXnUiEngineImpl::AddToDirtyListL( CXnNode* aNode ) |
|
9432 { |
|
9433 |
|
9434 if ( aNode ) |
|
9435 { |
|
9436 CXnNode* nodeToRedrawList( aNode ); |
|
9437 CXnNode* nodeToDirtyList( aNode ); |
|
9438 |
|
9439 if ( aNode == RootNode() ) |
|
9440 { |
|
9441 // Force relayout and redraw from current view |
|
9442 iDirtyList.Reset(); |
|
9443 if ( !iCurrentView ) |
|
9444 { |
|
9445 iCurrentView = iViewManager.ViewNode(); |
|
9446 } |
|
9447 iDirtyList.AppendL( iCurrentView ); |
|
9448 TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView ); |
|
9449 if( dirtyRegion ) |
|
9450 { |
|
9451 dirtyRegion->iRegion.Clear(); |
|
9452 } |
|
9453 iLayoutControl |= XnLayoutControl::EViewDirty; |
|
9454 nodeToDirtyList = nodeToRedrawList = iCurrentView; |
|
9455 nodeToDirtyList->ClearRenderedAndLaidOut(); |
|
9456 |
|
9457 // Add to draw list for redraw |
|
9458 AddToRedrawListL( nodeToRedrawList ); |
|
9459 } |
|
9460 else |
|
9461 { |
|
9462 if ( !IsAbsoluteL( *aNode ) && !IsNodeTooltip( *aNode ) ) |
|
9463 { |
|
9464 // Check adaptives in normal flow |
|
9465 CXnNode* oldest( NULL ); |
|
9466 CXnNode* adaptive( aNode ); |
|
9467 |
|
9468 if ( !aNode->IsAdaptive( ETrue ) ) |
|
9469 { |
|
9470 adaptive = aNode->Parent(); |
|
9471 } |
|
9472 |
|
9473 for ( ; adaptive && adaptive->IsAdaptive( ETrue ); |
|
9474 adaptive = adaptive->Parent() ) |
|
9475 { |
|
9476 oldest = adaptive; |
|
9477 } |
|
9478 |
|
9479 // Now we have found the oldest adaptive node if present |
|
9480 if ( oldest ) |
|
9481 { |
|
9482 nodeToRedrawList = nodeToDirtyList = adaptive; |
|
9483 } |
|
9484 } |
|
9485 |
|
9486 RPointerArray< CXnNode > dirtyList; |
|
9487 CleanupClosePushL( dirtyList ); |
|
9488 TInt count( iDirtyList.Count() ); |
|
9489 TBool found; |
|
9490 |
|
9491 // first, check that aNode's children are not in the dirty array |
|
9492 for ( TInt i = 0; i < count; ++i ) |
|
9493 { |
|
9494 found = EFalse; |
|
9495 CXnNode* candidate( iDirtyList[i] ); |
|
9496 |
|
9497 for ( CXnNode* node = candidate->Parent(); node && !found; |
|
9498 node = node->Parent() ) |
|
9499 { |
|
9500 if ( nodeToDirtyList == node ) |
|
9501 { |
|
9502 found = ETrue; |
|
9503 } |
|
9504 } |
|
9505 |
|
9506 if ( !found ) |
|
9507 { |
|
9508 // Put candidate back to list as child is not found |
|
9509 dirtyList.AppendL( candidate ); |
|
9510 } |
|
9511 } |
|
9512 |
|
9513 found = EFalse; |
|
9514 |
|
9515 // second, check that aNode's parent is not in dirty array |
|
9516 for ( TInt i = 0; i < count && !found; ++i ) |
|
9517 { |
|
9518 CXnNode* candidate( iDirtyList[i] ); |
|
9519 |
|
9520 for ( CXnNode* node = nodeToDirtyList; node && !found; |
|
9521 node = node->Parent() ) |
|
9522 { |
|
9523 if ( node == candidate ) |
|
9524 { |
|
9525 found = ETrue; |
|
9526 } |
|
9527 } |
|
9528 } |
|
9529 |
|
9530 if ( !found && iDirtyList.Find( nodeToDirtyList ) == KErrNotFound ) |
|
9531 { |
|
9532 // Add node to dirty list as parent is neither found |
|
9533 dirtyList.AppendL( nodeToDirtyList ); |
|
9534 nodeToDirtyList->ClearRenderedAndLaidOut(); |
|
9535 |
|
9536 // Add to draw list for redraw |
|
9537 AddToRedrawListL( nodeToRedrawList ); |
|
9538 } |
|
9539 |
|
9540 // finally update the dirty list |
|
9541 iDirtyList.Reset(); |
|
9542 iDirtyList = dirtyList; |
|
9543 |
|
9544 CleanupStack::Pop( &dirtyList ); |
|
9545 } |
|
9546 } |
|
9547 } |
|
9548 |
|
9549 // ----------------------------------------------------------------------------- |
|
9550 // CXnUiEngineImpl::SetClientRectL |
|
9551 // ----------------------------------------------------------------------------- |
|
9552 // |
|
9553 void CXnUiEngineImpl::SetClientRectL( TRect aRect, TBool aDrawNow ) |
|
9554 { |
|
9555 if ( iClientRect != aRect ) |
|
9556 { |
|
9557 iClientRect = aRect; |
|
9558 |
|
9559 UpdateInternalUnits( iHorizontalUnitInPixels, iVerticalUnitInPixels, |
|
9560 iClientRect ); |
|
9561 |
|
9562 iEditMode->SetClientRect( aRect ); |
|
9563 |
|
9564 if ( aDrawNow ) |
|
9565 { |
|
9566 RootNode()->SetDirtyL(); |
|
9567 iUiEngine->RenderUIL(); |
|
9568 } |
|
9569 } |
|
9570 } |
|
9571 |
|
9572 // ----------------------------------------------------------------------------- |
|
9573 // CXnUiEngineImpl::ClientRect |
|
9574 // ----------------------------------------------------------------------------- |
|
9575 // |
|
9576 TRect CXnUiEngineImpl::ClientRect() const |
|
9577 { |
|
9578 return iClientRect; |
|
9579 } |
|
9580 |
|
9581 // ----------------------------------------------------------------------------- |
|
9582 // CXnUiEngineImpl::Editor |
|
9583 // ----------------------------------------------------------------------------- |
|
9584 // |
|
9585 CXnEditor* CXnUiEngineImpl::Editor()const |
|
9586 { |
|
9587 return &iViewManager.Editor(); |
|
9588 } |
|
9589 |
|
9590 // ----------------------------------------------------------------------------- |
|
9591 // CXnUiEngineImpl::EditMode |
|
9592 // ----------------------------------------------------------------------------- |
|
9593 // |
|
9594 CXnEditMode* CXnUiEngineImpl::EditMode() |
|
9595 { |
|
9596 return iEditMode; |
|
9597 } |
|
9598 |
|
9599 // ----------------------------------------------------------------------------- |
|
9600 // CXnUiEngineImpl::StartLayoutFromL |
|
9601 // ----------------------------------------------------------------------------- |
|
9602 // |
|
9603 CXnNode* CXnUiEngineImpl::StartLayoutFromL() |
|
9604 { |
|
9605 if ( iLayoutControl & XnLayoutControl::EViewDirty ) |
|
9606 { |
|
9607 return iCurrentView; |
|
9608 } |
|
9609 |
|
9610 RPointerArray< CXnNode >parentArray; |
|
9611 CleanupClosePushL( parentArray ); |
|
9612 TInt dirtyCount = iDirtyList.Count(); |
|
9613 CXnNode* startNode( NULL ); |
|
9614 |
|
9615 for ( TInt dirtyIndex = 0; dirtyIndex < dirtyCount; dirtyIndex++ ) |
|
9616 { |
|
9617 startNode = iDirtyList[dirtyIndex]; |
|
9618 |
|
9619 for ( ;startNode && startNode != iCurrentView; ) |
|
9620 { |
|
9621 parentArray.Append( startNode->Parent() ); |
|
9622 startNode = startNode->Parent(); |
|
9623 } |
|
9624 } |
|
9625 |
|
9626 TInt parentCount = parentArray.Count(); |
|
9627 |
|
9628 for ( TInt parentIndex = 0; parentIndex < parentCount; parentIndex++ ) |
|
9629 { |
|
9630 TInt parentsFound = 0; |
|
9631 |
|
9632 for ( TInt checkIndex = 0; checkIndex < parentCount; checkIndex++ ) |
|
9633 { |
|
9634 if ( parentArray[parentIndex] == parentArray[checkIndex] ) |
|
9635 { |
|
9636 parentsFound++; |
|
9637 |
|
9638 if ( parentsFound == dirtyCount ) |
|
9639 { |
|
9640 startNode = parentArray[parentIndex]; |
|
9641 CleanupStack::PopAndDestroy( &parentArray ); |
|
9642 return startNode; |
|
9643 } |
|
9644 } |
|
9645 } |
|
9646 } |
|
9647 |
|
9648 CleanupStack::PopAndDestroy( &parentArray ); |
|
9649 |
|
9650 return iCurrentView; |
|
9651 } |
|
9652 |
|
9653 // ----------------------------------------------------------------------------- |
|
9654 // CXnUiEngineImpl::Plugins |
|
9655 // ----------------------------------------------------------------------------- |
|
9656 // |
|
9657 RPointerArray< CXnNode >* CXnUiEngineImpl::Plugins() |
|
9658 { |
|
9659 return &iViewManager.PluginNodes(); |
|
9660 } |
|
9661 |
|
9662 // ----------------------------------------------------------------------------- |
|
9663 // CXnUiEngineImpl::ForceRenderUIL |
|
9664 // ----------------------------------------------------------------------------- |
|
9665 // |
|
9666 void CXnUiEngineImpl::ForceRenderUIL( TBool aLayoutOnly ) |
|
9667 { |
|
9668 iLayoutControl |= XnLayoutControl::EIgnoreState; |
|
9669 if ( aLayoutOnly ) |
|
9670 { |
|
9671 LayoutUIL(); |
|
9672 } |
|
9673 else |
|
9674 { |
|
9675 LayoutUIL(); |
|
9676 RenderUIL(); |
|
9677 } |
|
9678 iLayoutControl &= ~XnLayoutControl::EIgnoreState; |
|
9679 } |
|
9680 |
|
9681 // ----------------------------------------------------------------------------- |
|
9682 // CXnUiEngineImpl::GetThemeResource |
|
9683 // ----------------------------------------------------------------------------- |
|
9684 // |
|
9685 TInt CXnUiEngineImpl::GetThemeResource( const TDesC& aPath, RFile& aFile ) |
|
9686 { |
|
9687 TInt err = KErrNone; |
|
9688 |
|
9689 // parse file name and extension |
|
9690 TParsePtrC fileParser( aPath ); |
|
9691 TPtrC filepath = fileParser.DriveAndPath(); |
|
9692 |
|
9693 RFs session ( CCoeEnv::Static()->FsSession() ); |
|
9694 |
|
9695 // open resource file |
|
9696 session.SetSessionPath( filepath ); |
|
9697 session.ShareProtected(); |
|
9698 err = aFile.Open( session, aPath, EFileShareReadersOnly ); |
|
9699 if ( err != KErrNone ) |
|
9700 { |
|
9701 aFile.Close(); |
|
9702 } |
|
9703 |
|
9704 return err; |
|
9705 } |
|
9706 |
|
9707 // ----------------------------------------------------------------------------- |
|
9708 // CXnUiEngineImpl::AnalyseAddedWidgetL |
|
9709 // ----------------------------------------------------------------------------- |
|
9710 // |
|
9711 TBool CXnUiEngineImpl::AnalyseAddedWidgetL( CXnNode& aNode ) |
|
9712 { |
|
9713 TBool retval( ETrue ); |
|
9714 |
|
9715 // Force layout to analyse added widget's dimensions |
|
9716 ForceRenderUIL( ETrue ); |
|
9717 |
|
9718 if ( aNode.IsAdaptive( ETrue ) ) |
|
9719 { |
|
9720 // If widget place holder (plugin in view.xml) is adaptive, then |
|
9721 // we need to verify that added widget will fit to available space |
|
9722 retval = EFalse; |
|
9723 |
|
9724 CXnNode* parent( aNode.Parent() ); |
|
9725 RPointerArray< CXnNode >& children( parent->Children() ); |
|
9726 CXnProperty* prop( parent->BlockProgressionL() ); |
|
9727 |
|
9728 const TDesC8* bp( |
|
9729 &XnPropertyNames::style::common::block_progression::KTB() ); |
|
9730 |
|
9731 if ( prop ) |
|
9732 { |
|
9733 bp = &prop->StringValue(); |
|
9734 } |
|
9735 |
|
9736 prop = parent->DirectionL(); |
|
9737 |
|
9738 const TDesC8* dir( |
|
9739 &XnPropertyNames::style::common::direction::KLTR() ); |
|
9740 |
|
9741 if ( prop ) |
|
9742 { |
|
9743 // use default |
|
9744 dir = &prop->StringValue(); |
|
9745 } |
|
9746 |
|
9747 TSize space( CalculateSpaceUsedByChildrenL( children, *parent, |
|
9748 *bp, *dir, *iCurrentGraphicsDevice, iHorizontalUnitInPixels, |
|
9749 iVerticalUnitInPixels ) ); |
|
9750 |
|
9751 TSize parentSize( parent->Rect().Size() ); |
|
9752 |
|
9753 if ( *bp == XnPropertyNames::style::common::block_progression::KTB || |
|
9754 *bp == XnPropertyNames::style::common::block_progression::KBT ) |
|
9755 { |
|
9756 if ( parentSize.iHeight >= space.iHeight ) |
|
9757 { |
|
9758 retval = ETrue; |
|
9759 } |
|
9760 } |
|
9761 else // LR / RL |
|
9762 { |
|
9763 if ( parentSize.iWidth >= space.iWidth ) |
|
9764 { |
|
9765 retval = ETrue; |
|
9766 } |
|
9767 } |
|
9768 } |
|
9769 |
|
9770 return retval; |
|
9771 } |
|
9772 |
|
9773 |
|
9774 |
|
9775 // ----------------------------------------------------------------------------- |
|
9776 // CXnUiEngineImpl::NotifyWidgetRemovalL( ) |
|
9777 // Notify about widget removal |
|
9778 // ----------------------------------------------------------------------------- |
|
9779 // |
|
9780 void CXnUiEngineImpl::NotifyWidgetRemovalL( |
|
9781 const CXnPluginData& /*aPluginData*/ ) |
|
9782 { |
|
9783 } |
|
9784 |
|
9785 // ----------------------------------------------------------------------------- |
|
9786 // CXnUiEngineImpl::NotifyConfigureWidgetL( ) |
|
9787 // ----------------------------------------------------------------------------- |
|
9788 // |
|
9789 void CXnUiEngineImpl::NotifyConfigureWidgetL( |
|
9790 const CHsContentInfo& /*aContentInfo*/, CXnPluginData& /*aPluginData*/ ) |
|
9791 { |
|
9792 } |
|
9793 |
|
9794 // ----------------------------------------------------------------------------- |
|
9795 // CXnUiEngineImpl::NotifyViewDeactivatedL |
|
9796 // ----------------------------------------------------------------------------- |
|
9797 // |
|
9798 void CXnUiEngineImpl::NotifyViewDeactivatedL( |
|
9799 const CXnViewData& /*aViewData*/ ) |
|
9800 { |
|
9801 } |
|
9802 |
|
9803 // ----------------------------------------------------------------------------- |
|
9804 // ----------------------------------------------------------------------------- |
|
9805 // |
|
9806 void CXnUiEngineImpl::DisableRenderUiLC() |
|
9807 { |
|
9808 CleanupStack::PushL( TCleanupItem( EnableRenderUi, this ) ); |
|
9809 |
|
9810 iDisableCount++; |
|
9811 } |
|
9812 |
|
9813 // ----------------------------------------------------------------------------- |
|
9814 // ----------------------------------------------------------------------------- |
|
9815 // |
|
9816 EXPORT_C /* static */ void CXnUiEngineImpl::EnableRenderUi( TAny* aAny ) |
|
9817 { |
|
9818 CXnUiEngineImpl* self = static_cast< CXnUiEngineImpl* >( aAny ); |
|
9819 |
|
9820 if ( self->iDisableCount > 0 ) |
|
9821 { |
|
9822 self->iDisableCount--; |
|
9823 |
|
9824 if ( self->iDisableCount == 0 ) |
|
9825 { |
|
9826 TRAP_IGNORE( |
|
9827 // Is menu refresh pending? |
|
9828 if ( ( self->iLayoutControl & XnLayoutControl::ERefreshMenu ) && |
|
9829 !self->IsMenuDisplaying() ) |
|
9830 { |
|
9831 // RefreshMenuL will reset the state flag |
|
9832 self->RefreshMenuL(); |
|
9833 } |
|
9834 |
|
9835 // Is layout pending? |
|
9836 if ( self->iLayoutControl & XnLayoutControl::ELayoutUI ) |
|
9837 { |
|
9838 self->LayoutUIL(); |
|
9839 } |
|
9840 |
|
9841 // Is render pending? |
|
9842 if ( self->iLayoutControl & XnLayoutControl::ERenderUI ) |
|
9843 { |
|
9844 self->RenderUIL(); |
|
9845 } |
|
9846 ); |
|
9847 } |
|
9848 } |
|
9849 } |
|
9850 |
|
9851 |
|
9852 // ----------------------------------------------------------------------------- |
|
9853 // ----------------------------------------------------------------------------- |
|
9854 // |
|
9855 void CXnUiEngineImpl::ReportScreenDeviceChangeL() |
|
9856 { |
|
9857 CXnNode* trigger( BuildScreenDeviceChangeTriggerNodeLC( *iUiEngine ) ); |
|
9858 |
|
9859 // Notify current orientation to iCurrentView |
|
9860 iCurrentView->ReportXuikonEventL( *trigger ); |
|
9861 |
|
9862 // Notify also plugins |
|
9863 RPointerArray<CXnNode> plugins = *Plugins(); |
|
9864 for( TInt i=0; i<plugins.Count(); i++ ) |
|
9865 { |
|
9866 CXnNode* pluginNode = plugins[i]; |
|
9867 RPointerArray<CXnNode> pluginChildren = pluginNode->Children(); |
|
9868 for( TInt ii=0; ii<pluginChildren.Count(); ii++ ) |
|
9869 { |
|
9870 CXnDomNode* widgetNode = pluginChildren[ii]->DomNode(); |
|
9871 if( widgetNode && widgetNode->Name() == KWidgetNodeName ) |
|
9872 { |
|
9873 pluginChildren[ii]->ReportXuikonEventL( *trigger ); |
|
9874 } |
|
9875 } |
|
9876 } |
|
9877 |
|
9878 CleanupStack::PopAndDestroy(); // trigger |
|
9879 } |
|
9880 |
|
9881 // ----------------------------------------------------------------------------- |
|
9882 // CXnUiEngineImpl::HandlePartialTouchInputL() |
|
9883 // ----------------------------------------------------------------------------- |
|
9884 void CXnUiEngineImpl::HandlePartialTouchInputL( CXnNode& aNode, TBool aEnable ) |
|
9885 { |
|
9886 CXnNode* editorplugin = FindPlugin( aNode ); |
|
9887 if ( !editorplugin ) |
|
9888 { |
|
9889 User::Leave( KErrNotFound ); |
|
9890 } |
|
9891 |
|
9892 DisableRenderUiLC(); |
|
9893 |
|
9894 if ( aEnable ) |
|
9895 { |
|
9896 iSplitScreenState.iPartialScreenOpen = ETrue; |
|
9897 iSplitScreenState.iPartialScreenEditorNode = &aNode; |
|
9898 |
|
9899 // make sure that we always get up event |
|
9900 CXnViewControlAdapter* control = static_cast< CXnViewControlAdapter* >( |
|
9901 iViewManager.ActiveViewData().ViewNode()->Control() ); |
|
9902 |
|
9903 control->ResetGrabbing(); |
|
9904 |
|
9905 // Block progression must be bottom-to-top when partial screen is open |
|
9906 // Previous value needs to be stored first |
|
9907 CXnProperty* prop( |
|
9908 editorplugin->Parent()->GetPropertyL( |
|
9909 XnPropertyNames::style::common::KBlockProgression ) ); |
|
9910 if ( prop ) |
|
9911 { |
|
9912 iSplitScreenState.iPartialScreenBlock = &prop->StringValue(); |
|
9913 } |
|
9914 else |
|
9915 { |
|
9916 iSplitScreenState.iPartialScreenBlock = |
|
9917 &XnPropertyNames::style::common::block_progression::KTB(); |
|
9918 } |
|
9919 |
|
9920 SetPartialScreenBlockProgressionL( |
|
9921 editorplugin->Parent(), |
|
9922 XnPropertyNames::style::common::block_progression::KBT ); |
|
9923 |
|
9924 // Hide all plugins except the one that contains given editor node |
|
9925 RPointerArray< CXnNode >& plugins( *Plugins() ); |
|
9926 for( TInt i=0; i<plugins.Count(); i++ ) |
|
9927 { |
|
9928 CXnNode* pluginNode = plugins[i]; |
|
9929 if ( pluginNode != editorplugin ) |
|
9930 { |
|
9931 SetNodeVisibleL(pluginNode, EFalse); |
|
9932 } |
|
9933 } |
|
9934 |
|
9935 // Hide statuspane |
|
9936 iAppUiAdapter.StatusPane()->MakeVisible( EFalse ); |
|
9937 } |
|
9938 |
|
9939 else |
|
9940 { |
|
9941 // Show plugin nodes again |
|
9942 RPointerArray< CXnNode >& plugins( *Plugins() ); |
|
9943 |
|
9944 for( TInt i=0; i<plugins.Count(); i++ ) |
|
9945 { |
|
9946 CXnNode* pluginNode = plugins[i]; |
|
9947 |
|
9948 if ( pluginNode != editorplugin ) |
|
9949 { |
|
9950 SetNodeVisibleL(pluginNode, ETrue); |
|
9951 } |
|
9952 } |
|
9953 |
|
9954 SetPartialScreenBlockProgressionL( |
|
9955 editorplugin->Parent(), |
|
9956 *iSplitScreenState.iPartialScreenBlock ); |
|
9957 |
|
9958 iSplitScreenState.iPartialScreenBlock = NULL; |
|
9959 iSplitScreenState.iPartialScreenEditorNode = NULL; |
|
9960 iSplitScreenState.iPartialScreenOpen = EFalse; |
|
9961 |
|
9962 // Show statuspane again |
|
9963 iAppUiAdapter.StatusPane()->MakeVisible(ETrue); |
|
9964 } |
|
9965 |
|
9966 RootNode()->SetDirtyL(); |
|
9967 ForceRenderUIL(); |
|
9968 CleanupStack::PopAndDestroy(); |
|
9969 } |
|
9970 |
|
9971 // ----------------------------------------------------------------------------- |
|
9972 // ----------------------------------------------------------------------------- |
|
9973 CCoeControl* CXnUiEngineImpl::WindowOwningControl( CXnNode& aNode ) |
|
9974 { |
|
9975 CXnNode* parent = &aNode; |
|
9976 while( parent ) |
|
9977 { |
|
9978 CXnControlAdapter* adapter = parent->Control(); |
|
9979 if( adapter ) |
|
9980 { |
|
9981 if( parent->ViewNodeImpl() && |
|
9982 adapter == iCurrentViewControlAdapter ) |
|
9983 { |
|
9984 return adapter; |
|
9985 } |
|
9986 else if( adapter->OwnsWindow() ) |
|
9987 { |
|
9988 if( !IsNodeTooltip( *parent ) ) |
|
9989 { |
|
9990 return adapter; |
|
9991 } |
|
9992 else |
|
9993 { |
|
9994 return NULL; |
|
9995 } |
|
9996 } |
|
9997 } |
|
9998 parent = parent->Parent(); |
|
9999 } |
|
10000 return NULL; |
|
10001 } |
|
10002 |
|
10003 // ----------------------------------------------------------------------------- |
|
10004 // ----------------------------------------------------------------------------- |
|
10005 TXnDirtyRegion* CXnUiEngineImpl::FindDirtyRegionL( CXnNode& aNode ) |
|
10006 { |
|
10007 CCoeControl* control = WindowOwningControl( aNode ); |
|
10008 if( !control ) |
|
10009 { |
|
10010 return NULL; |
|
10011 } |
|
10012 for( TInt i=0; i<iRedrawRegions.Count(); i++ ) |
|
10013 { |
|
10014 if( iRedrawRegions[i]->iControl == control ) |
|
10015 { |
|
10016 return iRedrawRegions[i]; |
|
10017 } |
|
10018 } |
|
10019 TXnDirtyRegion* region = new (ELeave) TXnDirtyRegion; |
|
10020 CleanupStack::PushL( region ); |
|
10021 region->iControl = control; |
|
10022 iRedrawRegions.AppendL( region ); |
|
10023 CleanupStack::Pop(); |
|
10024 return region; |
|
10025 } |
|
10026 |
|
10027 // ----------------------------------------------------------------------------- |
|
10028 // ----------------------------------------------------------------------------- |
|
10029 void CXnUiEngineImpl::AddRedrawRectL( TRect aRect, CXnNode& aNode ) |
|
10030 { |
|
10031 TXnDirtyRegion* dirtyReg = FindDirtyRegionL( aNode ); |
|
10032 if( dirtyReg ) |
|
10033 { |
|
10034 dirtyReg->iRegion.AddRect( aRect ); |
|
10035 dirtyReg->iRegion.Tidy(); |
|
10036 } |
|
10037 } |
|
10038 |
|
10039 // ----------------------------------------------------------------------------- |
|
10040 // SetEventDispatcher |
|
10041 // ----------------------------------------------------------------------------- |
|
10042 void CXnUiEngineImpl::SetEventDispatcher( CXnKeyEventDispatcher* aDispatcher ) |
|
10043 { |
|
10044 iKeyEventDispatcher = aDispatcher; |
|
10045 } |
|
10046 |
|
10047 // ----------------------------------------------------------------------------- |
|
10048 // NotifyStatusPaneSizeChanged |
|
10049 // ----------------------------------------------------------------------------- |
|
10050 void CXnUiEngineImpl::NotifyStatusPaneSizeChanged() |
|
10051 { |
|
10052 TRAP_IGNORE( iUiEngine->SetClientRectL( iAppUiAdapter.ClientRect(), EFalse ) ); |
|
10053 } |
|
10054 |
|
10055 // ----------------------------------------------------------------------------- |
|
10056 // NotifyResourceChanged |
|
10057 // ----------------------------------------------------------------------------- |
|
10058 void CXnUiEngineImpl::NotifyResourceChanged( TInt aType ) |
|
10059 { |
|
10060 TRAP_IGNORE( HandleResourceChangeL( aType ) ); |
|
10061 } |
|
10062 |
|
10063 // ----------------------------------------------------------------------------- |
|
10064 // EnablePartialTouchInput |
|
10065 // ----------------------------------------------------------------------------- |
|
10066 void CXnUiEngineImpl::EnablePartialTouchInput( CXnNode& aNode, TBool aEnable ) |
|
10067 { |
|
10068 if( aEnable && !iSplitScreenState.iPartialScreenOpen || |
|
10069 !aEnable && iSplitScreenState.iPartialScreenOpen ) |
|
10070 { |
|
10071 TRAP_IGNORE( HandlePartialTouchInputL( aNode, aEnable ) ); |
|
10072 } |
|
10073 } |
|
10074 |
|
10075 // ----------------------------------------------------------------------------- |
|
10076 // SetNodeVisibleL |
|
10077 // ----------------------------------------------------------------------------- |
|
10078 void CXnUiEngineImpl::SetNodeVisibleL( CXnNode* aNode , TBool aVisible ) |
|
10079 { |
|
10080 CXnDomStringPool* sp( iUiEngine->ODT()->DomDocument().StringPool()); |
|
10081 |
|
10082 if(!aVisible) |
|
10083 { |
|
10084 CXnProperty* display = CXnProperty::NewL( |
|
10085 XnPropertyNames::style::common::KDisplay, |
|
10086 XnPropertyNames::style::common::display::KNone, |
|
10087 CXnDomPropertyValue::EString, *sp ); |
|
10088 |
|
10089 CleanupStack::PushL( display ); |
|
10090 aNode->SetPropertyL(display); |
|
10091 CleanupStack::Pop( display ); |
|
10092 } |
|
10093 else |
|
10094 { |
|
10095 CXnProperty* visible = CXnProperty::NewL( |
|
10096 XnPropertyNames::style::common::KDisplay, |
|
10097 XnPropertyNames::style::common::display::KBlock, |
|
10098 CXnDomPropertyValue::EString, *sp ); |
|
10099 |
|
10100 CleanupStack::PushL( visible ); |
|
10101 aNode->SetPropertyL(visible); |
|
10102 CleanupStack::Pop( visible ); |
|
10103 } |
|
10104 } |
|
10105 |
|
10106 // ----------------------------------------------------------------------------- |
|
10107 // SetPartialScreenBlockProgressionL |
|
10108 // ----------------------------------------------------------------------------- |
|
10109 void CXnUiEngineImpl::SetPartialScreenBlockProgressionL( |
|
10110 CXnNode* aParent, const TDesC8& aBlockProgression ) |
|
10111 { |
|
10112 CXnDomStringPool* sp( iUiEngine->ODT()->DomDocument().StringPool()); |
|
10113 if( aParent && sp ) |
|
10114 { |
|
10115 CXnProperty* block_progression = CXnProperty::NewL( |
|
10116 XnPropertyNames::style::common::KBlockProgression, |
|
10117 aBlockProgression, |
|
10118 CXnDomPropertyValue::EString, *sp ); |
|
10119 if ( block_progression ) |
|
10120 { |
|
10121 CleanupStack::PushL( block_progression ); |
|
10122 aParent->SetPropertyL(block_progression); |
|
10123 CleanupStack::Pop( block_progression ); |
|
10124 } |
|
10125 } |
|
10126 } |
|
10127 |
|
10128 // ----------------------------------------------------------------------------- |
|
10129 // isPartialInputActive |
|
10130 // ----------------------------------------------------------------------------- |
|
10131 TBool CXnUiEngineImpl::IsPartialInputActive() |
|
10132 { |
|
10133 return iSplitScreenState.iPartialScreenOpen; |
|
10134 } |
|
10135 |
|
10136 // ----------------------------------------------------------------------------- |
|
10137 // CXnUiEngineImpl::IsTextEditorActive() |
|
10138 // ----------------------------------------------------------------------------- |
|
10139 // |
|
10140 TBool CXnUiEngineImpl::IsTextEditorActive() |
|
10141 { |
|
10142 if( iSplitScreenState.iPartialScreenOpen ) |
|
10143 { |
|
10144 return ETrue; |
|
10145 } |
|
10146 CXnNode* focusedNode = FocusedNode(); |
|
10147 if( focusedNode ) |
|
10148 { |
|
10149 if( focusedNode->Type()->Type() == KEditorNodeName ) |
|
10150 { |
|
10151 return ETrue; |
|
10152 } |
|
10153 } |
|
10154 return EFalse; |
|
10155 } |
|
10156 |
|
10157 // End of file |