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