|
1 /* |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Utility functions of Xuikon. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef C_XNUTILS_H |
|
20 #define C_XNUTILS_H |
|
21 |
|
22 // System includes |
|
23 #include <e32base.h> |
|
24 #include <gdi.h> |
|
25 #include <gulalign.h> |
|
26 |
|
27 // Forward declarations |
|
28 class CXnNodePluginIf; |
|
29 class CFont; |
|
30 class CXnNode; |
|
31 class CXnResource; |
|
32 class TAknsItemID; |
|
33 |
|
34 // Class declaration |
|
35 /** |
|
36 * Utility functions for Xuikon. |
|
37 * |
|
38 * @ingroup group_xnlayoutengine |
|
39 * @lib xn3layoutengine.lib |
|
40 * @since S60 v3.1 |
|
41 */ |
|
42 class CXnUtils : public CBase |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Creates the font according the parameters found from the given node. |
|
47 * Avkon font ids or font-family names can be used. If font family is |
|
48 * missing or defined as normal, system normal font is created. |
|
49 * |
|
50 * @since S60 v3.1 |
|
51 * @param aNode Text element node. |
|
52 * @param aFont Font to be created. |
|
53 * @param aReleaseFont Whether the font needs to be released or not. |
|
54 */ |
|
55 IMPORT_C static void CreateFontL( |
|
56 CXnNodePluginIf& aNode, |
|
57 CFont*& aFont, |
|
58 TInt& aReleaseFont ); |
|
59 |
|
60 /** |
|
61 * Creates the font according the given parameters. |
|
62 * Avkon font ids or font-family names can be used. If font family is |
|
63 * missing or defined as normal, system normal font is created. |
|
64 * |
|
65 * @since S60 v3.2 |
|
66 * @param aFontName Font name. |
|
67 * @param aFontSizeInPixels Defines a font size. |
|
68 * @param aFontStyle Defines the style, i.e. italic, bold, etc. |
|
69 * @param aFont Font to be created. |
|
70 * @param aReleaseFont Whether the font needs to be released or not. |
|
71 */ |
|
72 IMPORT_C static void CreateFontL( |
|
73 const TDesC& aFontName, |
|
74 TInt aFontSizeInPixels, |
|
75 TFontStyle aFontStyle, |
|
76 CFont*& aFont, |
|
77 TInt& aReleaseFont ); |
|
78 |
|
79 /** |
|
80 * Collapses the white spaces and special charachters from the given string |
|
81 * according to properties found from the given node. |
|
82 * |
|
83 * @since S60 v3.1 |
|
84 * @param aNode Text element node. |
|
85 * @param aDes Descriptor to be modified. |
|
86 */ |
|
87 IMPORT_C static void CollapseWhiteSpace( |
|
88 CXnNodePluginIf& aNode, TDes &aDes ); |
|
89 |
|
90 /** |
|
91 * Returns the text alignment according to properties found from the given |
|
92 * node. |
|
93 * |
|
94 * @since S60 v3.1 |
|
95 * @param aNode Text element node. |
|
96 * @return The text alignment. |
|
97 */ |
|
98 IMPORT_C static TGulAlignmentValue TextAlignment( CXnNodePluginIf& aNode ); |
|
99 |
|
100 /** |
|
101 * Scales the source bitmap into a given rectangle of the target bitmap. |
|
102 * Source and target bitmaps must have the same display mode. |
|
103 * |
|
104 * @since S60 v3.1 |
|
105 * @param aTrgRect A rectangle area where the source bitmap is scaled. |
|
106 * @param aTrgBitmap A newly created bitmap. |
|
107 * @param aSrcBitmap An original bitmap. |
|
108 */ |
|
109 IMPORT_C static void ScaleBitmapL( |
|
110 const TRect& aTrgRect, |
|
111 CFbsBitmap* aTrgBitmap, |
|
112 CFbsBitmap* aSrcBitmap ); |
|
113 |
|
114 /** |
|
115 * Strips quotes from a descriptor string. |
|
116 * |
|
117 * @param aString A string. |
|
118 */ |
|
119 IMPORT_C static void StripQuotes( HBufC*& aString ); |
|
120 |
|
121 /** |
|
122 * Resolves a skin item ID from a descriptor string. The skin item ID is |
|
123 * stored in aItemID |
|
124 * |
|
125 * @param aSkinId A skin ID as a string descriptor. |
|
126 * @param aItemID An item ID to which the values are set from the |
|
127 * descriptor. |
|
128 */ |
|
129 IMPORT_C static TBool ResolveSkinItemIDL( |
|
130 const TDesC& aSkinId, |
|
131 TAknsItemID& aItemID ); |
|
132 |
|
133 /** |
|
134 * Resolves a skin item ID and an integer index from a descriptor string. |
|
135 * The skin item ID is stored in aItemID and the index is stored in aIndex. |
|
136 * |
|
137 * @param aSkinId A skin ID as a descriptor string. |
|
138 * @param aItemID An item ID to which the values are set from the |
|
139 * descriptor. |
|
140 * @param aIndex An integer index. |
|
141 */ |
|
142 IMPORT_C static TBool ResolveSkinItemIDL( |
|
143 const TDesC& aSkinId, |
|
144 TAknsItemID& aItemID, |
|
145 TInt& aIndex ); |
|
146 |
|
147 /** |
|
148 * Resolves RGB colour value from a string. |
|
149 * |
|
150 * @param aValue Resolved RGB value. |
|
151 * @param aData String from which RGB value is resolved. |
|
152 */ |
|
153 IMPORT_C static TBool GetRgbValue( TRgb& aValue, const TDesC8& aData ); |
|
154 |
|
155 /** |
|
156 * Converts HSL value to RGB and returns the RGB value. |
|
157 * |
|
158 * @param aHue Hue. |
|
159 * @param aSaturation Saturation. |
|
160 * @param aLightness Lightness. |
|
161 */ |
|
162 IMPORT_C static TRgb ConvertHslToRgb( |
|
163 TInt aHue, |
|
164 TInt aSaturation, |
|
165 TInt aLightness ); |
|
166 |
|
167 /** |
|
168 * Handles power save mode |
|
169 * |
|
170 * @param aNode A node where to start iterate. |
|
171 * @param aEvent Mode event. |
|
172 * @param aEnter enter or exit the mode. |
|
173 * @return ETrue if entered to the mode, EFalse if exited |
|
174 */ |
|
175 IMPORT_C static TBool HandlePowerSaveModeL( |
|
176 CXnNode* aNode, |
|
177 TBool aEnter, |
|
178 TInt aEvent ); |
|
179 |
|
180 /** |
|
181 * Finds a CXnResource object by the resource file name. |
|
182 * |
|
183 * @param aArray UIEngine's resource array |
|
184 * @param aResourceFileName resource file name |
|
185 * @param aBitmapIndex bitmap index |
|
186 */ |
|
187 IMPORT_C static CXnResource* FindResource( |
|
188 CArrayPtrSeg< CXnResource >& aArray, |
|
189 const TDesC& aResourceFileName, |
|
190 TInt& aBitmapIndex ); |
|
191 |
|
192 /** |
|
193 * @internal |
|
194 */ |
|
195 static TBool DoesScaleBitmapUseFallBack( CFbsBitmap* aSrcBitmap ); |
|
196 |
|
197 /** |
|
198 * @internal |
|
199 */ |
|
200 static void ScaleBitmapExtL( |
|
201 const TRect& aTrgRect, |
|
202 CFbsBitmap* aTrgBitmap, |
|
203 CFbsBitmap* aSrcBitmap, |
|
204 TBool aForceFallBack ); |
|
205 }; |
|
206 |
|
207 #endif |