|
1 /* |
|
2 * Copyright (c) 2008 - 2009 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: Window which draws priority and followup flags on navi |
|
15 * pane area. Real navi pane is not used because there was problems to |
|
16 * show editor indicator in custom navi pane. |
|
17 * |
|
18 */ |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include <AknUtils.h> |
|
22 #include <aknnavide.h> // CAknNavigationDecorator |
|
23 #include <eikspane.h> // CEikStatusPane |
|
24 |
|
25 #include <aknlayoutscalable_apps.cdl.h> |
|
26 |
|
27 // INTERNAL INCLUDES |
|
28 #include "cmailcustomstatuspaneindicators.h" |
|
29 #include "ncsconstants.h" // TMsgPriority |
|
30 #include "FreestyleEmailUiLayoutHandler.h" |
|
31 #include "FreestyleEmailUiTextureManager.h" |
|
32 #include "FreestyleEmailUiAppui.h" |
|
33 #include "freestyleemailui.mbg" |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CCustomStatuspaneIndicators::CCustomStatuspaneIndicators |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CCustomStatuspaneIndicators* CCustomStatuspaneIndicators::NewL( CEikStatusPane* aStatusPane ) |
|
40 { |
|
41 CCustomStatuspaneIndicators* self = new (ELeave) CCustomStatuspaneIndicators; |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aStatusPane ); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CCustomStatuspaneIndicators::CCustomStatuspaneIndicators |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CCustomStatuspaneIndicators::CCustomStatuspaneIndicators() |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CCustomStatuspaneIndicators::~CCustomStatuspaneIndicators |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CCustomStatuspaneIndicators::~CCustomStatuspaneIndicators() |
|
61 { |
|
62 delete iPriorityIconLow; |
|
63 delete iPriorityIconHigh; |
|
64 delete iBitmapFollowUp; |
|
65 delete iBitmapFollowUpMask; |
|
66 delete iBitmapFollowUpComplete; |
|
67 delete iBitmapFollowUpCompleteMask; |
|
68 delete iFollowUpIcon; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CCustomStatuspaneIndicators::ConstructL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CCustomStatuspaneIndicators::ConstructL( CEikStatusPane* aStatusPane ) |
|
76 { |
|
77 iStatusPane = aStatusPane; |
|
78 |
|
79 // We use normal window instead of navigation decorator because |
|
80 // Editor indicator cannot be shown with custom navi pane. |
|
81 // This transparent window is drawn on top of navi pane. |
|
82 CreateWindowL(); |
|
83 SetNonFocusing(); |
|
84 |
|
85 // Read icon graphics |
|
86 ConstructControlsL(); |
|
87 DoSetRectL(); |
|
88 |
|
89 Window().SetTransparencyAlphaChannel(); |
|
90 Window().SetOrdinalPosition( 0 ); |
|
91 ActivateL(); |
|
92 |
|
93 HideStatusPaneIndicators(); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CCustomStatuspaneIndicators::MinimumSize |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 |
|
101 TSize CCustomStatuspaneIndicators::MinimumSize() |
|
102 { |
|
103 return TSize( Rect().Width(), Rect().Height() ); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CCustomStatuspaneIndicators::CountComponentControls |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CCustomStatuspaneIndicators::CountComponentControls() const |
|
111 { |
|
112 TInt count( 0 ); |
|
113 if ( iPriorityIconLow ) |
|
114 { |
|
115 ++count; |
|
116 } |
|
117 if ( iPriorityIconHigh ) |
|
118 { |
|
119 ++count; |
|
120 } |
|
121 if ( iFollowUpIcon ) |
|
122 { |
|
123 ++count; |
|
124 } |
|
125 return count; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CCustomStatuspaneIndicators::ComponentControl |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 CCoeControl* CCustomStatuspaneIndicators::ComponentControl( TInt aIndex ) const |
|
133 { |
|
134 switch ( aIndex ) |
|
135 { |
|
136 case 0: |
|
137 return iPriorityIconLow; |
|
138 case 1: |
|
139 return iPriorityIconHigh; |
|
140 case 2: |
|
141 return iFollowUpIcon; |
|
142 default: |
|
143 return NULL; |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CCustomStatuspaneIndicators::SizeChanged |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CCustomStatuspaneIndicators::SizeChanged() |
|
152 { |
|
153 TRect rect = Rect(); |
|
154 |
|
155 // icon area |
|
156 TAknLayoutRect naviPane; |
|
157 naviPane.LayoutRect( rect, |
|
158 AknLayoutScalable_Apps::navi_pane_mv_g2( 3 ) ); |
|
159 TRect naviPaneRect( naviPane.Rect() ); |
|
160 |
|
161 // icon size |
|
162 CFreestyleEmailUiAppUi* fsAppUi = |
|
163 static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
164 TSize iconSize = fsAppUi->LayoutHandler()->statusPaneIconSize(); |
|
165 |
|
166 // calculate margins |
|
167 TInt marginX( Abs( naviPaneRect.Width() - iconSize.iWidth ) / 2 ); |
|
168 TInt marginY( Abs( naviPaneRect.Height() - iconSize.iHeight ) / 2 ); |
|
169 |
|
170 // adjust for scroll arrows |
|
171 if ( CheckScrollButtonState() ) |
|
172 { |
|
173 TAknLayoutRect leftScrollPane; |
|
174 leftScrollPane.LayoutRect( rect, |
|
175 AknLayoutScalable_Apps::navi_pane_g2( 5 ) ); |
|
176 |
|
177 marginX -= leftScrollPane.Rect().Width(); |
|
178 } |
|
179 |
|
180 if( iPriorityIconLow ) |
|
181 { |
|
182 AknLayoutUtils::SAknLayoutRect layout; |
|
183 layout.iC=ELayoutEmpty; |
|
184 layout.iL=naviPaneRect.iTl.iX + marginX; // X |
|
185 layout.iT=naviPaneRect.iTl.iY + marginY; // Y |
|
186 layout.iR=ELayoutEmpty; // r-border |
|
187 layout.iB=ELayoutEmpty; // y-border |
|
188 layout.iW=iconSize.iWidth; // Width |
|
189 layout.iH=iconSize.iHeight; // Height |
|
190 |
|
191 AknLayoutUtils::LayoutImage( iPriorityIconLow, rect, layout ); |
|
192 } |
|
193 if( iPriorityIconHigh ) |
|
194 { |
|
195 AknLayoutUtils::SAknLayoutRect layout; |
|
196 layout.iC=ELayoutEmpty; |
|
197 layout.iL=naviPaneRect.iTl.iX + marginX; |
|
198 layout.iT=naviPaneRect.iTl.iY + marginY; |
|
199 layout.iR=ELayoutEmpty; |
|
200 layout.iB=ELayoutEmpty; |
|
201 layout.iW=iconSize.iWidth; |
|
202 layout.iH=iconSize.iHeight; |
|
203 |
|
204 AknLayoutUtils::LayoutImage( iPriorityIconHigh, rect, layout ); |
|
205 } |
|
206 if( iFollowUpIcon ) |
|
207 { |
|
208 AknLayoutUtils::SAknLayoutRect layout; |
|
209 layout.iC=ELayoutEmpty; |
|
210 layout.iL=iconSize.iWidth + naviPaneRect.iTl.iX + marginX; |
|
211 layout.iT=naviPaneRect.iTl.iY + marginY; |
|
212 layout.iR=ELayoutEmpty; |
|
213 layout.iB=ELayoutEmpty; |
|
214 layout.iW=iconSize.iWidth; |
|
215 layout.iH=iconSize.iHeight; |
|
216 |
|
217 AknLayoutUtils::LayoutImage( iFollowUpIcon, rect, layout ); |
|
218 } |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CCustomStatuspaneIndicators::HandleResourceChange |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CCustomStatuspaneIndicators::HandleResourceChange( TInt aType ) |
|
226 { |
|
227 CCoeControl::HandleResourceChange( aType ); |
|
228 |
|
229 switch ( aType ) |
|
230 { |
|
231 case KAknsMessageSkinChange: |
|
232 case KEikMessageColorSchemeChange: |
|
233 { |
|
234 TRAP_IGNORE(ConstructControlsL()); |
|
235 } |
|
236 case KEikDynamicLayoutVariantSwitch: |
|
237 case KAknLocalZoomLayoutSwitch: |
|
238 { |
|
239 // Get new navipane rect |
|
240 TRAP_IGNORE( DoSetRectL() ); |
|
241 SizeChanged(); |
|
242 break; |
|
243 } |
|
244 default: |
|
245 { |
|
246 break; |
|
247 } |
|
248 } |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CCustomStatuspaneIndicators::SetPriorityFlag |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CCustomStatuspaneIndicators::SetPriorityFlag( TMsgPriority aFlagType ) |
|
256 { |
|
257 if ( iPriorityIconHigh && iPriorityIconLow ) |
|
258 { |
|
259 switch ( aFlagType ) |
|
260 { |
|
261 case EMsgPriorityLow: |
|
262 { |
|
263 iPriorityIconLow->MakeVisible( ETrue ); |
|
264 iPriorityIconHigh->MakeVisible( EFalse ); |
|
265 break; |
|
266 } |
|
267 case EMsgPriorityHigh: |
|
268 { |
|
269 iPriorityIconLow->MakeVisible( EFalse ); |
|
270 iPriorityIconHigh->MakeVisible( ETrue ); |
|
271 break; |
|
272 } |
|
273 default: // EMsgPriorityNormal |
|
274 { |
|
275 // Normal priority -> icons not visible |
|
276 iPriorityIconLow->MakeVisible( EFalse ); |
|
277 iPriorityIconHigh->MakeVisible( EFalse ); |
|
278 } |
|
279 } |
|
280 DrawNow(); |
|
281 } |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CCustomStatuspaneIndicators::SetFollowUpFlag |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void CCustomStatuspaneIndicators::SetFollowUpFlag( CCustomStatuspaneIndicators::TFollowUpFlagType aFlag ) |
|
289 { |
|
290 CFreestyleEmailUiAppUi* fsAppUi = |
|
291 static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
292 TSize iconSize = fsAppUi->LayoutHandler()->statusPaneIconSize(); |
|
293 |
|
294 if ( iFollowUpIcon ) |
|
295 { |
|
296 switch (aFlag) |
|
297 { |
|
298 case EFollowUp: |
|
299 { |
|
300 AknIconUtils::SetSize( iBitmapFollowUp, iconSize, EAspectRatioPreserved ); |
|
301 iFollowUpIcon->SetPicture(iBitmapFollowUp, iBitmapFollowUpMask); |
|
302 iFollowUpIcon->SetBrushStyle( CWindowGc::ENullBrush ); |
|
303 iFollowUpIcon->SetSize( iconSize ); |
|
304 } |
|
305 break; |
|
306 case EFollowUpComplete: |
|
307 { |
|
308 AknIconUtils::SetSize( iBitmapFollowUpComplete, iconSize, EAspectRatioPreserved ); |
|
309 iFollowUpIcon->SetPicture(iBitmapFollowUpComplete, iBitmapFollowUpCompleteMask); |
|
310 iFollowUpIcon->SetBrushStyle( CWindowGc::ENullBrush ); |
|
311 iFollowUpIcon->SetSize( iconSize ); |
|
312 } |
|
313 break; |
|
314 case EFollowUpNone: |
|
315 { |
|
316 |
|
317 } |
|
318 break; |
|
319 } |
|
320 iFollowUpIcon->MakeVisible( aFlag != EFollowUpNone ); |
|
321 DrawDeferred(); |
|
322 } |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CCustomStatuspaneIndicators::HideStatusPaneIndicatorsL |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 void CCustomStatuspaneIndicators::HideStatusPaneIndicators() |
|
330 { |
|
331 MakeVisible( EFalse ); |
|
332 SetPriorityFlag( EMsgPriorityNormal ); |
|
333 SetFollowUpFlag( EFollowUpNone ); |
|
334 DrawNow(); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CCustomStatuspaneIndicators::ShowStatusPaneIndicatorsL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CCustomStatuspaneIndicators::ShowStatusPaneIndicators() |
|
342 { |
|
343 MakeVisible( ETrue ); |
|
344 TRAP_IGNORE( DoSetRectL() ); |
|
345 SetPriorityFlag( EMsgPriorityNormal ); |
|
346 SetFollowUpFlag( EFollowUpNone ); |
|
347 DrawNow(); |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CCustomStatuspaneIndicators::CheckScrollButtonState |
|
352 // --------------------------------------------------------------------------- |
|
353 // |
|
354 TBool CCustomStatuspaneIndicators::CheckScrollButtonState() |
|
355 { |
|
356 CAknNavigationControlContainer* NaviPane = NULL; |
|
357 TRAP_IGNORE( NaviPane = (CAknNavigationControlContainer*) |
|
358 iStatusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
359 CAknNavigationDecorator* NaviDecorator = NaviPane->Top(); |
|
360 if ( NaviDecorator ) |
|
361 { |
|
362 return NaviDecorator->ScrollButtonVisible(); |
|
363 } |
|
364 return EFalse; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CCustomStatuspaneIndicators::DoSetRectL |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CCustomStatuspaneIndicators::DoSetRectL() |
|
372 { |
|
373 TRect rect = iStatusPane->PaneRectL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
374 |
|
375 // adjust for scroll arrows (to avoid overlapping the scrolling arrows) |
|
376 if ( CheckScrollButtonState() ) |
|
377 { |
|
378 TAknLayoutRect leftScrollPane; |
|
379 leftScrollPane.LayoutRect( rect, |
|
380 AknLayoutScalable_Apps::navi_pane_g2( 5 ) ); |
|
381 |
|
382 rect.iTl.iX += leftScrollPane.Rect().Width(); |
|
383 |
|
384 TAknLayoutRect rightScrollPane; |
|
385 rightScrollPane.LayoutRect( rect, |
|
386 AknLayoutScalable_Apps::navi_pane_g3( 5 ) ); |
|
387 |
|
388 rect.iBr.iX -= rightScrollPane.Rect().Width(); |
|
389 } |
|
390 SetRect( rect ); |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // CCustomStatuspaneIndicators::ConstructControlsL |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void CCustomStatuspaneIndicators::ConstructControlsL() |
|
398 { |
|
399 CCustomStatuspaneIndicators::TFollowUpFlagType followUpFlagType = CCustomStatuspaneIndicators::EFollowUpNone; |
|
400 TMsgPriority priorityIconType = EMsgPriorityNormal; |
|
401 if (iPriorityIconLow && iPriorityIconLow->IsVisible()) |
|
402 { |
|
403 priorityIconType = EMsgPriorityLow; |
|
404 } |
|
405 else if (iPriorityIconHigh && iPriorityIconHigh->IsVisible()) |
|
406 { |
|
407 priorityIconType = EMsgPriorityHigh; |
|
408 } |
|
409 |
|
410 if (iFollowUpIcon) |
|
411 { |
|
412 if (iFollowUpIcon->Bitmap() == iBitmapFollowUp) |
|
413 { |
|
414 followUpFlagType = CCustomStatuspaneIndicators::EFollowUp; |
|
415 } |
|
416 else if (iFollowUpIcon->Bitmap() == iBitmapFollowUpComplete) |
|
417 { |
|
418 followUpFlagType = CCustomStatuspaneIndicators::EFollowUpComplete; |
|
419 } |
|
420 } |
|
421 |
|
422 delete iPriorityIconLow; |
|
423 iPriorityIconLow = NULL; |
|
424 delete iPriorityIconHigh; |
|
425 iPriorityIconHigh = NULL; |
|
426 delete iFollowUpIcon; |
|
427 iFollowUpIcon = NULL; |
|
428 iBitmapPriorityLow = NULL; |
|
429 iBitmapMaskPriorityLow = NULL; |
|
430 iBitmapPriorityHigh = NULL; |
|
431 iBitmapMaskPriorityHigh = NULL; |
|
432 delete iBitmapFollowUp; |
|
433 iBitmapFollowUp = NULL; |
|
434 delete iBitmapFollowUpMask; |
|
435 iBitmapFollowUpMask = NULL; |
|
436 delete iBitmapFollowUpComplete; |
|
437 iBitmapFollowUpComplete = NULL; |
|
438 delete iBitmapFollowUpCompleteMask; |
|
439 iBitmapFollowUpCompleteMask = NULL; |
|
440 |
|
441 CFreestyleEmailUiAppUi* fsAppUi = |
|
442 static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
443 fsAppUi->FsTextureManager()->ProvideBitmapL( |
|
444 EComposerTexturePriorityLow, |
|
445 iBitmapPriorityLow, |
|
446 iBitmapMaskPriorityLow ); |
|
447 fsAppUi->FsTextureManager()->ProvideBitmapL( |
|
448 EComposerTexturePriorityHigh, |
|
449 iBitmapPriorityHigh, |
|
450 iBitmapMaskPriorityHigh ); |
|
451 fsAppUi->FsTextureManager()->ProvideBitmapL( |
|
452 EFollowUpFlag, |
|
453 iBitmapFollowUp, |
|
454 iBitmapFollowUpMask ); |
|
455 fsAppUi->FsTextureManager()->ProvideBitmapL( |
|
456 EFollowUpFlagComplete, |
|
457 iBitmapFollowUpComplete, |
|
458 iBitmapFollowUpCompleteMask ); |
|
459 |
|
460 TSize iconSize = fsAppUi->LayoutHandler()->statusPaneIconSize(); |
|
461 |
|
462 if ( iBitmapPriorityLow && iBitmapMaskPriorityLow ) |
|
463 { |
|
464 iPriorityIconLow = new (ELeave) CEikImage; |
|
465 iPriorityIconLow->SetPictureOwnedExternally( EFalse ); |
|
466 AknIconUtils::SetSize( iBitmapPriorityLow, iconSize, EAspectRatioPreserved ); |
|
467 iPriorityIconLow->SetPicture( iBitmapPriorityLow, |
|
468 iBitmapMaskPriorityLow ); |
|
469 iPriorityIconLow->SetBrushStyle( CWindowGc::ENullBrush ); |
|
470 iPriorityIconLow->SetSize( iconSize ); |
|
471 iPriorityIconLow->SetContainerWindowL( *this ); |
|
472 iPriorityIconLow->MakeVisible(priorityIconType == EMsgPriorityLow); |
|
473 } |
|
474 if ( iBitmapPriorityHigh && iBitmapMaskPriorityHigh ) |
|
475 { |
|
476 iPriorityIconHigh = new (ELeave) CEikImage; |
|
477 iPriorityIconHigh->SetPictureOwnedExternally( EFalse ); |
|
478 AknIconUtils::SetSize( iBitmapPriorityHigh, iconSize, EAspectRatioPreserved ); |
|
479 iPriorityIconHigh->SetPicture( iBitmapPriorityHigh, |
|
480 iBitmapMaskPriorityHigh ); |
|
481 iPriorityIconHigh->SetBrushStyle( CWindowGc::ENullBrush ); |
|
482 iPriorityIconHigh->SetSize( iconSize ); |
|
483 iPriorityIconHigh->SetContainerWindowL( *this ); |
|
484 iPriorityIconHigh->MakeVisible(priorityIconType == EMsgPriorityHigh); |
|
485 } |
|
486 if ( iBitmapFollowUp && iBitmapFollowUpMask && iBitmapFollowUpComplete && iBitmapFollowUpCompleteMask ) |
|
487 { |
|
488 iFollowUpIcon = new (ELeave) CEikImage; |
|
489 iFollowUpIcon->SetPictureOwnedExternally( ETrue ); |
|
490 if (followUpFlagType == CCustomStatuspaneIndicators::EFollowUp) |
|
491 { |
|
492 AknIconUtils::SetSize( iBitmapFollowUp, iconSize, EAspectRatioNotPreserved ); |
|
493 iFollowUpIcon->SetPicture( iBitmapFollowUp, |
|
494 iBitmapFollowUpMask ); |
|
495 } |
|
496 else if (followUpFlagType == CCustomStatuspaneIndicators::EFollowUpComplete) |
|
497 { |
|
498 AknIconUtils::SetSize( iBitmapFollowUpComplete, iconSize, EAspectRatioNotPreserved ); |
|
499 iFollowUpIcon->SetPicture( iBitmapFollowUpComplete, |
|
500 iBitmapFollowUpCompleteMask ); |
|
501 } |
|
502 iFollowUpIcon->SetBrushStyle( CWindowGc::ENullBrush ); |
|
503 iFollowUpIcon->SetSize( iconSize ); |
|
504 iFollowUpIcon->SetContainerWindowL( *this ); |
|
505 iFollowUpIcon->MakeVisible(followUpFlagType != CCustomStatuspaneIndicators::EFollowUpNone); |
|
506 } |
|
507 DrawDeferred(); |
|
508 } |