|
1 /* |
|
2 * Copyright (c) 2007 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: Active Palette Utilities* |
|
15 */ |
|
16 |
|
17 |
|
18 /** |
|
19 * @file ActivePalette2Utils.cpp |
|
20 * Active Palette Utilities |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "ActivePalette2Utils.h" |
|
25 |
|
26 #include "ActivePalette2Cfg.h" |
|
27 |
|
28 #include <fbs.h> |
|
29 #include <bitstd.h> |
|
30 #include <eikenv.h> |
|
31 #include <e32math.h> |
|
32 #include <AknUtils.h> |
|
33 |
|
34 // LOCAL CONSTANTS |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // ActivePalette2Utils::CreateDrawingObjectsL( |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void ActivePalette2Utils::CreateDrawingObjectsL(const TDisplayMode aDisplayMode, |
|
43 const TSize aSize, |
|
44 CFbsBitmap** aBitmap, |
|
45 CFbsBitmapDevice** aDevice, |
|
46 CBitmapContext** aGc) |
|
47 { |
|
48 CreateDrawingObjectsLC(aDisplayMode,aSize,aBitmap,aDevice,aGc); |
|
49 CleanupStack::Pop(*aGc); |
|
50 CleanupStack::Pop(*aDevice); |
|
51 CleanupStack::Pop(*aBitmap); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // ActivePalette2Utils::CreateDrawingObjectsLC() |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void ActivePalette2Utils::CreateDrawingObjectsLC(const TDisplayMode aDisplayMode, |
|
59 const TSize aSize, |
|
60 CFbsBitmap** aBitmap, |
|
61 CFbsBitmapDevice** aDevice, |
|
62 CBitmapContext** aGc) |
|
63 { |
|
64 *aBitmap = new (ELeave) CFbsBitmap(); |
|
65 CleanupStack::PushL(*aBitmap); |
|
66 |
|
67 User::LeaveIfError((*aBitmap)->Create(aSize,aDisplayMode)); |
|
68 |
|
69 *aDevice = CFbsBitmapDevice::NewL(*aBitmap); |
|
70 CleanupStack::PushL(*aDevice); |
|
71 |
|
72 CFbsBitGc* context; |
|
73 User::LeaveIfError((*aDevice)->CreateContext(context)); |
|
74 *aGc = context; |
|
75 CleanupStack::PushL(*aGc); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // ActivePalette2Utils::CreateDrawingObjectsL() |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void ActivePalette2Utils::CreateDrawingObjectsL(const TSize aSize, |
|
83 CFbsBitmap** aBitmap, |
|
84 CFbsBitmapDevice** aDevice, |
|
85 CBitmapContext** aGc) |
|
86 { |
|
87 TInt color; |
|
88 TInt gray; |
|
89 TDisplayMode displayMode; |
|
90 displayMode = CEikonEnv::Static()->WsSession().GetDefModeMaxNumColors(color,gray); |
|
91 CreateDrawingObjectsL(displayMode,aSize,aBitmap,aDevice,aGc); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // ActivePalette2Utils::DeleteDrawingObjects() |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void ActivePalette2Utils::DeleteDrawingObjects( CFbsBitmap** aBitmap, |
|
99 CFbsBitmapDevice** aDevice, |
|
100 CBitmapContext** aGc) |
|
101 { |
|
102 if (*aGc) |
|
103 { |
|
104 delete *aGc; |
|
105 *aGc = NULL; |
|
106 } |
|
107 if (*aDevice) |
|
108 { |
|
109 delete *aDevice; |
|
110 *aDevice = NULL; |
|
111 } |
|
112 if (*aBitmap) |
|
113 { |
|
114 delete *aBitmap; |
|
115 *aBitmap = NULL; |
|
116 } |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // ActivePalette2Utils::APDimension() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 TInt ActivePalette2Utils::APDimension( TAPDimension aDimensionType, TInt aGeneric ) |
|
125 { |
|
126 TSize ScreenSize( 0, 0 ); |
|
127 AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EScreen, ScreenSize ); |
|
128 TInt baseheight = 240; |
|
129 TInt lower = 0; |
|
130 if ( ScreenSize.iWidth < ScreenSize.iHeight ) |
|
131 { |
|
132 lower = ScreenSize.iWidth; |
|
133 } |
|
134 else |
|
135 { |
|
136 lower = ScreenSize.iHeight; |
|
137 } |
|
138 TReal ratio = TReal(lower)/baseheight; |
|
139 TInt returnValue = 0; |
|
140 TReal roundResult; |
|
141 switch ( aDimensionType ) |
|
142 { |
|
143 case EItemWidth: |
|
144 { |
|
145 Math::Round( roundResult, ratio*NAP2Cfg::KItemWidth, 0 ); |
|
146 } |
|
147 break; |
|
148 case EItemHeight: |
|
149 { |
|
150 Math::Round( roundResult, ratio*NAP2Cfg::KItemHeight, 0 ); |
|
151 } |
|
152 break; |
|
153 case EPaletteWidth: |
|
154 { |
|
155 Math::Round( roundResult, ratio*NAP2Cfg::KPaletteWidth, 0 ); |
|
156 } |
|
157 break; |
|
158 case ETopSectionHeight: |
|
159 { |
|
160 Math::Round( roundResult, ratio*NAP2Cfg::KTopSectionHeight, 0 ); |
|
161 } |
|
162 break; |
|
163 case EBottomSectionHeight: |
|
164 { |
|
165 Math::Round( roundResult, ratio*NAP2Cfg::KBottomSectionHeight, 0 ); |
|
166 } |
|
167 break; |
|
168 case EGapBetweenItems: |
|
169 { |
|
170 Math::Round( roundResult, ratio*NAP2Cfg::KGapBetweenItems, 0 ); |
|
171 } |
|
172 break; |
|
173 case EItemXOffset: |
|
174 { |
|
175 Math::Round( roundResult, ratio*NAP2Cfg::KItemXOffset, 0 ); |
|
176 } |
|
177 break; |
|
178 case EFocusRingWidth: |
|
179 { |
|
180 Math::Round( roundResult, ratio*NAP2Cfg::KFocusRingWidth, 0 ); |
|
181 } |
|
182 break; |
|
183 case EFocusRingHeight: |
|
184 { |
|
185 Math::Round( roundResult, ratio*NAP2Cfg::KFocusRingHeight, 0 ); |
|
186 } |
|
187 break; |
|
188 case EFocusRingXOffset: |
|
189 { |
|
190 Math::Round( roundResult, ratio*NAP2Cfg::KFocusRingXOffset, 0 ); |
|
191 } |
|
192 break; |
|
193 case EFocusRingYOffset: |
|
194 { |
|
195 Math::Round( roundResult, ratio*NAP2Cfg::KFocusRingYOffset, 0 ); |
|
196 } |
|
197 break; |
|
198 case ETooltipYOffset: |
|
199 { |
|
200 Math::Round( roundResult, ratio*NAP2Cfg::KTooltipYOffset, 0 ); |
|
201 } |
|
202 break; |
|
203 case ETooltipHeight: |
|
204 { |
|
205 Math::Round( roundResult, NAP2Cfg::KTooltipFactor*ratio*NAP2Cfg::KTooltipHeight, 0 ); |
|
206 } |
|
207 break; |
|
208 case ETooltipWidth: |
|
209 { |
|
210 Math::Round( roundResult, NAP2Cfg::KTooltipFactor*ratio*NAP2Cfg::KTooltipWidth, 0 ); |
|
211 } |
|
212 break; |
|
213 case ETooltipBaseline: |
|
214 { |
|
215 Math::Round( roundResult, ratio*NAP2Cfg::KTooltipBaseline, 0 ); |
|
216 } |
|
217 break; |
|
218 case ETooltipTail: |
|
219 { |
|
220 Math::Round( roundResult, NAP2Cfg::KTooltipFactor*ratio*NAP2Cfg::KTooltipTail, 0 ); |
|
221 } |
|
222 break; |
|
223 case ETooltipNose: |
|
224 { |
|
225 Math::Round( roundResult, NAP2Cfg::KTooltipFactor*ratio*NAP2Cfg::KTooltipNose, 0 ); |
|
226 } |
|
227 break; |
|
228 case E3dTooltipTextYOffset: |
|
229 { |
|
230 Math::Round( roundResult, ratio*NAP2Cfg::K3dTooltipTextYOffset, 0 ); |
|
231 } |
|
232 break; |
|
233 case E3dTooltipMaxWidth: |
|
234 { |
|
235 roundResult = ScreenSize.iWidth; |
|
236 } |
|
237 break; |
|
238 case EGenericParam: |
|
239 { |
|
240 Math::Round( roundResult, ratio*aGeneric, 0 ); |
|
241 } |
|
242 break; |
|
243 default: |
|
244 { |
|
245 //PRINT( _L("Camera :: CCamAppUi::HandleCommandL Panic!") ) |
|
246 //CamPanic( ECamPanicUi ); |
|
247 } |
|
248 break; |
|
249 } |
|
250 returnValue = TInt(roundResult); |
|
251 return returnValue; |
|
252 } |
|
253 |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // ActivePalette2Utils::APDimensionSize() |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 TSize ActivePalette2Utils::APDimensionSize( TAPDimensionSize aDimensionSize ) |
|
260 { |
|
261 TSize returnSize( 0, 0 ); |
|
262 switch ( aDimensionSize ) |
|
263 { |
|
264 case EItemSize: |
|
265 { |
|
266 TInt width = ActivePalette2Utils::APDimension( EItemWidth ); |
|
267 TInt height = ActivePalette2Utils::APDimension( EItemHeight ); |
|
268 returnSize.SetSize( width, height ); |
|
269 } |
|
270 break; |
|
271 case E3dPaletteTextureSize: |
|
272 { |
|
273 TInt width = ActivePalette2Utils::APDimension( EGenericParam, K3dPaletteTextureSize.iWidth ); |
|
274 TInt height = ActivePalette2Utils::APDimension( EGenericParam, K3dPaletteTextureSize.iHeight ); |
|
275 returnSize.SetSize( width, height ); |
|
276 } |
|
277 break; |
|
278 case E3dScrollIconSize: |
|
279 { |
|
280 TInt width = ActivePalette2Utils::APDimension( EGenericParam, K3dScrollIconSize.iWidth ); |
|
281 TInt height = ActivePalette2Utils::APDimension( EGenericParam, K3dScrollIconSize.iHeight ); |
|
282 returnSize.SetSize( width, height ); |
|
283 } |
|
284 break; |
|
285 case E3dFocusRingSize: |
|
286 { |
|
287 TInt width = ActivePalette2Utils::APDimension( EGenericParam, K3dFocusRingSize.iWidth ); |
|
288 TInt height = ActivePalette2Utils::APDimension( EGenericParam, K3dFocusRingSize.iHeight ); |
|
289 returnSize.SetSize( width, height ); |
|
290 } |
|
291 break; |
|
292 default: |
|
293 { |
|
294 //PRINT( _L("Camera :: CCamAppUi::HandleCommandL Panic!") ) |
|
295 //CamPanic( ECamPanicUi ); |
|
296 } |
|
297 break; |
|
298 } |
|
299 return returnSize; |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // ActivePalette2Utils::APDimensionPoint() |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 TPoint ActivePalette2Utils::APDimensionPoint( TAPDimensionPoint aDimensionPoint ) |
|
307 { |
|
308 TPoint returnPoint( 0, 0 ); |
|
309 switch ( aDimensionPoint ) |
|
310 { |
|
311 case EDefault2dPaletteOffset: |
|
312 { |
|
313 TInt x = ActivePalette2Utils::APDimension( EGenericParam, KDefault2dPaletteOffset.iX ); |
|
314 TInt y = ActivePalette2Utils::APDimension( EGenericParam, KDefault2dPaletteOffset.iY ); |
|
315 returnPoint.SetXY( x, y ); |
|
316 } |
|
317 break; |
|
318 case EDefault3dPaletteOffset: |
|
319 { |
|
320 TInt x = ActivePalette2Utils::APDimension( EGenericParam, KDefault3dPaletteOffset.iX ); |
|
321 TInt y = ActivePalette2Utils::APDimension( EGenericParam, KDefault3dPaletteOffset.iY ); |
|
322 returnPoint.SetXY( x, y ); |
|
323 } |
|
324 break; |
|
325 case E3dScrollIconOffset: |
|
326 { |
|
327 TInt x = ActivePalette2Utils::APDimension( EGenericParam, K3dScrollIconOffset.iX ); |
|
328 TInt y = ActivePalette2Utils::APDimension( EGenericParam, K3dScrollIconOffset.iY ); |
|
329 returnPoint.SetXY( x, y ); |
|
330 } |
|
331 break; |
|
332 case E3dFocusRingOffset: |
|
333 { |
|
334 TInt x = ActivePalette2Utils::APDimension( EGenericParam, K3dFocusRingOffset.iX ); |
|
335 TInt y = ActivePalette2Utils::APDimension( EGenericParam, K3dFocusRingOffset.iY ); |
|
336 returnPoint.SetXY( x, y ); |
|
337 } |
|
338 break; |
|
339 case E3dTooltipOffset: |
|
340 { |
|
341 TInt x = -ActivePalette2Utils::APDimension( EItemXOffset ); |
|
342 TInt y = ActivePalette2Utils::APDimension( EGenericParam, K3dTooltipOffset.iY ); |
|
343 returnPoint.SetXY( x, y ); |
|
344 } |
|
345 break; |
|
346 default: |
|
347 { |
|
348 //PRINT( _L("Camera :: CCamAppUi::HandleCommandL Panic!") ) |
|
349 //CamPanic( ECamPanicUi ); |
|
350 } |
|
351 break; |
|
352 } |
|
353 return returnPoint; |
|
354 } |
|
355 |
|
356 // End of File |