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