|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Xuikon control adapter source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <utf.h> |
|
21 #include <SVGEngineInterfaceImpl.h> |
|
22 #include <s32file.h> |
|
23 #include <mifconvdefs.h> |
|
24 //skinning support |
|
25 #include <AknsFrameBackgroundControlContext.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <aknconsts.h> |
|
28 #include <AknUtils.h> |
|
29 #include <AknsListBoxBackgroundControlContext.h> |
|
30 #include <gulicon.h> |
|
31 #include <aknpointereventsuppressor.h> |
|
32 #ifdef RD_TACTILE_FEEDBACK |
|
33 #include <touchfeedback.h> |
|
34 #endif // RD_TACTILE_FEEDBACK |
|
35 |
|
36 // User includes |
|
37 #include "xnappuiadapter.h" |
|
38 #include "xnviewadapter.h" |
|
39 #include "xnviewmanager.h" |
|
40 #include "xncontroladapterimpl.h" |
|
41 #include "xncontroladapter.h" |
|
42 #include "xnmenuadapter.h" |
|
43 #include "xnviewcontroladapter.h" |
|
44 #include "xncomponentnodeimpl.h" |
|
45 #include "xntype.h" |
|
46 #include "xnnodepluginif.h" |
|
47 #include "xnuiengine.h" |
|
48 #include "xnviewnodeimpl.h" |
|
49 #include "c_xnutils.h" |
|
50 #include "xndomdocument.h" |
|
51 #include "xndomattribute.h" |
|
52 #include "xndomnode.h" |
|
53 #include "xnproperty.h" |
|
54 #include "xndomlist.h" |
|
55 #include "xnodt.h" |
|
56 #include "xnresource.h" |
|
57 #include "xnplugindata.h" |
|
58 #include "xnnode.h" |
|
59 #include "xnpanic.h" |
|
60 #include "xnviewdata.h" |
|
61 #include "xnscrollablecontroladapter.h" |
|
62 #include "xnfocuscontrol.h" |
|
63 #include "xneditmode.h" |
|
64 |
|
65 _LIT8(KScrollableBoxNodeName, "scrollablebox"); |
|
66 _LIT8( KView, "view" ); |
|
67 |
|
68 // Constants |
|
69 const TInt KSkinGfxInnerRectShrink = 5; |
|
70 const TInt KFocusGrowValue = 3; |
|
71 |
|
72 const TInt KLongTapStartShortDelay( 150000 ); // 0.15s for Sk |
|
73 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s |
|
74 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK |
|
75 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s |
|
76 |
|
77 const TInt KDragThreshold = 100; // pixels |
|
78 const TInt KMaxTapMove = 100; //100x100 pixels |
|
79 |
|
80 const TReal KEps( 3e-16 ); // proximite EPS value for double FP numbers |
|
81 |
|
82 // LOCAL FUNCTION PROTOTYPES |
|
83 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness ); |
|
84 static void ConvertRgbToHsl( TRgb aRGB, TUint& aHue, TUint& aSaturation, |
|
85 TUint& aLightness ); |
|
86 static void LoadFbsBitmapL( |
|
87 CXnResource& aResource, CFbsBitmap*& aTarget, RFs& aFsSession ); |
|
88 static void LoadMbmBitmapL( CXnResource& aResource, |
|
89 TInt aBitmapIndex, CFbsBitmap*& aTarget, RFs& aFsSession ); |
|
90 static void LoadSVGBitmapL( CXnResource& aResource, |
|
91 CFbsBitmap*& aBitmap, CFbsBitmap*& aBitmapMask, |
|
92 TRect aRect, RFs& aFsSession ); |
|
93 static TBool GetBitmapL( CXnUiEngine& aEngine, CXnNode& aNode, |
|
94 const TDesC& aResourceFileName, TInt& aBitmapIndex, |
|
95 CFbsBitmap*& aTarget, CFbsBitmap*& aBitmapMask, |
|
96 CXnControlAdapterImpl::TIconProvider*& aIconProvider, |
|
97 TRect aRect, RFs& aFsSession ); |
|
98 |
|
99 static void LimitRectToPaddingRect( CXnNode& aNode, TRect& aRect ); |
|
100 static void DrawSpaceBackgroundY( CWindowGc& aGc, TInt aYRepeatCount, |
|
101 CXnNode& aNode, TRect& aRect, CFbsBitmap* aBitmap, TRect aBitmapRect, |
|
102 TRect aImageRect, TInt& aYOffset ); |
|
103 static void DrawRepeatBackgroundY( CWindowGc& aGc, TInt aYRepeatCount, |
|
104 CXnNode& aNode, TRect& aRect, CFbsBitmap* aBitmap, TRect aBitmapRect, |
|
105 TRect aImageRect, TInt& aYOffset ); |
|
106 static void StripQuotes( HBufC*& aString ); |
|
107 static void DrawBackgroundColorL( |
|
108 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc ); |
|
109 static void GetBackroundRepeatValuesL( CXnNode& aNode, TBool& aRepeatX, |
|
110 TBool& aRepeatY, TBool& aSpaceX, TBool& aSpaceY ); |
|
111 static void DrawRepeatedBackgroundImage( CWindowGc& aGc, CXnNode& aNode, |
|
112 TRect& aRect, TRect aImageRect, TRect aBitmapRect, |
|
113 CFbsBitmap* aBitmap, TBool aRepeatX, TBool aRepeatY, TBool aSpaceX, |
|
114 TBool aSpaceY, TInt aXRepeatCount, TInt aYRepeatCount ); |
|
115 static TBool GetBackgroundPositionFromPropertyL( |
|
116 CXnNode& aNode, TBool aScaleImage, TRect& aRect, |
|
117 TRect aImageRect, CFbsBitmap* aBitmap, TBool& aHeightSet ); |
|
118 static TBool GetBackgroundSizeFromPropertyL( TRect& aRect, CXnNode& aNode, |
|
119 CFbsBitmap* aBitmap, TBool& aScaleImage ); |
|
120 static TRgb LighterColor( const TRgb& aRgb ); |
|
121 static TRgb DarkerColor( const TRgb& aRgb ); |
|
122 static void DrawSolidTopBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ); |
|
123 static void SplitTopBorderPolygonL( CArrayFix< TPoint >* aArray, |
|
124 CArrayFix< TPoint >*& aUpperPart, CArrayFix< TPoint >*& aLowerPart ); |
|
125 static void DrawRidgeTopBorderL( |
|
126 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
127 static void DrawGrooveTopBorderL( |
|
128 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
129 static void DrawInsetTopBorder( |
|
130 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
131 static void DrawOutsetTopBorder( |
|
132 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
133 static TBool GetBorderColorL( |
|
134 const TDesC8& aPropertyName, CXnNode& aNode, CWindowGc& aGc, TRgb& aRgb ); |
|
135 static void DrawTopBorderL( |
|
136 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc ); |
|
137 static void DrawBottomBorderL( |
|
138 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc ); |
|
139 static void DrawSolidBottomBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ); |
|
140 static void SplitBottomBorderPolygonL( CArrayFix< TPoint >* aArray, |
|
141 CArrayFix< TPoint >*& aUpperPart, CArrayFix< TPoint >*& aLowerPart ); |
|
142 static void DrawRidgeBottomBorderL( |
|
143 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
144 static void DrawGrooveBottomBorderL( |
|
145 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
146 static void DrawInsetBottomBorder( |
|
147 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
148 static void DrawOutsetBottomBorder( |
|
149 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
150 static void DrawSolidLeftBorder( |
|
151 CArrayFix< TPoint >* aArray, CWindowGc& aGc ); |
|
152 static void SplitLeftBorderPolygonL( CArrayFix< TPoint >* aArray, |
|
153 CArrayFix< TPoint >*& aLeftPart, CArrayFix< TPoint >*& aRightPart ); |
|
154 static void DrawRidgeLeftBorderL( |
|
155 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
156 static void DrawGrooveLeftBorderL( |
|
157 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
158 static void DrawInsetLeftBorder( |
|
159 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
160 static void DrawOutsetLeftBorder( |
|
161 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
162 static void DrawLeftBorderL( |
|
163 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc ); |
|
164 static void DrawRightBorderL( |
|
165 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc ); |
|
166 static void DrawSolidRightBorder( |
|
167 CArrayFix< TPoint >* aArray, CWindowGc& aGc ); |
|
168 static void SplitRightBorderPolygonL( CArrayFix< TPoint >* aArray, |
|
169 CArrayFix< TPoint >*& aLeftPart, CArrayFix< TPoint >*& aRightPart ); |
|
170 static void DrawRidgeRightBorderL( |
|
171 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
172 static void DrawGrooveRightBorderL( |
|
173 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
174 static void DrawInsetRightBorder( |
|
175 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
176 static void DrawOutsetRightBorder( |
|
177 CArrayFix< TPoint >* aArray, CWindowGc& aGc, TRgb& aRgb ); |
|
178 static void DrawBorderImagesL( |
|
179 const TRect& /*aRect*/, CXnNode& aNode, CWindowGc& aGc, |
|
180 CFbsBitmap* aBitmap, TInt aBorderBitmapDividerTop, |
|
181 TInt aBorderBitmapDividerRight, |
|
182 TInt aBorderBitmapDividerBottom, TInt aBorderBitmapDividerLeft ); |
|
183 static TBool IsPropertyNone( CXnProperty& aProperty ); |
|
184 static void DrawBordersL( const TRect& aRect, CXnNode& aNode, CWindowGc& aGc ); |
|
185 static void SwapChildArrays( RPointerArray< CXnControlAdapter >& originalArray, |
|
186 RPointerArray< CXnControlAdapter >& sortedArray ); |
|
187 static CXnProperty* GetZIndexL( CXnControlAdapter* aAdapter ); |
|
188 static void InsertChildToSortedArrayL( |
|
189 RPointerArray< CXnControlAdapter >& aTargetArray, |
|
190 CXnControlAdapter* aChild ); |
|
191 static void InitializeBackgroundBitmapL( CXnUiEngine& aEngine, CXnNode& aNode, |
|
192 TInt& aBitmapIndex, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, |
|
193 CXnControlAdapterImpl::TIconProvider*& aIconProvider, RFs& aFsSession ); |
|
194 static HBufC* GetBackgroundImagePathLC( CXnNode& aNode ); |
|
195 static CFbsBitmap* InitializeBorderBitmapL( |
|
196 CXnUiEngine& aEngine, CXnNode& aNode, |
|
197 TInt& aBitmapIndex, TInt& aBorderBitmapDividerTop, |
|
198 TInt& aBorderBitmapDividerRight, TInt& aBorderBitmapDividerBottom, |
|
199 TInt& aBorderBitmapDividerLeft, |
|
200 CXnControlAdapterImpl::TIconProvider*& aIconProvider, RFs& aFsSession ); |
|
201 static void DrawDottedBorder( |
|
202 TRect aBorderRect, CWindowGc& aGc, TRgb& aRgb, TBool aHorizontal ); |
|
203 static HBufC* GetBackgroundImageMaskPathLC( CXnNode& aNode ); |
|
204 static CFbsBitmap* CreateBitmapFromColorL( TSize aSize, TRgb aColor ); |
|
205 static TBool CreateGestureHelperL( CXnNode& aNode ); |
|
206 static TInt AccessResourceFileL( |
|
207 CXnResource& aResource, RFile& aFile, RFs& aFsSession ); |
|
208 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc ); |
|
209 static CXnDomNode* HasHoldTrigger( CXnDomNode* aNode ); |
|
210 static void CancelFocusRefusalL( CXnUiEngine& aUiEngine ); |
|
211 |
|
212 // ============================= LOCAL FUNCTIONS =============================== |
|
213 // ----------------------------------------------------------------------------- |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 static CXnScrollableControlAdapter* IsChildOfScrollableControl( CXnNode& aNode ) |
|
217 { |
|
218 CXnNode* parent = aNode.Parent(); |
|
219 while( parent ) |
|
220 { |
|
221 if( parent->Type()->Type() == KScrollableBoxNodeName ) |
|
222 { |
|
223 CXnScrollableControlAdapter* ret = static_cast<CXnScrollableControlAdapter*>(parent->Control()); |
|
224 return ret; |
|
225 } |
|
226 parent = parent->Parent(); |
|
227 } |
|
228 return NULL; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // SetControlContext |
|
233 // |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 static void SetControlContext(CXnControlAdapter& aChild, CXnNode& aNode) |
|
237 { |
|
238 CXnScrollableControlAdapter* scrollableControl = IsChildOfScrollableControl( aNode ); |
|
239 if(scrollableControl) |
|
240 { |
|
241 aNode.SetScrollableControl(scrollableControl); |
|
242 aChild.CopyControlContextFrom(scrollableControl); |
|
243 } |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // AccessResourceFileL |
|
248 // Opens a resource file for accessing. The caller must close the file. |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 static TInt AccessResourceFileL( |
|
252 CXnResource& aResource, |
|
253 RFile& aFile, |
|
254 RFs& aFsSession ) |
|
255 { |
|
256 TInt err = KErrNone; |
|
257 |
|
258 // parse file name and extension |
|
259 const TDesC& fileName = aResource.FileName(); |
|
260 TParsePtrC fileParser( fileName ); |
|
261 TPtrC filepath = fileParser.DriveAndPath(); |
|
262 |
|
263 // open resource file |
|
264 aFsSession.SetSessionPath( filepath ); |
|
265 aFsSession.ShareProtected(); |
|
266 err = aFile.Open( aFsSession, fileName, EFileShareReadersOnly ); |
|
267 if ( err != KErrNone ) |
|
268 { |
|
269 aFile.Close(); |
|
270 } |
|
271 |
|
272 return err; |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // LoadFbsBitmapL |
|
277 // Loads a bitmap file from the theme server and creates a CFbsBitmap |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 static void LoadFbsBitmapL( |
|
281 CXnResource& aResource, |
|
282 CFbsBitmap*& aTarget, |
|
283 RFs& aFsSession ) |
|
284 { |
|
285 RFile file; |
|
286 |
|
287 TInt ret = AccessResourceFileL( aResource, file, aFsSession ); |
|
288 if ( ret == KErrNone ) |
|
289 { |
|
290 CleanupClosePushL( file ); |
|
291 aTarget = new ( ELeave ) CFbsBitmap; |
|
292 if ( !aTarget ) |
|
293 { |
|
294 CleanupStack::PopAndDestroy(); |
|
295 return; |
|
296 } |
|
297 RFileReadStream readStream( file ); |
|
298 CleanupClosePushL( readStream ); |
|
299 aTarget->InternalizeL( readStream ); |
|
300 CleanupStack::PopAndDestroy( &readStream ); |
|
301 CleanupStack::PopAndDestroy( &file ); |
|
302 } |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // LoadMifBitmapL |
|
307 // Loads a bitmap file from the theme server and creates a CFbsBitmap |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 static void LoadMifBitmapL( |
|
311 CXnResource& aResource, |
|
312 TInt aBitmapIndex, |
|
313 CFbsBitmap*& aBitmap, |
|
314 CFbsBitmap*& aMask, |
|
315 CXnControlAdapterImpl::TIconProvider*& aIconProvider, |
|
316 RFs& aFsSession, |
|
317 const TRect& aRect ) |
|
318 { |
|
319 RFile file; |
|
320 |
|
321 TInt ret = AccessResourceFileL( aResource, file, aFsSession ); |
|
322 if ( ret == KErrNone ) |
|
323 { |
|
324 aIconProvider = new ( ELeave ) CXnControlAdapterImpl::TIconProvider( file ); |
|
325 } |
|
326 |
|
327 if ( ret == KErrNone ) |
|
328 { |
|
329 // Mask is next after bitmap |
|
330 AknIconUtils::CreateIconL( aBitmap, aMask, *aIconProvider, |
|
331 aBitmapIndex + KMifIdFirst, aBitmapIndex + KMifIdFirst + 1 ); |
|
332 AknIconUtils::SetSize( aBitmap, aRect.Size(), EAspectRatioNotPreserved ); |
|
333 } |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // LoadMbmBitmapL |
|
338 // Loads a bitmap file from the theme server and creates a CFbsBitmap |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 static void LoadMbmBitmapL( |
|
342 CXnResource& aResource, |
|
343 TInt aBitmapIndex, |
|
344 CFbsBitmap*& aTarget, |
|
345 RFs& aFsSession ) |
|
346 { |
|
347 RFile file; |
|
348 |
|
349 TInt ret = AccessResourceFileL( aResource, file, aFsSession ); |
|
350 if ( ret == KErrNone ) |
|
351 { |
|
352 CleanupClosePushL( file ); |
|
353 aTarget = new ( ELeave ) CFbsBitmap; |
|
354 aTarget->Load( file, aBitmapIndex ); |
|
355 CleanupStack::PopAndDestroy(); |
|
356 } |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // LoadSVGBitmapL |
|
361 // Loads an SVG file from the theme server and creates a CFbsBitmap. |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 static void LoadSVGBitmapL( |
|
365 CXnResource& aResource, |
|
366 CFbsBitmap*& aBitmap, |
|
367 CFbsBitmap*& aBitmapMask, |
|
368 TRect aRect, |
|
369 RFs& aFsSession ) |
|
370 { |
|
371 RFile file; |
|
372 |
|
373 TInt ret = AccessResourceFileL( aResource, file, aFsSession ); |
|
374 if ( ret == KErrNone ) |
|
375 { |
|
376 CleanupClosePushL( file ); |
|
377 |
|
378 CFbsBitmap* frameBuffer = new ( ELeave ) CFbsBitmap; |
|
379 CleanupStack::PushL( frameBuffer ); |
|
380 |
|
381 TSize contentSize( aRect.Size() ); |
|
382 |
|
383 frameBuffer->Create( contentSize, EColor16M ); |
|
384 |
|
385 TFontSpec fontSpec; |
|
386 CSvgEngineInterfaceImpl* svgEngine = |
|
387 CSvgEngineInterfaceImpl::NewL( frameBuffer, NULL, fontSpec ); |
|
388 |
|
389 CleanupStack::PushL( svgEngine ); |
|
390 |
|
391 svgEngine->Load( file ); |
|
392 |
|
393 TInt domHandle; |
|
394 svgEngine->PrepareDom( file, domHandle ); |
|
395 |
|
396 CFbsBitmap* target = new ( ELeave ) CFbsBitmap; |
|
397 target->Create( contentSize, EColor16M ); |
|
398 svgEngine->RenderDom( domHandle, target ); |
|
399 |
|
400 aBitmap = target; |
|
401 |
|
402 CFbsBitmap* mask = new ( ELeave ) CFbsBitmap; |
|
403 mask->Create( contentSize, EGray256 ); |
|
404 svgEngine->GenerateMask( mask ); |
|
405 |
|
406 aBitmapMask = mask; |
|
407 |
|
408 CleanupStack::PopAndDestroy( 3, &file ); // frameBuffer, svgEngine, file |
|
409 } |
|
410 } |
|
411 |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // ResolveMifIDL |
|
415 // Resolves a mif id from a given string. |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 static TBool ResolveMifIDL( |
|
419 const TDesC& aMifId, |
|
420 TInt& aMifID ) |
|
421 { |
|
422 HBufC* str = aMifId.AllocL(); |
|
423 TPtr ptrMif = str->Des(); |
|
424 ptrMif.TrimAll(); |
|
425 TInt pos( ptrMif.FindF( KMif ) ); |
|
426 if ( KErrNotFound != pos ) |
|
427 { |
|
428 pos += KMif().Length(); |
|
429 TPtr ptr = ptrMif.MidTPtr( pos, ( ptrMif.Length() - pos ) ); |
|
430 ptr.TrimAll(); |
|
431 TInt offset( ptr.Locate( KRightParenthesis ) ); |
|
432 if ( KErrNotFound != offset ) |
|
433 { |
|
434 TLex lex( ptr.Left( offset ) ); |
|
435 lex.SkipSpace(); |
|
436 lex.Val( aMifID ); |
|
437 delete str; |
|
438 return ETrue; |
|
439 } |
|
440 } |
|
441 delete str; |
|
442 return EFalse; |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // LoadSkinBitmapL |
|
447 // Loads a skin bitmap and creates a CFbsBitmap from it. |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 static TBool LoadSkinBitmapL( |
|
451 const TDesC& aSkinId, |
|
452 CFbsBitmap*& aBitmap, |
|
453 CFbsBitmap*& aBitmapMask, |
|
454 TRect aRect ) |
|
455 { |
|
456 TAknsItemID itemID; |
|
457 |
|
458 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
459 |
|
460 TInt mifId( 0 ); |
|
461 |
|
462 TInt mifFound( ResolveMifIDL( aSkinId, mifId ) ); |
|
463 |
|
464 TInt colorIndex( KErrNotFound ); |
|
465 |
|
466 if ( skin && CXnUtils::ResolveSkinItemIDL( aSkinId, itemID, colorIndex ) ) |
|
467 { |
|
468 if ( itemID.iMajor == EAknsMajorAppIcon ) // Check if appl. icon request |
|
469 { |
|
470 TUid applUid; |
|
471 applUid = TUid::Uid( itemID.iMinor ); |
|
472 |
|
473 AknsUtils::CreateAppIconLC( |
|
474 skin, applUid, EAknsAppIconTypeList, aBitmap, aBitmapMask ); |
|
475 AknIconUtils::SetSize( |
|
476 aBitmap, aRect.Size(), EAspectRatioNotPreserved ); |
|
477 CleanupStack::Pop( 2 ); //aBitmap, aBitmapMask |
|
478 |
|
479 return ETrue; |
|
480 } |
|
481 else |
|
482 { |
|
483 TInt error( KErrNone ); |
|
484 |
|
485 // if we have a color index, then we create a colored icon |
|
486 if ( colorIndex != KErrNotFound ) |
|
487 { |
|
488 TRgb defaultColor( 0, 0, 0 ); |
|
489 |
|
490 TRAP( error, AknsUtils::CreateColorIconL( |
|
491 skin, itemID, KAknsIIDQsnTextColors, |
|
492 colorIndex, aBitmap, aBitmapMask, |
|
493 KNullDesC, mifId, mifId + 1, defaultColor ) ); |
|
494 } |
|
495 else |
|
496 { |
|
497 TRAP( error, AknsUtils::CreateIconL( |
|
498 skin, itemID, aBitmap, aBitmapMask, KNullDesC, |
|
499 mifId, mifId + 1 ) ); |
|
500 } |
|
501 |
|
502 if ( error != KErrNone ) |
|
503 { |
|
504 error = KErrNone; |
|
505 TRAP( error, AknsUtils::CreateIconL( |
|
506 skin, itemID, aBitmap, KNullDesC, mifId ) ); |
|
507 } |
|
508 |
|
509 if ( error == KErrNone ) |
|
510 { |
|
511 AknIconUtils::SetSize( |
|
512 aBitmap, aRect.Size(), EAspectRatioNotPreserved ); |
|
513 |
|
514 return ETrue; |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 if ( mifFound ) |
|
520 { |
|
521 AknIconUtils::CreateIconL( |
|
522 aBitmap, aBitmapMask, KAvkonBitmapFile, mifId, mifId + 1 ); |
|
523 AknIconUtils::SetSize( |
|
524 aBitmap, aRect.Size(), EAspectRatioNotPreserved ); |
|
525 |
|
526 return ETrue; |
|
527 } |
|
528 |
|
529 return EFalse; |
|
530 } |
|
531 |
|
532 // ----------------------------------------------------------------------------- |
|
533 // GetBitmap |
|
534 // Fetches a bitmap |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 static TBool GetBitmapL( |
|
538 CXnUiEngine& aEngine, |
|
539 CXnNode& /*aNode*/, |
|
540 const TDesC& aResourceFileName, |
|
541 TInt& aBitmapIndex, |
|
542 CFbsBitmap*& aBitmap, |
|
543 CFbsBitmap*& aBitmapMask, |
|
544 CXnControlAdapterImpl::TIconProvider*& aIconProvider, |
|
545 TRect aRect, |
|
546 RFs& aFsSession ) |
|
547 { |
|
548 if ( LoadSkinBitmapL( aResourceFileName, aBitmap, aBitmapMask, aRect ) ) |
|
549 { |
|
550 return ETrue; |
|
551 } |
|
552 |
|
553 CXnResource* resource( CXnUtils::FindResource( |
|
554 aEngine.Resources(), aResourceFileName, aBitmapIndex ) ); |
|
555 |
|
556 if ( resource ) |
|
557 { |
|
558 if ( resource->ResourceType() == EResourceSVG ) |
|
559 { |
|
560 LoadSVGBitmapL( *resource, aBitmap, aBitmapMask, aRect, aFsSession ); |
|
561 |
|
562 return ETrue; |
|
563 } |
|
564 else if ( resource->ResourceType() == EResourceMIF ) |
|
565 { |
|
566 LoadMifBitmapL( *resource, aBitmapIndex, aBitmap, |
|
567 aBitmapMask, aIconProvider, aFsSession, aRect ); |
|
568 |
|
569 return ETrue; |
|
570 } |
|
571 else if ( resource->ResourceType() == EResourceMBM ) |
|
572 { |
|
573 LoadMbmBitmapL( *resource, aBitmapIndex, aBitmap, aFsSession ); |
|
574 |
|
575 return ETrue; |
|
576 } |
|
577 else if ( resource->ResourceType() == EResourceFBS ) |
|
578 { |
|
579 LoadFbsBitmapL( *resource, aBitmap, aFsSession ); |
|
580 |
|
581 return ETrue; |
|
582 } |
|
583 } |
|
584 |
|
585 return EFalse; |
|
586 } |
|
587 |
|
588 // ----------------------------------------------------------------------------- |
|
589 // DrawBackgroundColorL |
|
590 // Draws background color to the padding rect |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 static void DrawBackgroundColorL( |
|
594 const TRect& /*aRect*/, |
|
595 CXnNode& aNode, |
|
596 CWindowGc& aGc ) |
|
597 { |
|
598 CXnProperty* colorProperty( aNode.BackgroundColorL() ); |
|
599 |
|
600 if ( colorProperty ) |
|
601 { |
|
602 TRect paddingRect = aNode.PaddingRect(); |
|
603 |
|
604 CXnDomPropertyValue* value = |
|
605 static_cast< CXnDomPropertyValue* >( |
|
606 colorProperty->Property()->PropertyValueList().Item( 0 ) ); |
|
607 |
|
608 if ( value->PrimitiveValueType() == CXnDomPropertyValue::ERgbColor ) |
|
609 { |
|
610 TRgb rgb( value->RgbColorValueL() ); |
|
611 |
|
612 aGc.SetPenColor( rgb ); |
|
613 |
|
614 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
615 aGc.SetBrushColor( rgb ); |
|
616 |
|
617 aGc.DrawRect( paddingRect ); |
|
618 } |
|
619 } |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // StripQuotes |
|
624 // Strips enclosing quotes from a string |
|
625 // ----------------------------------------------------------------------------- |
|
626 // |
|
627 static void StripQuotes( HBufC*& aString ) |
|
628 { |
|
629 TInt pos1 = aString->Locate( '\"' ); |
|
630 TInt pos2 = aString->Locate( '\'' ); |
|
631 // check, if the first character is " or ' |
|
632 if ( pos1 == 0 || pos2 == 0 ) |
|
633 { |
|
634 TInt len = aString->Length() - 2; |
|
635 TPtr ptr = aString->Des(); |
|
636 TPtrC16 newString( aString->Mid( 1, len ).Ptr(), len ); |
|
637 ptr = newString; |
|
638 } |
|
639 } |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // DrawRepeatBackgroundY |
|
643 // Draws repeated background in the vertical direction |
|
644 // ----------------------------------------------------------------------------- |
|
645 // |
|
646 static void DrawRepeatBackgroundY( |
|
647 CWindowGc& aGc, TInt aYRepeatCount, CXnNode& aNode, TRect& aRect, |
|
648 CFbsBitmap* aBitmap, TRect aBitmapRect, |
|
649 TRect aImageRect, TInt& aYOffset ) |
|
650 { |
|
651 for (TInt i = 0; i <= aYRepeatCount && aRect.iTl.iY < aNode.PaddingRect().iBr.iY;) |
|
652 { |
|
653 TRect newRect; |
|
654 newRect = TRect( |
|
655 aRect.iTl, |
|
656 TPoint( |
|
657 aRect.iTl.iX + aImageRect.Width(), |
|
658 aRect.iTl.iY + aImageRect.Height() ) ); |
|
659 aGc.DrawBitmap( newRect, aBitmap, aBitmapRect ); |
|
660 aRect.Move( 0, newRect.Height() ); |
|
661 aYOffset += newRect.Height(); |
|
662 if ( ++i == aYRepeatCount || aYRepeatCount == 0 ) |
|
663 { |
|
664 break; |
|
665 } |
|
666 } |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // DrawSpaceBackgroundY |
|
671 // Draws spaced background in the vertical direction |
|
672 // ----------------------------------------------------------------------------- |
|
673 // |
|
674 static void DrawSpaceBackgroundY( |
|
675 CWindowGc& aGc, TInt aYRepeatCount, CXnNode& aNode, TRect& aRect, |
|
676 CFbsBitmap* aBitmap, TRect aBitmapRect, |
|
677 TRect aImageRect, TInt& aYOffset ) |
|
678 { |
|
679 for (TInt j = 0; j <= aYRepeatCount && aRect.iTl.iY < aNode.PaddingRect().iBr.iY;) |
|
680 { |
|
681 TRect newRect = aRect; |
|
682 newRect = TRect( |
|
683 aRect.iTl, |
|
684 TPoint( |
|
685 aRect.iTl.iX + aImageRect.Width(), |
|
686 aRect.iTl.iY + aImageRect.Height() ) ); |
|
687 aGc.DrawBitmap( newRect, aBitmap, aBitmapRect ); |
|
688 aRect.Move( 0, newRect.Height() ); |
|
689 aYOffset += newRect.Height(); |
|
690 if ( ++j == aYRepeatCount || aYRepeatCount == 0 ) |
|
691 { |
|
692 break; |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // LimitRectToPaddingRect |
|
699 // Limits a rect so that it does not exceed padding rect |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 static void LimitRectToPaddingRect( CXnNode& aNode, TRect& aRect ) |
|
703 { |
|
704 TRect tmpRect = aNode.PaddingRect(); |
|
705 if ( aRect.iTl.iX < tmpRect.iTl.iX ) |
|
706 { |
|
707 aRect.SetRect( tmpRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY ); |
|
708 } |
|
709 if ( aRect.iTl.iY < tmpRect.iTl.iY ) |
|
710 { |
|
711 aRect.SetRect( aRect.iTl.iX, tmpRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY ); |
|
712 } |
|
713 if ( aRect.iBr.iX > tmpRect.iBr.iX ) |
|
714 { |
|
715 aRect.SetRect( aRect.iTl.iX, aRect.iTl.iY, tmpRect.iBr.iX, aRect.iBr.iY ); |
|
716 } |
|
717 if ( aRect.iBr.iY > tmpRect.iBr.iY ) |
|
718 { |
|
719 aRect.SetRect( aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, tmpRect.iBr.iY ); |
|
720 } |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // GetBackroundRepeatValuesL |
|
725 // Gets background repeat information from node properties |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 static void GetBackroundRepeatValuesL( |
|
729 CXnNode& aNode, |
|
730 TBool& aRepeatX, |
|
731 TBool& aRepeatY, |
|
732 TBool& aSpaceX, |
|
733 TBool& aSpaceY ) |
|
734 { |
|
735 CXnProperty* backgroundRepeatProperty = aNode.GetPropertyL( |
|
736 XnPropertyNames::appearance::common::KBackGroundRepeat ); |
|
737 if ( backgroundRepeatProperty ) |
|
738 { |
|
739 CXnDomList& propertyValueList = |
|
740 backgroundRepeatProperty->Property()->PropertyValueList(); |
|
741 TInt valueCount = propertyValueList.Length(); |
|
742 for ( TInt i = 0; i < valueCount; ++i ) |
|
743 { |
|
744 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
745 propertyValueList.Item( i ) ); |
|
746 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
747 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
748 { |
|
749 switch ( i ) |
|
750 { |
|
751 case 0: |
|
752 { |
|
753 if ( value->StringValueL() == |
|
754 XnPropertyNames::appearance::common::backgroundrepeat::KRepeat ) |
|
755 { |
|
756 aRepeatX = ETrue; |
|
757 aRepeatY = ETrue; |
|
758 } |
|
759 else if ( value->StringValueL() == |
|
760 XnPropertyNames::appearance::common::backgroundrepeat::KSpace ) |
|
761 { |
|
762 aSpaceX = ETrue; |
|
763 aSpaceY = ETrue; |
|
764 } |
|
765 else if ( value->StringValueL() == |
|
766 XnPropertyNames::appearance::common::backgroundrepeat::KRepeatX ) |
|
767 { |
|
768 aRepeatX = ETrue; |
|
769 aRepeatY = EFalse; |
|
770 } |
|
771 else if ( value->StringValueL() == |
|
772 XnPropertyNames::appearance::common::backgroundrepeat::KRepeatY ) |
|
773 { |
|
774 aRepeatX = EFalse; |
|
775 aRepeatY = ETrue; |
|
776 } |
|
777 break; |
|
778 } |
|
779 case 1: |
|
780 { |
|
781 if ( value->StringValueL() == |
|
782 XnPropertyNames::appearance::common::backgroundrepeat::KRepeat ) |
|
783 { |
|
784 aRepeatY = ETrue; |
|
785 aSpaceY = EFalse; |
|
786 } |
|
787 else if ( value->StringValueL() == |
|
788 XnPropertyNames::appearance::common::backgroundrepeat::KSpace ) |
|
789 { |
|
790 aRepeatY = EFalse; |
|
791 aSpaceY = ETrue; |
|
792 } |
|
793 else if ( value->StringValueL() == |
|
794 XnPropertyNames::appearance::common::backgroundrepeat::KNoRepeat ) |
|
795 { |
|
796 aRepeatY = EFalse; |
|
797 aSpaceY = EFalse; |
|
798 } |
|
799 break; |
|
800 } |
|
801 } |
|
802 } |
|
803 } |
|
804 } |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // DrawRepeatedBackgroundImage |
|
809 // Draws a repeated background image |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 static void DrawRepeatedBackgroundImage( |
|
813 CWindowGc& aGc, |
|
814 CXnNode& aNode, |
|
815 TRect& aRect, |
|
816 TRect aImageRect, |
|
817 TRect aBitmapRect, |
|
818 CFbsBitmap* aBitmap, |
|
819 TBool aRepeatX, |
|
820 TBool aRepeatY, |
|
821 TBool aSpaceX, |
|
822 TBool aSpaceY, |
|
823 TInt aXRepeatCount, |
|
824 TInt aYRepeatCount ) |
|
825 { |
|
826 TRect paddingRect = aNode.PaddingRect(); |
|
827 if ( aRepeatX && !aRepeatY && !aSpaceX && !aSpaceY ) |
|
828 { |
|
829 aRect.SetRect( TPoint( paddingRect.iTl.iX, aRect.iTl.iY ), aRect.Size() ); |
|
830 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
831 { |
|
832 TRect newRect = TRect( |
|
833 aRect.iTl, |
|
834 TPoint( |
|
835 aRect.iTl.iX + aImageRect.Width(), |
|
836 aRect.iTl.iY + aImageRect.Height() ) ); |
|
837 aGc.DrawBitmap( newRect, aBitmap, aBitmapRect ); |
|
838 aRect.Move( newRect.Width(), 0 ); |
|
839 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
840 { |
|
841 break; |
|
842 } |
|
843 } |
|
844 } |
|
845 else if ( !aRepeatX && !aRepeatY && aSpaceX && !aSpaceY ) |
|
846 { |
|
847 aRect.SetRect( TPoint( paddingRect.iTl.iX, aRect.iTl.iY ), aRect.Size() ); |
|
848 if ( aImageRect.Width() < paddingRect.Width() && aXRepeatCount > 0 ) |
|
849 { |
|
850 aRect.Move( |
|
851 ( paddingRect.Width() - aImageRect.Width() * aXRepeatCount ) / 2, |
|
852 0 ); |
|
853 } |
|
854 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
855 { |
|
856 TRect newRect = TRect( |
|
857 aRect.iTl, |
|
858 TPoint( |
|
859 aRect.iTl.iX + aImageRect.Width(), |
|
860 aRect.iTl.iY + aImageRect.Height() ) ); |
|
861 aGc.DrawBitmap( newRect, aBitmap, aBitmapRect ); |
|
862 aRect.Move( newRect.Width(), 0 ); |
|
863 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
864 { |
|
865 break; |
|
866 } |
|
867 } |
|
868 } |
|
869 else if ( !aRepeatX && aRepeatY && !aSpaceX && !aSpaceY ) |
|
870 { |
|
871 aRect.SetRect( TPoint( aRect.iTl.iX, paddingRect.iTl.iY ), aRect.Size() ); |
|
872 TInt yOffset = 0; |
|
873 DrawRepeatBackgroundY( |
|
874 aGc, aYRepeatCount, aNode, aRect, |
|
875 aBitmap, aBitmapRect, |
|
876 aImageRect, yOffset ); |
|
877 } |
|
878 else if ( !aRepeatX && !aRepeatY && !aSpaceX && aSpaceY ) |
|
879 { |
|
880 aRect.SetRect( TPoint( aRect.iTl.iX, paddingRect.iTl.iY ), aRect.Size() ); |
|
881 if ( aImageRect.Height() < paddingRect.Height() && aYRepeatCount > 0 ) |
|
882 { |
|
883 aRect.Move( |
|
884 0, |
|
885 ( paddingRect.Height() - aImageRect.Height() * aYRepeatCount ) / 2 ); |
|
886 } |
|
887 TInt yOffset = 0; |
|
888 DrawSpaceBackgroundY( |
|
889 aGc, aYRepeatCount, aNode, aRect, |
|
890 aBitmap, aBitmapRect, |
|
891 aImageRect, yOffset ); |
|
892 } |
|
893 else if ( aRepeatX && aRepeatY && !aSpaceX && !aSpaceY ) |
|
894 { |
|
895 aRect.SetRect( paddingRect.iTl, aRect.Size() ); |
|
896 TInt yOffset = 0; |
|
897 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
898 { |
|
899 aRect.Move( 0, -yOffset ); |
|
900 yOffset = 0; |
|
901 TRect newRect = TRect( |
|
902 aRect.iTl, |
|
903 TPoint( |
|
904 aRect.iTl.iX + aImageRect.Width(), |
|
905 aRect.iTl.iY + aImageRect.Height() ) ); |
|
906 aRect = newRect; |
|
907 DrawRepeatBackgroundY( |
|
908 aGc, aYRepeatCount, aNode, aRect, |
|
909 aBitmap, aBitmapRect, |
|
910 aImageRect, yOffset ); |
|
911 aRect.Move( newRect.Width(), 0 ); |
|
912 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
913 { |
|
914 break; |
|
915 } |
|
916 } |
|
917 } |
|
918 else if ( !aRepeatX && !aRepeatY && aSpaceX && aSpaceY ) |
|
919 { |
|
920 aRect.SetRect( paddingRect.iTl, aRect.Size() ); |
|
921 if ( aImageRect.Width() < paddingRect.Width() && aXRepeatCount > 0 ) |
|
922 { |
|
923 aRect.Move( |
|
924 ( paddingRect.Width() - aImageRect.Width() * aXRepeatCount ) / 2, |
|
925 0 ); |
|
926 } |
|
927 if ( aImageRect.Height() < paddingRect.Height() && aYRepeatCount > 0 ) |
|
928 { |
|
929 aRect.Move( |
|
930 0, |
|
931 ( paddingRect.Height() - aImageRect.Height() * aYRepeatCount ) / 2 ); |
|
932 } |
|
933 TInt yOffset = 0; |
|
934 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
935 { |
|
936 aRect.Move( 0, -yOffset ); |
|
937 yOffset = 0; |
|
938 TRect newRect = TRect( |
|
939 aRect.iTl, |
|
940 TPoint( |
|
941 aRect.iTl.iX + aImageRect.Width(), |
|
942 aRect.iTl.iY + aImageRect.Height() ) ); |
|
943 aRect = newRect; |
|
944 DrawSpaceBackgroundY( |
|
945 aGc, aYRepeatCount, aNode, aRect, |
|
946 aBitmap, aBitmapRect, |
|
947 aImageRect, yOffset ); |
|
948 aRect.Move( newRect.Width(), 0 ); |
|
949 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
950 { |
|
951 break; |
|
952 } |
|
953 } |
|
954 } |
|
955 else if ( aRepeatX && !aRepeatY && !aSpaceX && aSpaceY ) |
|
956 { |
|
957 aRect.SetRect( paddingRect.iTl, aRect.Size() ); |
|
958 if ( aImageRect.Height() < paddingRect.Height() && aYRepeatCount > 0 ) |
|
959 { |
|
960 aRect.Move( |
|
961 0, |
|
962 ( paddingRect.Height() - aImageRect.Height() * aYRepeatCount ) / 2 ); |
|
963 } |
|
964 TInt yOffset = 0; |
|
965 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
966 { |
|
967 aRect.Move( 0, -yOffset ); |
|
968 yOffset = 0; |
|
969 TRect newRect = TRect( |
|
970 aRect.iTl, |
|
971 TPoint( |
|
972 aRect.iTl.iX + aImageRect.Width(), |
|
973 aRect.iTl.iY + aImageRect.Height() ) ); |
|
974 aRect = newRect; |
|
975 DrawSpaceBackgroundY( |
|
976 aGc, aYRepeatCount, aNode, aRect, |
|
977 aBitmap, aBitmapRect, |
|
978 aImageRect, yOffset ); |
|
979 aRect.Move( newRect.Width(), 0 ); |
|
980 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
981 { |
|
982 break; |
|
983 } |
|
984 } |
|
985 } |
|
986 else if ( !aRepeatX && aRepeatY && aSpaceX && !aSpaceY ) |
|
987 { |
|
988 aRect.SetRect( paddingRect.iTl, aRect.Size() ); |
|
989 TInt yOffset = 0; |
|
990 if ( aImageRect.Width() < paddingRect.Width() && aXRepeatCount > 0 ) |
|
991 { |
|
992 aRect.Move( |
|
993 ( paddingRect.Width() - aImageRect.Width() * aXRepeatCount ) / 2, |
|
994 -yOffset ); |
|
995 } |
|
996 for ( TInt i = 0; i <= aXRepeatCount && aRect.iTl.iX < paddingRect.iBr.iX; ) |
|
997 { |
|
998 aRect.Move( 0, -yOffset ); |
|
999 yOffset = 0; |
|
1000 TRect newRect = TRect( |
|
1001 aRect.iTl, |
|
1002 TPoint( |
|
1003 aRect.iTl.iX + aImageRect.Width(), |
|
1004 aRect.iTl.iY + aImageRect.Height() ) ); |
|
1005 aRect = newRect; |
|
1006 DrawRepeatBackgroundY( |
|
1007 aGc, aYRepeatCount, aNode, aRect, |
|
1008 aBitmap, aBitmapRect, |
|
1009 aImageRect, yOffset ); |
|
1010 aRect.Move( newRect.Width(), 0 ); |
|
1011 if ( ++i == aXRepeatCount || aXRepeatCount == 0 ) |
|
1012 { |
|
1013 break; |
|
1014 } |
|
1015 } |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // GetBackgroundPositionFromPropertyL |
|
1021 // Gets background position information from node properties |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 static TBool GetBackgroundPositionFromPropertyL( |
|
1025 CXnNode& aNode, |
|
1026 TBool aScaleImage, |
|
1027 TRect& aRect, |
|
1028 TRect aImageRect, |
|
1029 CFbsBitmap* aBitmap, |
|
1030 TBool& aHeightSet ) |
|
1031 { |
|
1032 CXnProperty* backgroundPositionProperty = aNode.GetPropertyL( |
|
1033 XnPropertyNames::appearance::common::KBackGroundPosition ); |
|
1034 TBool centerHorizontal = ETrue; |
|
1035 if ( backgroundPositionProperty ) |
|
1036 { |
|
1037 CXnDomList& propertyValueList = |
|
1038 backgroundPositionProperty->Property()->PropertyValueList(); |
|
1039 TSize size; |
|
1040 for ( TInt i = propertyValueList.Length() - 1; i >= 0; --i ) |
|
1041 { |
|
1042 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
1043 propertyValueList.Item( i ) ); |
|
1044 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
1045 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
1046 { |
|
1047 if ( aScaleImage ) |
|
1048 { |
|
1049 size = aImageRect.Size(); |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 size = aBitmap->SizeInPixels(); |
|
1054 } |
|
1055 switch ( i ) |
|
1056 { |
|
1057 case 0: |
|
1058 { |
|
1059 // StringValueL will not leave, we check the type first |
|
1060 if ( value->StringValueL() == |
|
1061 XnPropertyNames::appearance::common::backgroundposition::KRight ) |
|
1062 { |
|
1063 centerHorizontal = EFalse; |
|
1064 aRect.Move( aRect.Width(), 0 ); |
|
1065 aRect.Move( -size.iWidth, 0 ); |
|
1066 } |
|
1067 else if ( value->StringValueL() == |
|
1068 XnPropertyNames::appearance::common::backgroundposition::KLeft ) |
|
1069 { |
|
1070 centerHorizontal = EFalse; |
|
1071 } |
|
1072 else if ( value->StringValueL() == |
|
1073 XnPropertyNames::appearance::common::backgroundposition::KBottom ) |
|
1074 { |
|
1075 aHeightSet = ETrue; |
|
1076 aRect.Move( 0, aRect.Height() ); |
|
1077 aRect.Move( 0, -size.iHeight ); |
|
1078 } |
|
1079 else if ( value->StringValueL() == |
|
1080 XnPropertyNames::appearance::common::backgroundposition::KTop ) |
|
1081 { |
|
1082 aHeightSet = ETrue; |
|
1083 } |
|
1084 break; |
|
1085 } |
|
1086 case 1: |
|
1087 { |
|
1088 // StringValueL will not leave, we check the type first |
|
1089 if ( value->StringValueL() == |
|
1090 XnPropertyNames::appearance::common::backgroundposition::KRight ) |
|
1091 { |
|
1092 aRect.Move( aRect.Width(), 0 ); |
|
1093 aRect.Move( -size.iWidth, 0 ); |
|
1094 centerHorizontal = EFalse; |
|
1095 } |
|
1096 else if ( value->StringValueL() == |
|
1097 XnPropertyNames::appearance::common::backgroundposition::KLeft ) |
|
1098 { |
|
1099 centerHorizontal = EFalse; |
|
1100 } |
|
1101 else if ( value->StringValueL() == |
|
1102 XnPropertyNames::appearance::common::backgroundposition::KBottom ) |
|
1103 { |
|
1104 aHeightSet = ETrue; |
|
1105 aRect.Move( 0, aRect.Height() ); |
|
1106 aRect.Move( 0, -size.iHeight ); |
|
1107 } |
|
1108 else if ( value->StringValueL() == |
|
1109 XnPropertyNames::appearance::common::backgroundposition::KTop ) |
|
1110 { |
|
1111 aHeightSet = ETrue; |
|
1112 } |
|
1113 break; |
|
1114 } |
|
1115 } |
|
1116 } |
|
1117 else if ( value->PrimitiveValueType() == CXnDomPropertyValue::EPercentage ) |
|
1118 { |
|
1119 // FloatValueL will not leave, we check the type first |
|
1120 TReal percentage = value->FloatValueL(); |
|
1121 if ( percentage > 100 ) |
|
1122 { |
|
1123 percentage = 100; |
|
1124 } |
|
1125 TSize size = aImageRect.Size(); |
|
1126 switch ( i ) |
|
1127 { |
|
1128 case 0: |
|
1129 { |
|
1130 TInt rectOffset = ( percentage / 100.0 ) * aRect.Width(); |
|
1131 TInt bitmapOffset = ( percentage / 100.0 ) * size.iWidth; |
|
1132 aRect.Move( rectOffset, 0 ); |
|
1133 aRect.Move( -bitmapOffset, 0 ); |
|
1134 centerHorizontal = EFalse; |
|
1135 break; |
|
1136 } |
|
1137 case 1: |
|
1138 { |
|
1139 aHeightSet = ETrue; |
|
1140 TInt rectOffset = ( percentage / 100.0 ) * aRect.Height(); |
|
1141 TInt bitmapOffset = ( percentage / 100.0 ) * size.iHeight; |
|
1142 aRect.Move( 0, rectOffset ); |
|
1143 aRect.Move( 0, -bitmapOffset ); |
|
1144 break; |
|
1145 } |
|
1146 } |
|
1147 } |
|
1148 else |
|
1149 { |
|
1150 CXnDomPropertyValue* tmpValue = NULL; |
|
1151 TRAPD( error, tmpValue = value->CloneL(); ); |
|
1152 if ( error != KErrNone ) |
|
1153 { |
|
1154 return EFalse; |
|
1155 } |
|
1156 CXnProperty* tmpProperty = NULL; |
|
1157 TRAP( error, tmpProperty = CXnProperty::NewL( |
|
1158 KNullDesC8, |
|
1159 tmpValue, |
|
1160 *aNode.UiEngine()->ODT()->DomDocument().StringPool() ); ); |
|
1161 if ( error != KErrNone ) |
|
1162 { |
|
1163 delete tmpValue; |
|
1164 return EFalse; |
|
1165 } |
|
1166 switch ( i ) |
|
1167 { |
|
1168 case 0: |
|
1169 { |
|
1170 TInt intValue = 0; |
|
1171 TRAP( error, |
|
1172 intValue = aNode.UiEngine()->HorizontalPixelValueL( |
|
1173 tmpProperty, 0 ); ); |
|
1174 if ( error != KErrNone ) |
|
1175 { |
|
1176 delete tmpProperty; |
|
1177 return EFalse; |
|
1178 } |
|
1179 aRect.Move( intValue, 0 ); |
|
1180 centerHorizontal = EFalse; |
|
1181 break; |
|
1182 } |
|
1183 case 1: |
|
1184 { |
|
1185 aHeightSet = ETrue; |
|
1186 TInt intValue = 0; |
|
1187 TRAP( error, |
|
1188 intValue = aNode.UiEngine()->VerticalPixelValueL( |
|
1189 tmpProperty, 0 ); ); |
|
1190 if ( error != KErrNone ) |
|
1191 { |
|
1192 delete tmpProperty; |
|
1193 return EFalse; |
|
1194 } |
|
1195 aRect.Move( 0, intValue ); |
|
1196 break; |
|
1197 } |
|
1198 } |
|
1199 delete tmpProperty; |
|
1200 } |
|
1201 } |
|
1202 if ( centerHorizontal ) |
|
1203 { |
|
1204 aRect.Move( aRect.Width() / 2, 0 ); |
|
1205 aRect.Move( -size.iWidth / 2, 0 ); |
|
1206 } |
|
1207 } |
|
1208 else |
|
1209 { |
|
1210 aHeightSet = ETrue; |
|
1211 } |
|
1212 return ETrue; |
|
1213 } |
|
1214 |
|
1215 // ----------------------------------------------------------------------------- |
|
1216 // GetBackgroundSizeFromPropertyL |
|
1217 // Gets background size information from node properties |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // |
|
1220 static TBool GetBackgroundSizeFromPropertyL( |
|
1221 TRect& aRect, |
|
1222 CXnNode& aNode, |
|
1223 CFbsBitmap* aBitmap, |
|
1224 TBool& aScaleImage ) |
|
1225 { |
|
1226 CXnProperty* backgroundSizeProperty = aNode.GetPropertyL( |
|
1227 XnPropertyNames::appearance::common::KBackGroundSize ); |
|
1228 TBool widthAuto = ETrue; |
|
1229 TBool heightAuto = ETrue; |
|
1230 TBool heightSet = EFalse; |
|
1231 TSize size = aBitmap->SizeInPixels(); |
|
1232 if ( backgroundSizeProperty ) |
|
1233 { |
|
1234 widthAuto = EFalse; |
|
1235 heightAuto = EFalse; |
|
1236 CXnDomList& propertyValueList = |
|
1237 backgroundSizeProperty->Property()->PropertyValueList(); |
|
1238 for ( TInt i = propertyValueList.Length() - 1; i >= 0; --i ) |
|
1239 { |
|
1240 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
1241 propertyValueList.Item( i ) ); |
|
1242 if ( value->IsAutoIdent() ) |
|
1243 { |
|
1244 switch ( i ) |
|
1245 { |
|
1246 case 0: |
|
1247 { |
|
1248 widthAuto = ETrue; |
|
1249 break; |
|
1250 } |
|
1251 case 1: |
|
1252 { |
|
1253 heightAuto = ETrue; |
|
1254 break; |
|
1255 } |
|
1256 } |
|
1257 } |
|
1258 } |
|
1259 for ( TInt i = propertyValueList.Length() - 1; i >= 0; --i ) |
|
1260 { |
|
1261 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
1262 propertyValueList.Item( i ) ); |
|
1263 if ( value->IsAutoIdent() ) |
|
1264 { |
|
1265 continue; |
|
1266 } |
|
1267 else if ( value->PrimitiveValueType() == CXnDomPropertyValue::EPercentage ) |
|
1268 { |
|
1269 // FloatValueL will not leave, we check the type first |
|
1270 TReal percentage = 100; |
|
1271 TRAP_IGNORE( percentage = value->FloatValueL() ); |
|
1272 if ( percentage > 100 ) |
|
1273 { |
|
1274 percentage = 100; |
|
1275 } |
|
1276 switch ( i ) |
|
1277 { |
|
1278 case 0: |
|
1279 { |
|
1280 TInt widthOffset = ( 1 - ( percentage / 100.0 ) ) * aRect.Width(); |
|
1281 if ( heightAuto ) |
|
1282 { |
|
1283 TReal aspectRatio = |
|
1284 static_cast< TReal >( size.iHeight ) / |
|
1285 static_cast< TReal >( size.iWidth ); |
|
1286 aRect.Resize( -widthOffset, 0 ); |
|
1287 aRect.SetHeight( |
|
1288 static_cast< TInt >( |
|
1289 static_cast< TReal >( |
|
1290 aRect.Width() ) * aspectRatio + 0.5 ) ); |
|
1291 aScaleImage = ETrue; |
|
1292 heightSet = ETrue; |
|
1293 } |
|
1294 else |
|
1295 { |
|
1296 aRect.Resize( -widthOffset, 0 ); |
|
1297 aScaleImage = ETrue; |
|
1298 } |
|
1299 if ( !heightSet ) |
|
1300 { |
|
1301 TInt heightOffset = ( 1 - ( percentage / 100.0 ) ) * aRect.Height(); |
|
1302 aRect.Resize( 0, -heightOffset ); |
|
1303 } |
|
1304 break; |
|
1305 } |
|
1306 case 1: |
|
1307 { |
|
1308 TInt heightOffset = ( 1 - ( percentage / 100.0 ) ) * aRect.Height(); |
|
1309 if ( widthAuto ) |
|
1310 { |
|
1311 TReal aspectRatio = |
|
1312 static_cast< TReal >( size.iHeight ) / |
|
1313 static_cast< TReal >( size.iWidth ); |
|
1314 aRect.Resize( 0, -heightOffset ); |
|
1315 aRect.SetWidth( |
|
1316 static_cast< TInt >( |
|
1317 static_cast< TReal >( |
|
1318 aRect.Height() ) / aspectRatio + 0.5 ) ); |
|
1319 aScaleImage = ETrue; |
|
1320 heightSet = ETrue; |
|
1321 } |
|
1322 else |
|
1323 { |
|
1324 aRect.Resize( 0, -heightOffset ); |
|
1325 aScaleImage = ETrue; |
|
1326 heightSet = ETrue; |
|
1327 } |
|
1328 break; |
|
1329 } |
|
1330 } |
|
1331 } |
|
1332 else |
|
1333 { |
|
1334 CXnDomPropertyValue* tmpValue = NULL; |
|
1335 TRAPD( error, tmpValue = value->CloneL(); ); |
|
1336 if ( error != KErrNone ) |
|
1337 { |
|
1338 return EFalse; |
|
1339 } |
|
1340 CXnProperty* tmpProperty = NULL; |
|
1341 TRAP( error, tmpProperty = CXnProperty::NewL( |
|
1342 KNullDesC8, tmpValue, |
|
1343 *aNode.UiEngine()->ODT()->DomDocument().StringPool() ); ); |
|
1344 if ( error != KErrNone ) |
|
1345 { |
|
1346 delete tmpValue; |
|
1347 return EFalse; |
|
1348 } |
|
1349 switch ( i ) |
|
1350 { |
|
1351 case 0: |
|
1352 { |
|
1353 TInt intValue = 0; |
|
1354 TRAP( error, |
|
1355 intValue = aNode.UiEngine()->HorizontalPixelValueL( |
|
1356 tmpProperty, 0 ); ); |
|
1357 TInt widthOffset = aRect.Width() - intValue; |
|
1358 if ( heightAuto ) |
|
1359 { |
|
1360 TReal aspectRatio = |
|
1361 static_cast< TReal >( size.iHeight ) / |
|
1362 static_cast< TReal >( size.iWidth ); |
|
1363 aRect.Resize( -widthOffset, 0 ); |
|
1364 aRect.SetHeight( |
|
1365 static_cast< TInt >( |
|
1366 static_cast< TReal >( |
|
1367 aRect.Width() ) * aspectRatio + 0.5 ) ); |
|
1368 aScaleImage = ETrue; |
|
1369 heightSet = ETrue; |
|
1370 } |
|
1371 else |
|
1372 { |
|
1373 aRect.Resize( -widthOffset, 0 ); |
|
1374 aScaleImage = ETrue; |
|
1375 } |
|
1376 if ( !heightSet ) |
|
1377 { |
|
1378 TInt heightOffset = aRect.Height() - intValue; |
|
1379 aRect.Resize( 0, -heightOffset ); |
|
1380 } |
|
1381 break; |
|
1382 } |
|
1383 case 1: |
|
1384 { |
|
1385 TInt intValue = 0; |
|
1386 TRAP( error, |
|
1387 intValue = aNode.UiEngine()->VerticalPixelValueL( |
|
1388 tmpProperty, 0 ); ); |
|
1389 TInt heightOffset = aRect.Height() - intValue; |
|
1390 if ( widthAuto ) |
|
1391 { |
|
1392 TReal aspectRatio = |
|
1393 static_cast< TReal >( size.iHeight ) / |
|
1394 static_cast< TReal >( size.iWidth ); |
|
1395 aRect.Resize( 0, -heightOffset ); |
|
1396 aRect.SetWidth( |
|
1397 static_cast< TInt >( |
|
1398 static_cast< TReal >( |
|
1399 aRect.Height() ) / aspectRatio + 0.5 ) ); |
|
1400 aScaleImage = ETrue; |
|
1401 heightSet = ETrue; |
|
1402 } |
|
1403 else |
|
1404 { |
|
1405 aRect.Resize( 0, -heightOffset ); |
|
1406 aScaleImage = ETrue; |
|
1407 heightSet = ETrue; |
|
1408 } |
|
1409 break; |
|
1410 } |
|
1411 } |
|
1412 delete tmpProperty; |
|
1413 } |
|
1414 } |
|
1415 } |
|
1416 if ( widthAuto && heightAuto ) |
|
1417 { |
|
1418 if ( size.iHeight < aRect.Height() ) |
|
1419 { |
|
1420 aRect.SetHeight( size.iHeight ); |
|
1421 } |
|
1422 if ( size.iWidth < aRect.Width() ) |
|
1423 { |
|
1424 aRect.SetWidth( size.iWidth ); |
|
1425 } |
|
1426 aScaleImage = EFalse; |
|
1427 } |
|
1428 return ETrue; |
|
1429 } |
|
1430 |
|
1431 // ----------------------------------------------------------------------------- |
|
1432 // LighterColor |
|
1433 // Gets a color that has more HSL lightness (used for border effects) |
|
1434 // ----------------------------------------------------------------------------- |
|
1435 // |
|
1436 static TRgb LighterColor( const TRgb& aRgb ) |
|
1437 { |
|
1438 TUint hue; |
|
1439 TUint saturation; |
|
1440 TUint lightness; |
|
1441 ConvertRgbToHsl( aRgb, hue, saturation, lightness ); |
|
1442 if ( ( static_cast< TInt >( lightness ) + 10 ) <= 100 ) |
|
1443 { |
|
1444 lightness += 10; |
|
1445 } |
|
1446 else |
|
1447 { |
|
1448 lightness = 100; |
|
1449 } |
|
1450 return ConvertHslToRgb( hue, saturation, lightness ); |
|
1451 } |
|
1452 |
|
1453 // ----------------------------------------------------------------------------- |
|
1454 // DarkerColor |
|
1455 // Gets a color that has less HSL lightness (used for border effects) |
|
1456 // ----------------------------------------------------------------------------- |
|
1457 // |
|
1458 static TRgb DarkerColor( const TRgb& aRgb ) |
|
1459 { |
|
1460 TUint hue; |
|
1461 TUint saturation; |
|
1462 TUint lightness; |
|
1463 ConvertRgbToHsl( aRgb, hue, saturation, lightness ); |
|
1464 if ( ( static_cast< TInt >( lightness ) - 10 ) >= 0 ) |
|
1465 { |
|
1466 lightness -= 10; |
|
1467 } |
|
1468 else |
|
1469 { |
|
1470 lightness = 0; |
|
1471 } |
|
1472 return ConvertHslToRgb( hue, saturation, lightness ); |
|
1473 } |
|
1474 |
|
1475 // ----------------------------------------------------------------------------- |
|
1476 // DrawSolidTopBorder |
|
1477 // Draw a top border with solid style |
|
1478 // ----------------------------------------------------------------------------- |
|
1479 // |
|
1480 static void DrawSolidTopBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ) |
|
1481 { |
|
1482 aGc.DrawPolygon( aArray ); |
|
1483 } |
|
1484 |
|
1485 // ----------------------------------------------------------------------------- |
|
1486 // SplitTopBorderPolygonL |
|
1487 // Split top border to two parts for border effect drawing |
|
1488 // ----------------------------------------------------------------------------- |
|
1489 // |
|
1490 static void SplitTopBorderPolygonL( |
|
1491 CArrayFix< TPoint >* aArray, |
|
1492 CArrayFix< TPoint >*& aUpperPart, |
|
1493 CArrayFix< TPoint >*& aLowerPart ) |
|
1494 { |
|
1495 TPoint leftHalf = |
|
1496 TPoint( |
|
1497 ( *aArray )[0].iX + ( ( *aArray )[3].iX - ( *aArray )[0].iX ) / 2, |
|
1498 ( *aArray )[0].iY + ( ( *aArray )[3].iY - ( *aArray )[0].iY ) / 2); |
|
1499 TPoint rightHalf = |
|
1500 TPoint( |
|
1501 ( *aArray )[2].iX + ( ( *aArray )[1].iX - ( *aArray )[2].iX ) / 2, |
|
1502 ( *aArray )[1].iY + ( ( *aArray )[2].iY - ( *aArray )[1].iY ) / 2); |
|
1503 aUpperPart->AppendL( ( *aArray )[0] ); |
|
1504 aUpperPart->AppendL( ( *aArray )[1] ); |
|
1505 aUpperPart->AppendL( rightHalf ); |
|
1506 aUpperPart->AppendL( leftHalf ); |
|
1507 aLowerPart->AppendL( leftHalf ); |
|
1508 aLowerPart->AppendL( rightHalf ); |
|
1509 aLowerPart->AppendL( ( *aArray )[2] ); |
|
1510 aLowerPart->AppendL( ( *aArray )[3] ); |
|
1511 } |
|
1512 |
|
1513 // ----------------------------------------------------------------------------- |
|
1514 // DrawRidgeTopBorderL |
|
1515 // Draw top border with ridge style |
|
1516 // ----------------------------------------------------------------------------- |
|
1517 // |
|
1518 static void DrawRidgeTopBorderL( |
|
1519 CArrayFix< TPoint >* aArray, |
|
1520 CWindowGc& aGc, TRgb& aRgb ) |
|
1521 { |
|
1522 CArrayFix< TPoint >* upperPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1523 CleanupStack::PushL( upperPart ); |
|
1524 CArrayFix< TPoint >* lowerPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1525 CleanupStack::PushL( lowerPart ); |
|
1526 SplitTopBorderPolygonL( aArray, upperPart, lowerPart ); |
|
1527 TRgb rgb = LighterColor( aRgb ); |
|
1528 aGc.SetPenColor( rgb ); |
|
1529 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1530 aGc.SetBrushColor( rgb ); |
|
1531 aGc.DrawPolygon( upperPart ); |
|
1532 rgb = DarkerColor( aRgb ); |
|
1533 aGc.SetPenColor( rgb ); |
|
1534 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1535 aGc.SetBrushColor( rgb ); |
|
1536 aGc.DrawPolygon( lowerPart ); |
|
1537 CleanupStack::PopAndDestroy( lowerPart ); |
|
1538 CleanupStack::PopAndDestroy( upperPart ); |
|
1539 } |
|
1540 |
|
1541 // ----------------------------------------------------------------------------- |
|
1542 // DrawGrooveTopBorderL |
|
1543 // Draw top border with groove style |
|
1544 // ----------------------------------------------------------------------------- |
|
1545 // |
|
1546 static void DrawGrooveTopBorderL( |
|
1547 CArrayFix< TPoint >* aArray, |
|
1548 CWindowGc& aGc, TRgb& aRgb ) |
|
1549 { |
|
1550 CArrayFix< TPoint >* upperPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1551 CleanupStack::PushL( upperPart ); |
|
1552 CArrayFix< TPoint >* lowerPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1553 CleanupStack::PushL( lowerPart ); |
|
1554 SplitTopBorderPolygonL( aArray, upperPart, lowerPart ); |
|
1555 TRgb rgb = DarkerColor( aRgb ); |
|
1556 aGc.SetPenColor( rgb ); |
|
1557 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1558 aGc.SetBrushColor( rgb ); |
|
1559 aGc.DrawPolygon( upperPart ); |
|
1560 rgb = LighterColor( aRgb ); |
|
1561 aGc.SetPenColor( rgb ); |
|
1562 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1563 aGc.SetBrushColor( rgb ); |
|
1564 aGc.DrawPolygon( lowerPart ); |
|
1565 CleanupStack::PopAndDestroy( lowerPart ); |
|
1566 CleanupStack::PopAndDestroy( upperPart ); |
|
1567 } |
|
1568 |
|
1569 // ----------------------------------------------------------------------------- |
|
1570 // DrawInsetTopBorder |
|
1571 // Draw top border with inset style |
|
1572 // ----------------------------------------------------------------------------- |
|
1573 // |
|
1574 static void DrawInsetTopBorder( |
|
1575 CArrayFix< TPoint >* aArray, |
|
1576 CWindowGc& aGc, TRgb& aRgb ) |
|
1577 { |
|
1578 TRgb rgb = DarkerColor( aRgb ); |
|
1579 aGc.SetPenColor( rgb ); |
|
1580 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1581 aGc.SetBrushColor( rgb ); |
|
1582 aGc.DrawPolygon( aArray ); |
|
1583 } |
|
1584 |
|
1585 // ----------------------------------------------------------------------------- |
|
1586 // DrawOutsetTopBorder |
|
1587 // Draw top border with outset style |
|
1588 // ----------------------------------------------------------------------------- |
|
1589 // |
|
1590 static void DrawOutsetTopBorder( |
|
1591 CArrayFix< TPoint >* aArray, |
|
1592 CWindowGc& aGc, TRgb& aRgb ) |
|
1593 { |
|
1594 TRgb rgb = LighterColor( aRgb ); |
|
1595 aGc.SetPenColor( rgb ); |
|
1596 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1597 aGc.SetBrushColor( rgb ); |
|
1598 aGc.DrawPolygon( aArray ); |
|
1599 } |
|
1600 |
|
1601 // ----------------------------------------------------------------------------- |
|
1602 // GetBorderColorL |
|
1603 // Get border color from properties |
|
1604 // ----------------------------------------------------------------------------- |
|
1605 // |
|
1606 static TBool GetBorderColorL( |
|
1607 const TDesC8& aPropertyName, |
|
1608 CXnNode& aNode, |
|
1609 CWindowGc& aGc, |
|
1610 TRgb& aRgb ) |
|
1611 { |
|
1612 CXnProperty* colorProperty = aNode.GetPropertyL( aPropertyName ); |
|
1613 CXnProperty* currentColorProperty = aNode.GetPropertyL( |
|
1614 XnPropertyNames::appearance::common::KColor ); |
|
1615 CXnProperty* borderColorProperty = aNode.GetPropertyL( |
|
1616 XnPropertyNames::appearance::common::KBorderColor ); |
|
1617 if ( colorProperty ) |
|
1618 { |
|
1619 CXnDomProperty* domProperty = colorProperty->Property(); |
|
1620 CXnDomPropertyValue* propertyValue = NULL; |
|
1621 propertyValue = static_cast< CXnDomPropertyValue* >( |
|
1622 domProperty->PropertyValueList().Item( 0 ) ); |
|
1623 if ( propertyValue->IsAutoIdent() ) |
|
1624 { |
|
1625 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1626 TInt error = AknsUtils::GetCachedColor( |
|
1627 skinInstance, |
|
1628 aRgb, |
|
1629 KAknsIIDQsnLineColors, |
|
1630 EAknsCIQsnLineColorsCG4 ); |
|
1631 if ( error != KErrNone ) |
|
1632 { |
|
1633 return EFalse; |
|
1634 } |
|
1635 } |
|
1636 else |
|
1637 { |
|
1638 TRAPD( error, aRgb = propertyValue->RgbColorValueL(); ); |
|
1639 if ( error != KErrNone ) |
|
1640 { |
|
1641 return EFalse; |
|
1642 } |
|
1643 } |
|
1644 aGc.SetPenColor( aRgb ); |
|
1645 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1646 aGc.SetBrushColor( aRgb ); |
|
1647 } |
|
1648 else if ( borderColorProperty ) |
|
1649 { |
|
1650 CXnDomProperty* domProperty = borderColorProperty->Property(); |
|
1651 CXnDomPropertyValue* propertyValue = NULL; |
|
1652 propertyValue = static_cast< CXnDomPropertyValue* >( |
|
1653 domProperty->PropertyValueList().Item( 0 ) ); |
|
1654 if ( propertyValue->IsAutoIdent() ) |
|
1655 { |
|
1656 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1657 TInt error = AknsUtils::GetCachedColor( |
|
1658 skinInstance, |
|
1659 aRgb, |
|
1660 KAknsIIDQsnLineColors, |
|
1661 EAknsCIQsnLineColorsCG4 ); |
|
1662 if ( error != KErrNone ) |
|
1663 { |
|
1664 return EFalse; |
|
1665 } |
|
1666 } |
|
1667 else |
|
1668 { |
|
1669 TRAPD( error, aRgb = propertyValue->RgbColorValueL(); ); |
|
1670 if ( error != KErrNone ) |
|
1671 { |
|
1672 return EFalse; |
|
1673 } |
|
1674 } |
|
1675 aGc.SetPenColor( aRgb ); |
|
1676 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1677 aGc.SetBrushColor( aRgb ); |
|
1678 } |
|
1679 else if ( currentColorProperty ) |
|
1680 { |
|
1681 CXnDomProperty* domProperty = currentColorProperty->Property(); |
|
1682 CXnDomPropertyValue* propertyValue = NULL; |
|
1683 propertyValue = static_cast< CXnDomPropertyValue* >( |
|
1684 domProperty->PropertyValueList().Item( 0 ) ); |
|
1685 if ( propertyValue->IsAutoIdent() ) |
|
1686 { |
|
1687 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1688 TInt error = AknsUtils::GetCachedColor( |
|
1689 skinInstance, |
|
1690 aRgb, |
|
1691 KAknsIIDQsnLineColors, |
|
1692 EAknsCIQsnLineColorsCG4 ); |
|
1693 if ( error != KErrNone ) |
|
1694 { |
|
1695 return EFalse; |
|
1696 } |
|
1697 } |
|
1698 else |
|
1699 { |
|
1700 TRAPD( error, aRgb = propertyValue->RgbColorValueL(); ); |
|
1701 if ( error != KErrNone ) |
|
1702 { |
|
1703 return EFalse; |
|
1704 } |
|
1705 } |
|
1706 aGc.SetPenColor( aRgb ); |
|
1707 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1708 aGc.SetBrushColor( aRgb ); |
|
1709 } |
|
1710 else |
|
1711 { |
|
1712 return EFalse; |
|
1713 } |
|
1714 return ETrue; |
|
1715 } |
|
1716 |
|
1717 // ----------------------------------------------------------------------------- |
|
1718 // DrawTopBorderL |
|
1719 // Draw top border |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // |
|
1722 static void DrawTopBorderL( |
|
1723 const TRect& /*aRect*/, |
|
1724 CXnNode& aNode, |
|
1725 CWindowGc& aGc ) |
|
1726 { |
|
1727 TRect borderRect = aNode.BorderRect(); |
|
1728 TRect paddingRect = aNode.PaddingRect(); |
|
1729 TRgb rgb; |
|
1730 if ( !GetBorderColorL( XnPropertyNames::appearance::common::KBorderTopColor, aNode, aGc, rgb ) ) |
|
1731 { |
|
1732 return; |
|
1733 } |
|
1734 TPoint tl = borderRect.iTl; |
|
1735 TPoint bl = paddingRect.iTl; |
|
1736 bl.iY -= 1; |
|
1737 bl.iX -= 1; |
|
1738 TPoint tr = borderRect.iTl; |
|
1739 tr.iX += borderRect.Width()-1; |
|
1740 TPoint br = paddingRect.iTl; |
|
1741 br.iX += paddingRect.Width(); |
|
1742 br.iY -= 1; |
|
1743 CArrayFix< TPoint >* array = NULL; |
|
1744 array = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1745 TRAPD( error, |
|
1746 array->AppendL( tl ); |
|
1747 array->AppendL( tr ); |
|
1748 array->AppendL( br ); |
|
1749 array->AppendL( bl ) ); |
|
1750 if ( error != KErrNone ) |
|
1751 { |
|
1752 delete array; |
|
1753 return; |
|
1754 } |
|
1755 CXnProperty* borderTopStyle = aNode.BorderTopStyleL(); |
|
1756 CXnProperty* borderStyle = aNode.BorderStyleL(); |
|
1757 const TDesC8& borderStyleString = ( borderTopStyle ) ? |
|
1758 borderTopStyle->StringValue() : |
|
1759 ( borderStyle ) ? borderStyle->StringValue() : KNullDesC8; |
|
1760 if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KSolid ) |
|
1761 { |
|
1762 DrawSolidTopBorder( array, aGc ); |
|
1763 } |
|
1764 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KInset ) |
|
1765 { |
|
1766 DrawInsetTopBorder( array, aGc, rgb ); |
|
1767 } |
|
1768 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KOutset ) |
|
1769 { |
|
1770 DrawOutsetTopBorder( array, aGc, rgb ); |
|
1771 } |
|
1772 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KRidge ) |
|
1773 { |
|
1774 TRAP_IGNORE( DrawRidgeTopBorderL( array, aGc, rgb ) ); |
|
1775 } |
|
1776 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KGroove ) |
|
1777 { |
|
1778 TRAP_IGNORE( DrawGrooveTopBorderL( array, aGc, rgb ) ); |
|
1779 } |
|
1780 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KDotted ) |
|
1781 { |
|
1782 TPoint end( borderRect.iBr.iX, paddingRect.iTl.iY ); |
|
1783 TRect rect( borderRect.iTl, end ); |
|
1784 DrawDottedBorder( rect, aGc, rgb, ETrue ); |
|
1785 } |
|
1786 delete array; |
|
1787 } |
|
1788 |
|
1789 // ----------------------------------------------------------------------------- |
|
1790 // DrawSolidBottomBorder |
|
1791 // Draw bottom border with solid style |
|
1792 // ----------------------------------------------------------------------------- |
|
1793 // |
|
1794 static void DrawSolidBottomBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ) |
|
1795 { |
|
1796 aGc.DrawPolygon( aArray ); |
|
1797 } |
|
1798 |
|
1799 // ----------------------------------------------------------------------------- |
|
1800 // SplitBottomBorderPolygonL |
|
1801 // Split bottom border to two parts for border effect drawing |
|
1802 // ----------------------------------------------------------------------------- |
|
1803 // |
|
1804 static void SplitBottomBorderPolygonL( |
|
1805 CArrayFix< TPoint >* aArray, |
|
1806 CArrayFix< TPoint >*& aUpperPart, |
|
1807 CArrayFix< TPoint >*& aLowerPart ) |
|
1808 { |
|
1809 TPoint leftHalf = |
|
1810 TPoint( |
|
1811 ( *aArray )[3].iX + ( ( *aArray )[0].iX - ( *aArray )[3].iX ) / 2, |
|
1812 ( *aArray )[3].iY + ( ( *aArray )[0].iY - ( *aArray )[3].iY ) / 2); |
|
1813 TPoint rightHalf = |
|
1814 TPoint( |
|
1815 ( *aArray )[1].iX + ( ( *aArray )[2].iX - ( *aArray )[1].iX ) / 2, |
|
1816 ( *aArray )[2].iY + ( ( *aArray )[1].iY - ( *aArray )[2].iY ) / 2); |
|
1817 aUpperPart->AppendL( ( *aArray )[0] ); |
|
1818 aUpperPart->AppendL( ( *aArray )[1] ); |
|
1819 aUpperPart->AppendL( rightHalf ); |
|
1820 aUpperPart->AppendL( leftHalf ); |
|
1821 aLowerPart->AppendL( leftHalf ); |
|
1822 aLowerPart->AppendL( rightHalf ); |
|
1823 aLowerPart->AppendL( ( *aArray )[2] ); |
|
1824 aLowerPart->AppendL( ( *aArray )[3] ); |
|
1825 } |
|
1826 |
|
1827 // ----------------------------------------------------------------------------- |
|
1828 // DrawRidgeBottomBorderL |
|
1829 // Draw bottom border with ridge style |
|
1830 // ----------------------------------------------------------------------------- |
|
1831 // |
|
1832 static void DrawRidgeBottomBorderL( |
|
1833 CArrayFix< TPoint >* aArray, |
|
1834 CWindowGc& aGc, |
|
1835 TRgb& aRgb ) |
|
1836 { |
|
1837 CArrayFix< TPoint >* upperPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1838 CleanupStack::PushL( upperPart ); |
|
1839 CArrayFix< TPoint >* lowerPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1840 CleanupStack::PushL( lowerPart ); |
|
1841 SplitBottomBorderPolygonL( aArray, upperPart, lowerPart ); |
|
1842 TRgb rgb = LighterColor( aRgb ); |
|
1843 aGc.SetPenColor( rgb ); |
|
1844 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1845 aGc.SetBrushColor( rgb ); |
|
1846 aGc.DrawPolygon( upperPart ); |
|
1847 rgb = DarkerColor( aRgb ); |
|
1848 aGc.SetPenColor( rgb ); |
|
1849 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1850 aGc.SetBrushColor( rgb ); |
|
1851 aGc.DrawPolygon( lowerPart ); |
|
1852 CleanupStack::PopAndDestroy( lowerPart ); |
|
1853 CleanupStack::PopAndDestroy( upperPart ); |
|
1854 } |
|
1855 |
|
1856 // ----------------------------------------------------------------------------- |
|
1857 // DrawGrooveBottomBorderL |
|
1858 // Draw bottom border with groove style |
|
1859 // ----------------------------------------------------------------------------- |
|
1860 // |
|
1861 static void DrawGrooveBottomBorderL( |
|
1862 CArrayFix< TPoint >* aArray, |
|
1863 CWindowGc& aGc, |
|
1864 TRgb& aRgb ) |
|
1865 { |
|
1866 CArrayFix< TPoint >* upperPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1867 CleanupStack::PushL( upperPart ); |
|
1868 CArrayFix< TPoint >* lowerPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
1869 CleanupStack::PushL( lowerPart ); |
|
1870 SplitBottomBorderPolygonL( aArray, upperPart, lowerPart ); |
|
1871 TRgb rgb = DarkerColor( aRgb ); |
|
1872 aGc.SetPenColor( rgb ); |
|
1873 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1874 aGc.SetBrushColor( rgb ); |
|
1875 aGc.DrawPolygon( upperPart ); |
|
1876 rgb = LighterColor( aRgb ); |
|
1877 aGc.SetPenColor( rgb ); |
|
1878 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1879 aGc.SetBrushColor( rgb ); |
|
1880 aGc.DrawPolygon( lowerPart ); |
|
1881 CleanupStack::PopAndDestroy( lowerPart ); |
|
1882 CleanupStack::PopAndDestroy( upperPart ); |
|
1883 } |
|
1884 |
|
1885 // ----------------------------------------------------------------------------- |
|
1886 // DrawInsetBottomBorder |
|
1887 // Draw bottom border with inset style |
|
1888 // ----------------------------------------------------------------------------- |
|
1889 // |
|
1890 static void DrawInsetBottomBorder( |
|
1891 CArrayFix< TPoint >* aArray, |
|
1892 CWindowGc& aGc, |
|
1893 TRgb& aRgb ) |
|
1894 { |
|
1895 TRgb rgb = LighterColor( aRgb ); |
|
1896 aGc.SetPenColor( rgb ); |
|
1897 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1898 aGc.SetBrushColor( rgb ); |
|
1899 aGc.DrawPolygon( aArray ); |
|
1900 } |
|
1901 |
|
1902 // ----------------------------------------------------------------------------- |
|
1903 // DrawOutsetBottomBorder |
|
1904 // Draw bottom border with outset style |
|
1905 // ----------------------------------------------------------------------------- |
|
1906 // |
|
1907 static void DrawOutsetBottomBorder( |
|
1908 CArrayFix< TPoint >* aArray, |
|
1909 CWindowGc& aGc, |
|
1910 TRgb& aRgb ) |
|
1911 { |
|
1912 TRgb rgb = DarkerColor( aRgb ); |
|
1913 aGc.SetPenColor( rgb ); |
|
1914 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1915 aGc.SetBrushColor( rgb ); |
|
1916 aGc.DrawPolygon( aArray ); |
|
1917 } |
|
1918 |
|
1919 // ----------------------------------------------------------------------------- |
|
1920 // DrawDottedBorder |
|
1921 // Draw dotted border |
|
1922 // ----------------------------------------------------------------------------- |
|
1923 // |
|
1924 static void DrawDottedBorder( |
|
1925 TRect aBorderRect, |
|
1926 CWindowGc& aGc, |
|
1927 TRgb& aRgb, |
|
1928 TBool aHorizontal ) |
|
1929 { |
|
1930 TInt height( aBorderRect.Height() ); |
|
1931 TInt width( aBorderRect.Width() ); |
|
1932 |
|
1933 TInt squareSide( Min( height, width ) ); |
|
1934 |
|
1935 if ( !squareSide ) |
|
1936 { |
|
1937 return; |
|
1938 } |
|
1939 |
|
1940 // Square size 1, 2 and 3 can be drawn with pen patterns |
|
1941 if ( squareSide < 4 ) |
|
1942 { |
|
1943 aGc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1944 |
|
1945 aGc.SetPenColor( aRgb ); |
|
1946 |
|
1947 for ( TInt i = 0; i < squareSide; i++ ) |
|
1948 { |
|
1949 TPoint start; |
|
1950 TPoint end; |
|
1951 |
|
1952 if ( aHorizontal ) |
|
1953 { |
|
1954 start = TPoint( aBorderRect.iTl.iX, aBorderRect.iTl.iY + i ); |
|
1955 end = TPoint( |
|
1956 aBorderRect.iTl.iX + aBorderRect.Width(), |
|
1957 aBorderRect.iTl.iY + i ); |
|
1958 } |
|
1959 else |
|
1960 { |
|
1961 start = TPoint( aBorderRect.iTl.iX + i, aBorderRect.iTl.iY ); |
|
1962 end = TPoint( |
|
1963 aBorderRect.iTl.iX + i, |
|
1964 aBorderRect.iTl.iY + aBorderRect.Height() ); |
|
1965 } |
|
1966 |
|
1967 if ( squareSide == 3 ) |
|
1968 { |
|
1969 // dashed pen pattern 111000... |
|
1970 aGc.SetPenStyle( CGraphicsContext::EDashedPen ); |
|
1971 aGc.DrawLine( start, end ); |
|
1972 } |
|
1973 else |
|
1974 { |
|
1975 // dotted pen pattern 1000... |
|
1976 aGc.SetPenStyle( CGraphicsContext::EDottedPen ); |
|
1977 aGc.DrawLine( start, end ); |
|
1978 |
|
1979 if ( aHorizontal ) |
|
1980 { |
|
1981 start.iX += ( squareSide == 1 ) ? 2 : 1; |
|
1982 } |
|
1983 else |
|
1984 { |
|
1985 start.iY += ( squareSide == 1 ) ? 2 : 1; |
|
1986 } |
|
1987 |
|
1988 aGc.SetPenStyle( CGraphicsContext::EDottedPen ); |
|
1989 aGc.DrawLine( start, end ); |
|
1990 } |
|
1991 } |
|
1992 } |
|
1993 else |
|
1994 { |
|
1995 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1996 aGc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
1997 |
|
1998 aGc.SetBrushColor( aRgb ); |
|
1999 |
|
2000 TInt divideCount( 0 ); |
|
2001 |
|
2002 if ( aHorizontal ) |
|
2003 { |
|
2004 divideCount = width / squareSide; |
|
2005 } |
|
2006 else |
|
2007 { |
|
2008 divideCount = height / squareSide; |
|
2009 } |
|
2010 |
|
2011 TRect drawingRect( aBorderRect.iTl, TSize( squareSide, squareSide ) ); |
|
2012 |
|
2013 // every other is drawn |
|
2014 TInt count( divideCount / 2 ); |
|
2015 |
|
2016 for ( TInt i = 0; i <= count; i++ ) |
|
2017 { |
|
2018 aGc.DrawRect( drawingRect ); |
|
2019 |
|
2020 if ( aHorizontal ) |
|
2021 { |
|
2022 drawingRect.Move( squareSide * 2, 0 ); |
|
2023 } |
|
2024 else |
|
2025 { |
|
2026 drawingRect.Move( 0, squareSide * 2 ); |
|
2027 } |
|
2028 } |
|
2029 } |
|
2030 } |
|
2031 |
|
2032 // ----------------------------------------------------------------------------- |
|
2033 // DrawBottomBorder |
|
2034 // Draw bottom border |
|
2035 // ----------------------------------------------------------------------------- |
|
2036 // |
|
2037 static void DrawBottomBorderL( |
|
2038 const TRect& /*aRect*/, |
|
2039 CXnNode& aNode, |
|
2040 CWindowGc& aGc ) |
|
2041 { |
|
2042 TRect borderRect = aNode.BorderRect(); |
|
2043 TRect paddingRect = aNode.PaddingRect(); |
|
2044 TRgb rgb; |
|
2045 if ( !GetBorderColorL( XnPropertyNames::appearance::common::KBorderBottomColor, aNode, aGc, rgb ) ) |
|
2046 { |
|
2047 return; |
|
2048 } |
|
2049 TPoint tl = paddingRect.iBr; |
|
2050 tl.iX -= paddingRect.Width() + 1; |
|
2051 TPoint bl = borderRect.iBr; |
|
2052 bl.iX -= borderRect.Width(); |
|
2053 bl.iY-= 1; |
|
2054 TPoint tr = paddingRect.iBr; |
|
2055 TPoint br = borderRect.iBr; |
|
2056 br.iY -= 1; |
|
2057 br.iX -= 1; |
|
2058 CArrayFix< TPoint >* array = NULL; |
|
2059 array = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2060 TRAPD( error, |
|
2061 array->AppendL( tl ); |
|
2062 array->AppendL( tr ); |
|
2063 array->AppendL( br ); |
|
2064 array->AppendL( bl ); ); |
|
2065 if ( error != KErrNone ) |
|
2066 { |
|
2067 delete array; |
|
2068 return; |
|
2069 } |
|
2070 CXnProperty* borderBottomStyle = aNode.BorderBottomStyleL(); |
|
2071 CXnProperty* borderStyle = aNode.BorderStyleL(); |
|
2072 const TDesC8& borderStyleString = ( borderBottomStyle ) ? |
|
2073 borderBottomStyle->StringValue() : |
|
2074 ( borderStyle ) ? borderStyle->StringValue() : KNullDesC8; |
|
2075 if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KSolid ) |
|
2076 { |
|
2077 DrawSolidBottomBorder( array, aGc ); |
|
2078 } |
|
2079 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KInset ) |
|
2080 { |
|
2081 DrawInsetBottomBorder( array, aGc, rgb ); |
|
2082 } |
|
2083 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KOutset ) |
|
2084 { |
|
2085 DrawOutsetBottomBorder( array, aGc, rgb ); |
|
2086 } |
|
2087 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KRidge ) |
|
2088 { |
|
2089 TRAP_IGNORE( DrawRidgeBottomBorderL( array, aGc, rgb ) ); |
|
2090 } |
|
2091 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KGroove ) |
|
2092 { |
|
2093 TRAP_IGNORE( DrawGrooveBottomBorderL( array, aGc, rgb ) ); |
|
2094 } |
|
2095 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KDotted ) |
|
2096 { |
|
2097 TPoint origo( borderRect.iTl.iX, paddingRect.iBr.iY ); |
|
2098 TRect rect( origo, borderRect.iBr ); |
|
2099 DrawDottedBorder( rect, aGc, rgb, ETrue ); |
|
2100 } |
|
2101 delete array; |
|
2102 } |
|
2103 |
|
2104 // ----------------------------------------------------------------------------- |
|
2105 // DrawSolidLeftBorder |
|
2106 // ----------------------------------------------------------------------------- |
|
2107 // |
|
2108 static void DrawSolidLeftBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ) |
|
2109 { |
|
2110 aGc.DrawPolygon( aArray ); |
|
2111 } |
|
2112 |
|
2113 // ----------------------------------------------------------------------------- |
|
2114 // SplitLeftBorderPolygonL |
|
2115 // ----------------------------------------------------------------------------- |
|
2116 // |
|
2117 static void SplitLeftBorderPolygonL( |
|
2118 CArrayFix< TPoint >* aArray, |
|
2119 CArrayFix< TPoint >*& aLeftPart, |
|
2120 CArrayFix< TPoint >*& aRightPart ) |
|
2121 { |
|
2122 TPoint upHalf = |
|
2123 TPoint( |
|
2124 ( *aArray )[0].iX + ( ( *aArray )[1].iX - ( *aArray )[0].iX ) / 2, |
|
2125 ( *aArray )[0].iY + ( ( *aArray )[1].iY - ( *aArray )[0].iY ) / 2); |
|
2126 TPoint downHalf = |
|
2127 TPoint( |
|
2128 ( *aArray )[3].iX + ( ( *aArray )[2].iX - ( *aArray )[3].iX ) / 2, |
|
2129 ( *aArray )[2].iY + ( ( *aArray )[3].iY - ( *aArray )[2].iY ) / 2); |
|
2130 aLeftPart->AppendL( ( *aArray )[0] ); |
|
2131 aLeftPart->AppendL( upHalf ); |
|
2132 aLeftPart->AppendL( downHalf ); |
|
2133 aLeftPart->AppendL( ( *aArray )[3] ); |
|
2134 |
|
2135 aRightPart->AppendL( upHalf ); |
|
2136 aRightPart->AppendL( ( *aArray )[1] ); |
|
2137 aRightPart->AppendL( ( *aArray )[2]) ; |
|
2138 aRightPart->AppendL( downHalf ); |
|
2139 } |
|
2140 |
|
2141 // ----------------------------------------------------------------------------- |
|
2142 // DrawRidgeLeftBorderL |
|
2143 // ----------------------------------------------------------------------------- |
|
2144 // |
|
2145 static void DrawRidgeLeftBorderL( |
|
2146 CArrayFix< TPoint >* aArray, |
|
2147 CWindowGc& aGc, |
|
2148 TRgb& aRgb ) |
|
2149 { |
|
2150 CArrayFix< TPoint >* leftPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2151 CleanupStack::PushL( leftPart ); |
|
2152 CArrayFix< TPoint >* rightPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2153 CleanupStack::PushL( rightPart ); |
|
2154 SplitLeftBorderPolygonL( aArray, leftPart, rightPart ); |
|
2155 TRgb rgb = LighterColor( aRgb ); |
|
2156 aGc.SetPenColor( rgb ); |
|
2157 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2158 aGc.SetBrushColor( rgb ); |
|
2159 aGc.DrawPolygon( leftPart ); |
|
2160 rgb = DarkerColor( aRgb ); |
|
2161 aGc.SetPenColor( rgb ); |
|
2162 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2163 aGc.SetBrushColor( rgb ); |
|
2164 aGc.DrawPolygon( rightPart ); |
|
2165 CleanupStack::PopAndDestroy( rightPart ); |
|
2166 CleanupStack::PopAndDestroy( leftPart ); |
|
2167 } |
|
2168 |
|
2169 // ----------------------------------------------------------------------------- |
|
2170 // DrawGrooveLeftBorderL |
|
2171 // ----------------------------------------------------------------------------- |
|
2172 // |
|
2173 static void DrawGrooveLeftBorderL( |
|
2174 CArrayFix< TPoint >* aArray, |
|
2175 CWindowGc& aGc, |
|
2176 TRgb& aRgb ) |
|
2177 { |
|
2178 CArrayFix< TPoint >* leftPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2179 CleanupStack::PushL( leftPart ); |
|
2180 CArrayFix< TPoint >* rightPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2181 CleanupStack::PushL( rightPart ); |
|
2182 SplitLeftBorderPolygonL( aArray, leftPart, rightPart ); |
|
2183 TRgb rgb = DarkerColor( aRgb ); |
|
2184 aGc.SetPenColor( rgb ); |
|
2185 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2186 aGc.SetBrushColor( rgb ); |
|
2187 aGc.DrawPolygon( leftPart ); |
|
2188 rgb = LighterColor( aRgb ); |
|
2189 aGc.SetPenColor( rgb ); |
|
2190 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2191 aGc.SetBrushColor( rgb ); |
|
2192 aGc.DrawPolygon( rightPart ); |
|
2193 CleanupStack::PopAndDestroy( rightPart ); |
|
2194 CleanupStack::PopAndDestroy( leftPart ); |
|
2195 } |
|
2196 |
|
2197 // ----------------------------------------------------------------------------- |
|
2198 // DrawInsetLeftBorder |
|
2199 // ----------------------------------------------------------------------------- |
|
2200 // |
|
2201 static void DrawInsetLeftBorder( |
|
2202 CArrayFix< TPoint >* aArray, |
|
2203 CWindowGc& aGc, |
|
2204 TRgb& aRgb ) |
|
2205 { |
|
2206 TRgb rgb = DarkerColor( aRgb ); |
|
2207 aGc.SetPenColor( rgb ); |
|
2208 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2209 aGc.SetBrushColor( rgb ); |
|
2210 aGc.DrawPolygon( aArray ); |
|
2211 } |
|
2212 |
|
2213 // ----------------------------------------------------------------------------- |
|
2214 // DrawOutsetLeftBorder |
|
2215 // ----------------------------------------------------------------------------- |
|
2216 // |
|
2217 static void DrawOutsetLeftBorder( |
|
2218 CArrayFix< TPoint >* aArray, |
|
2219 CWindowGc& aGc, |
|
2220 TRgb& aRgb ) |
|
2221 { |
|
2222 TRgb rgb = LighterColor( aRgb ); |
|
2223 aGc.SetPenColor( rgb ); |
|
2224 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2225 aGc.SetBrushColor( rgb ); |
|
2226 aGc.DrawPolygon( aArray ); |
|
2227 } |
|
2228 |
|
2229 // ----------------------------------------------------------------------------- |
|
2230 // DrawLeftBorderL |
|
2231 // ----------------------------------------------------------------------------- |
|
2232 // |
|
2233 static void DrawLeftBorderL( |
|
2234 const TRect& /*aRect*/, |
|
2235 CXnNode& aNode, |
|
2236 CWindowGc& aGc ) |
|
2237 { |
|
2238 TRect borderRect = aNode.BorderRect(); |
|
2239 TRect paddingRect = aNode.PaddingRect(); |
|
2240 TRgb rgb; |
|
2241 if ( !GetBorderColorL( XnPropertyNames::appearance::common::KBorderLeftColor, aNode, aGc, rgb ) ) |
|
2242 { |
|
2243 return; |
|
2244 } |
|
2245 TPoint tl = borderRect.iTl; |
|
2246 TPoint bl = borderRect.iBr; |
|
2247 bl.iX -= borderRect.Width(); |
|
2248 TPoint tr = paddingRect.iTl; |
|
2249 tr.iX -= 1; |
|
2250 tr.iY -= 1; |
|
2251 TPoint br = paddingRect.iBr; |
|
2252 br.iX -= paddingRect.Width() + 1; |
|
2253 CArrayFix< TPoint >* array = NULL; |
|
2254 array = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2255 TRAPD( error, |
|
2256 array->AppendL( tl ); |
|
2257 array->AppendL( tr ); |
|
2258 array->AppendL( br ); |
|
2259 array->AppendL( bl ); ); |
|
2260 if ( error != KErrNone ) |
|
2261 { |
|
2262 delete array; |
|
2263 return; |
|
2264 } |
|
2265 CXnProperty* borderLeftStyle = aNode.BorderLeftStyleL(); |
|
2266 CXnProperty* borderStyle = aNode.BorderStyleL(); |
|
2267 const TDesC8& borderStyleString = ( borderLeftStyle ) ? |
|
2268 borderLeftStyle->StringValue() : |
|
2269 ( borderStyle ) ? borderStyle->StringValue() : KNullDesC8; |
|
2270 if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KSolid ) |
|
2271 { |
|
2272 DrawSolidLeftBorder( array, aGc ); |
|
2273 } |
|
2274 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KInset ) |
|
2275 { |
|
2276 DrawInsetLeftBorder( array, aGc, rgb ); |
|
2277 } |
|
2278 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KOutset ) |
|
2279 { |
|
2280 DrawOutsetLeftBorder( array, aGc, rgb ); |
|
2281 } |
|
2282 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KRidge ) |
|
2283 { |
|
2284 TRAP_IGNORE( DrawRidgeLeftBorderL( array, aGc, rgb ) ); |
|
2285 } |
|
2286 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KGroove ) |
|
2287 { |
|
2288 TRAP_IGNORE( DrawGrooveLeftBorderL( array, aGc, rgb ) ); |
|
2289 } |
|
2290 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KDotted ) |
|
2291 { |
|
2292 TPoint origo( borderRect.iTl.iX, paddingRect.iTl.iY ); |
|
2293 TPoint end( paddingRect.iTl.iX, paddingRect.iBr.iY ); |
|
2294 TRect rect( origo, end ); |
|
2295 DrawDottedBorder( rect, aGc, rgb, EFalse ); |
|
2296 } |
|
2297 delete array; |
|
2298 } |
|
2299 |
|
2300 // ----------------------------------------------------------------------------- |
|
2301 // DrawSolidRightBorder |
|
2302 // ----------------------------------------------------------------------------- |
|
2303 // |
|
2304 static void DrawSolidRightBorder( CArrayFix< TPoint >* aArray, CWindowGc& aGc ) |
|
2305 { |
|
2306 aGc.DrawPolygon( aArray ); |
|
2307 } |
|
2308 |
|
2309 // ----------------------------------------------------------------------------- |
|
2310 // SplitRightBorderPolygonL |
|
2311 // ----------------------------------------------------------------------------- |
|
2312 // |
|
2313 static void SplitRightBorderPolygonL( |
|
2314 CArrayFix< TPoint >* aArray, |
|
2315 CArrayFix< TPoint >*& aLeftPart, |
|
2316 CArrayFix< TPoint >*& aRightPart ) |
|
2317 { |
|
2318 TPoint upHalf = |
|
2319 TPoint( |
|
2320 ( *aArray )[0].iX + ( ( *aArray )[1].iX - ( *aArray )[0].iX ) / 2, |
|
2321 ( *aArray )[1].iY + ( ( *aArray )[0].iY - ( *aArray )[1].iY ) / 2); |
|
2322 TPoint downHalf = |
|
2323 TPoint( |
|
2324 ( *aArray )[3].iX + ( ( *aArray )[2].iX - ( *aArray )[3].iX ) / 2, |
|
2325 ( *aArray )[3].iY + ( ( *aArray )[2].iY - ( *aArray )[3].iY ) / 2); |
|
2326 aLeftPart->AppendL( ( *aArray )[0] ); |
|
2327 aLeftPart->AppendL( upHalf ); |
|
2328 aLeftPart->AppendL( downHalf ); |
|
2329 aLeftPart->AppendL( ( *aArray )[3] ); |
|
2330 |
|
2331 aRightPart->AppendL( upHalf ); |
|
2332 aRightPart->AppendL( ( *aArray )[1] ); |
|
2333 aRightPart->AppendL( ( *aArray )[2]) ; |
|
2334 aRightPart->AppendL( downHalf ); |
|
2335 } |
|
2336 |
|
2337 // ----------------------------------------------------------------------------- |
|
2338 // DrawRidgeRightBorderL |
|
2339 // ----------------------------------------------------------------------------- |
|
2340 // |
|
2341 static void DrawRidgeRightBorderL( |
|
2342 CArrayFix< TPoint >* aArray, |
|
2343 CWindowGc& aGc, |
|
2344 TRgb& aRgb ) |
|
2345 { |
|
2346 CArrayFix< TPoint >* leftPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2347 CleanupStack::PushL( leftPart ); |
|
2348 CArrayFix< TPoint >* rightPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2349 CleanupStack::PushL( rightPart ); |
|
2350 SplitRightBorderPolygonL( aArray, leftPart, rightPart ); |
|
2351 TRgb rgb = LighterColor( aRgb ); |
|
2352 aGc.SetPenColor( rgb ); |
|
2353 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2354 aGc.SetBrushColor( rgb ); |
|
2355 aGc.DrawPolygon( leftPart ); |
|
2356 rgb = DarkerColor( aRgb ); |
|
2357 aGc.SetPenColor( rgb ); |
|
2358 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2359 aGc.SetBrushColor( rgb ); |
|
2360 aGc.DrawPolygon( rightPart ); |
|
2361 CleanupStack::PopAndDestroy( rightPart ); |
|
2362 CleanupStack::PopAndDestroy( leftPart ); |
|
2363 } |
|
2364 |
|
2365 // ----------------------------------------------------------------------------- |
|
2366 // DrawGrooveRightBorderL |
|
2367 // ----------------------------------------------------------------------------- |
|
2368 // |
|
2369 static void DrawGrooveRightBorderL( |
|
2370 CArrayFix< TPoint >* aArray, |
|
2371 CWindowGc& aGc, |
|
2372 TRgb& aRgb ) |
|
2373 { |
|
2374 CArrayFix< TPoint >* leftPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2375 CleanupStack::PushL( leftPart ); |
|
2376 CArrayFix< TPoint >* rightPart = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2377 CleanupStack::PushL( rightPart ); |
|
2378 SplitRightBorderPolygonL( aArray, leftPart, rightPart ); |
|
2379 TRgb rgb = DarkerColor( aRgb ); |
|
2380 aGc.SetPenColor( rgb ); |
|
2381 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2382 aGc.SetBrushColor( rgb ); |
|
2383 aGc.DrawPolygon( leftPart ); |
|
2384 rgb = LighterColor( aRgb ); |
|
2385 aGc.SetPenColor( rgb ); |
|
2386 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2387 aGc.SetBrushColor( rgb ); |
|
2388 aGc.DrawPolygon( rightPart ); |
|
2389 CleanupStack::PopAndDestroy( rightPart ); |
|
2390 CleanupStack::PopAndDestroy( leftPart ); |
|
2391 } |
|
2392 |
|
2393 // ----------------------------------------------------------------------------- |
|
2394 // DrawInsetRightBorder |
|
2395 // ----------------------------------------------------------------------------- |
|
2396 // |
|
2397 static void DrawInsetRightBorder( |
|
2398 CArrayFix< TPoint >* aArray, |
|
2399 CWindowGc& aGc, |
|
2400 TRgb& aRgb ) |
|
2401 { |
|
2402 TRgb rgb = LighterColor( aRgb ); |
|
2403 aGc.SetPenColor( rgb ); |
|
2404 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2405 aGc.SetBrushColor( rgb ); |
|
2406 aGc.DrawPolygon( aArray ); |
|
2407 } |
|
2408 |
|
2409 // ----------------------------------------------------------------------------- |
|
2410 // DrawOutsetRightBorder |
|
2411 // ----------------------------------------------------------------------------- |
|
2412 // |
|
2413 static void DrawOutsetRightBorder( |
|
2414 CArrayFix< TPoint >* aArray, |
|
2415 CWindowGc& aGc, |
|
2416 TRgb& aRgb ) |
|
2417 { |
|
2418 TRgb rgb = DarkerColor( aRgb ); |
|
2419 aGc.SetPenColor( rgb ); |
|
2420 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
2421 aGc.SetBrushColor( rgb ); |
|
2422 aGc.DrawPolygon( aArray ); |
|
2423 } |
|
2424 |
|
2425 // ----------------------------------------------------------------------------- |
|
2426 // DrawRightBorderL |
|
2427 // ----------------------------------------------------------------------------- |
|
2428 // |
|
2429 static void DrawRightBorderL( |
|
2430 const TRect& /*aRect*/, |
|
2431 CXnNode& aNode, |
|
2432 CWindowGc& aGc ) |
|
2433 { |
|
2434 TRect borderRect = aNode.BorderRect(); |
|
2435 TRect paddingRect = aNode.PaddingRect(); |
|
2436 TRgb rgb; |
|
2437 if ( !GetBorderColorL( XnPropertyNames::appearance::common::KBorderRightColor, aNode, aGc, rgb ) ) |
|
2438 { |
|
2439 return; |
|
2440 } |
|
2441 TPoint tl = paddingRect.iTl; |
|
2442 tl.iX += paddingRect.Width(); |
|
2443 TPoint bl = paddingRect.iBr; |
|
2444 TPoint tr = borderRect.iTl; |
|
2445 tr.iX += borderRect.Width()-1; |
|
2446 TPoint br = borderRect.iBr; |
|
2447 br.iX -= 1; |
|
2448 br.iY -= 1; |
|
2449 CArrayFix< TPoint >* array = NULL; |
|
2450 array = new ( ELeave ) CArrayFixFlat< TPoint >( 3 ); |
|
2451 TRAPD( error, |
|
2452 array->AppendL( tl ); |
|
2453 array->AppendL( tr ); |
|
2454 array->AppendL( br ); |
|
2455 array->AppendL( bl ); ); |
|
2456 if ( error != KErrNone ) |
|
2457 { |
|
2458 delete array; |
|
2459 return; |
|
2460 } |
|
2461 CXnProperty* borderRightStyle = aNode.BorderRightStyleL(); |
|
2462 CXnProperty* borderStyle = aNode.BorderStyleL(); |
|
2463 const TDesC8& borderStyleString = ( borderRightStyle ) ? |
|
2464 borderRightStyle->StringValue() : |
|
2465 ( borderStyle ) ? borderStyle->StringValue() : KNullDesC8; |
|
2466 if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KSolid ) |
|
2467 { |
|
2468 DrawSolidRightBorder( array, aGc ); |
|
2469 } |
|
2470 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KInset ) |
|
2471 { |
|
2472 DrawInsetRightBorder( array, aGc, rgb ); |
|
2473 } |
|
2474 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KOutset ) |
|
2475 { |
|
2476 DrawOutsetRightBorder( array, aGc, rgb ); |
|
2477 } |
|
2478 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KRidge ) |
|
2479 { |
|
2480 TRAP_IGNORE( DrawRidgeRightBorderL( array, aGc, rgb ) ); |
|
2481 } |
|
2482 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KGroove ) |
|
2483 { |
|
2484 TRAP_IGNORE( DrawGrooveRightBorderL( array, aGc, rgb ) ); |
|
2485 } |
|
2486 else if ( borderStyleString == XnPropertyNames::appearance::common::borderstyle::KDotted ) |
|
2487 { |
|
2488 TPoint origo( paddingRect.iBr.iX, paddingRect.iTl.iY ); |
|
2489 TPoint end( borderRect.iBr.iX, paddingRect.iBr.iY ); |
|
2490 TRect rect( origo, end ); |
|
2491 DrawDottedBorder( rect, aGc, rgb, EFalse ); |
|
2492 } |
|
2493 delete array; |
|
2494 } |
|
2495 |
|
2496 // ----------------------------------------------------------------------------- |
|
2497 // DrawBorderImagesL |
|
2498 // ----------------------------------------------------------------------------- |
|
2499 // |
|
2500 static void DrawBorderImagesL( |
|
2501 const TRect& /*aRect*/, |
|
2502 CXnNode& aNode, |
|
2503 CWindowGc& aGc, |
|
2504 CFbsBitmap* aBitmap, |
|
2505 TInt aBorderBitmapDividerTop, |
|
2506 TInt aBorderBitmapDividerRight, |
|
2507 TInt aBorderBitmapDividerBottom, |
|
2508 TInt aBorderBitmapDividerLeft ) |
|
2509 { |
|
2510 CXnProperty* pathProperty = aNode.BorderImageL(); |
|
2511 if ( !pathProperty ) |
|
2512 { |
|
2513 return; |
|
2514 } |
|
2515 TRect borderRect = aNode.BorderRect(); |
|
2516 TRect paddingRect = aNode.PaddingRect(); |
|
2517 TRect topLeft = TRect( borderRect.iTl, paddingRect.iTl ); |
|
2518 TRect topLeftSource = TRect( |
|
2519 TPoint( 0, 0 ), |
|
2520 TPoint( aBorderBitmapDividerLeft, aBorderBitmapDividerTop ) ); |
|
2521 aGc.DrawBitmap( topLeft, aBitmap, topLeftSource ); |
|
2522 TRect bottomLeft = TRect( |
|
2523 TPoint( borderRect.iTl.iX, paddingRect.iTl.iY + paddingRect.Height() ), |
|
2524 TPoint( paddingRect.iTl.iX, borderRect.iTl.iY + borderRect.Height() ) ); |
|
2525 TSize imageSize = aBitmap->SizeInPixels(); |
|
2526 TRect bottomLeftSource = TRect( |
|
2527 TPoint( 0, imageSize.iHeight - aBorderBitmapDividerBottom ), |
|
2528 TPoint( aBorderBitmapDividerLeft, imageSize.iHeight ) ); |
|
2529 aGc.DrawBitmap( bottomLeft, aBitmap, bottomLeftSource ); |
|
2530 TRect topRight = TRect( |
|
2531 TPoint( paddingRect.iBr.iX, borderRect.iTl.iY ), |
|
2532 TPoint( borderRect.iBr.iX, paddingRect.iTl.iY ) ); |
|
2533 TRect topRightSource = TRect( |
|
2534 TPoint( imageSize.iWidth - aBorderBitmapDividerRight, 0 ), |
|
2535 TPoint( imageSize.iWidth, aBorderBitmapDividerTop ) ); |
|
2536 aGc.DrawBitmap( topRight, aBitmap, topRightSource ); |
|
2537 TRect bottomRight = TRect( paddingRect.iBr, borderRect.iBr ); |
|
2538 TRect bottomRightSource = TRect( |
|
2539 TPoint( |
|
2540 imageSize.iWidth - aBorderBitmapDividerRight, |
|
2541 imageSize.iHeight - aBorderBitmapDividerBottom ), |
|
2542 TPoint( |
|
2543 imageSize.iWidth, |
|
2544 imageSize.iHeight ) ); |
|
2545 aGc.DrawBitmap( bottomRight, aBitmap, bottomRightSource ); |
|
2546 TBool xStretch = ETrue; |
|
2547 TBool xRepeat = EFalse; |
|
2548 TBool xRound = EFalse; |
|
2549 TBool yStretch = ETrue; |
|
2550 TBool yRepeat = EFalse; |
|
2551 TBool yRound = EFalse; |
|
2552 if ( pathProperty ) |
|
2553 { |
|
2554 CXnDomList& propertyValueList = pathProperty->Property()->PropertyValueList(); |
|
2555 TBool xHandled = EFalse; |
|
2556 TInt count = propertyValueList.Length(); |
|
2557 for ( TInt i = 0; i < count; ++i ) |
|
2558 { |
|
2559 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
2560 propertyValueList.Item( i ) ); |
|
2561 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
2562 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
2563 { |
|
2564 const TDesC8& stringValue = value->StringValueL(); |
|
2565 if ( !xHandled ) |
|
2566 { |
|
2567 xHandled = ETrue; |
|
2568 if ( stringValue == XnPropertyNames::appearance::common::borderimage::KStretch ) |
|
2569 { |
|
2570 xStretch = ETrue; |
|
2571 yStretch = ETrue; |
|
2572 } |
|
2573 else if ( stringValue == XnPropertyNames::appearance::common::borderimage::KRepeat ) |
|
2574 { |
|
2575 xStretch = EFalse; |
|
2576 yStretch = EFalse; |
|
2577 xRepeat = ETrue; |
|
2578 yRepeat = ETrue; |
|
2579 } |
|
2580 else if ( stringValue == XnPropertyNames::appearance::common::borderimage::KRound ) |
|
2581 { |
|
2582 xStretch = EFalse; |
|
2583 yStretch = EFalse; |
|
2584 xRound = ETrue; |
|
2585 yRound = ETrue; |
|
2586 } |
|
2587 } |
|
2588 else |
|
2589 { |
|
2590 if ( stringValue == XnPropertyNames::appearance::common::borderimage::KStretch ) |
|
2591 { |
|
2592 yStretch = ETrue; |
|
2593 yRepeat = EFalse; |
|
2594 yRound = EFalse; |
|
2595 } |
|
2596 else if ( stringValue == XnPropertyNames::appearance::common::borderimage::KRepeat ) |
|
2597 { |
|
2598 yStretch = EFalse; |
|
2599 yRepeat = ETrue; |
|
2600 yRound = EFalse; |
|
2601 } |
|
2602 else if ( stringValue == XnPropertyNames::appearance::common::borderimage::KRound ) |
|
2603 { |
|
2604 yStretch = EFalse; |
|
2605 yRepeat = EFalse; |
|
2606 yRound = ETrue; |
|
2607 } |
|
2608 } |
|
2609 } |
|
2610 } |
|
2611 } |
|
2612 TRect top = TRect( |
|
2613 TPoint( paddingRect.iTl.iX, borderRect.iTl.iY ), |
|
2614 TPoint( paddingRect.iBr.iX, paddingRect.iTl.iY ) ); |
|
2615 TRect topSource = TRect( |
|
2616 TPoint( aBorderBitmapDividerLeft, 0 ), |
|
2617 TPoint( imageSize.iWidth - aBorderBitmapDividerRight, aBorderBitmapDividerTop ) ); |
|
2618 if ( xStretch ) |
|
2619 { |
|
2620 aGc.DrawBitmap( top, aBitmap, topSource ); |
|
2621 } |
|
2622 else if ( xRepeat && topSource.Width() ) |
|
2623 { |
|
2624 TInt count = top.Width() / topSource.Width(); |
|
2625 TInt topWidth = top.Width(); |
|
2626 top.SetWidth( topSource.Width() ); |
|
2627 for ( TInt i = 0; i < count; ++i ) |
|
2628 { |
|
2629 aGc.DrawBitmap( top, aBitmap, topSource ); |
|
2630 top.Move( topSource.Width(), 0 ); |
|
2631 } |
|
2632 top.SetWidth( topWidth - count * topSource.Width() ); |
|
2633 aGc.DrawBitmap( top, aBitmap, topSource ); |
|
2634 } |
|
2635 else if ( xRound && topSource.Width() ) |
|
2636 { |
|
2637 TInt count = top.Width() / topSource.Width(); |
|
2638 TInt topWidth = top.Width(); |
|
2639 //top.Move((topWidth - count * topSource.Width()) / 2, 0); |
|
2640 if ( ( count * topSource.Width() ) < topWidth ) |
|
2641 { |
|
2642 ++count; |
|
2643 top.SetWidth( topWidth / count ); |
|
2644 } |
|
2645 else |
|
2646 { |
|
2647 top.SetWidth( topSource.Width() ); |
|
2648 } |
|
2649 for ( TInt i = 0; i < count; ++i ) |
|
2650 { |
|
2651 aGc.DrawBitmap( top, aBitmap, topSource ); |
|
2652 top.Move( top.Width(), 0 ); |
|
2653 } |
|
2654 } |
|
2655 TRect right = TRect( |
|
2656 TPoint( paddingRect.iBr.iX, paddingRect.iTl.iY ), |
|
2657 TPoint( borderRect.iBr.iX, paddingRect.iBr.iY ) ); |
|
2658 TRect rightSource = TRect( |
|
2659 TPoint( imageSize.iWidth - aBorderBitmapDividerRight, aBorderBitmapDividerTop ), |
|
2660 TPoint( imageSize.iWidth, imageSize.iHeight - aBorderBitmapDividerBottom ) ); |
|
2661 if ( yStretch ) |
|
2662 { |
|
2663 aGc.DrawBitmap( right, aBitmap, rightSource ); |
|
2664 } |
|
2665 else if ( yRepeat && rightSource.Height() ) |
|
2666 { |
|
2667 TInt count = right.Height() / rightSource.Height(); |
|
2668 TInt rightHeight = right.Height(); |
|
2669 right.SetHeight( rightSource.Height() ); |
|
2670 for ( TInt i = 0; i < count; ++i ) |
|
2671 { |
|
2672 aGc.DrawBitmap( right, aBitmap, rightSource ); |
|
2673 right.Move( 0, rightSource.Height() ); |
|
2674 } |
|
2675 right.SetHeight( rightHeight - count * rightSource.Height() ); |
|
2676 aGc.DrawBitmap( right, aBitmap, rightSource ); |
|
2677 } |
|
2678 else if ( yRound && rightSource.Height() ) |
|
2679 { |
|
2680 TInt count = right.Height() / rightSource.Height(); |
|
2681 TInt rightHeight = right.Height(); |
|
2682 if ( ( count * rightSource.Height() ) < rightHeight ) |
|
2683 { |
|
2684 ++count; |
|
2685 right.SetHeight( rightHeight / count ); |
|
2686 } |
|
2687 else |
|
2688 { |
|
2689 right.SetHeight( rightSource.Width() ); |
|
2690 } |
|
2691 for ( TInt i = 0; i < count; ++i ) |
|
2692 { |
|
2693 aGc.DrawBitmap( right, aBitmap, rightSource ); |
|
2694 right.Move( 0, right.Height() ); |
|
2695 } |
|
2696 } |
|
2697 TRect bottom = TRect( |
|
2698 TPoint( paddingRect.iTl.iX, paddingRect.iBr.iY ), |
|
2699 TPoint( paddingRect.iBr.iX, borderRect.iBr.iY ) ); |
|
2700 TRect bottomSource = TRect( |
|
2701 TPoint( aBorderBitmapDividerLeft, imageSize.iHeight - aBorderBitmapDividerBottom ), |
|
2702 TPoint( imageSize.iWidth - aBorderBitmapDividerRight, imageSize.iHeight ) ); |
|
2703 if ( xStretch ) |
|
2704 { |
|
2705 aGc.DrawBitmap( bottom, aBitmap, bottomSource ); |
|
2706 } |
|
2707 else if ( xRepeat && bottomSource.Width() ) |
|
2708 { |
|
2709 TInt count = bottom.Width() / bottomSource.Width(); |
|
2710 TInt bottomWidth = bottom.Width(); |
|
2711 bottom.SetWidth( bottomSource.Width() ); |
|
2712 for ( TInt i = 0; i < count; ++i ) |
|
2713 { |
|
2714 aGc.DrawBitmap( bottom, aBitmap, bottomSource ); |
|
2715 bottom.Move( bottomSource.Width(), 0 ); |
|
2716 } |
|
2717 bottom.SetWidth( bottomWidth - count * bottomSource.Width() ); |
|
2718 aGc.DrawBitmap( bottom, aBitmap, bottomSource ); |
|
2719 } |
|
2720 else if ( xRound && bottomSource.Width() ) |
|
2721 { |
|
2722 TInt count = bottom.Width() / bottomSource.Width(); |
|
2723 TInt bottomWidth = bottom.Width(); |
|
2724 if ( ( count * bottomSource.Width() ) < bottomWidth ) |
|
2725 { |
|
2726 ++count; |
|
2727 bottom.SetWidth( bottomWidth / count ); |
|
2728 } |
|
2729 else |
|
2730 { |
|
2731 bottom.SetWidth( bottomSource.Width() ); |
|
2732 } |
|
2733 for ( TInt i = 0; i < count; ++i ) |
|
2734 { |
|
2735 aGc.DrawBitmap( bottom, aBitmap, bottomSource ); |
|
2736 bottom.Move( bottom.Width(), 0 ); |
|
2737 } |
|
2738 } |
|
2739 TRect left = TRect( |
|
2740 TPoint( borderRect.iTl.iX, paddingRect.iTl.iY ), |
|
2741 TPoint( paddingRect.iTl.iX, paddingRect.iBr.iY ) ); |
|
2742 TRect leftSource = TRect( |
|
2743 TPoint( 0, aBorderBitmapDividerTop ), |
|
2744 TPoint( aBorderBitmapDividerLeft, imageSize.iHeight - aBorderBitmapDividerBottom ) ); |
|
2745 if ( yStretch ) |
|
2746 { |
|
2747 aGc.DrawBitmap( left, aBitmap, leftSource ); |
|
2748 } |
|
2749 else if ( yRepeat && leftSource.Height() ) |
|
2750 { |
|
2751 TInt count = left.Height() / leftSource.Height(); |
|
2752 TInt leftHeight = left.Height(); |
|
2753 left.SetHeight( leftSource.Height() ); |
|
2754 for ( TInt i = 0; i < count; ++i ) |
|
2755 { |
|
2756 aGc.DrawBitmap( left, aBitmap, leftSource ); |
|
2757 left.Move( 0, leftSource.Height() ); |
|
2758 } |
|
2759 left.SetHeight( leftHeight - count * leftSource.Height() ); |
|
2760 aGc.DrawBitmap( left, aBitmap, leftSource ); |
|
2761 } |
|
2762 else if ( yRound && leftSource.Height() ) |
|
2763 { |
|
2764 TInt count = left.Height() / leftSource.Height(); |
|
2765 TInt leftHeight = left.Height(); |
|
2766 if ( ( count * leftSource.Height() ) < leftHeight ) |
|
2767 { |
|
2768 ++count; |
|
2769 left.SetHeight( leftHeight / count ); |
|
2770 } |
|
2771 else |
|
2772 { |
|
2773 left.SetHeight( leftSource.Width() ); |
|
2774 } |
|
2775 for ( TInt i = 0; i < count; ++i ) |
|
2776 { |
|
2777 aGc.DrawBitmap( left, aBitmap, leftSource ); |
|
2778 left.Move( 0, left.Height() ); |
|
2779 } |
|
2780 } |
|
2781 } |
|
2782 |
|
2783 // ----------------------------------------------------------------------------- |
|
2784 // IsPropertyNone |
|
2785 // ----------------------------------------------------------------------------- |
|
2786 // |
|
2787 static TBool IsPropertyNone( CXnProperty& aProperty ) |
|
2788 { |
|
2789 if ( &aProperty ) |
|
2790 { |
|
2791 TInt index = 0; |
|
2792 CXnDomProperty* domProperty = aProperty.Property(); |
|
2793 CXnDomPropertyValue* domPropertyValue = |
|
2794 static_cast< CXnDomPropertyValue* >( |
|
2795 domProperty->PropertyValueList().Item( index ) ); |
|
2796 return domPropertyValue->IsNoneIdent(); |
|
2797 } |
|
2798 return EFalse; |
|
2799 } |
|
2800 |
|
2801 // ----------------------------------------------------------------------------- |
|
2802 // DrawBordersL |
|
2803 // ----------------------------------------------------------------------------- |
|
2804 // |
|
2805 static void DrawBordersL( const TRect& aRect, CXnNode& aNode, CWindowGc& aGc ) |
|
2806 { |
|
2807 TRect borderRect( aNode.BorderRect() ); |
|
2808 |
|
2809 if( aNode.PaddingRect() == borderRect ) |
|
2810 { |
|
2811 return; |
|
2812 } |
|
2813 |
|
2814 CXnProperty* commonBorderStyle( aNode.BorderStyleL() ); |
|
2815 CXnProperty* borderStyle( aNode.BorderTopStyleL() ); |
|
2816 |
|
2817 if ( ( borderStyle && !IsPropertyNone( *borderStyle ) ) || |
|
2818 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) ) |
|
2819 { |
|
2820 DrawTopBorderL( aRect, aNode, aGc ); |
|
2821 } |
|
2822 |
|
2823 borderStyle = aNode.BorderLeftStyleL(); |
|
2824 |
|
2825 if ( ( borderStyle && !IsPropertyNone( *borderStyle ) ) || |
|
2826 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) ) |
|
2827 { |
|
2828 DrawLeftBorderL( aRect, aNode, aGc ); |
|
2829 } |
|
2830 |
|
2831 borderStyle = aNode.BorderRightStyleL(); |
|
2832 |
|
2833 if ( ( borderStyle && !IsPropertyNone( *borderStyle ) ) || |
|
2834 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) ) |
|
2835 { |
|
2836 DrawRightBorderL( aRect, aNode, aGc ); |
|
2837 } |
|
2838 |
|
2839 borderStyle = aNode.BorderBottomStyleL(); |
|
2840 |
|
2841 if ( ( borderStyle && !IsPropertyNone( *borderStyle ) ) || |
|
2842 ( commonBorderStyle && !IsPropertyNone( *commonBorderStyle ) ) ) |
|
2843 { |
|
2844 DrawBottomBorderL( aRect, aNode, aGc ); |
|
2845 } |
|
2846 } |
|
2847 |
|
2848 // ----------------------------------------------------------------------------- |
|
2849 // SwapChildArrays |
|
2850 // ----------------------------------------------------------------------------- |
|
2851 // |
|
2852 static void SwapChildArrays( |
|
2853 RPointerArray< CXnControlAdapter >& originalArray, |
|
2854 RPointerArray< CXnControlAdapter >& sortedArray ) |
|
2855 { |
|
2856 originalArray.Reset(); |
|
2857 TInt count = sortedArray.Count(); |
|
2858 for ( TInt i = 0; i < count; ++i ) |
|
2859 { |
|
2860 originalArray.Append( sortedArray[i] ); |
|
2861 } |
|
2862 sortedArray.Reset(); |
|
2863 } |
|
2864 |
|
2865 // ----------------------------------------------------------------------------- |
|
2866 // IsChildZIndexLowerThanCandidateZIndexL |
|
2867 // ----------------------------------------------------------------------------- |
|
2868 // |
|
2869 static TBool IsChildZIndexLowerThanCandidateZIndexL( |
|
2870 CXnProperty* aChildZIndex, |
|
2871 CXnDomPropertyValue* aChildZIndexValue, |
|
2872 CXnProperty* aCandidateZIndex ) |
|
2873 { |
|
2874 if ( !aChildZIndex && !aCandidateZIndex ) |
|
2875 { |
|
2876 return ETrue; |
|
2877 } |
|
2878 if ( !aChildZIndex ) |
|
2879 { |
|
2880 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
2881 aCandidateZIndex->Property()->PropertyValueList().Item( 0 ) ); |
|
2882 if ( value->IsAutoIdent() ) |
|
2883 { |
|
2884 return ETrue; |
|
2885 } |
|
2886 TReal num = value->FloatValueL(); |
|
2887 if ( num > 0 ) |
|
2888 { |
|
2889 return ETrue; |
|
2890 } |
|
2891 } |
|
2892 else if ( !aCandidateZIndex ) |
|
2893 { |
|
2894 if ( aChildZIndexValue->IsAutoIdent() ) |
|
2895 { |
|
2896 return ETrue; |
|
2897 } |
|
2898 TReal num = aChildZIndexValue->FloatValueL(); |
|
2899 if ( num < 0 ) |
|
2900 { |
|
2901 return ETrue; |
|
2902 } |
|
2903 } |
|
2904 else |
|
2905 { |
|
2906 CXnDomPropertyValue* candidateValue = |
|
2907 static_cast< CXnDomPropertyValue* >( |
|
2908 aCandidateZIndex->Property()->PropertyValueList().Item( 0 ) ); |
|
2909 if ( aChildZIndexValue->IsAutoIdent() && candidateValue->IsAutoIdent() ) |
|
2910 { |
|
2911 return ETrue; |
|
2912 } |
|
2913 else if ( aChildZIndexValue->IsAutoIdent() && !candidateValue->IsAutoIdent() ) |
|
2914 { |
|
2915 return ETrue; |
|
2916 } |
|
2917 else if ( !aChildZIndexValue->IsAutoIdent() && candidateValue->IsAutoIdent() ) |
|
2918 { |
|
2919 return EFalse; |
|
2920 } |
|
2921 TReal childNum = aChildZIndexValue->FloatValueL(); |
|
2922 TReal candidateNum = candidateValue->FloatValueL(); |
|
2923 if ( childNum <= candidateNum ) |
|
2924 { |
|
2925 return ETrue; |
|
2926 } |
|
2927 } |
|
2928 return EFalse; |
|
2929 } |
|
2930 |
|
2931 // ----------------------------------------------------------------------------- |
|
2932 // GetZIndex |
|
2933 // ----------------------------------------------------------------------------- |
|
2934 // |
|
2935 static CXnProperty* GetZIndexL( CXnControlAdapter* aAdapter ) |
|
2936 { |
|
2937 CXnComponent* component = aAdapter->Component(); |
|
2938 if ( !component ) |
|
2939 { |
|
2940 return NULL; |
|
2941 } |
|
2942 CXnNode& node = component->Node()->Node(); |
|
2943 return node.ZIndexL(); |
|
2944 } |
|
2945 |
|
2946 // ----------------------------------------------------------------------------- |
|
2947 // InsertChildToSortedArrayL |
|
2948 // ----------------------------------------------------------------------------- |
|
2949 // |
|
2950 static void InsertChildToSortedArrayL( |
|
2951 RPointerArray< CXnControlAdapter >& aTargetArray, |
|
2952 CXnControlAdapter* aChild ) |
|
2953 { |
|
2954 CXnProperty* childZIndex = GetZIndexL( aChild ); |
|
2955 CXnDomPropertyValue* childValue = NULL; |
|
2956 if ( childZIndex ) |
|
2957 { |
|
2958 childValue = static_cast< CXnDomPropertyValue* >( |
|
2959 childZIndex->Property()->PropertyValueList().Item( 0 ) ); |
|
2960 } |
|
2961 TInt count = aTargetArray.Count(); |
|
2962 for ( TInt i = 0; i < count; ++i ) |
|
2963 { |
|
2964 CXnControlAdapter* candidate = aTargetArray[i]; |
|
2965 if ( IsChildZIndexLowerThanCandidateZIndexL( |
|
2966 childZIndex, childValue, GetZIndexL( candidate ) ) ) |
|
2967 { |
|
2968 aTargetArray.Insert( aChild, i ); |
|
2969 return; |
|
2970 } |
|
2971 } |
|
2972 aTargetArray.Append( aChild ); |
|
2973 } |
|
2974 |
|
2975 // ----------------------------------------------------------------------------- |
|
2976 // InitializeBackgroundBitmapL |
|
2977 // ----------------------------------------------------------------------------- |
|
2978 // |
|
2979 static void InitializeBackgroundBitmapL( CXnUiEngine& aEngine, CXnNode& aNode, |
|
2980 TInt& aBitmapIndex, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, |
|
2981 CXnControlAdapterImpl::TIconProvider*& aIconProvider, RFs& aFsSession ) |
|
2982 { |
|
2983 HBufC* bgPath( GetBackgroundImagePathLC( aNode ) ); |
|
2984 TPtr ptr( bgPath->Des() ); |
|
2985 |
|
2986 GetBitmapL( aEngine, aNode, ptr, aBitmapIndex, |
|
2987 aBitmap, aMask, aIconProvider, aNode.PaddingRect(), aFsSession ); |
|
2988 |
|
2989 CleanupStack::PopAndDestroy( bgPath ); |
|
2990 |
|
2991 if ( !aMask ) |
|
2992 { |
|
2993 HBufC* bgMaskPath( GetBackgroundImageMaskPathLC( aNode ) ); |
|
2994 TPtr ptr( bgMaskPath->Des() ); |
|
2995 |
|
2996 if ( ptr != KNullDesC ) |
|
2997 { |
|
2998 CFbsBitmap* tmpMask( NULL ); |
|
2999 |
|
3000 TRAP_IGNORE( GetBitmapL( aEngine, aNode, ptr, aBitmapIndex, aMask, |
|
3001 tmpMask, aIconProvider, aNode.PaddingRect(), aFsSession ) ); |
|
3002 |
|
3003 delete tmpMask; |
|
3004 } |
|
3005 |
|
3006 CleanupStack::PopAndDestroy( bgMaskPath ); |
|
3007 } |
|
3008 } |
|
3009 |
|
3010 // ----------------------------------------------------------------------------- |
|
3011 // GetBackgroundImagePathLC |
|
3012 // ----------------------------------------------------------------------------- |
|
3013 // |
|
3014 static HBufC* GetBackgroundImagePathLC( CXnNode& aNode ) |
|
3015 { |
|
3016 CXnProperty* pathProperty( aNode.BackgroundImageL() ); |
|
3017 |
|
3018 if ( pathProperty && pathProperty->StringValue() != KNullDesC8 ) |
|
3019 { |
|
3020 HBufC* path( pathProperty->StringValueL() ); |
|
3021 CleanupStack::PushL( path ); |
|
3022 |
|
3023 CXnUtils::StripQuotes( path ); |
|
3024 |
|
3025 return path; |
|
3026 } |
|
3027 |
|
3028 return KNullDesC().AllocLC(); |
|
3029 } |
|
3030 |
|
3031 // ----------------------------------------------------------------------------- |
|
3032 // GetBackgroundImageMaskPathLC |
|
3033 // ----------------------------------------------------------------------------- |
|
3034 // |
|
3035 static HBufC* GetBackgroundImageMaskPathLC( CXnNode& aNode ) |
|
3036 { |
|
3037 CXnProperty* pathProperty( aNode.GetPropertyL( |
|
3038 XnPropertyNames::common::KBackgroundMask ) ); |
|
3039 |
|
3040 if ( pathProperty && pathProperty->StringValue() != KNullDesC8 ) |
|
3041 { |
|
3042 HBufC* path( pathProperty->StringValueL() ); |
|
3043 CleanupStack::PushL( path ); |
|
3044 |
|
3045 CXnUtils::StripQuotes( path ); |
|
3046 |
|
3047 return path; |
|
3048 } |
|
3049 |
|
3050 return KNullDesC().AllocLC(); |
|
3051 } |
|
3052 |
|
3053 // ----------------------------------------------------------------------------- |
|
3054 // InitializeBorderBitmapL |
|
3055 // ----------------------------------------------------------------------------- |
|
3056 // |
|
3057 static CFbsBitmap* InitializeBorderBitmapL( |
|
3058 CXnUiEngine& aEngine, |
|
3059 CXnNode& aNode, |
|
3060 TInt& aBitmapIndex, |
|
3061 TInt& aBorderBitmapDividerTop, |
|
3062 TInt& aBorderBitmapDividerRight, |
|
3063 TInt& aBorderBitmapDividerBottom, |
|
3064 TInt& aBorderBitmapDividerLeft, |
|
3065 CXnControlAdapterImpl::TIconProvider*& aIconProvider, |
|
3066 RFs& aFsSession ) |
|
3067 { |
|
3068 CXnProperty* pathProperty = aNode.BorderImageL(); |
|
3069 CFbsBitmap* returnValue = NULL; |
|
3070 CFbsBitmap* bitmapMask = NULL; |
|
3071 |
|
3072 if ( !pathProperty ) |
|
3073 { |
|
3074 return NULL; |
|
3075 } |
|
3076 |
|
3077 CXnDomList& propertyValueList = pathProperty->Property()->PropertyValueList(); |
|
3078 TInt count = propertyValueList.Length(); |
|
3079 |
|
3080 for ( TInt i = 0; i < count; ++i ) |
|
3081 { |
|
3082 CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >( |
|
3083 propertyValueList.Item( i ) ); |
|
3084 |
|
3085 if ( value->PrimitiveValueType() == CXnDomPropertyValue::EUri ) |
|
3086 { |
|
3087 const TDesC8& path = value->StringValueL(); |
|
3088 |
|
3089 HBufC* utfPath = HBufC::NewL( path.Length() ); |
|
3090 TPtr16 ptr = utfPath->Des(); |
|
3091 |
|
3092 CnvUtfConverter::ConvertToUnicodeFromUtf8( ptr, path ); |
|
3093 CleanupStack::PushL( utfPath ); |
|
3094 |
|
3095 StripQuotes( utfPath ); |
|
3096 |
|
3097 GetBitmapL( aEngine, aNode, *utfPath, aBitmapIndex, returnValue, |
|
3098 bitmapMask, aIconProvider, aNode.BorderRect(), aFsSession ); |
|
3099 |
|
3100 delete bitmapMask; |
|
3101 |
|
3102 CleanupStack::PopAndDestroy( utfPath ); |
|
3103 } |
|
3104 else if ( value->PrimitiveValueType() == CXnDomPropertyValue::EPercentage ) |
|
3105 { |
|
3106 if ( returnValue ) |
|
3107 { |
|
3108 CXnDomPropertyValue* tmpValue = NULL; |
|
3109 tmpValue = value->CloneL(); |
|
3110 CXnProperty* tmpProperty = NULL; |
|
3111 CleanupStack::PushL( tmpValue ); |
|
3112 tmpProperty = CXnProperty::NewL( |
|
3113 KNullDesC8, |
|
3114 tmpValue, |
|
3115 *aNode.UiEngine()->ODT()->DomDocument().StringPool() ); |
|
3116 CleanupStack::Pop( tmpValue ); |
|
3117 TSize imageSize = returnValue->SizeInPixels(); |
|
3118 CleanupStack::PushL( tmpProperty ); |
|
3119 TInt intValue = static_cast< TInt >( value->FloatValueL() ); |
|
3120 TInt dividerValue = 0; |
|
3121 |
|
3122 switch ( i ) |
|
3123 { |
|
3124 case 1: |
|
3125 { |
|
3126 dividerValue = aNode.UiEngine()->VerticalPixelValueL( |
|
3127 tmpProperty, imageSize.iHeight ); |
|
3128 aBorderBitmapDividerTop = dividerValue; |
|
3129 break; |
|
3130 } |
|
3131 case 2: |
|
3132 { |
|
3133 dividerValue = aNode.UiEngine()->HorizontalPixelValueL( |
|
3134 tmpProperty, imageSize.iWidth ); |
|
3135 aBorderBitmapDividerRight = dividerValue; |
|
3136 break; |
|
3137 } |
|
3138 case 3: |
|
3139 { |
|
3140 dividerValue = aNode.UiEngine()->VerticalPixelValueL( |
|
3141 tmpProperty, imageSize.iHeight ); |
|
3142 aBorderBitmapDividerBottom = dividerValue; |
|
3143 break; |
|
3144 } |
|
3145 case 4: |
|
3146 { |
|
3147 dividerValue = aNode.UiEngine()->HorizontalPixelValueL( |
|
3148 tmpProperty, imageSize.iWidth ); |
|
3149 aBorderBitmapDividerLeft = dividerValue; |
|
3150 break; |
|
3151 } |
|
3152 } |
|
3153 |
|
3154 CleanupStack::PopAndDestroy( tmpProperty ); |
|
3155 } |
|
3156 } |
|
3157 else if ( value->PrimitiveValueType() == CXnDomPropertyValue::EString || |
|
3158 value->PrimitiveValueType() == CXnDomPropertyValue::EIdent ) |
|
3159 { |
|
3160 } |
|
3161 else |
|
3162 { |
|
3163 TInt intValue = static_cast< TInt >( value->FloatValueL() ); |
|
3164 |
|
3165 switch ( i ) |
|
3166 { |
|
3167 case 1: |
|
3168 { |
|
3169 aBorderBitmapDividerTop = intValue; |
|
3170 break; |
|
3171 } |
|
3172 case 2: |
|
3173 { |
|
3174 aBorderBitmapDividerRight = intValue; |
|
3175 break; |
|
3176 } |
|
3177 case 3: |
|
3178 { |
|
3179 aBorderBitmapDividerBottom = intValue; |
|
3180 break; |
|
3181 } |
|
3182 case 4: |
|
3183 { |
|
3184 aBorderBitmapDividerLeft = intValue; |
|
3185 break; |
|
3186 } |
|
3187 } |
|
3188 } |
|
3189 } |
|
3190 |
|
3191 return returnValue; |
|
3192 } |
|
3193 |
|
3194 // ----------------------------------------------------------------------------- |
|
3195 // BuildTriggerTypeNodeL |
|
3196 // ----------------------------------------------------------------------------- |
|
3197 // |
|
3198 static CXnNode* BuildTriggerTypeNodeL( const TDesC8& aName, |
|
3199 const TDesC8& aValue, CXnUiEngine& aUiEngine ) |
|
3200 { |
|
3201 CXnNode* node = CXnNode::NewL(); |
|
3202 CleanupStack::PushL( node ); |
|
3203 CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty ); |
|
3204 CleanupStack::PushL( type ); |
|
3205 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
3206 CleanupStack::Pop( type ); |
|
3207 node->SetImpl( impl ); |
|
3208 node->SetUiEngine( aUiEngine ); |
|
3209 CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL( |
|
3210 aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3211 CleanupStack::PushL( nameValue ); |
|
3212 nameValue->SetStringValueL( CXnDomPropertyValue::EString, aName ); |
|
3213 CXnProperty* name = CXnProperty::NewL( XnPropertyNames::action::KName, |
|
3214 nameValue, *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3215 CleanupStack::Pop( nameValue ); |
|
3216 CleanupStack::PushL( name ); |
|
3217 node->SetPropertyL( name ); |
|
3218 CleanupStack::Pop( name ); |
|
3219 CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL( |
|
3220 aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3221 CleanupStack::PushL( valueValue ); |
|
3222 valueValue->SetStringValueL( CXnDomPropertyValue::EString, aValue ); |
|
3223 CXnProperty* value = CXnProperty::NewL( XnPropertyNames::action::KValue, |
|
3224 valueValue, *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3225 CleanupStack::Pop( valueValue ); |
|
3226 CleanupStack::PushL( value ); |
|
3227 node->SetPropertyL( value ); |
|
3228 CleanupStack::Pop( value ); |
|
3229 CleanupStack::Pop( node ); |
|
3230 return node; |
|
3231 } |
|
3232 |
|
3233 // ----------------------------------------------------------------------------- |
|
3234 // BuildTriggerNodeL |
|
3235 // Builds a trigger node |
|
3236 // ----------------------------------------------------------------------------- |
|
3237 // |
|
3238 static CXnNode* BuildTriggerNodeL( |
|
3239 CXnUiEngine& aUiEngine, |
|
3240 const TDesC8& aTriggerName, |
|
3241 const TDesC8& aTriggerValueName, |
|
3242 const TDesC8& aTriggerValue ) |
|
3243 { |
|
3244 CXnNode* node = CXnNode::NewL(); |
|
3245 CleanupStack::PushL( node ); |
|
3246 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
3247 CleanupStack::PushL( type ); |
|
3248 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
3249 CleanupStack::Pop( type ); |
|
3250 node->SetImpl( impl ); |
|
3251 node->SetUiEngine( aUiEngine ); |
|
3252 CXnDomPropertyValue* nameValue = |
|
3253 CXnDomPropertyValue::NewL( aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3254 CleanupStack::PushL( nameValue ); |
|
3255 nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName ); |
|
3256 CXnProperty* name = CXnProperty::NewL( XnPropertyNames::action::trigger::KName, |
|
3257 nameValue, *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3258 CleanupStack::Pop( nameValue ); |
|
3259 CleanupStack::PushL( name ); |
|
3260 node->SetPropertyL( name ); |
|
3261 CleanupStack::Pop( name ); |
|
3262 CXnNode* triggerType = BuildTriggerTypeNodeL( aTriggerValueName, |
|
3263 aTriggerValue, aUiEngine ); |
|
3264 CleanupStack::PushL( triggerType ); |
|
3265 node->AddChildL( triggerType ); |
|
3266 CleanupStack::Pop( triggerType ); |
|
3267 CleanupStack::Pop( node ); |
|
3268 return node; |
|
3269 } |
|
3270 |
|
3271 // ----------------------------------------------------------------------------- |
|
3272 // BuildTriggerNodeL |
|
3273 // Builds a trigger node |
|
3274 // ----------------------------------------------------------------------------- |
|
3275 // |
|
3276 static CXnNode* BuildTriggerNodeL( |
|
3277 CXnUiEngine& aUiEngine, |
|
3278 const TDesC8& aTriggerName ) |
|
3279 { |
|
3280 CXnNode* node = CXnNode::NewL(); |
|
3281 CleanupStack::PushL( node ); |
|
3282 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
3283 CleanupStack::PushL( type ); |
|
3284 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
3285 CleanupStack::Pop( type ); |
|
3286 node->SetImpl( impl ); |
|
3287 node->SetUiEngine( aUiEngine ); |
|
3288 CXnDomPropertyValue* nameValue = |
|
3289 CXnDomPropertyValue::NewL( aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3290 CleanupStack::PushL( nameValue ); |
|
3291 nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName ); |
|
3292 CXnProperty* name = CXnProperty::NewL( XnPropertyNames::action::trigger::KName, |
|
3293 nameValue, *aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3294 CleanupStack::Pop( nameValue ); |
|
3295 CleanupStack::PushL( name ); |
|
3296 node->SetPropertyL( name ); |
|
3297 CleanupStack::Pop( name ); |
|
3298 CleanupStack::Pop( node ); |
|
3299 return node; |
|
3300 } |
|
3301 |
|
3302 // ----------------------------------------------------------------------------- |
|
3303 // SoftkeyNode |
|
3304 // Gets the node of softkey according to pointer location |
|
3305 // ----------------------------------------------------------------------------- |
|
3306 // |
|
3307 static CXnNode* SoftkeyNode( CXnNode* aMenuBarNode, const TPoint aPosition ) |
|
3308 { |
|
3309 if ( aMenuBarNode ) |
|
3310 { |
|
3311 CXnMenuAdapter* adapter = static_cast< CXnMenuAdapter* >( |
|
3312 aMenuBarNode->ComponentNodeImpl()->Component()->ControlAdapter() ); |
|
3313 |
|
3314 CXnNodePluginIf* node( NULL ); |
|
3315 |
|
3316 if ( adapter->FindSoftKeyNodeByPosition( aPosition, node ) ) |
|
3317 { |
|
3318 return &node->Node(); |
|
3319 } |
|
3320 } |
|
3321 |
|
3322 return NULL; |
|
3323 } |
|
3324 |
|
3325 // ----------------------------------------------------------------------------- |
|
3326 // DrawFocusAppearance |
|
3327 // Draws focus appearance |
|
3328 // ----------------------------------------------------------------------------- |
|
3329 // |
|
3330 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc ) |
|
3331 { |
|
3332 TBool grow( EFalse ); |
|
3333 |
|
3334 const TDesC8& name( aNode.DomNode()->Name() ); |
|
3335 |
|
3336 if( name == XnPropertyNames::KPlugin ) |
|
3337 { |
|
3338 grow = ETrue; |
|
3339 } |
|
3340 else |
|
3341 { |
|
3342 TRect marginRect( aNode.MarginRect() ); |
|
3343 |
|
3344 CXnNode* parent( aNode.Parent() ); |
|
3345 |
|
3346 for( ; parent; parent = parent->Parent() ) |
|
3347 { |
|
3348 if( parent->DomNode()->Name() == XnPropertyNames::KPlugin ) |
|
3349 { |
|
3350 if( parent->Rect() == marginRect ) |
|
3351 { |
|
3352 grow = ETrue; |
|
3353 } |
|
3354 |
|
3355 break; |
|
3356 } |
|
3357 } |
|
3358 } |
|
3359 |
|
3360 TRect rect( aNode.PaddingRect() ); |
|
3361 |
|
3362 if( grow ) |
|
3363 { |
|
3364 rect.Grow( KFocusGrowValue, KFocusGrowValue ); |
|
3365 } |
|
3366 |
|
3367 CXnAppUiAdapter* appui( |
|
3368 static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
|
3369 |
|
3370 appui->ViewAdapter().FocusControl().Draw( rect, aGc ); |
|
3371 } |
|
3372 |
|
3373 // ----------------------------------------------------------------------------- |
|
3374 // HasHoldTrigger |
|
3375 // Queries whether this node has a hold trigger defined |
|
3376 // ----------------------------------------------------------------------------- |
|
3377 // |
|
3378 static CXnDomNode* HasHoldTrigger( CXnDomNode* aNode ) |
|
3379 { |
|
3380 if ( !aNode ) |
|
3381 { |
|
3382 return NULL; |
|
3383 } |
|
3384 |
|
3385 if ( aNode->Name() == XnPropertyNames::action::KTrigger ) |
|
3386 { |
|
3387 CXnDomList& list( aNode->AttributeList() ); |
|
3388 |
|
3389 CXnDomAttribute* name( NULL ); |
|
3390 |
|
3391 name = static_cast< CXnDomAttribute* >( |
|
3392 list.FindByName( XnPropertyNames::action::KName ) ); |
|
3393 |
|
3394 if ( name && name->Value() == XnPropertyNames::action::trigger::name::KHold ) |
|
3395 { |
|
3396 return aNode; |
|
3397 } |
|
3398 } |
|
3399 |
|
3400 CXnDomList& list( aNode->ChildNodes() ); |
|
3401 |
|
3402 for ( TInt i = 0; i < list.Length(); i++ ) |
|
3403 { |
|
3404 CXnDomNode* retval( HasHoldTrigger( |
|
3405 static_cast< CXnDomNode* >( list.Item( i ) ) ) ); |
|
3406 |
|
3407 if ( retval ) |
|
3408 { |
|
3409 return retval; |
|
3410 } |
|
3411 } |
|
3412 |
|
3413 return NULL; |
|
3414 } |
|
3415 |
|
3416 // ----------------------------------------------------------------------------- |
|
3417 // CancelFocusRefusalL |
|
3418 // Cancels focus refusal |
|
3419 // ----------------------------------------------------------------------------- |
|
3420 // |
|
3421 static void CancelFocusRefusalL( CXnUiEngine& aUiEngine ) |
|
3422 { |
|
3423 CXnNode* focused( aUiEngine.FocusedNode() ); |
|
3424 |
|
3425 if ( focused ) |
|
3426 { |
|
3427 CXnControlAdapter* control( focused->Control() ); |
|
3428 |
|
3429 if ( control && control->RefusesFocusLoss() ) |
|
3430 { |
|
3431 focused->HideTooltipsL(); |
|
3432 |
|
3433 // It is now time to give up holding focus |
|
3434 focused->UnsetStateL( |
|
3435 XnPropertyNames::style::common::KFocus ); |
|
3436 } |
|
3437 } |
|
3438 } |
|
3439 |
|
3440 // ----------------------------------------------------------------------------- |
|
3441 // Calculates scaled bitmap size (rect) |
|
3442 // ----------------------------------------------------------------------------- |
|
3443 // |
|
3444 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize, |
|
3445 const TSize& aImageSize ) |
|
3446 { |
|
3447 //no scaling as default |
|
3448 TReal scaleRatio( 1.0f ); |
|
3449 aScaledSize.SetSize( aDrawSize.iWidth, aDrawSize.iHeight ); |
|
3450 |
|
3451 //If any dimension is 0, then we do not bother to scale |
|
3452 if ( aDrawSize.iWidth == 0 || aDrawSize.iHeight == 0 ) |
|
3453 { |
|
3454 return; |
|
3455 } |
|
3456 |
|
3457 TReal xRatio = |
|
3458 ( ( TReal )aImageSize.iWidth / ( TReal )aDrawSize.iWidth ); |
|
3459 TReal yRatio = |
|
3460 ( ( TReal )aImageSize.iHeight / ( TReal )aDrawSize.iHeight ); |
|
3461 //Find out appropriate scaling factor |
|
3462 xRatio > yRatio ? ( scaleRatio = xRatio ) : ( scaleRatio = yRatio ); |
|
3463 |
|
3464 // ratio is too small (can be considered as division by zero) |
|
3465 if ( scaleRatio < KEps && scaleRatio > -KEps ) |
|
3466 { |
|
3467 return; |
|
3468 } |
|
3469 |
|
3470 // Otherwise scaling can be done |
|
3471 aScaledSize.iWidth = ( TInt )( ( TReal )aImageSize.iWidth / scaleRatio ); |
|
3472 aScaledSize.iHeight = |
|
3473 ( TInt )( ( TReal )aImageSize.iHeight / scaleRatio ); |
|
3474 } |
|
3475 |
|
3476 // ----------------------------------------------------------------------------- |
|
3477 // BuildSwipeTriggerNodeLC |
|
3478 // Build trigger node for swipe event |
|
3479 // ----------------------------------------------------------------------------- |
|
3480 // |
|
3481 CXnNode* CXnControlAdapterImpl::BuildSwipeTriggerNodeLC( |
|
3482 CXnUiEngine& aUiEngine, |
|
3483 const TDesC8& aDirection ) |
|
3484 { |
|
3485 CXnDomStringPool* sp( aUiEngine.ODT()->DomDocument().StringPool() ); |
|
3486 |
|
3487 CXnNode* node = CXnNode::NewL(); |
|
3488 CleanupStack::PushL( node ); |
|
3489 |
|
3490 CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger ); |
|
3491 CleanupStack::PushL( type ); |
|
3492 |
|
3493 CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); |
|
3494 CleanupStack::Pop( type ); |
|
3495 |
|
3496 node->SetImpl( impl ); |
|
3497 node->SetUiEngine( aUiEngine ); |
|
3498 |
|
3499 CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL( sp ); |
|
3500 CleanupStack::PushL( nameValue ); |
|
3501 |
|
3502 nameValue->SetStringValueL( |
|
3503 CXnDomPropertyValue::EString, |
|
3504 XnPropertyNames::action::trigger::name::KSwipe ); |
|
3505 |
|
3506 CXnProperty* name = CXnProperty::NewL( |
|
3507 XnPropertyNames::action::trigger::KName, |
|
3508 nameValue, *sp ); |
|
3509 |
|
3510 CleanupStack::Pop( nameValue ); |
|
3511 CleanupStack::PushL( name ); |
|
3512 |
|
3513 node->SetPropertyL( name ); |
|
3514 CleanupStack::Pop( name ); |
|
3515 |
|
3516 CXnDomPropertyValue* reasonValue = CXnDomPropertyValue::NewL( sp ); |
|
3517 CleanupStack::PushL( reasonValue ); |
|
3518 |
|
3519 reasonValue->SetStringValueL( CXnDomPropertyValue::EString, aDirection ); |
|
3520 |
|
3521 CXnProperty* reason = CXnProperty::NewL( |
|
3522 XnPropertyNames::action::trigger::name::swipe::KDirection, |
|
3523 reasonValue, *sp ); |
|
3524 |
|
3525 CleanupStack::Pop( reasonValue ); |
|
3526 |
|
3527 CleanupStack::PushL( reason ); |
|
3528 node->SetPropertyL( reason ); |
|
3529 CleanupStack::Pop( reason ); |
|
3530 |
|
3531 return node; |
|
3532 } |
|
3533 |
|
3534 // ----------------------------------------------------------------------------- |
|
3535 // CreateGestureHelperL |
|
3536 // Checks whether gesture is needed to be detected for this node |
|
3537 // ----------------------------------------------------------------------------- |
|
3538 // |
|
3539 static TBool CreateGestureHelperL( CXnNode& aNode ) |
|
3540 { |
|
3541 if ( AknLayoutUtils::PenEnabled() ) |
|
3542 { |
|
3543 CXnProperty* prop( aNode.GetPropertyL( XnPropertyNames::common::KSwipe ) ); |
|
3544 |
|
3545 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
|
3546 { |
|
3547 return ETrue; |
|
3548 } |
|
3549 } |
|
3550 |
|
3551 return EFalse; |
|
3552 } |
|
3553 |
|
3554 // ============================ MEMBER FUNCTIONS =============================== |
|
3555 |
|
3556 // ----------------------------------------------------------------------------- |
|
3557 // CXnControlAdapterImpl::NewL |
|
3558 // Two-phased constructor. Can leave. |
|
3559 // ----------------------------------------------------------------------------- |
|
3560 // |
|
3561 CXnControlAdapterImpl* CXnControlAdapterImpl::NewL( |
|
3562 CXnNodePluginIf& aNode, |
|
3563 CXnControlAdapter& aAdapter, |
|
3564 CWindowGc& aGc ) |
|
3565 { |
|
3566 CXnControlAdapterImpl* self = new ( ELeave ) CXnControlAdapterImpl( aNode ); |
|
3567 CleanupStack::PushL( self ); |
|
3568 self->ConstructL( aNode, aAdapter, aGc ); |
|
3569 CleanupStack::Pop(); |
|
3570 return self; |
|
3571 } |
|
3572 |
|
3573 // ----------------------------------------------------------------------------- |
|
3574 // CXnControlAdapterImpl::~CXnControlAdapterImpl |
|
3575 // Destructor. |
|
3576 // ----------------------------------------------------------------------------- |
|
3577 // |
|
3578 CXnControlAdapterImpl::~CXnControlAdapterImpl() |
|
3579 { |
|
3580 delete iBackgroundBitmap; |
|
3581 delete iBackgroundMask; |
|
3582 delete iBorderBitmap; |
|
3583 delete iContentBitmap; |
|
3584 delete iContentMask; |
|
3585 |
|
3586 iChildren.Reset(); |
|
3587 |
|
3588 if ( iAnimation ) |
|
3589 { |
|
3590 iAnimation->Stop(); |
|
3591 delete iAnimation; |
|
3592 } |
|
3593 |
|
3594 delete iGestureFw; |
|
3595 delete iSuppressor; |
|
3596 } |
|
3597 |
|
3598 // ----------------------------------------------------------------------------- |
|
3599 // CXnControlAdapterImpl::CXnControlAdapterImpl |
|
3600 // C++ default constructor. Must not leave. |
|
3601 // ----------------------------------------------------------------------------- |
|
3602 // |
|
3603 CXnControlAdapterImpl::CXnControlAdapterImpl( CXnNodePluginIf& aNode ) |
|
3604 : iNode( aNode ), |
|
3605 iBackgrondInitialized ( EFalse ), |
|
3606 iBorderInitialized ( EFalse ) |
|
3607 { |
|
3608 } |
|
3609 |
|
3610 // ----------------------------------------------------------------------------- |
|
3611 // CXnControlAdapterImpl::SetComponent |
|
3612 // Sets component object to adapter. |
|
3613 // ----------------------------------------------------------------------------- |
|
3614 // |
|
3615 void CXnControlAdapterImpl::SetComponent( CXnComponent* aComponent ) |
|
3616 { |
|
3617 iComponent = aComponent; |
|
3618 } |
|
3619 |
|
3620 // ----------------------------------------------------------------------------- |
|
3621 // CXnControlAdapterImpl::Component |
|
3622 // Gets component object from adapter. |
|
3623 // ----------------------------------------------------------------------------- |
|
3624 // |
|
3625 CXnComponent* CXnControlAdapterImpl::Component() |
|
3626 { |
|
3627 return iComponent; |
|
3628 } |
|
3629 |
|
3630 // ----------------------------------------------------------------------------- |
|
3631 // CXnControlAdapterImpl::Component |
|
3632 // Gets component object from adapter. |
|
3633 // ----------------------------------------------------------------------------- |
|
3634 // |
|
3635 CXnComponent* CXnControlAdapterImpl::Component() const |
|
3636 { |
|
3637 return iComponent; |
|
3638 } |
|
3639 |
|
3640 // ----------------------------------------------------------------------------- |
|
3641 // CXnControlAdapterImpl::OfferKeyEventL |
|
3642 // Handles key events. |
|
3643 // ----------------------------------------------------------------------------- |
|
3644 // |
|
3645 TKeyResponse CXnControlAdapterImpl::OfferKeyEventL( |
|
3646 const TKeyEvent& aKeyEvent, |
|
3647 TEventCode aType ) |
|
3648 { |
|
3649 CXnNode* node( &iNode.Node() ); |
|
3650 |
|
3651 // Need to get softkey nodes |
|
3652 CXnUiEngine* engine( node->UiEngine() ); |
|
3653 |
|
3654 CXnNode* menuBar( engine->MenuBarNode() ); |
|
3655 |
|
3656 CXnNode* temp( node ); |
|
3657 |
|
3658 for ( ; temp; temp = temp->Parent() ) |
|
3659 { |
|
3660 if ( temp == menuBar ) |
|
3661 { |
|
3662 // This is softkey node |
|
3663 XnMenuInterface::MXnMenuInterface* menuIf( NULL ); |
|
3664 XnComponentInterface::MakeInterfaceL( menuIf, menuBar->AppIfL() ); |
|
3665 |
|
3666 if ( menuIf ) |
|
3667 { |
|
3668 CXnNodePluginIf* eventNode( menuIf->KeyEventNode() ); |
|
3669 |
|
3670 if ( eventNode ) |
|
3671 { |
|
3672 node = &eventNode->Node(); |
|
3673 } |
|
3674 } |
|
3675 |
|
3676 break; |
|
3677 } |
|
3678 } |
|
3679 |
|
3680 if ( !node ) |
|
3681 { |
|
3682 return EKeyWasNotConsumed; |
|
3683 } |
|
3684 |
|
3685 if ( aKeyEvent.iScanCode == EStdKeyDevice0 || // RSK |
|
3686 aKeyEvent.iScanCode == EStdKeyDevice1 || // LSK |
|
3687 aKeyEvent.iScanCode == EStdKeyDevice3 || // MSK |
|
3688 aKeyEvent.iCode == EKeyEnter ) |
|
3689 { |
|
3690 if ( aType == EEventKeyDown ) |
|
3691 { |
|
3692 iLongtap = EFalse; |
|
3693 |
|
3694 if ( aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
3695 aKeyEvent.iCode == EKeyEnter ) |
|
3696 { |
|
3697 if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
3698 { |
|
3699 // Set "pressed down" |
|
3700 node->SetStateL( |
|
3701 XnPropertyNames::style::common::KPressedDown ); |
|
3702 |
|
3703 node->UiEngine()->RenderUIL(); |
|
3704 } |
|
3705 } |
|
3706 |
|
3707 _LIT8( KDown, "3" ); // EEventKeyDown == 3 |
|
3708 |
|
3709 CXnNode* keydown( BuildTriggerNodeL( *engine, |
|
3710 XnPropertyNames::action::trigger::name::KActivate, |
|
3711 XnPropertyNames::action::trigger::name::keyevent::KEventType, KDown ) ); |
|
3712 CleanupStack::PushL( keydown ); |
|
3713 |
|
3714 node->ReportXuikonEventL( *keydown ); |
|
3715 |
|
3716 CleanupStack::PopAndDestroy( keydown ); |
|
3717 } |
|
3718 else if( aType == EEventKey ) |
|
3719 { |
|
3720 if ( aKeyEvent.iRepeats == 0 ) |
|
3721 { |
|
3722 if ( !HasHoldTrigger( node->DomNode() ) ) |
|
3723 { |
|
3724 // If node doesn't define hold trigger, then report activate |
|
3725 // immediately. Otherwise activate is triggered with keyup event |
|
3726 node->SetStateL( |
|
3727 XnPropertyNames::style::common::KActive ); |
|
3728 } |
|
3729 } |
|
3730 else |
|
3731 { |
|
3732 CXnNode* hold( BuildTriggerNodeL( *engine, |
|
3733 XnPropertyNames::action::trigger::name::KHold ) ); |
|
3734 CleanupStack::PushL( hold ); |
|
3735 |
|
3736 node->ReportXuikonEventL( *hold ); |
|
3737 |
|
3738 CleanupStack::PopAndDestroy( hold ); |
|
3739 |
|
3740 iLongtap = ETrue; |
|
3741 } |
|
3742 } |
|
3743 |
|
3744 else if ( aType == EEventKeyUp ) |
|
3745 { |
|
3746 if ( !iLongtap ) |
|
3747 { |
|
3748 if ( HasHoldTrigger( node->DomNode() ) ) |
|
3749 { |
|
3750 // Hold trigger defined, report activate event here |
|
3751 node->SetStateL( |
|
3752 XnPropertyNames::style::common::KActive ); |
|
3753 } |
|
3754 else |
|
3755 { |
|
3756 _LIT8( KUp, "2" ); // EEventKeyUp == 2 |
|
3757 |
|
3758 CXnNode* keyup( BuildTriggerNodeL( *engine, |
|
3759 XnPropertyNames::action::trigger::name::KActivate, |
|
3760 XnPropertyNames::action::trigger::name::keyevent::KEventType, KUp ) ); |
|
3761 CleanupStack::PushL( keyup ); |
|
3762 |
|
3763 node->ReportXuikonEventL( *keyup ); |
|
3764 |
|
3765 CleanupStack::PopAndDestroy( keyup ); |
|
3766 } |
|
3767 } |
|
3768 |
|
3769 if ( aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
3770 aKeyEvent.iCode == EKeyEnter ) |
|
3771 { |
|
3772 // Reset "pressed down" |
|
3773 node->UnsetStateL( |
|
3774 XnPropertyNames::style::common::KPressedDown ); |
|
3775 |
|
3776 node->UiEngine()->RenderUIL(); |
|
3777 } |
|
3778 |
|
3779 iLongtap = EFalse; |
|
3780 } |
|
3781 } |
|
3782 else |
|
3783 { |
|
3784 // Other than softkey node |
|
3785 node->OfferKeyEventL( aKeyEvent, aType ); |
|
3786 } |
|
3787 |
|
3788 CXnNode* viewNode( engine->ActiveView() ); |
|
3789 |
|
3790 if ( viewNode && node != viewNode ) |
|
3791 { |
|
3792 viewNode->OfferKeyEventL( aKeyEvent, aType ); |
|
3793 } |
|
3794 |
|
3795 return EKeyWasConsumed; |
|
3796 } |
|
3797 |
|
3798 // ----------------------------------------------------------------------------- |
|
3799 // CXnControlAdapterImpl::HandleLongTapEventL |
|
3800 // Handles the long tap events. |
|
3801 // ----------------------------------------------------------------------------- |
|
3802 // |
|
3803 void CXnControlAdapterImpl::HandleLongTapEventL( |
|
3804 const TPoint& /*aPenEventLocation*/, const TPoint& aPenEventScreenLocation ) |
|
3805 { |
|
3806 CXnNode* node( &iNode.Node() ); |
|
3807 |
|
3808 CXnUiEngine* engine( node->UiEngine() ); |
|
3809 |
|
3810 TBool menuBar( node == engine->MenuBarNode() ); |
|
3811 |
|
3812 if ( menuBar ) |
|
3813 { |
|
3814 // Need to update node to match to the real softkey node |
|
3815 node = SoftkeyNode( engine->MenuBarNode(), aPenEventScreenLocation ); |
|
3816 } |
|
3817 |
|
3818 if ( node ) |
|
3819 { |
|
3820 CXnProperty* prop( node->GetPropertyL( |
|
3821 XnPropertyNames::common::KLongTap ) ); |
|
3822 |
|
3823 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
|
3824 { |
|
3825 CXnUiEngine* engine( node->UiEngine() ); |
|
3826 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
|
3827 |
|
3828 CancelFocusRefusalL( *engine ); |
|
3829 |
|
3830 appui.HideFocus(); |
|
3831 |
|
3832 if ( !menuBar ) |
|
3833 { |
|
3834 CXnViewControlAdapter* control = static_cast< CXnViewControlAdapter* >( |
|
3835 appui.ViewManager().ActiveViewData().ViewNode()->Control() ); |
|
3836 |
|
3837 control->ResetGrabbing(); |
|
3838 |
|
3839 #ifdef RD_TACTILE_FEEDBACK |
|
3840 MTouchFeedback* feedback( MTouchFeedback::Instance() ); |
|
3841 |
|
3842 if ( feedback ) |
|
3843 { |
|
3844 feedback->InstantFeedback( iAdapter, ETouchFeedbackBasic, |
|
3845 ETouchFeedbackVibra, TPointerEvent() ); |
|
3846 |
|
3847 } |
|
3848 #endif |
|
3849 } |
|
3850 |
|
3851 // Indicate long tap has taken place |
|
3852 iLongtap = ETrue; |
|
3853 |
|
3854 CXnNode* hold = BuildTriggerNodeL( *engine, |
|
3855 XnPropertyNames::action::trigger::name::KHold ); |
|
3856 |
|
3857 CleanupStack::PushL( hold ); |
|
3858 |
|
3859 node->ReportXuikonEventL( *hold ); |
|
3860 |
|
3861 CleanupStack::PopAndDestroy( hold ); |
|
3862 } |
|
3863 } |
|
3864 } |
|
3865 |
|
3866 // ----------------------------------------------------------------------------- |
|
3867 // CXnControlAdapterImpl::IsDragThresholdExceeded |
|
3868 // Checks if drag threshold is exceeded |
|
3869 // ----------------------------------------------------------------------------- |
|
3870 // |
|
3871 TBool CXnControlAdapterImpl::IsDragThresholdExceeded( const TPoint& aPoint ) |
|
3872 { |
|
3873 TBool ret = EFalse; |
|
3874 TPoint distance = aPoint - iButtonDownStartPoint; |
|
3875 if ( Abs( distance.iX ) >= KDragThreshold || |
|
3876 Abs( distance.iY ) >= KDragThreshold ) |
|
3877 { |
|
3878 ret = ETrue; |
|
3879 } |
|
3880 return ret; |
|
3881 } |
|
3882 |
|
3883 // ----------------------------------------------------------------------------- |
|
3884 // CXnControlAdapterImpl::HandlePointerEventL |
|
3885 // Handle pointer events |
|
3886 // ----------------------------------------------------------------------------- |
|
3887 // |
|
3888 TBool CXnControlAdapterImpl::HandlePointerEventL( |
|
3889 const TPointerEvent& aPointerEvent ) |
|
3890 { |
|
3891 const TPointerEvent& event( aPointerEvent ); |
|
3892 |
|
3893 CXnNode* node( &iNode.Node() ); |
|
3894 CXnUiEngine* engine( node->UiEngine() ); |
|
3895 |
|
3896 if ( !engine->IsPartialInputActive() ) |
|
3897 { |
|
3898 InitializeGestureL( aPointerEvent ); |
|
3899 } |
|
3900 else |
|
3901 { |
|
3902 // reset destination |
|
3903 iGestureDestination = NULL; |
|
3904 } |
|
3905 |
|
3906 TBool menuBar( node == engine->MenuBarNode() ); |
|
3907 |
|
3908 if ( menuBar ) |
|
3909 { |
|
3910 // Need to update node to match to the real softkey node |
|
3911 node = SoftkeyNode( engine->MenuBarNode(), event.iParentPosition ); |
|
3912 |
|
3913 if ( !node ) |
|
3914 { |
|
3915 // No softkey node found, consume event |
|
3916 return ETrue; |
|
3917 } |
|
3918 } |
|
3919 else if ( iSuppressor && |
|
3920 iSuppressor->SuppressPointerEvent( aPointerEvent ) ) |
|
3921 { |
|
3922 // if view does not handle swipe we have to pass event to children |
|
3923 return ( iGestureDestination == node ); |
|
3924 } |
|
3925 |
|
3926 CAknLongTapDetector* detector( iAdapter->LongTapDetector() ); |
|
3927 |
|
3928 if ( ( detector && ( !engine->IsPartialInputActive() || |
|
3929 event.iType == TPointerEvent::EButton1Up ) ) ) |
|
3930 { |
|
3931 if ( menuBar ) |
|
3932 { |
|
3933 // CXnMenuAdapter owns the longtap detector, but only |
|
3934 // softkey nodes can have longtap functionality, so |
|
3935 // need to check whether this softkey node has a longtap |
|
3936 // property defined |
|
3937 CXnProperty* prop( |
|
3938 node->GetPropertyL( XnPropertyNames::common::KLongTap ) ); |
|
3939 |
|
3940 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
|
3941 { |
|
3942 iAdapter->SetLongTapDelays( KLongTapStartShortDelay, |
|
3943 KLongTapTimeShortDelay ); |
|
3944 detector->PointerEventL( event ); |
|
3945 } |
|
3946 } |
|
3947 else |
|
3948 { |
|
3949 iAdapter->SetLongTapDelays( KLongTapStartLongDelay, |
|
3950 KLongTapTimeLongDelay ); |
|
3951 detector->PointerEventL( event ); |
|
3952 } |
|
3953 } |
|
3954 |
|
3955 CXnProperty* focusable( |
|
3956 node->GetPropertyL( XnPropertyNames::common::KFocusable ) ); |
|
3957 |
|
3958 if ( !menuBar && ( !focusable || |
|
3959 focusable->StringValue() == XnPropertyNames::KFalse ) ) |
|
3960 { |
|
3961 iLongtap = EFalse; |
|
3962 |
|
3963 return EFalse; |
|
3964 } |
|
3965 |
|
3966 if ( event.iType == TPointerEvent::EButton1Down ) |
|
3967 { |
|
3968 iLongtap = EFalse; |
|
3969 node->HideTooltipsL(); |
|
3970 |
|
3971 if ( !menuBar ) |
|
3972 { |
|
3973 CancelFocusRefusalL( *engine ); |
|
3974 } |
|
3975 |
|
3976 if ( !menuBar && !engine->FocusedNode() ) |
|
3977 { |
|
3978 // save starting point |
|
3979 iButtonDownStartPoint = event.iPosition; |
|
3980 // Require focus to be shown |
|
3981 engine->AppUiAdapter().ShowFocus(); |
|
3982 |
|
3983 #ifdef RD_TACTILE_FEEDBACK |
|
3984 MTouchFeedback* feedback( MTouchFeedback::Instance() ); |
|
3985 |
|
3986 if ( feedback ) |
|
3987 { |
|
3988 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
3989 } |
|
3990 #endif |
|
3991 node->SetStateL( |
|
3992 XnPropertyNames::style::common::KFocus, |
|
3993 XnEventSource::EStylus ); |
|
3994 } |
|
3995 } |
|
3996 else if ( event.iType == TPointerEvent::EDrag ) |
|
3997 { |
|
3998 if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
3999 { |
|
4000 if ( IsDragThresholdExceeded( event.iPosition ) ) |
|
4001 { |
|
4002 // Remove focus |
|
4003 node->UnsetStateL( |
|
4004 XnPropertyNames::style::common::KFocus ); |
|
4005 } |
|
4006 } |
|
4007 } |
|
4008 else if ( event.iType == TPointerEvent::EButton1Up ) |
|
4009 { |
|
4010 if ( !iLongtap ) |
|
4011 { |
|
4012 if ( menuBar ) |
|
4013 { |
|
4014 node->SetStateL( XnPropertyNames::style::common::KActive ); |
|
4015 } |
|
4016 else if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
4017 { |
|
4018 #ifdef RD_TACTILE_FEEDBACK |
|
4019 MTouchFeedback* feedback( MTouchFeedback::Instance() ); |
|
4020 |
|
4021 if ( feedback ) |
|
4022 { |
|
4023 feedback->InstantFeedback( iAdapter, ETouchFeedbackBasic, |
|
4024 ETouchFeedbackVibra, |
|
4025 aPointerEvent ); |
|
4026 } |
|
4027 #endif |
|
4028 node->SetStateL( XnPropertyNames::style::common::KActive ); |
|
4029 } |
|
4030 } |
|
4031 |
|
4032 // Remove focus |
|
4033 engine->AppUiAdapter().HideFocus(); |
|
4034 } |
|
4035 |
|
4036 return EFalse; |
|
4037 } |
|
4038 |
|
4039 // ----------------------------------------------------------------------------- |
|
4040 // CXnControlAdapterImpl::DoDrawL |
|
4041 // Leaving draw function. |
|
4042 // ----------------------------------------------------------------------------- |
|
4043 // |
|
4044 void CXnControlAdapterImpl::DoDrawL( const TRect& aRect, CWindowGc& aGc ) const |
|
4045 { |
|
4046 CXnNode& node = iComponent->Node()->Node(); |
|
4047 |
|
4048 DrawBordersL( aRect, node, aGc ); |
|
4049 |
|
4050 const_cast< CXnControlAdapterImpl* >( this )->DrawBackgroundDataL( aRect, node, aGc ); |
|
4051 |
|
4052 if ( iAdapter->IsFocused() ) |
|
4053 { |
|
4054 DrawFocusAppearance( node, aGc ); |
|
4055 } |
|
4056 |
|
4057 // Draw plus sign for empty plugins in edit mode. |
|
4058 if( node.UiEngine()->EditMode()->EditState() ) |
|
4059 { |
|
4060 const_cast< CXnControlAdapterImpl* >( this )->DrawPlusSign( node, aGc ); |
|
4061 } |
|
4062 |
|
4063 if ( iAnimation ) |
|
4064 { |
|
4065 TRect rect = iComponent->Node()->Rect(); |
|
4066 iAnimation->Render( aGc, rect ); |
|
4067 } |
|
4068 |
|
4069 if ( iBorderBitmap ) |
|
4070 { |
|
4071 DrawBorderImagesL( |
|
4072 aRect, node, aGc, iBorderBitmap, |
|
4073 iBorderBitmapDividerTop, iBorderBitmapDividerRight, |
|
4074 iBorderBitmapDividerBottom, iBorderBitmapDividerLeft ); |
|
4075 } |
|
4076 |
|
4077 DrawContentImageL( aGc ); |
|
4078 } |
|
4079 |
|
4080 // ----------------------------------------------------------------------------- |
|
4081 // CXnControlAdapterImpl::DrawBackgroundDataL |
|
4082 // Draws the background (color and image) |
|
4083 // ----------------------------------------------------------------------------- |
|
4084 // |
|
4085 void CXnControlAdapterImpl::DrawBackgroundDataL( |
|
4086 const TRect& aRect, |
|
4087 CXnNode& aNode, |
|
4088 CWindowGc& aGc ) |
|
4089 { |
|
4090 if( aNode.UiEngine()->EditMode()->EditState() ) |
|
4091 { |
|
4092 DrawEditModeBgData( aNode, aGc ); |
|
4093 return; |
|
4094 } |
|
4095 |
|
4096 if ( !iBackgroundBitmap && iBackgroundMask ) |
|
4097 // mask, but no bitmap: draw masked color (if available) |
|
4098 { |
|
4099 DrawTransparentColorL( aNode, aGc, iBackgroundMask ); |
|
4100 } |
|
4101 else if ( !iBackgroundBitmap || !iBackgroundMask ) |
|
4102 // no mask or no bitmap: draw color (if available) |
|
4103 { |
|
4104 DrawBackgroundColorL( aRect, aNode, aGc ); |
|
4105 } |
|
4106 |
|
4107 CXnProperty* colorProperty( aNode.BackgroundColorL() ); |
|
4108 DrawBackgroundSkinL( aNode, iBackgroundMask, aGc, colorProperty ); |
|
4109 |
|
4110 if ( !iBackgroundBitmap ) |
|
4111 { |
|
4112 return; |
|
4113 } |
|
4114 |
|
4115 CXnProperty* pathProperty( aNode.BackgroundImageL() ); |
|
4116 |
|
4117 if ( pathProperty && pathProperty->StringValue() != KNullDesC8 ) |
|
4118 { |
|
4119 if ( iBackgroundMask ) |
|
4120 { |
|
4121 // draw transparent background image |
|
4122 DrawBackgroundImageL( aRect, aNode, aGc, iBackgroundBitmap, iBackgroundMask ); |
|
4123 } |
|
4124 else |
|
4125 { |
|
4126 // draw background image without mask |
|
4127 DrawBackgroundImageL( aRect, aNode, aGc, iBackgroundBitmap, NULL ); |
|
4128 } |
|
4129 } |
|
4130 } |
|
4131 |
|
4132 // ----------------------------------------------------------------------------- |
|
4133 // CXnControlAdapterImpl::DrawEditModeBgDataL |
|
4134 // |
|
4135 // ----------------------------------------------------------------------------- |
|
4136 // |
|
4137 void CXnControlAdapterImpl::DrawEditModeBgData( |
|
4138 CXnNode& aNode, |
|
4139 CWindowGc& aGc ) |
|
4140 { |
|
4141 // Draw rastered background for plugins |
|
4142 const TDesC8& widgetType = aNode.DomNode()->Name(); |
|
4143 if( widgetType == XnPropertyNames::KPlugin ) |
|
4144 { |
|
4145 TRect rect = aNode.PaddingRect(); |
|
4146 DrawBackgroundSkin( KAknsIIDQgnHomeEditBgWidget, aGc, rect ); |
|
4147 } |
|
4148 } |
|
4149 |
|
4150 // ----------------------------------------------------------------------------- |
|
4151 // CXnControlAdapterImpl::DrawPlusSign |
|
4152 // |
|
4153 // ----------------------------------------------------------------------------- |
|
4154 // |
|
4155 void CXnControlAdapterImpl::DrawPlusSign( CXnNode& aNode, CWindowGc& aGc ) |
|
4156 { |
|
4157 const TDesC8& widgetType = aNode.DomNode()->Name(); |
|
4158 if( widgetType == XnPropertyNames::KPlugin ) |
|
4159 { |
|
4160 CXnPluginData* data( aNode.UiEngine()->ViewManager()->ActiveViewData().Plugin( &aNode ) ); |
|
4161 if( data && !data->Occupied() ) // Empty widget |
|
4162 { |
|
4163 // Draw + -icon |
|
4164 // Make rect as 50% of the widget's height. |
|
4165 // It needs to be square in order to keep aspect ratio. |
|
4166 TRect rect = aNode.PaddingRect(); |
|
4167 TInt w = rect.Width(); |
|
4168 TInt h = rect.Height(); |
|
4169 rect.Shrink( ( w - h * 0.5 ) * 0.5, h * 0.25 ); |
|
4170 DrawBackgroundSkin( KAknsIIDQgnHomeAdd, aGc, rect ); |
|
4171 } |
|
4172 } |
|
4173 } |
|
4174 |
|
4175 // ----------------------------------------------------------------------------- |
|
4176 // CXnControlAdapterImpl::DrawTransparentColorL |
|
4177 // Draws masked background by RGB color. |
|
4178 // ----------------------------------------------------------------------------- |
|
4179 // |
|
4180 void CXnControlAdapterImpl::DrawTransparentColorL( |
|
4181 CXnNode& aNode, |
|
4182 CWindowGc& aGc, |
|
4183 CFbsBitmap* aMask ) |
|
4184 { |
|
4185 CXnProperty* colorProperty( aNode.BackgroundColorL() ); |
|
4186 |
|
4187 if ( colorProperty ) |
|
4188 { |
|
4189 // check value type |
|
4190 CXnDomPropertyValue* value = |
|
4191 static_cast< CXnDomPropertyValue* >( |
|
4192 colorProperty->Property()->PropertyValueList().Item( 0 ) ); |
|
4193 |
|
4194 if ( value->PrimitiveValueType() == CXnDomPropertyValue::ERgbColor ) |
|
4195 { |
|
4196 CFbsBitmap* bitmap( NULL ); |
|
4197 TRgb rgb( value->RgbColorValueL() ); |
|
4198 bitmap = CreateBitmapFromColorL( aMask->SizeInPixels(), rgb ); |
|
4199 |
|
4200 aGc.DrawBitmapMasked( |
|
4201 aNode.PaddingRect(), |
|
4202 bitmap, |
|
4203 TRect( TPoint( 0, 0 ), bitmap->SizeInPixels() ), |
|
4204 aMask, |
|
4205 EFalse ); |
|
4206 |
|
4207 delete bitmap; |
|
4208 } |
|
4209 } |
|
4210 } |
|
4211 |
|
4212 // ----------------------------------------------------------------------------- |
|
4213 // CXnControlAdapterImpl::DrawBackgroundSkin |
|
4214 // Draws a skin item to the given rect |
|
4215 // ----------------------------------------------------------------------------- |
|
4216 // |
|
4217 void CXnControlAdapterImpl::DrawBackgroundSkin(const TAknsItemID& aSkinId, |
|
4218 CWindowGc& aGc, TRect aRect) |
|
4219 { |
|
4220 TRect shrunkRect = aRect; |
|
4221 |
|
4222 shrunkRect.Shrink( |
|
4223 KSkinGfxInnerRectShrink, |
|
4224 KSkinGfxInnerRectShrink ); |
|
4225 |
|
4226 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), aGc, |
|
4227 aRect, shrunkRect, aSkinId, KAknsIIDDefault ); |
|
4228 } |
|
4229 |
|
4230 // ----------------------------------------------------------------------------- |
|
4231 // CXnControlAdapterImpl::DrawBackgroundSkinL |
|
4232 // Draws a skin item to the padding rect |
|
4233 // ----------------------------------------------------------------------------- |
|
4234 // |
|
4235 void CXnControlAdapterImpl::DrawBackgroundSkinL(CXnNode& aNode, |
|
4236 CFbsBitmap* aMask, CWindowGc& aGc, CXnProperty* aBgColor, |
|
4237 TRect aRect) |
|
4238 { |
|
4239 if( aRect == TRect::EUninitialized ) |
|
4240 { |
|
4241 aRect = aNode.PaddingRect(); |
|
4242 } |
|
4243 |
|
4244 CXnProperty* colorProperty( aBgColor ); |
|
4245 if ( colorProperty ) |
|
4246 { |
|
4247 HBufC* skinID = colorProperty->StringValueL(); |
|
4248 CleanupStack::PushL( skinID ); |
|
4249 |
|
4250 if ( skinID->Length() != 0 ) |
|
4251 { |
|
4252 TAknsItemID itemID; |
|
4253 StripQuotes( skinID ); |
|
4254 |
|
4255 if ( CXnUtils::ResolveSkinItemIDL( *skinID, itemID ) ) |
|
4256 { |
|
4257 if ( aMask ) // If there is a mask, draw masked. |
|
4258 { |
|
4259 TRect paddingRect = aRect; |
|
4260 TRect outerRect = TRect( paddingRect.Size() ); |
|
4261 TRect innerRect = outerRect; |
|
4262 innerRect.Shrink( |
|
4263 KSkinGfxInnerRectShrink, |
|
4264 KSkinGfxInnerRectShrink ); |
|
4265 |
|
4266 if ( !iBackgroundBitmap ) |
|
4267 { |
|
4268 iBackgroundBitmap = new ( ELeave ) CFbsBitmap; |
|
4269 iBackgroundBitmap->Create( aMask->SizeInPixels(), |
|
4270 aGc.Device()->DisplayMode() ); |
|
4271 |
|
4272 CFbsBitmapDevice* device = |
|
4273 CFbsBitmapDevice::NewL( iBackgroundBitmap ); |
|
4274 CleanupStack::PushL( device ); |
|
4275 |
|
4276 CBitmapContext* bc( NULL ); |
|
4277 |
|
4278 User::LeaveIfError( device->CreateBitmapContext( bc ) ); |
|
4279 CleanupStack::PushL( bc ); |
|
4280 |
|
4281 CAknsFrameBackgroundControlContext* frameContext = |
|
4282 CAknsFrameBackgroundControlContext::NewL( |
|
4283 itemID, outerRect, innerRect, EFalse ); |
|
4284 CleanupStack::PushL( frameContext ); |
|
4285 |
|
4286 AknsDrawUtils::Background( AknsUtils::SkinInstance(), |
|
4287 frameContext, NULL, |
|
4288 static_cast< CWindowGc& >( *bc ), |
|
4289 outerRect, KAknsDrawParamNoClearUnderImage ); |
|
4290 |
|
4291 CleanupStack::PopAndDestroy( 3, device ); |
|
4292 } |
|
4293 |
|
4294 aGc.DrawBitmapMasked( paddingRect, |
|
4295 iBackgroundBitmap, |
|
4296 TRect(TPoint(0, 0), iBackgroundBitmap->SizeInPixels()), |
|
4297 aMask, |
|
4298 ETrue ); |
|
4299 } |
|
4300 else // draw background skin graphics without mask |
|
4301 { |
|
4302 TRect paddingRect = aRect; |
|
4303 TRect shrunkRect = paddingRect; |
|
4304 |
|
4305 shrunkRect.Shrink( |
|
4306 KSkinGfxInnerRectShrink, |
|
4307 KSkinGfxInnerRectShrink ); |
|
4308 |
|
4309 CAknsFrameBackgroundControlContext* frameContext = |
|
4310 CAknsFrameBackgroundControlContext::NewL( |
|
4311 itemID, paddingRect, shrunkRect, EFalse ); |
|
4312 |
|
4313 CleanupStack::PushL( frameContext ); |
|
4314 |
|
4315 AknsDrawUtils::Background( AknsUtils::SkinInstance(), |
|
4316 frameContext, |
|
4317 NULL, |
|
4318 aGc, |
|
4319 paddingRect, |
|
4320 KAknsDrawParamNoClearUnderImage ); |
|
4321 |
|
4322 CleanupStack::PopAndDestroy( frameContext ); |
|
4323 } |
|
4324 } |
|
4325 } |
|
4326 |
|
4327 CleanupStack::PopAndDestroy( skinID ); |
|
4328 } |
|
4329 } |
|
4330 |
|
4331 // ----------------------------------------------------------------------------- |
|
4332 // DrawBackgroundImageL |
|
4333 // Draws the background image |
|
4334 // ----------------------------------------------------------------------------- |
|
4335 // |
|
4336 void CXnControlAdapterImpl::DrawBackgroundImageL( |
|
4337 const TRect& aRect, |
|
4338 CXnNode& aNode, |
|
4339 CWindowGc& aGc, |
|
4340 CFbsBitmap* aBitmap, |
|
4341 CFbsBitmap* aMask ) |
|
4342 { |
|
4343 if ( !aBitmap ) |
|
4344 { |
|
4345 return; |
|
4346 } |
|
4347 |
|
4348 TRect rect = aNode.PaddingRect(); |
|
4349 TBool scaleImage = EFalse; |
|
4350 |
|
4351 if (!GetBackgroundSizeFromPropertyL( rect, aNode, aBitmap, scaleImage ) ) |
|
4352 { |
|
4353 return; |
|
4354 } |
|
4355 if ( AknIconUtils::IsMifIcon( aBitmap ) ) |
|
4356 { |
|
4357 if ( scaleImage ) |
|
4358 { |
|
4359 AknIconUtils::SetSize( aBitmap, rect.Size(), EAspectRatioNotPreserved ); |
|
4360 } |
|
4361 else |
|
4362 { |
|
4363 AknIconUtils::SetSize( aBitmap, rect.Size(), EAspectRatioPreserved ); |
|
4364 } |
|
4365 } |
|
4366 TRect imageRect = rect; |
|
4367 rect = aNode.PaddingRect(); |
|
4368 TBool heightSet = EFalse; |
|
4369 TBool backgroundPosFound = EFalse; |
|
4370 TRAP_IGNORE( backgroundPosFound = GetBackgroundPositionFromPropertyL( |
|
4371 aNode, scaleImage, rect, imageRect, aBitmap, heightSet ); ); |
|
4372 if ( !backgroundPosFound ) |
|
4373 { |
|
4374 return; |
|
4375 } |
|
4376 if ( !heightSet ) |
|
4377 { |
|
4378 rect.Move( 0, rect.Height() / 2 ); |
|
4379 if ( scaleImage ) |
|
4380 { |
|
4381 rect.Move( 0, -imageRect.Height() / 2 ); |
|
4382 } |
|
4383 else |
|
4384 { |
|
4385 rect.Move( 0, -aBitmap->SizeInPixels().iHeight / 2 ); |
|
4386 } |
|
4387 } |
|
4388 TRect tmpRect = aNode.PaddingRect(); |
|
4389 LimitRectToPaddingRect( aNode, rect ); |
|
4390 TBool repeatX = EFalse; |
|
4391 TBool repeatY = EFalse; |
|
4392 TBool spaceX = EFalse; |
|
4393 TBool spaceY = EFalse; |
|
4394 TRAP_IGNORE( GetBackroundRepeatValuesL( aNode, repeatX, repeatY, spaceX, spaceY ) ); |
|
4395 TRect bitmapRect = TRect( |
|
4396 TPoint( 0, 0 ), |
|
4397 TPoint( aBitmap->SizeInPixels().iWidth, aBitmap->SizeInPixels().iHeight ) ); |
|
4398 TInt xRepeatCount = 0; |
|
4399 TInt yRepeatCount = 0; |
|
4400 TRect paddingRect = aNode.PaddingRect(); |
|
4401 if ( scaleImage ) |
|
4402 { |
|
4403 if ( imageRect.Width() && imageRect.Height() ) |
|
4404 { |
|
4405 xRepeatCount = paddingRect.Width() / imageRect.Width(); |
|
4406 yRepeatCount = paddingRect.Height() / imageRect.Height(); |
|
4407 } |
|
4408 } |
|
4409 else |
|
4410 { |
|
4411 TSize size = aBitmap->SizeInPixels(); |
|
4412 if ( size.iWidth == 0 || size.iHeight == 0 ) |
|
4413 { |
|
4414 return; |
|
4415 } |
|
4416 xRepeatCount = paddingRect.Width() / size.iWidth; |
|
4417 yRepeatCount = paddingRect.Height() / size.iHeight; |
|
4418 } |
|
4419 |
|
4420 if ( xRepeatCount == 0 && yRepeatCount == 0 || |
|
4421 !repeatX && !repeatY && !spaceX && !spaceY ) |
|
4422 { |
|
4423 TRect newRect = TRect( |
|
4424 rect.iTl, |
|
4425 TPoint( |
|
4426 rect.iTl.iX + imageRect.Width(), |
|
4427 rect.iTl.iY + imageRect.Height() ) ); |
|
4428 aGc.SetClippingRect( aRect ); |
|
4429 |
|
4430 if ( aMask ) |
|
4431 { |
|
4432 aGc.DrawBitmapMasked( newRect, |
|
4433 aBitmap, |
|
4434 TRect(TPoint(0, 0), aBitmap->SizeInPixels()), |
|
4435 aMask, |
|
4436 EFalse ); |
|
4437 } |
|
4438 else |
|
4439 { |
|
4440 TRect newRect = TRect( |
|
4441 rect.iTl, |
|
4442 TPoint( |
|
4443 rect.iTl.iX + imageRect.Width(), |
|
4444 rect.iTl.iY + imageRect.Height() ) ); |
|
4445 aGc.SetClippingRect( aRect ); |
|
4446 |
|
4447 aGc.DrawBitmap( newRect, aBitmap, bitmapRect ); |
|
4448 } |
|
4449 |
|
4450 aGc.CancelClippingRect(); |
|
4451 |
|
4452 return; |
|
4453 } |
|
4454 |
|
4455 DrawRepeatedBackgroundImage( |
|
4456 aGc, |
|
4457 aNode, |
|
4458 rect, |
|
4459 imageRect, |
|
4460 bitmapRect, |
|
4461 aBitmap, |
|
4462 repeatX, |
|
4463 repeatY, |
|
4464 spaceX, |
|
4465 spaceY, |
|
4466 xRepeatCount, |
|
4467 yRepeatCount ); |
|
4468 } |
|
4469 |
|
4470 // ----------------------------------------------------------------------------- |
|
4471 // CXnControlAdapterImpl::Draw |
|
4472 // Draws the control |
|
4473 // ----------------------------------------------------------------------------- |
|
4474 // |
|
4475 void CXnControlAdapterImpl::Draw( const TRect& aRect ) const |
|
4476 { |
|
4477 if ( iBlank ) |
|
4478 { |
|
4479 return; |
|
4480 } |
|
4481 |
|
4482 CWindowGc& gc = iAdapter->SystemGc(); |
|
4483 //gc.SetClippingRect(aRect); |
|
4484 #ifdef _XN_DEBUG_ |
|
4485 CXnComponent* comp = Component(); |
|
4486 CXnNode& node = comp->Node()->Node(); |
|
4487 TRect contentRect = node.Rect(); |
|
4488 TRect marginRect = node.MarginRect(); |
|
4489 TRect paddingRect = node.PaddingRect(); |
|
4490 |
|
4491 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
4492 gc.SetPenColor( KRgbBlue ); |
|
4493 gc.DrawRect( marginRect ); |
|
4494 gc.SetPenColor( KRgbGray ); |
|
4495 gc.DrawRect( paddingRect ); |
|
4496 gc.SetPenColor( KRgbRed ); |
|
4497 gc.DrawRect( contentRect ); |
|
4498 #endif |
|
4499 TRAP_IGNORE( DoDrawL( aRect, gc )); |
|
4500 //gc.CancelClippingRect(); |
|
4501 RPointerArray< CXnControlAdapter > sortedArray; |
|
4502 TBool needsSorting = EFalse; |
|
4503 for ( TInt count = iChildren.Count() - 1; count >= 0; --count ) |
|
4504 { |
|
4505 needsSorting = ETrue; |
|
4506 CXnControlAdapter* child = iChildren[count]; |
|
4507 TRAP_IGNORE( InsertChildToSortedArrayL( sortedArray, child ) ); |
|
4508 } |
|
4509 if ( !needsSorting ) |
|
4510 { |
|
4511 return; |
|
4512 } |
|
4513 SwapChildArrays( iChildren, sortedArray ); |
|
4514 } |
|
4515 |
|
4516 // ----------------------------------------------------------------------------- |
|
4517 // CXnControlAdapterImpl::Draw |
|
4518 // Draws the control |
|
4519 // ----------------------------------------------------------------------------- |
|
4520 // |
|
4521 void CXnControlAdapterImpl::Draw( const TRect& aRect, CWindowGc& aGc ) const |
|
4522 { |
|
4523 if ( iBlank ) |
|
4524 { |
|
4525 return; |
|
4526 } |
|
4527 |
|
4528 // aGc.SetClippingRect( aRect ); |
|
4529 #ifdef _XN_DEBUG_ |
|
4530 CXnComponent* comp = Component(); |
|
4531 CXnNode& node = comp->Node()->Node(); |
|
4532 TRect contentRect = node.Rect(); |
|
4533 TRect marginRect = node.MarginRect(); |
|
4534 TRect paddingRect = node.PaddingRect(); |
|
4535 aGc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
4536 aGc.SetPenColor( KRgbBlue ); |
|
4537 aGc.DrawRect( marginRect ); |
|
4538 aGc.SetPenColor( KRgbGray ); |
|
4539 aGc.DrawRect( paddingRect ); |
|
4540 aGc.SetPenColor( KRgbRed ); |
|
4541 aGc.DrawRect( contentRect ); |
|
4542 #endif |
|
4543 TRAP_IGNORE( DoDrawL( aRect, aGc ) ); |
|
4544 // aGc.CancelClippingRect(); |
|
4545 } |
|
4546 |
|
4547 // ----------------------------------------------------------------------------- |
|
4548 // CXnControlAdapterImpl::ComponentControl |
|
4549 // Return a child control by index |
|
4550 // ----------------------------------------------------------------------------- |
|
4551 // |
|
4552 CCoeControl* CXnControlAdapterImpl::ComponentControl( TInt aIndex ) const |
|
4553 { |
|
4554 return iChildren[aIndex]; |
|
4555 } |
|
4556 |
|
4557 // ----------------------------------------------------------------------------- |
|
4558 // CXnControlAdapterImpl::CountComponentControls |
|
4559 // Return count of children |
|
4560 // ----------------------------------------------------------------------------- |
|
4561 // |
|
4562 TInt CXnControlAdapterImpl::CountComponentControls() const |
|
4563 { |
|
4564 return iChildren.Count(); |
|
4565 } |
|
4566 |
|
4567 // ----------------------------------------------------------------------------- |
|
4568 // CXnControlAdapterImpl::AppendChildL |
|
4569 // ----------------------------------------------------------------------------- |
|
4570 // |
|
4571 void CXnControlAdapterImpl::AppendChildL(CXnControlAdapter& aChild, CXnNode& aNode) |
|
4572 { |
|
4573 if( !aChild.OwnsWindow() ) |
|
4574 { |
|
4575 SetControlContext( aChild, aNode ); |
|
4576 if( iChildren.Append( &aChild ) != KErrNone ) |
|
4577 { |
|
4578 User::Leave( KXnErrAppendingChildToControlAdapterFailed ); |
|
4579 } |
|
4580 aChild.SetContainerWindowL( *iAdapter ); |
|
4581 } |
|
4582 } |
|
4583 |
|
4584 |
|
4585 // ----------------------------------------------------------------------------- |
|
4586 // ConvertHslToRgb |
|
4587 // Converts a HSL color to RGB color |
|
4588 // ----------------------------------------------------------------------------- |
|
4589 // |
|
4590 static TRgb ConvertHslToRgb( |
|
4591 TInt aHue, TInt aSaturation, TInt aLightness ) |
|
4592 { |
|
4593 TRgb rgb( 0, 0, 0 ); |
|
4594 TReal h( aHue ); |
|
4595 h /= 360; |
|
4596 TReal s( aSaturation ); |
|
4597 s /= 100; |
|
4598 TReal l( aLightness ); |
|
4599 l /= 100; |
|
4600 |
|
4601 if ( 0 == aSaturation ) |
|
4602 { |
|
4603 rgb.SetRed( TInt( l * 255 ) ); |
|
4604 rgb.SetGreen( TInt( l * 255 ) ); |
|
4605 rgb.SetBlue( TInt( l * 255 ) ); |
|
4606 } |
|
4607 else |
|
4608 { |
|
4609 TReal m1( 0 ); |
|
4610 TReal m2( 0 ); |
|
4611 |
|
4612 // l<=0.5: PUT l*(s+1) IN m2 |
|
4613 if ( aLightness < 0.5 ) |
|
4614 { |
|
4615 m2 = l * ( s + 1.0 ); |
|
4616 } |
|
4617 // PUT l+s-l*s IN m2 |
|
4618 else |
|
4619 { |
|
4620 m2 = l + s - ( l * s ); |
|
4621 } |
|
4622 |
|
4623 // PUT l*2-m2 IN m1 |
|
4624 m1 = l * 2.0 - m2; |
|
4625 |
|
4626 TReal helperH( h ); |
|
4627 TReal helperM1( m1 ); |
|
4628 TReal helperM2( m2 ); |
|
4629 |
|
4630 // calculate Red |
|
4631 helperH = h + ( 1.0 / 3.0 ); |
|
4632 |
|
4633 // IF h<0: PUT h+1 IN h |
|
4634 if ( helperH < 0 ) |
|
4635 { |
|
4636 helperH += 1.0; |
|
4637 } |
|
4638 |
|
4639 // IF h>1: PUT h-1 IN h |
|
4640 else if ( helperH > 1 ) |
|
4641 { |
|
4642 helperH -= 1.0; |
|
4643 } |
|
4644 else |
|
4645 { |
|
4646 } |
|
4647 |
|
4648 TReal val( 0 ); |
|
4649 |
|
4650 // IF h*6<1: RETURN m1+(m2-m1)*h*6 |
|
4651 if ( ( helperH * 6 ) < 1 ) |
|
4652 { |
|
4653 val = ( 255 * ( helperM1 + ( helperM2 - helperM1 ) * helperH * 6.0 ) ); |
|
4654 } |
|
4655 |
|
4656 // IF h*2<1: RETURN m2 ) |
|
4657 else if ( ( helperH * 2.0 ) < 1.0 ) |
|
4658 { |
|
4659 val = ( 255.0 * helperM2 ); |
|
4660 } |
|
4661 |
|
4662 // IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6 |
|
4663 else if ( ( helperH * 3.0 ) < 2.0 ) |
|
4664 { |
|
4665 val = ( 255.0 * ( helperM1 + ( helperM2 - helperM1 ) * |
|
4666 ( 2.0 / 3.0 - helperH ) * 6.0 ) ); |
|
4667 } |
|
4668 else |
|
4669 { |
|
4670 val = 255.0 * helperM1; |
|
4671 } |
|
4672 TInt tmpVal = TInt( val + 0.5 ); |
|
4673 rgb.SetRed( ( tmpVal >= 0) ? tmpVal : -tmpVal ); |
|
4674 |
|
4675 // calculate Green |
|
4676 // PUT hue.to.rgb(m1, m2, h ) IN g |
|
4677 helperH = h; |
|
4678 helperM1 = m1; |
|
4679 helperM2 = m2; |
|
4680 |
|
4681 // IF h<0: PUT h+1 IN h |
|
4682 if ( helperH < 0 ) |
|
4683 { |
|
4684 helperH += 1.0; |
|
4685 } |
|
4686 // IF h>1: PUT h-1 IN h |
|
4687 else if ( helperH > 1 ) |
|
4688 { |
|
4689 helperH -= 1.0; |
|
4690 } |
|
4691 else |
|
4692 { |
|
4693 } |
|
4694 |
|
4695 // IF h*6<1: RETURN m1+(m2-m1)*h*6 |
|
4696 if ( ( helperH * 6 ) < 1 ) |
|
4697 { |
|
4698 val = ( 255.0 * ( helperM1 + ( helperM2 - helperM1 ) * helperH * 6.0 ) ); |
|
4699 } |
|
4700 // IF h*2<1: RETURN m2 |
|
4701 else if ( ( helperH * 2 ) < 1 ) |
|
4702 { |
|
4703 val = ( 255.0 * helperM2 ); |
|
4704 } |
|
4705 // IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6 |
|
4706 else if ( ( helperH * 3 ) < 2 ) |
|
4707 { |
|
4708 val = ( 255.0 * ( helperM1 + ( helperM2 - helperM1 ) * |
|
4709 ( 2.0 / 3.0 - helperH ) * 6.0 ) ); |
|
4710 } |
|
4711 else |
|
4712 { |
|
4713 val = 255.0 * helperM1; |
|
4714 } |
|
4715 |
|
4716 tmpVal = TInt( val + 0.5 ); |
|
4717 rgb.SetGreen( ( tmpVal >= 0) ? tmpVal : tmpVal ); |
|
4718 |
|
4719 // calculate Blue |
|
4720 // PUT hue.to.rgb(m1, m2, h-1/3) IN b |
|
4721 helperH = h - ( 1.0 / 3.0 ); |
|
4722 helperM1 = m1; |
|
4723 helperM2 = m2; |
|
4724 |
|
4725 // IF h<0: PUT h+1 IN h |
|
4726 if ( helperH < 0 ) |
|
4727 { |
|
4728 helperH += 1.0; |
|
4729 } |
|
4730 // IF h>1: PUT h-1 IN h |
|
4731 else if ( helperH > 1 ) |
|
4732 { |
|
4733 helperH -= 1.0; |
|
4734 } |
|
4735 else |
|
4736 { |
|
4737 } |
|
4738 |
|
4739 // IF h*6<1: RETURN m1+(m2-m1)*h*6 |
|
4740 if ( ( helperH * 6 ) < 1 ) |
|
4741 { |
|
4742 val = ( 255.0 * ( helperM1 + ( helperM2 - helperM1 ) * helperH * 6.0 ) ); |
|
4743 } |
|
4744 // IF h*2<1: RETURN m2 |
|
4745 else if ( ( helperH * 2 ) < 1 ) |
|
4746 { |
|
4747 val = ( 255.0 * helperM2 ); |
|
4748 } |
|
4749 // IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6 |
|
4750 else if ( ( helperH * 3 ) < 2 ) |
|
4751 { |
|
4752 val = ( 255.0 * ( helperM1 + ( helperM2 - helperM1 ) * |
|
4753 ( 2.0 / 3.0 - helperH ) * 6.0 ) ); |
|
4754 } |
|
4755 else |
|
4756 { |
|
4757 val = 255.0 * helperM1; |
|
4758 } |
|
4759 |
|
4760 tmpVal = TInt( val + 0.5 ); |
|
4761 rgb.SetBlue( ( tmpVal >= 0) ? tmpVal : -tmpVal ); |
|
4762 |
|
4763 } |
|
4764 return rgb; |
|
4765 } |
|
4766 |
|
4767 // ----------------------------------------------------------------------------- |
|
4768 // ConvertRgbToHsl |
|
4769 // Converts a RGB color to HSL color |
|
4770 // ----------------------------------------------------------------------------- |
|
4771 // |
|
4772 static void ConvertRgbToHsl( |
|
4773 TRgb aRGB, |
|
4774 TUint& aHue, |
|
4775 TUint& aSaturation, |
|
4776 TUint& aLightness ) |
|
4777 { |
|
4778 TReal red = static_cast< TReal >( aRGB.Red() ) / 255.0; |
|
4779 TReal green = static_cast< TReal >( aRGB.Green() ) / 255.0; |
|
4780 TReal blue = static_cast< TReal >( aRGB.Blue() ) / 255.0; |
|
4781 TReal maxColor = ( red > green && red > blue ) ? |
|
4782 red : ( green > red && green > blue ) ? green : blue; |
|
4783 TReal minColor = ( red <= green && red <= blue ) ? |
|
4784 red : ( green <= red && green <= blue ) ? green : blue; |
|
4785 TReal lightness = ( maxColor + minColor ) / 2.0; |
|
4786 if ( maxColor == minColor ) |
|
4787 { |
|
4788 aSaturation = 0; |
|
4789 aHue = 0; |
|
4790 aLightness = static_cast< TInt >( 100.0 * lightness + 0.5 ); |
|
4791 return; |
|
4792 } |
|
4793 |
|
4794 if ( lightness < 0.5 ) |
|
4795 { |
|
4796 TReal saturation = ( maxColor - minColor ) / ( maxColor + minColor ); |
|
4797 aSaturation = static_cast< TInt >( 100.0 * saturation + 0.5 ); |
|
4798 } |
|
4799 else |
|
4800 { |
|
4801 TReal saturation = ( maxColor - minColor ) / ( 2.0 - maxColor - minColor ); |
|
4802 aSaturation = static_cast< TInt >( 100.0 * saturation + 0.5 ); |
|
4803 } |
|
4804 |
|
4805 if ( red == maxColor ) |
|
4806 { |
|
4807 TReal hue = ( green - blue ) / ( maxColor - minColor ); |
|
4808 TInt tmp = static_cast< TInt >( 60.0 * hue + 0.5 ); |
|
4809 aHue = ( tmp >= 0 ) ? tmp : tmp + 360; |
|
4810 } |
|
4811 else if ( green == maxColor ) |
|
4812 { |
|
4813 TReal hue = 2.0 + ( ( blue - red ) / ( maxColor - minColor ) ); |
|
4814 TInt tmp = static_cast< TInt >( 60.0 * hue + 0.5 ); |
|
4815 aHue = ( tmp >= 0 ) ? tmp : tmp + 360; |
|
4816 } |
|
4817 else |
|
4818 { |
|
4819 TReal hue = 4.0 + ( ( red - green ) / ( maxColor - minColor ) ); |
|
4820 TInt tmp = static_cast< TInt >( 60.0 * hue + 0.5 ); |
|
4821 aHue = ( tmp >= 0 ) ? tmp : tmp + 360; |
|
4822 } |
|
4823 |
|
4824 aLightness = static_cast< TInt >( 100.0 * lightness + 0.5 ); |
|
4825 } |
|
4826 |
|
4827 // ----------------------------------------------------------------------------- |
|
4828 // CXnControlAdapterImpl::IsDrawingAllowed |
|
4829 // Checks whether drawing is allowed |
|
4830 // ----------------------------------------------------------------------------- |
|
4831 // |
|
4832 TBool CXnControlAdapterImpl::IsDrawingAllowed() const |
|
4833 { |
|
4834 TBool retVal = EFalse; |
|
4835 CXnNode& node = Component()->Node()->Node(); |
|
4836 CXnProperty* propVisibility = NULL; |
|
4837 TRAP_IGNORE( propVisibility = node.VisibilityL() ); |
|
4838 if ( propVisibility ) |
|
4839 { |
|
4840 const TDesC8& visibility = propVisibility->StringValue(); |
|
4841 if ( visibility != KNullDesC8 ) |
|
4842 { |
|
4843 if ( visibility == XnPropertyNames::style::common::visibility::KHidden ) |
|
4844 { |
|
4845 return EFalse; |
|
4846 } |
|
4847 else |
|
4848 { |
|
4849 retVal = ETrue; |
|
4850 } |
|
4851 } |
|
4852 } |
|
4853 else |
|
4854 { |
|
4855 // default value for visibility |
|
4856 retVal = ETrue; |
|
4857 } |
|
4858 CXnProperty* propDisplay = NULL; |
|
4859 TRAP_IGNORE( propDisplay = node.DisplayL() ); |
|
4860 if ( propDisplay ) |
|
4861 { |
|
4862 const TDesC8& display = propDisplay->StringValue(); |
|
4863 if ( display != KNullDesC8 ) |
|
4864 { |
|
4865 if ( display == XnPropertyNames::style::common::display::KNone ) |
|
4866 { |
|
4867 return EFalse; |
|
4868 } |
|
4869 else |
|
4870 { |
|
4871 retVal = ETrue; |
|
4872 } |
|
4873 } |
|
4874 } |
|
4875 if ( node.IsDropped() ) |
|
4876 { |
|
4877 return EFalse; |
|
4878 } |
|
4879 else |
|
4880 { |
|
4881 retVal = ETrue; |
|
4882 } |
|
4883 return retVal; |
|
4884 } |
|
4885 |
|
4886 // ----------------------------------------------------------------------------- |
|
4887 // CXnControlAdapterImpl::ContentBitmaps |
|
4888 // Gets content bitmaps |
|
4889 // ----------------------------------------------------------------------------- |
|
4890 // |
|
4891 void CXnControlAdapterImpl::ContentBitmaps( |
|
4892 CFbsBitmap*& aBitmap, |
|
4893 CFbsBitmap*& aMask ) |
|
4894 { |
|
4895 aBitmap = iContentBitmap; |
|
4896 aMask = iContentMask; |
|
4897 } |
|
4898 |
|
4899 // ----------------------------------------------------------------------------- |
|
4900 // CXnControlAdapterImpl::SetContentBitmaps |
|
4901 // Sets content bitmaps |
|
4902 // ----------------------------------------------------------------------------- |
|
4903 // |
|
4904 void CXnControlAdapterImpl::SetContentBitmaps( |
|
4905 CFbsBitmap* aBitmap, |
|
4906 CFbsBitmap* aMask ) |
|
4907 { |
|
4908 delete iContentBitmap; |
|
4909 iContentBitmap = NULL; |
|
4910 |
|
4911 delete iContentMask; |
|
4912 iContentMask = NULL; |
|
4913 |
|
4914 iContentBitmap = aBitmap; |
|
4915 iContentMask = aMask; |
|
4916 } |
|
4917 |
|
4918 // ----------------------------------------------------------------------------- |
|
4919 // CXnControlAdapterImpl::SetContentBitmapsL |
|
4920 // Sets content bitmaps |
|
4921 // ----------------------------------------------------------------------------- |
|
4922 // |
|
4923 void CXnControlAdapterImpl::SetContentBitmapsL( const TDesC& aBitmapUrl, |
|
4924 const TDesC& aMaskUrl ) |
|
4925 { |
|
4926 delete iContentBitmap; |
|
4927 iContentBitmap = NULL; |
|
4928 |
|
4929 delete iContentMask; |
|
4930 iContentMask = NULL; |
|
4931 |
|
4932 CXnNode& node( iNode.Node() ); |
|
4933 CXnUiEngine* engine( node.UiEngine() ); |
|
4934 |
|
4935 TRect rect( node.Rect() ); |
|
4936 |
|
4937 GetBitmapL( *engine, node, aBitmapUrl, iContentBitmapIndex, |
|
4938 iContentBitmap, iContentMask, iIconProvider, rect, FsSession() ); |
|
4939 if ( !iContentBitmap ) |
|
4940 { |
|
4941 CXnProperty* prop( node.GetPropertyL( |
|
4942 XnPropertyNames::appearance::common::KFallBackImage ) ); |
|
4943 |
|
4944 if ( prop ) |
|
4945 { |
|
4946 HBufC* fallBackImage( prop->StringValueL( ) ); |
|
4947 |
|
4948 CleanupStack::PushL( fallBackImage ); |
|
4949 |
|
4950 if ( *fallBackImage != KNullDesC ) |
|
4951 { |
|
4952 StripQuotes( fallBackImage ); |
|
4953 |
|
4954 GetBitmapL( *engine, node, *fallBackImage, iContentBitmapIndex, |
|
4955 iContentBitmap, iContentMask, iIconProvider, rect, FsSession() ); |
|
4956 } |
|
4957 |
|
4958 CleanupStack::PopAndDestroy( fallBackImage ); |
|
4959 } |
|
4960 } |
|
4961 |
|
4962 if ( !iContentMask ) |
|
4963 { |
|
4964 if ( aMaskUrl != KNullDesC ) |
|
4965 { |
|
4966 CFbsBitmap* bitmapMask( NULL ); |
|
4967 |
|
4968 GetBitmapL( *engine, node, aMaskUrl, iContentMaskIndex, |
|
4969 iContentMask, bitmapMask, iIconProvider, rect, FsSession() ); |
|
4970 |
|
4971 delete bitmapMask; |
|
4972 } |
|
4973 } |
|
4974 } |
|
4975 |
|
4976 // ----------------------------------------------------------------------------- |
|
4977 // CXnControlAdapterImpl::DrawContentImage |
|
4978 // Draws content image |
|
4979 // ----------------------------------------------------------------------------- |
|
4980 // |
|
4981 void CXnControlAdapterImpl::DrawContentImage() const |
|
4982 { |
|
4983 TRAP_IGNORE( DrawContentImageL( *iGc ) ); |
|
4984 } |
|
4985 |
|
4986 // ----------------------------------------------------------------------------- |
|
4987 // CXnControlAdapterImpl::DrawContentImage |
|
4988 // Draws content image |
|
4989 // ----------------------------------------------------------------------------- |
|
4990 // |
|
4991 void CXnControlAdapterImpl::DrawContentImageL( CWindowGc& aGc ) const |
|
4992 { |
|
4993 if ( !iContentBitmap ) |
|
4994 { |
|
4995 return; |
|
4996 } |
|
4997 |
|
4998 TRect rect = iComponent->Node()->Node().Rect(); |
|
4999 |
|
5000 // Check if the node has a property "preserve image aspect ratio". |
|
5001 TBool preserveAspectRatio = ETrue; |
|
5002 CXnNode& currentNode = iComponent->Node()->Node(); |
|
5003 |
|
5004 CXnProperty* aspectProperty = currentNode.GetPropertyL( |
|
5005 XnPropertyNames::image::KS60AspectRatio ); |
|
5006 if ( aspectProperty ) |
|
5007 { |
|
5008 const TDesC8& value = aspectProperty->StringValue(); |
|
5009 |
|
5010 if ( value.CompareF( XnPropertyNames::image::KNone ) == 0 ) |
|
5011 { |
|
5012 preserveAspectRatio = EFalse; |
|
5013 } |
|
5014 } |
|
5015 |
|
5016 TRect bitmapRect = rect; |
|
5017 bitmapRect.Move( -rect.iTl.iX, -rect.iTl.iY ); |
|
5018 // Finds appropriate method of scaling |
|
5019 if ( AknIconUtils::IsMifIcon( iContentBitmap ) ) |
|
5020 { |
|
5021 if ( preserveAspectRatio ) |
|
5022 { |
|
5023 AknIconUtils::SetSize( |
|
5024 iContentBitmap, bitmapRect.Size(), |
|
5025 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
5026 AknIconUtils::SetSize( |
|
5027 iContentMask, bitmapRect.Size(), |
|
5028 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
5029 // In some cases resizing might fail with previous settings |
|
5030 if ( iContentBitmap->SizeInPixels().iHeight == 0 || |
|
5031 iContentBitmap->SizeInPixels().iWidth == 0 ) |
|
5032 { |
|
5033 AknIconUtils::SetSize( |
|
5034 iContentBitmap, bitmapRect.Size(), |
|
5035 EAspectRatioPreserved ); |
|
5036 AknIconUtils::SetSize( |
|
5037 iContentMask, bitmapRect.Size(), |
|
5038 EAspectRatioPreserved ); |
|
5039 } |
|
5040 } |
|
5041 else |
|
5042 { |
|
5043 AknIconUtils::SetSize( |
|
5044 iContentBitmap, bitmapRect.Size(), EAspectRatioNotPreserved ); |
|
5045 AknIconUtils::SetSize( |
|
5046 iContentMask, bitmapRect.Size(), EAspectRatioNotPreserved ); |
|
5047 } |
|
5048 // Set a new bitmap size |
|
5049 bitmapRect.SetSize( iContentBitmap->SizeInPixels() ); |
|
5050 } |
|
5051 else |
|
5052 { |
|
5053 if ( preserveAspectRatio ) |
|
5054 { |
|
5055 TSize newBitmapSize; |
|
5056 // scaling is done in bitmap drawing routine, here only the |
|
5057 // sacling rect is calculated |
|
5058 CalculateScaledBitmapRect( newBitmapSize, rect.Size(), |
|
5059 iContentBitmap->SizeInPixels() ); |
|
5060 bitmapRect.SetSize( newBitmapSize ); |
|
5061 } |
|
5062 } |
|
5063 |
|
5064 // Calculate new point to start draw |
|
5065 // in order to center bitmap to drawing area |
|
5066 rect.iTl.iY += |
|
5067 ( rect.Height() - bitmapRect.Height() ) / 2; |
|
5068 rect.iTl.iX += |
|
5069 ( rect.Width() - bitmapRect.Width() ) / 2; |
|
5070 // sets a new size to draw |
|
5071 rect.SetSize( bitmapRect.Size() ); |
|
5072 |
|
5073 if ( iContentBitmap && iContentMask ) |
|
5074 { |
|
5075 aGc.DrawBitmapMasked( rect, |
|
5076 iContentBitmap, |
|
5077 TRect(TPoint(0, 0), iContentBitmap->SizeInPixels()), |
|
5078 iContentMask, |
|
5079 ETrue ); |
|
5080 } |
|
5081 else if ( iContentBitmap ) |
|
5082 { |
|
5083 aGc.DrawBitmap( rect, iContentBitmap ); |
|
5084 } |
|
5085 } |
|
5086 |
|
5087 // ----------------------------------------------------------------------------- |
|
5088 // CXnControlAdapterImpl::SizeChanged |
|
5089 // ----------------------------------------------------------------------------- |
|
5090 // |
|
5091 void CXnControlAdapterImpl::SizeChanged() |
|
5092 { |
|
5093 TRAP_IGNORE( InitializeBackgroundAndBorderBitmapsL() ); |
|
5094 } |
|
5095 |
|
5096 // ----------------------------------------------------------------------------- |
|
5097 // CXnControlAdapterImpl::SkinChanged |
|
5098 // ----------------------------------------------------------------------------- |
|
5099 // |
|
5100 void CXnControlAdapterImpl::SkinChanged() |
|
5101 { |
|
5102 TRAP_IGNORE( InitializeBackgroundAndBorderBitmapsL( ETrue ) ); |
|
5103 } |
|
5104 |
|
5105 // ----------------------------------------------------------------------------- |
|
5106 // CXnControlAdapterImpl::FocusChangedL |
|
5107 // ----------------------------------------------------------------------------- |
|
5108 // |
|
5109 void CXnControlAdapterImpl::FocusChangedL( TBool aFocused ) |
|
5110 { |
|
5111 CXnNode& node( iNode.Node() ); |
|
5112 |
|
5113 CXnUiEngine* engine( node.UiEngine() ); |
|
5114 |
|
5115 CXnNode* menubar( engine->MenuBarNode() ); |
|
5116 |
|
5117 if ( engine->IsEditMode() || !node.IsLayoutCapable() || !menubar ) |
|
5118 { |
|
5119 return; |
|
5120 } |
|
5121 |
|
5122 XnMenuInterface::MXnMenuInterface* menuIf( NULL ); |
|
5123 |
|
5124 XnComponentInterface::MakeInterfaceL( menuIf, menubar->AppIfL() ); |
|
5125 |
|
5126 if ( !menuIf ) |
|
5127 { |
|
5128 return; |
|
5129 } |
|
5130 |
|
5131 CXnViewManager* manager( engine->ViewManager() ); |
|
5132 |
|
5133 const TDesC8& ns( node.Namespace() ); |
|
5134 |
|
5135 CXnPluginData* data( manager->ActiveViewData().Plugin( ns ) ); |
|
5136 |
|
5137 if ( !data ) |
|
5138 { |
|
5139 return; |
|
5140 } |
|
5141 |
|
5142 CXnNode* plugin( data->Node()->LayoutNode() ); |
|
5143 |
|
5144 CXnNode* extension( NULL ); |
|
5145 |
|
5146 if ( plugin == engine->ActiveView() ) |
|
5147 { |
|
5148 // Pretend that this node is extension |
|
5149 extension = &node; |
|
5150 } |
|
5151 else |
|
5152 { |
|
5153 RPointerArray< CXnNode >& children( plugin->Children() ); |
|
5154 |
|
5155 for ( TInt i = 0; i < children.Count(); i++ ) |
|
5156 { |
|
5157 CXnNode* child( children[i] ); |
|
5158 |
|
5159 const TDesC8& type( child->Type()->Type() ); |
|
5160 |
|
5161 if ( type == XnPropertyNames::menu::KMenuExtension ) |
|
5162 { |
|
5163 extension = child; |
|
5164 break; |
|
5165 } |
|
5166 } |
|
5167 } |
|
5168 |
|
5169 if ( !extension ) |
|
5170 { |
|
5171 // No extension available |
|
5172 return; |
|
5173 } |
|
5174 |
|
5175 // Find proper softkey from extension |
|
5176 RPointerArray< CXnNode >& children( extension->Children() ); |
|
5177 |
|
5178 for ( TInt i = 0; i < children.Count(); i++ ) |
|
5179 { |
|
5180 CXnNode* child( children[i] ); |
|
5181 |
|
5182 const TDesC8& type( child->Type()->Type() ); |
|
5183 |
|
5184 if ( type == XnPropertyNames::softkey::KNodeName ) |
|
5185 { |
|
5186 |
|
5187 CXnProperty* prop( child->GetPropertyL( |
|
5188 XnPropertyNames::softkey::KTypeAttribute ) ); |
|
5189 |
|
5190 if ( prop ) |
|
5191 { |
|
5192 const TDesC8& type( prop->StringValue() ); |
|
5193 |
|
5194 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition pos; |
|
5195 |
|
5196 if ( type == XnPropertyNames::softkey::type::KLeft ) |
|
5197 { |
|
5198 pos = XnMenuInterface::MXnMenuInterface::ELeft; |
|
5199 } |
|
5200 else if ( type == XnPropertyNames::softkey::type::KMiddle ) |
|
5201 { |
|
5202 pos = XnMenuInterface::MXnMenuInterface::ECenter; |
|
5203 } |
|
5204 else if ( type == XnPropertyNames::softkey::type::KRight ) |
|
5205 { |
|
5206 pos = XnMenuInterface::MXnMenuInterface::ERight; |
|
5207 } |
|
5208 else |
|
5209 { |
|
5210 // Declaration error |
|
5211 __ASSERT_DEBUG( EFalse, Panic( EXnInvalidState ) ); |
|
5212 break; |
|
5213 } |
|
5214 |
|
5215 if ( aFocused ) |
|
5216 { |
|
5217 // Set softkey |
|
5218 menuIf->SetSoftKeyL( &child->PluginIfL(), pos ); |
|
5219 } |
|
5220 else |
|
5221 { |
|
5222 // Remove softkey |
|
5223 menuIf->SetSoftKeyL( NULL, pos ); |
|
5224 } |
|
5225 |
|
5226 // This is not a correct way to do dirty setting, |
|
5227 // but here in case of menubar it is acceptable |
|
5228 engine->AddDirtyNodeL( menubar, XnDirtyLevel::ERender ); |
|
5229 } |
|
5230 } |
|
5231 } |
|
5232 } |
|
5233 |
|
5234 // ----------------------------------------------------------------------------- |
|
5235 // CXnControlAdapterImpl::InitializeBackgroundandBorderBitmapsL |
|
5236 // ----------------------------------------------------------------------------- |
|
5237 // |
|
5238 void CXnControlAdapterImpl::InitializeBackgroundAndBorderBitmapsL( |
|
5239 TBool aForceRecreate ) |
|
5240 { |
|
5241 CXnNode& node( iNode.Node() ); |
|
5242 CXnUiEngine* engine( node.UiEngine() ); |
|
5243 |
|
5244 CXnProperty* backgroundImageProperty( node.BackgroundImageL() ); |
|
5245 |
|
5246 // if skin changed we need recreate icons |
|
5247 if ( backgroundImageProperty && aForceRecreate ) |
|
5248 { |
|
5249 iBackgrondInitialized = EFalse; |
|
5250 } |
|
5251 |
|
5252 if ( backgroundImageProperty && !iBackgrondInitialized ) |
|
5253 { |
|
5254 delete iBackgroundBitmap; |
|
5255 iBackgroundBitmap = NULL; |
|
5256 |
|
5257 delete iBackgroundMask; |
|
5258 iBackgroundMask = NULL; |
|
5259 |
|
5260 InitializeBackgroundBitmapL( *engine, node, iBackgroundBitmapIndex, |
|
5261 iBackgroundBitmap, iBackgroundMask, iIconProvider, FsSession() ); |
|
5262 |
|
5263 HBufC* bgPath( GetBackgroundImagePathLC( node ) ); |
|
5264 |
|
5265 if ( *bgPath != KNullDesC ) |
|
5266 { |
|
5267 iAnimIDResolved = CXnUtils::ResolveSkinItemIDL( *bgPath, iAnimIID ); |
|
5268 } |
|
5269 CleanupStack::PopAndDestroy( bgPath ); |
|
5270 iBackgrondInitialized = ETrue; |
|
5271 } |
|
5272 |
|
5273 CXnProperty* borderImageProperty( node.BorderImageL() ); |
|
5274 |
|
5275 // if skin changed we need recreate icons |
|
5276 if ( borderImageProperty && aForceRecreate ) |
|
5277 { |
|
5278 iBorderInitialized = EFalse; |
|
5279 } |
|
5280 |
|
5281 if ( borderImageProperty && !iBorderInitialized ) |
|
5282 { |
|
5283 delete iBorderBitmap; |
|
5284 iBorderBitmap = NULL; |
|
5285 |
|
5286 iBorderBitmap = InitializeBorderBitmapL( |
|
5287 *engine, node, |
|
5288 iBorderBitmapIndex, iBorderBitmapDividerTop, |
|
5289 iBorderBitmapDividerRight, |
|
5290 iBorderBitmapDividerBottom, iBorderBitmapDividerLeft, |
|
5291 iIconProvider, FsSession() ); |
|
5292 |
|
5293 iBorderInitialized = ETrue; |
|
5294 } |
|
5295 } |
|
5296 |
|
5297 // ----------------------------------------------------------------------------- |
|
5298 // CXnControlAdapterImpl::ConstructL |
|
5299 // 2nd phase constructor. Can leave. |
|
5300 // ----------------------------------------------------------------------------- |
|
5301 // |
|
5302 void CXnControlAdapterImpl::ConstructL( |
|
5303 CXnNodePluginIf& aNode, |
|
5304 CXnControlAdapter& aAdapter, |
|
5305 CWindowGc& aGc ) |
|
5306 { |
|
5307 iGc = &aGc; |
|
5308 |
|
5309 iAdapter = &aAdapter; |
|
5310 |
|
5311 if ( CreateGestureHelperL( aNode.Node() ) ) |
|
5312 { |
|
5313 iGestureFw = CAknTouchGestureFw::NewL( *this, aAdapter ); |
|
5314 iGestureFw->SetGestureInterestL( EAknTouchGestureFwGroupFlick ); |
|
5315 } |
|
5316 |
|
5317 if ( aNode.Type()->Type() == KView ) |
|
5318 { |
|
5319 iSuppressor = CAknPointerEventSuppressor::NewL(); |
|
5320 iSuppressor->SetMaxTapMove( TSize( KMaxTapMove, KMaxTapMove) ); |
|
5321 iSuppressor->SetMaxTapDuration( KLongTapTimeLongDelay ); |
|
5322 } |
|
5323 } |
|
5324 |
|
5325 // ----------------------------------------------------------------------------- |
|
5326 // CXnControlAdapterImpl::LoadBitmap |
|
5327 // Load a bitmap from the server. Ownership is transferred. |
|
5328 // ----------------------------------------------------------------------------- |
|
5329 // |
|
5330 CFbsBitmap* CXnControlAdapterImpl::LoadBitmap( const TDesC& aBitmapUrl ) |
|
5331 { |
|
5332 CXnNode& node( iNode.Node() ); |
|
5333 CXnUiEngine* engine( node.UiEngine() ); |
|
5334 |
|
5335 CFbsBitmap* bitmap( NULL ); |
|
5336 CFbsBitmap* mask( NULL ); |
|
5337 |
|
5338 TRect rect( node.Rect() ); |
|
5339 |
|
5340 TInt index( 0 ); |
|
5341 |
|
5342 TRAP_IGNORE( GetBitmapL( |
|
5343 *engine, node, |
|
5344 aBitmapUrl, index, |
|
5345 bitmap, mask, |
|
5346 iIconProvider, rect, FsSession() ) ); |
|
5347 |
|
5348 delete mask; |
|
5349 |
|
5350 return bitmap; |
|
5351 } |
|
5352 |
|
5353 // ----------------------------------------------------------------------------- |
|
5354 // CXnControlAdapterImpl::GetBitmapAndMask |
|
5355 // Load a bitmap and mask from the server. Ownership is transferred. |
|
5356 // ----------------------------------------------------------------------------- |
|
5357 // |
|
5358 void CXnControlAdapterImpl::GetBitmapAndMask( |
|
5359 const TDesC& aBitmapUrl, |
|
5360 const TDesC& aMaskUrl, |
|
5361 CFbsBitmap*& aBitmap, |
|
5362 CFbsBitmap*& aMask ) |
|
5363 { |
|
5364 CXnNode& node( iNode.Node() ); |
|
5365 CXnUiEngine* engine( node.UiEngine() ); |
|
5366 |
|
5367 TRect rect( node.Rect() ); |
|
5368 |
|
5369 TInt index( 0 ); |
|
5370 |
|
5371 TRAP_IGNORE( GetBitmapL( |
|
5372 *engine, node, |
|
5373 aBitmapUrl, index, |
|
5374 aBitmap, aMask, |
|
5375 iIconProvider, rect, FsSession() ) ); |
|
5376 |
|
5377 if ( !aMask ) |
|
5378 { |
|
5379 if ( aMaskUrl != KNullDesC ) |
|
5380 { |
|
5381 CFbsBitmap* bitmapMask( NULL ); |
|
5382 |
|
5383 TRAP_IGNORE( GetBitmapL( |
|
5384 *engine, node, |
|
5385 aMaskUrl, index, |
|
5386 aMask, bitmapMask, |
|
5387 iIconProvider, rect, FsSession() ) ); |
|
5388 |
|
5389 delete bitmapMask; |
|
5390 } |
|
5391 } |
|
5392 } |
|
5393 |
|
5394 // ----------------------------------------------------------------------------- |
|
5395 // CXnControlAdapterImpl::AnimFrameReady |
|
5396 // Callback of the animated skin background. |
|
5397 // ----------------------------------------------------------------------------- |
|
5398 // |
|
5399 void CXnControlAdapterImpl::AnimFrameReady( TInt aError, TInt /* aAnimId */ ) |
|
5400 { |
|
5401 if ( !aError ) |
|
5402 { |
|
5403 iAdapter->DrawNow(); |
|
5404 } |
|
5405 } |
|
5406 |
|
5407 // ----------------------------------------------------------------------------- |
|
5408 // CXnControlAdapterImpl::CreateAnimationL |
|
5409 // ----------------------------------------------------------------------------- |
|
5410 // |
|
5411 void CXnControlAdapterImpl::CreateAnimationL( /* TDesC& aPath */ ) |
|
5412 { |
|
5413 if ( iAnimation ) |
|
5414 { |
|
5415 delete iAnimation; |
|
5416 iAnimation = NULL; |
|
5417 } |
|
5418 |
|
5419 iAnimation = CAknsEffectAnim::NewL( this ); |
|
5420 TBool ok = iAnimation->ConstructFromSkinL( iAnimIID ); |
|
5421 if ( !ok ) |
|
5422 { |
|
5423 delete iAnimation; |
|
5424 iAnimation = NULL; |
|
5425 User::Leave( KErrNotSupported ); |
|
5426 } |
|
5427 |
|
5428 CXnNode& node = iComponent->Node()->Node(); |
|
5429 if ( !node.IsLaidOut() ) |
|
5430 { |
|
5431 // Animation is created before layout of nodes has been calculated |
|
5432 node.UiEngine()->LayoutUIL( &node ); |
|
5433 } |
|
5434 TRect rect( node.Rect() ); |
|
5435 |
|
5436 iAnimation->BeginConfigInputLayersL( rect.Size(), ETrue ); |
|
5437 |
|
5438 if ( iAnimation->InputRgbGc() ) |
|
5439 { |
|
5440 TRect mainPane; |
|
5441 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
5442 TRect mainPaneRect( mainPane.Size() ); |
|
5443 |
|
5444 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
5445 MAknsControlContext* cc = NULL; |
|
5446 const TAknsItemID* id = &KAknsIIDNone; |
|
5447 if ( AknsUtils::AvkonSkinEnabled() ) |
|
5448 { |
|
5449 cc = CAknsListBoxBackgroundControlContext::NewL( |
|
5450 KAknsIIDQsnBgAreaMainListGene, |
|
5451 mainPaneRect, |
|
5452 EFalse, |
|
5453 *id, |
|
5454 mainPaneRect ); |
|
5455 |
|
5456 AknsDrawUtils::DrawBackground( AknsUtils::SkinInstance(), |
|
5457 cc, |
|
5458 NULL, |
|
5459 *iAnimation->InputRgbGc(), |
|
5460 TPoint(), |
|
5461 rect, |
|
5462 KAknsDrawParamBottomLevelRGBOnly ); |
|
5463 } |
|
5464 } |
|
5465 |
|
5466 iAnimation->EndConfigInputLayersL(); |
|
5467 } |
|
5468 |
|
5469 // ----------------------------------------------------------------------------- |
|
5470 // CXnControlAdapterImpl::StartHighlightAnimation() |
|
5471 // ----------------------------------------------------------------------------- |
|
5472 // |
|
5473 void CXnControlAdapterImpl::StartHighlightAnimation( TBool aAnimRestart ) |
|
5474 { |
|
5475 TBool focused = EFalse; |
|
5476 |
|
5477 // No need to start animation again if already running |
|
5478 if ( iAnimation ) |
|
5479 { |
|
5480 if ( iAnimation->State() == EAknsAnimStateRunning && !aAnimRestart ) |
|
5481 { |
|
5482 return; |
|
5483 } |
|
5484 } |
|
5485 // Check control's focus |
|
5486 if ( iComponent ) |
|
5487 { |
|
5488 CXnNodePluginIf* pluginIf = iComponent->Node(); |
|
5489 if ( pluginIf ) |
|
5490 { |
|
5491 focused = pluginIf->IsFocusedState(); |
|
5492 } |
|
5493 else |
|
5494 { |
|
5495 return; |
|
5496 } |
|
5497 } |
|
5498 |
|
5499 // If the node is not focused or no Anim ID, return. |
|
5500 if ( !focused || !iAnimIDResolved ) |
|
5501 { |
|
5502 return; |
|
5503 } |
|
5504 |
|
5505 // Restart animation |
|
5506 if ( aAnimRestart ) |
|
5507 { |
|
5508 if ( iAnimation ) |
|
5509 { |
|
5510 iAnimation->Stop(); |
|
5511 delete iAnimation; |
|
5512 iAnimation = NULL; |
|
5513 |
|
5514 TRAPD( error, CreateAnimationL() ); |
|
5515 |
|
5516 if ( !error ) |
|
5517 { |
|
5518 iAnimation->Start(); |
|
5519 return; |
|
5520 } |
|
5521 } |
|
5522 } |
|
5523 |
|
5524 // Node is focused. Try to start animation. |
|
5525 if ( iAnimation ) |
|
5526 { |
|
5527 iAnimation->Start(); |
|
5528 } |
|
5529 else |
|
5530 { |
|
5531 TRAPD( error, CreateAnimationL() ); |
|
5532 |
|
5533 if ( !error ) |
|
5534 { |
|
5535 iAnimation->Start(); |
|
5536 } |
|
5537 } |
|
5538 } |
|
5539 |
|
5540 // ----------------------------------------------------------------------------- |
|
5541 // CXnControlAdapterImpl::StopHighlightAnimation() |
|
5542 // ----------------------------------------------------------------------------- |
|
5543 // |
|
5544 void CXnControlAdapterImpl::StopHighlightAnimation() |
|
5545 { |
|
5546 if ( iAnimation ) |
|
5547 { |
|
5548 // Stop animation and delete. |
|
5549 iAnimation->Stop(); |
|
5550 delete iAnimation; |
|
5551 iAnimation = NULL; |
|
5552 |
|
5553 iAdapter->DrawNow(); |
|
5554 } |
|
5555 } |
|
5556 |
|
5557 // ----------------------------------------------------------------------------- |
|
5558 // CXnControlAdapterImpl::MeasureAdaptiveContentL |
|
5559 // ----------------------------------------------------------------------------- |
|
5560 // |
|
5561 TSize CXnControlAdapterImpl::MeasureAdaptiveContentL( |
|
5562 const TSize& /* aAvailableSize */ ) |
|
5563 { |
|
5564 // By default the size is 0 |
|
5565 return TSize( 0, 0 ); |
|
5566 } |
|
5567 |
|
5568 // ----------------------------------------------------------------------------- |
|
5569 // CXnControlAdapterImpl::SetBlank |
|
5570 // |
|
5571 // ----------------------------------------------------------------------------- |
|
5572 // |
|
5573 void CXnControlAdapterImpl::SetBlank( TBool aBlank ) |
|
5574 { |
|
5575 iBlank = aBlank; |
|
5576 } |
|
5577 |
|
5578 // ----------------------------------------------------------------------------- |
|
5579 // CXnControlAdapterImpl::DoHandlePropertyChangeL |
|
5580 // ----------------------------------------------------------------------------- |
|
5581 // |
|
5582 void CXnControlAdapterImpl::DoHandlePropertyChangeL( CXnProperty* /*aProperty*/ ) |
|
5583 { |
|
5584 } |
|
5585 |
|
5586 // ----------------------------------------------------------------------------- |
|
5587 // CXnControlAdapterImpl::UpdateBackgroundImageL |
|
5588 // ----------------------------------------------------------------------------- |
|
5589 // |
|
5590 CXnControlAdapterImpl::TPropertyChangeResponse CXnControlAdapterImpl::UpdateBackgroundImageL( |
|
5591 CXnProperty* aProperty ) |
|
5592 { |
|
5593 if ( aProperty ) |
|
5594 { |
|
5595 const TDesC8& name( aProperty->Property()->Name() ); |
|
5596 |
|
5597 if ( name == XnPropertyNames::appearance::common::KBackGroundImage ) |
|
5598 { |
|
5599 delete iBackgroundBitmap; |
|
5600 iBackgroundBitmap = NULL; |
|
5601 |
|
5602 delete iBackgroundMask; |
|
5603 iBackgroundMask = NULL; |
|
5604 |
|
5605 InitializeBackgroundBitmapL( *( iNode.Node().UiEngine() ), iNode.Node(), |
|
5606 iBackgroundBitmapIndex, iBackgroundBitmap, iBackgroundMask, |
|
5607 iIconProvider, FsSession()); |
|
5608 |
|
5609 return EPropertyChangeConsumed; |
|
5610 } |
|
5611 } |
|
5612 |
|
5613 return EPropertyChangeNotConsumed; |
|
5614 } |
|
5615 |
|
5616 // ----------------------------------------------------------------------------- |
|
5617 // CXnControlAdapterImpl::HandleScreenDeviceChangedL |
|
5618 // ----------------------------------------------------------------------------- |
|
5619 // |
|
5620 void CXnControlAdapterImpl::HandleScreenDeviceChangedL() |
|
5621 { |
|
5622 } |
|
5623 |
|
5624 // ----------------------------------------------------------------------------- |
|
5625 // CreateBitmapFromColorL |
|
5626 // Creates a bitmap object with the given size and fill color |
|
5627 // ----------------------------------------------------------------------------- |
|
5628 // |
|
5629 static CFbsBitmap* CreateBitmapFromColorL( TSize aSize, TRgb aColor ) |
|
5630 { |
|
5631 CFbsBitmap* newBitmap = new ( ELeave ) CFbsBitmap; |
|
5632 newBitmap->Create( aSize, EColor16M ); |
|
5633 CleanupStack::PushL( newBitmap ); |
|
5634 |
|
5635 CFbsBitmapDevice* bitmapDev = CFbsBitmapDevice::NewL( newBitmap ); |
|
5636 CleanupStack::PushL( bitmapDev ); |
|
5637 |
|
5638 CFbsBitGc* bc = NULL; |
|
5639 User::LeaveIfError( bitmapDev->CreateContext( bc ) ); |
|
5640 CleanupStack::PushL( bc ); |
|
5641 |
|
5642 bc->SetBrushColor( aColor ); |
|
5643 bc->Clear(); // area is filled with the brush color |
|
5644 |
|
5645 CleanupStack::PopAndDestroy( bc ); |
|
5646 CleanupStack::PopAndDestroy( bitmapDev ); |
|
5647 CleanupStack::Pop( newBitmap ); |
|
5648 return newBitmap; |
|
5649 } |
|
5650 |
|
5651 // ----------------------------------------------------------------------------- |
|
5652 // InitializeGestureL |
|
5653 // Sets up gesture |
|
5654 // ----------------------------------------------------------------------------- |
|
5655 // |
|
5656 void CXnControlAdapterImpl::InitializeGestureL( |
|
5657 const TPointerEvent& aPointerEvent ) |
|
5658 { |
|
5659 if ( !iGestureFw || aPointerEvent.iType != TPointerEvent::EButton1Down ) |
|
5660 { |
|
5661 return; |
|
5662 } |
|
5663 |
|
5664 CXnUiEngine* engine( iNode.Node().UiEngine() ); |
|
5665 // Set default destination |
|
5666 iGestureDestination = &iNode.Node(); |
|
5667 |
|
5668 RPointerArray< CXnPluginData >& plugins( |
|
5669 engine->ViewManager()->ActiveViewData().PluginData() ); |
|
5670 |
|
5671 for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
5672 { |
|
5673 CXnPluginData* plugin( plugins[i] ); |
|
5674 |
|
5675 if ( plugin->Occupied() ) |
|
5676 { |
|
5677 CXnNode* widget( plugin->Node()->LayoutNode() ); |
|
5678 |
|
5679 if ( widget->MarginRect().Contains( aPointerEvent.iPosition ) ) |
|
5680 { |
|
5681 // Resolve swipe destination |
|
5682 CXnProperty* prop( widget->GetPropertyL( |
|
5683 XnPropertyNames::common::KSwipeDestination ) ); |
|
5684 |
|
5685 if ( prop ) |
|
5686 { |
|
5687 const TDesC8& value( prop->StringValue() ); |
|
5688 |
|
5689 if( value == XnPropertyNames::KWidget ) |
|
5690 { |
|
5691 // Set widget as destination |
|
5692 iGestureDestination = widget; |
|
5693 } |
|
5694 else if( value == XnPropertyNames::KNone ) |
|
5695 { |
|
5696 // Set no destination |
|
5697 iGestureDestination = NULL; |
|
5698 } |
|
5699 } |
|
5700 break; |
|
5701 } |
|
5702 } |
|
5703 } |
|
5704 } |
|
5705 |
|
5706 // ----------------------------------------------------------------------------- |
|
5707 // ----------------------------------------------------------------------------- |
|
5708 // |
|
5709 void CXnControlAdapterImpl::RemoveChildAdapters() |
|
5710 { |
|
5711 iChildren.Reset(); |
|
5712 } |
|
5713 |
|
5714 // ----------------------------------------------------------------------------- |
|
5715 // ----------------------------------------------------------------------------- |
|
5716 // |
|
5717 RPointerArray< CXnControlAdapter >& CXnControlAdapterImpl::ChildAdapters() |
|
5718 { |
|
5719 return iChildren; |
|
5720 } |
|
5721 |
|
5722 // ----------------------------------------------------------------------------- |
|
5723 // ----------------------------------------------------------------------------- |
|
5724 // |
|
5725 RFs& CXnControlAdapterImpl::FsSession() |
|
5726 { |
|
5727 return iAdapter->ControlEnv()->FsSession(); |
|
5728 } |
|
5729 |
|
5730 // ----------------------------------------------------------------------------- |
|
5731 // ----------------------------------------------------------------------------- |
|
5732 // |
|
5733 void CXnControlAdapterImpl::HandleTouchGestureL( MAknTouchGestureFwEvent& aEvent ) |
|
5734 { |
|
5735 if ( aEvent.Group() == EAknTouchGestureFwGroupFlick ) |
|
5736 { |
|
5737 TAknTouchGestureFwType type = aEvent.Type(); |
|
5738 |
|
5739 const TDesC8* swipe( NULL ); |
|
5740 |
|
5741 if ( type == EAknTouchGestureFwFlickLeft ) |
|
5742 { |
|
5743 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KLeft; |
|
5744 } |
|
5745 else if ( type == EAknTouchGestureFwFlickRight ) |
|
5746 { |
|
5747 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight; |
|
5748 } |
|
5749 |
|
5750 if ( swipe && iGestureDestination ) |
|
5751 { |
|
5752 CXnUiEngine* engine = iNode.Node().UiEngine(); |
|
5753 if ( iGestureDestination == &iNode.Node() ) |
|
5754 { |
|
5755 CancelFocusRefusalL( *engine ); |
|
5756 } |
|
5757 |
|
5758 // Remove focus |
|
5759 engine->AppUiAdapter().HideFocus(); |
|
5760 |
|
5761 CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) ); |
|
5762 iGestureDestination->ReportXuikonEventL( *trigger ); |
|
5763 CleanupStack::PopAndDestroy( trigger ); |
|
5764 |
|
5765 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
|
5766 CXnViewData& data( appui.ViewManager().ActiveViewData() ); |
|
5767 |
|
5768 CXnViewControlAdapter* control = |
|
5769 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() ); |
|
5770 |
|
5771 control->ResetGrabbing(); |
|
5772 } |
|
5773 } |
|
5774 } |
|
5775 |
|
5776 |
|
5777 // ============================= TIconProvider =============================== |
|
5778 |
|
5779 // ----------------------------------------------------------------------------- |
|
5780 // Constructor |
|
5781 // ----------------------------------------------------------------------------- |
|
5782 // |
|
5783 CXnControlAdapterImpl::TIconProvider::TIconProvider( RFile& aFile ) : |
|
5784 iFile( aFile ) |
|
5785 { |
|
5786 } |
|
5787 |
|
5788 // ----------------------------------------------------------------------------- |
|
5789 // Destructor |
|
5790 // ----------------------------------------------------------------------------- |
|
5791 // |
|
5792 CXnControlAdapterImpl::TIconProvider::~TIconProvider() |
|
5793 { |
|
5794 iFile.Close(); |
|
5795 } |
|
5796 |
|
5797 // ----------------------------------------------------------------------------- |
|
5798 // Retreive Icon handle |
|
5799 // ----------------------------------------------------------------------------- |
|
5800 // |
|
5801 void CXnControlAdapterImpl::TIconProvider::RetrieveIconFileHandleL( |
|
5802 RFile& aFile, const TIconFileType /*aType*/) |
|
5803 { |
|
5804 aFile.Duplicate( iFile ); |
|
5805 } |
|
5806 |
|
5807 // ----------------------------------------------------------------------------- |
|
5808 // Finish |
|
5809 // ----------------------------------------------------------------------------- |
|
5810 // |
|
5811 void CXnControlAdapterImpl::TIconProvider::Finished() |
|
5812 { |
|
5813 iFile.Close(); |
|
5814 delete this; |
|
5815 } |
|
5816 |