|
1 /* |
|
2 * Copyright (c) 2002 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: Folder navigation decorator for navipane |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "MceNaviPaneFolderIndicator.h" |
|
22 #include <StringLoader.h> |
|
23 #include <muiu.mbg> |
|
24 #include <mce.rsg> |
|
25 #include <AknIconArray.h> // CAknIconArray |
|
26 |
|
27 // security data caging |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <bldvariant.hrh> |
|
30 #include <aknlayoutscalable_avkon.cdl.h> |
|
31 #include <AknDef.h> |
|
32 #include "MceSessionHolder.h" |
|
33 |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 const TUint KMceRoot = 0; |
|
38 const TUint KMceFirstLevel = 1; |
|
39 _LIT( KMceDirAndFile,"muiu.mbm" ); |
|
40 |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMceNaviPaneFolderIndicator::CMceNaviPaneFolderIndicator |
|
46 // C++ default constructor can NOT contain any code, that |
|
47 // might leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CMceNaviPaneFolderIndicator::CMceNaviPaneFolderIndicator( |
|
51 TBool aPhoneMemory, |
|
52 const TInt aDepth ) |
|
53 : |
|
54 iMaxDepth( KMceNaviPaneMaxDepth - 1 ), |
|
55 iPhoneMemory( aPhoneMemory ) |
|
56 { |
|
57 // ensure that iDepth will be positive |
|
58 aDepth < 0 ? iDepth = 0 : iDepth = aDepth; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceNaviPaneFolderIndicator::ConstructL |
|
63 // Symbian 2nd phase constructor can leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CMceNaviPaneFolderIndicator::ConstructL() |
|
67 { |
|
68 // security data caging |
|
69 TParse fp; |
|
70 fp.Set( KMceDirAndFile, &KDC_APP_BITMAP_DIR , NULL ); |
|
71 iFilename = fp.FullName(); |
|
72 |
|
73 iSeparator = StringLoader::LoadL( R_MEMC_MAIN_SEPARATOR, iEikonEnv ); |
|
74 iEndChar = StringLoader::LoadL( R_MEMC_MAIN_END, iEikonEnv ); |
|
75 |
|
76 LoadFolderBitmapL(); |
|
77 // Set the default root bitmap |
|
78 ChangeRootL( iPhoneMemory ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMceNaviPaneFolderIndicator::NewL |
|
83 // Two-phased constructor. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CMceNaviPaneFolderIndicator* CMceNaviPaneFolderIndicator::NewL( |
|
87 TBool aPhoneMemory, |
|
88 const TInt aDepth ) |
|
89 { |
|
90 CMceNaviPaneFolderIndicator* self = CMceNaviPaneFolderIndicator::NewLC( |
|
91 aPhoneMemory, aDepth ); |
|
92 CleanupStack::Pop( self ); |
|
93 return self; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CMceNaviPaneFolderIndicator::NewLC |
|
98 // Two-phased constructor. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CMceNaviPaneFolderIndicator* CMceNaviPaneFolderIndicator::NewLC( |
|
102 TBool aPhoneMemory, |
|
103 const TInt aDepth ) |
|
104 { |
|
105 CMceNaviPaneFolderIndicator* self=new(ELeave) CMceNaviPaneFolderIndicator( |
|
106 aPhoneMemory, aDepth ); |
|
107 CleanupStack::PushL( self ); |
|
108 self->ConstructL(); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // Destructor |
|
113 CMceNaviPaneFolderIndicator::~CMceNaviPaneFolderIndicator() |
|
114 { |
|
115 delete iFolderBitmap; |
|
116 delete iFolderMask; |
|
117 |
|
118 delete iRootBitmap; |
|
119 delete iRootMask; |
|
120 |
|
121 delete iSeparator; |
|
122 delete iEndChar; |
|
123 } |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CMceNaviPaneFolderIndicator::SetFolderDepth |
|
126 // Sets the current folder navigation depth |
|
127 // (other items were commented in a header). |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CMceNaviPaneFolderIndicator::SetFolderDepth( const TInt aDepth ) |
|
131 { |
|
132 aDepth < 0 ? iDepth = 0 : iDepth = aDepth; |
|
133 |
|
134 // ReportChange() is used to notify CoeControl to redraw pane. |
|
135 ReportChange(); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMceNaviPaneFolderIndicator::SizeChanged |
|
140 // Handles size changes |
|
141 // (other items were commented in a header). |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CMceNaviPaneFolderIndicator::SizeChanged() |
|
145 { |
|
146 TSize size( TSize::EUninitialized ); |
|
147 AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::ENaviPane, size ); |
|
148 TRect parentRect( size ); |
|
149 |
|
150 // Get pane icon and text layouts |
|
151 TAknWindowLineLayout paneIconLayout( |
|
152 AknLayoutScalable_Avkon::navi_icon_text_pane_g1().LayoutLine() ); |
|
153 TAknTextLineLayout paneTextLayout( |
|
154 AknLayoutScalable_Avkon::navi_icon_text_pane_t1().LayoutLine() ); |
|
155 TAknLayoutRect layoutRect; |
|
156 TAknLayoutText layoutText; |
|
157 layoutRect.LayoutRect( parentRect, paneIconLayout ); |
|
158 layoutText.LayoutText( parentRect, paneTextLayout ); |
|
159 // Setup pane items |
|
160 TRect itemsRect( layoutRect.Rect() ); |
|
161 const CFont* font( layoutText.Font() ); // Not owned |
|
162 TInt bsWidth( font->MeasureText( *iSeparator ) ); |
|
163 TInt dotsWidth( font->MeasureText( *iEndChar ) ); |
|
164 TInt textWidth( KMceNaviPaneMaxDepth * bsWidth + dotsWidth ); |
|
165 TInt iconWidth( ( itemsRect.Width() - textWidth ) |
|
166 / KMceNaviPaneMaxDepth ); |
|
167 TInt i( 0 ); |
|
168 |
|
169 if ( AknLayoutUtils::LayoutMirrored() ) |
|
170 { |
|
171 TInt offs( itemsRect.Width() ); |
|
172 for ( i = 0 ; i < KMceNaviPaneMaxDepth; i++ ) |
|
173 { |
|
174 // Root and Folder Icons |
|
175 offs -= iconWidth; |
|
176 iBitmapLayout[ i ].LayoutRect( |
|
177 parentRect, |
|
178 paneIconLayout.iC, |
|
179 paneIconLayout.il + offs, |
|
180 paneIconLayout.it, |
|
181 paneIconLayout.ir, |
|
182 paneIconLayout.ib, |
|
183 iconWidth, |
|
184 paneIconLayout.iH |
|
185 ); |
|
186 // Backslashes |
|
187 offs -= bsWidth; |
|
188 iTextLayout[ i ].LayoutText( |
|
189 parentRect, |
|
190 paneTextLayout.iFont, |
|
191 paneTextLayout.iC, |
|
192 paneTextLayout.il + offs, |
|
193 paneTextLayout.ir, |
|
194 paneTextLayout.iB, |
|
195 paneTextLayout.iW, |
|
196 paneTextLayout.iJ |
|
197 ); |
|
198 } |
|
199 // Dots |
|
200 offs -= dotsWidth; |
|
201 iTextLayout[ i ].LayoutText( |
|
202 parentRect, |
|
203 paneTextLayout.iFont, |
|
204 paneTextLayout.iC, |
|
205 paneTextLayout.il + offs, |
|
206 paneTextLayout.ir, |
|
207 paneTextLayout.iB, |
|
208 paneTextLayout.iW, |
|
209 paneTextLayout.iJ |
|
210 ); |
|
211 } |
|
212 else |
|
213 { |
|
214 TInt offs( 0 ); |
|
215 for ( i = 0 ; i < KMceNaviPaneMaxDepth; i++ ) |
|
216 { |
|
217 // Root and Folder Icons |
|
218 iBitmapLayout[ i ].LayoutRect( |
|
219 parentRect, |
|
220 paneIconLayout.iC, |
|
221 paneIconLayout.il + offs, |
|
222 paneIconLayout.it, |
|
223 paneIconLayout.ir, |
|
224 paneIconLayout.ib, |
|
225 iconWidth, |
|
226 paneIconLayout.iH |
|
227 ); |
|
228 offs += iconWidth; |
|
229 // Backslashes |
|
230 iTextLayout[ i ].LayoutText( |
|
231 parentRect, |
|
232 paneTextLayout.iFont, |
|
233 paneTextLayout.iC, |
|
234 paneTextLayout.il + offs, |
|
235 paneTextLayout.ir, |
|
236 paneTextLayout.iB, |
|
237 paneTextLayout.iW, |
|
238 paneTextLayout.iJ |
|
239 ); |
|
240 offs += bsWidth; |
|
241 } |
|
242 // Dots |
|
243 iTextLayout[ i ].LayoutText( |
|
244 parentRect, |
|
245 paneTextLayout.iFont, |
|
246 paneTextLayout.iC, |
|
247 paneTextLayout.il + offs, |
|
248 paneTextLayout.ir, |
|
249 paneTextLayout.iB, |
|
250 paneTextLayout.iW, |
|
251 paneTextLayout.iJ |
|
252 ); |
|
253 } |
|
254 } |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CMceNaviPaneFolderIndicator::Draw |
|
257 // Handles drawing of the decorator |
|
258 // (other items were commented in a header). |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CMceNaviPaneFolderIndicator::Draw( const TRect& /*aRect*/ ) const |
|
262 { |
|
263 CWindowGc& gc = SystemGc(); |
|
264 |
|
265 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
266 |
|
267 CFbsBitmap* bmp = NULL; |
|
268 TRgb color( KRgbWhite ); // Default never used |
|
269 bmp = AknsUtils::GetCachedBitmap( skin, KAknsIIDQsnIconColors ); |
|
270 if (!IsLandscapeScreenOrientation()) |
|
271 { |
|
272 AknsUtils::GetCachedColor( skin, color, |
|
273 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG7 ); |
|
274 } |
|
275 else |
|
276 { |
|
277 AknsUtils::GetCachedColor( skin, color, |
|
278 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG25 ); |
|
279 } |
|
280 |
|
281 AknIconUtils::SetSize( iRootMask, iBitmapLayout[ KMceRoot ].Rect().Size() ); |
|
282 if( bmp ) |
|
283 { |
|
284 iBitmapLayout[ KMceRoot ].DrawImage( gc, bmp, iRootMask ); |
|
285 } |
|
286 else |
|
287 { |
|
288 AknIconUtils::SetSize( iRootBitmap, iBitmapLayout[ KMceRoot ].Rect().Size() ); |
|
289 iBitmapLayout[ KMceRoot ].DrawImage( gc, iRootBitmap, iRootMask ); |
|
290 } |
|
291 |
|
292 if( !bmp ) |
|
293 { |
|
294 AknIconUtils::SetSize( iFolderBitmap, iBitmapLayout[ KMceFirstLevel ].Rect().Size() ); |
|
295 bmp = iFolderBitmap; |
|
296 } |
|
297 |
|
298 |
|
299 // draw folder bitmaps depending on current folderdepth |
|
300 TInt count( iDepth > iMaxDepth ? iMaxDepth : iDepth ); |
|
301 AknIconUtils::SetSize( iFolderMask, iBitmapLayout[ KMceFirstLevel ].Rect().Size() ); |
|
302 for( TInt i( KMceFirstLevel ); i <= count; i++ ) |
|
303 { |
|
304 iBitmapLayout[ i ].DrawImage( gc, bmp, iFolderMask ); |
|
305 } |
|
306 |
|
307 // draw backslashes between folderbitmaps depending on current folderdepth |
|
308 TInt tc( iDepth > ( iMaxDepth + 1 ) ? ( iMaxDepth + 1 ) : iDepth ); |
|
309 for( TInt j( 0 ); j < tc; j++ ) |
|
310 { |
|
311 const CFont* font = iTextLayout[j].Font(); // Not owned |
|
312 gc.UseFont( font ); |
|
313 gc.SetPenColor( color ); |
|
314 gc.DrawText( *iSeparator, iTextLayout[j].TextRect(), |
|
315 font->AscentInPixels(), CGraphicsContext::ELeft, 0 ); |
|
316 } |
|
317 |
|
318 // draw "..." at the end if necessary |
|
319 if ( iDepth > iMaxDepth ) |
|
320 { |
|
321 const CFont* font = iTextLayout[iMaxDepth+1].Font(); // Not owned |
|
322 gc.UseFont( font ); |
|
323 gc.SetPenColor( color ); |
|
324 gc.DrawText( *iEndChar, iTextLayout[iMaxDepth+1].TextRect(), |
|
325 font->AscentInPixels(), CGraphicsContext::ELeft, 0 ); |
|
326 } |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CMceNaviPaneFolderIndicator::HandleResourceChange |
|
331 // (other items were commented in a header). |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 void CMceNaviPaneFolderIndicator::HandleResourceChange( TInt aType ) |
|
335 { |
|
336 CCoeControl::HandleResourceChange( aType ); |
|
337 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
338 { |
|
339 SizeChanged(); |
|
340 } |
|
341 else if( aType == KAknsMessageSkinChange ) |
|
342 { |
|
343 TRAP_IGNORE( LoadFolderBitmapL() ); |
|
344 // Set the default root bitmap |
|
345 TRAP_IGNORE( ChangeRootL( iPhoneMemory ) ); |
|
346 } |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CMceNaviPaneFolderIndicator::ReportChange |
|
351 // Reports changes |
|
352 // (other items were commented in a header). |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CMceNaviPaneFolderIndicator::ReportChange() |
|
356 { |
|
357 // Leave is trapped because it's not critical to functionality. |
|
358 // If leave occurs, navipane just may not be redrawn at that very moment. |
|
359 TRAP_IGNORE( ReportEventL( MCoeControlObserver::EEventStateChanged ) ); |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CMceNaviPaneFolderIndicator::ChangeRootL |
|
364 // Changes the root bitmap |
|
365 // (other items were commented in a header). |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void CMceNaviPaneFolderIndicator::ChangeRootL( TBool aPhoneMemory ) |
|
369 { |
|
370 iPhoneMemory = aPhoneMemory; |
|
371 delete iRootBitmap; |
|
372 iRootBitmap = NULL; |
|
373 delete iRootMask; |
|
374 iRootMask = NULL; |
|
375 |
|
376 if ( iPhoneMemory ) |
|
377 { |
|
378 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
379 KAknsIIDQgnPropMemcPhoneTab, |
|
380 KAknsIIDQsnIconColors, |
|
381 EAknsCIQsnIconColorsCG7, |
|
382 iRootBitmap, |
|
383 iRootMask, |
|
384 iFilename, |
|
385 EMbmMuiuQgn_prop_memc_phone_tab, |
|
386 EMbmMuiuQgn_prop_memc_phone_tab+1, |
|
387 KRgbBlack ); |
|
388 } |
|
389 else |
|
390 { |
|
391 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
392 KAknsIIDQgnPropMemcMmcTab, |
|
393 KAknsIIDQsnIconColors, |
|
394 EAknsCIQsnIconColorsCG7, |
|
395 iRootBitmap, |
|
396 iRootMask, |
|
397 iFilename, |
|
398 EMbmMuiuQgn_prop_memc_mmc_tab, |
|
399 EMbmMuiuQgn_prop_memc_mmc_tab+1, |
|
400 KRgbBlack ); |
|
401 } |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CMceNaviPaneFolderIndicator::LoadFolderBitmapL |
|
406 // Loads Folder Bitmaps |
|
407 // (other items were commented in a header). |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 void CMceNaviPaneFolderIndicator::LoadFolderBitmapL() |
|
411 { |
|
412 |
|
413 delete iFolderBitmap; |
|
414 iFolderBitmap = NULL; |
|
415 delete iFolderMask; |
|
416 iFolderMask = NULL; |
|
417 |
|
418 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
419 KAknsIIDQgnPropFolderTab, |
|
420 KAknsIIDQsnIconColors, |
|
421 EAknsCIQsnIconColorsCG7, |
|
422 iFolderBitmap, |
|
423 iFolderMask, |
|
424 iFilename, |
|
425 EMbmMuiuQgn_prop_folder_tab, |
|
426 EMbmMuiuQgn_prop_folder_tab+1, |
|
427 KRgbBlack ); |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CMceNaviPaneFolderIndicator::IsLandscapeScreenOrientation |
|
432 // Checks phone screen mode Landscape or Portrait |
|
433 // (other items were commented in a header). |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 TBool CMceNaviPaneFolderIndicator::IsLandscapeScreenOrientation() const |
|
437 { |
|
438 TRect rect; |
|
439 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect); |
|
440 return rect.Width() > rect.Height(); |
|
441 } |
|
442 |
|
443 // End of File |