1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
14 * Description: BatteryPopupControl implementation |
14 * Description: BatteryPopupControl implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <AknUtils.h> |
19 //#include <aknutils.h> |
20 #include <AknPanic.h> |
20 //#include <aknpanic.h> |
21 #include <AknPreviewPopUpController.h> |
21 //#include <aknpreviewpopupcontroller.h> |
22 #include <aknglobalpopupprioritycontroller.h> |
22 //#include <aknglobalpopupprioritycontroller.h> |
23 #include <barsread.h> // TResourceReader |
23 #include <barsread.h> // TResourceReader |
24 #include <eiklabel.h> |
24 #include <eiklabel.h> |
25 #include <fbs.h> |
25 #include <fbs.h> |
26 #include <aknappui.h> |
26 //#include <aknappui.h> |
27 #include <aknlayoutscalable_avkon.cdl.h> |
27 //#include <aknlayoutscalable_avkon.cdl.h> |
28 #include <AknsDrawUtils.h> |
28 //#include <aknsdrawutils.h> |
29 #include <AknBidiTextUtils.h> |
29 //#include <aknbiditextutils.h> |
30 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR |
30 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR |
31 #include <batterypopupcontrol.mbg> |
31 #include <batterypopupcontrol.mbg> |
32 // ----------- Touch feedback additions start |
32 // ----------- Touch feedback additions start |
33 #ifdef RD_TACTILE_FEEDBACK |
33 #ifdef RD_TACTILE_FEEDBACK |
34 #include <touchfeedback.h> |
34 #include <touchfeedback.h> |
37 #include <gulicon.h> |
37 #include <gulicon.h> |
38 #include "batterypopupcontrol.h" |
38 #include "batterypopupcontrol.h" |
39 #include "trace.h" |
39 #include "trace.h" |
40 |
40 |
41 // Constants |
41 // Constants |
42 const TInt KPopupShowDelay = 0; // Show immediately |
42 //const TInt KPopupShowDelay = 0; // Show immediately |
43 const TInt KPopupHideDelay = 3000000; // hide after 3 sec |
43 //const TInt KPopupHideDelay = 3000000; // hide after 3 sec |
44 const TInt KMaxLinkTextLength = 255; |
44 //const TInt KMaxLinkTextLength = 255; |
45 |
45 |
46 // ======== MEMBER FUNCTIONS ======== |
46 // ======== MEMBER FUNCTIONS ======== |
47 |
47 |
48 // ----------------------------------------------------------------------------- |
48 // ----------------------------------------------------------------------------- |
49 // Default constructor. |
49 // Default constructor. |
103 // |
103 // |
104 EXPORT_C void CBatteryPopupControl::ShowPopUpL() |
104 EXPORT_C void CBatteryPopupControl::ShowPopUpL() |
105 { |
105 { |
106 FUNC_LOG |
106 FUNC_LOG |
107 |
107 |
108 iController = CAknPreviewPopUpController::NewL( *this, CAknPreviewPopUpController::ELayoutDefault | CAknPreviewPopUpController::EDontClose ); |
108 /* iController = CAknPreviewPopUpController::NewL( *this, CAknPreviewPopUpController::ELayoutDefault | CAknPreviewPopUpController::EDontClose ); |
109 iController->AddObserverL( *this ); |
109 iController->AddObserverL( *this ); |
110 |
110 |
111 // Set popup's hide/show delays |
111 // Set popup's hide/show delays |
112 iController->SetPopUpShowDelay( KPopupShowDelay ); |
112 iController->SetPopUpShowDelay( KPopupShowDelay ); |
113 iController->SetPopUpHideDelay( KPopupHideDelay ); |
113 iController->SetPopUpHideDelay( KPopupHideDelay ); |
119 { |
119 { |
120 iController->SetPosition( uipRect ); |
120 iController->SetPosition( uipRect ); |
121 } |
121 } |
122 |
122 |
123 // Launch |
123 // Launch |
124 iController->ShowPopUp(); |
124 iController->ShowPopUp(); */ |
125 } |
125 } |
126 |
126 |
127 // ----------------------------------------------------------------------------- |
127 // ----------------------------------------------------------------------------- |
128 // From class CCoeControl. |
128 // From class CCoeControl. |
129 // CBatteryPopupControl::HandleResourceChange |
129 // CBatteryPopupControl::HandleResourceChange |
132 void CBatteryPopupControl::HandleResourceChange( |
132 void CBatteryPopupControl::HandleResourceChange( |
133 TInt aType ) |
133 TInt aType ) |
134 { |
134 { |
135 FUNC_LOG |
135 FUNC_LOG |
136 |
136 |
137 CCoeControl::HandleResourceChange( aType ); |
137 /* CCoeControl::HandleResourceChange( aType ); |
138 if ( aType == KEikDynamicLayoutVariantSwitch ) |
138 if ( aType == KEikDynamicLayoutVariantSwitch ) |
139 { |
139 { |
140 SizeChanged(); |
140 SizeChanged(); |
141 } |
141 }*/ |
142 } |
142 } |
143 |
143 |
144 |
144 |
145 // ----------------------------------------------------------------------------- |
145 // ----------------------------------------------------------------------------- |
146 // From class CCoeControl. |
146 // From class CCoeControl. |
173 } |
173 } |
174 // --------------------------------------------------------------------------- |
174 // --------------------------------------------------------------------------- |
175 // From MAknPreviewPopUpObserver |
175 // From MAknPreviewPopUpObserver |
176 // --------------------------------------------------------------------------- |
176 // --------------------------------------------------------------------------- |
177 // |
177 // |
|
178 /* |
178 void CBatteryPopupControl::HandlePreviewPopUpEventL( |
179 void CBatteryPopupControl::HandlePreviewPopUpEventL( |
179 CAknPreviewPopUpController* /*aController*/, |
180 CAknPreviewPopUpController aController, |
180 TPreviewPopUpEvent aEvent ) |
181 TPreviewPopUpEvent aEvent ) |
181 { |
182 { |
182 FUNC_LOG |
183 FUNC_LOG |
183 |
184 |
184 switch ( aEvent ) |
185 switch ( aEvent ) |
185 { |
186 { |
189 case EPreviewPopUpHidden: |
190 case EPreviewPopUpHidden: |
190 AknGlobalPopupPriorityController::RemovePopupPriority( *this ); |
191 AknGlobalPopupPriorityController::RemovePopupPriority( *this ); |
191 break; |
192 break; |
192 } |
193 } |
193 } |
194 } |
194 |
195 */ |
195 // ----------------------------------------------------------------------------- |
196 // ----------------------------------------------------------------------------- |
196 // CAknStylusActivatedPopUpContent::ConstructL |
197 // CAknStylusActivatedPopUpContent::ConstructL |
197 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
198 // |
199 // |
199 void CBatteryPopupControl::ConstructL( const TDesC& aContentText, |
200 void CBatteryPopupControl::ConstructL( const TDesC& aContentText, |
215 { |
216 { |
216 iVariant = EVariantIconTextLink; |
217 iVariant = EVariantIconTextLink; |
217 } |
218 } |
218 iLinkText = aLinkText.AllocL(); |
219 iLinkText = aLinkText.AllocL(); |
219 } |
220 } |
220 |
221 /* |
221 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
222 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
222 AknLayoutScalable_Avkon::popup_battery_window( iVariant ) ); |
223 AknLayoutScalable_Avkon::popup_battery_window( iVariant ) ); |
223 |
224 |
224 TAknWindowComponentLayout infoPaneLayout = |
225 TAknWindowComponentLayout infoPaneLayout = |
225 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ); |
226 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ); |
228 |
229 |
229 TAknTextComponentLayout textLayout = |
230 TAknTextComponentLayout textLayout = |
230 AknLayoutScalable_Avkon::popup_battery_window_t1( iVariant ); |
231 AknLayoutScalable_Avkon::popup_battery_window_t1( iVariant ); |
231 TAknLayoutText textRect; |
232 TAknLayoutText textRect; |
232 textRect.LayoutText( rectPopUpWindow, textLayout ); |
233 textRect.LayoutText( rectPopUpWindow, textLayout ); |
233 |
234 */ |
234 // Font for command links |
235 // Font for command links |
235 iFont = textRect.Font(); |
236 // iFont = textRect.Font(); |
236 } |
237 } |
237 |
238 |
238 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
239 // From class CCoeControl. |
240 // From class CCoeControl. |
240 // CBatteryPopupControl::ComponentControl |
241 // CBatteryPopupControl::ComponentControl |
373 baselineOffset = font->AscentInPixels() + |
374 baselineOffset = font->AscentInPixels() + |
374 ( rect.Height() - font->AscentInPixels() ) / 2; |
375 ( rect.Height() - font->AscentInPixels() ) / 2; |
375 gc.DrawText( ptr, rect, baselineOffset, |
376 gc.DrawText( ptr, rect, baselineOffset, |
376 CGraphicsContext::ELeft ); |
377 CGraphicsContext::ELeft ); |
377 delete visualText; |
378 delete visualText; |
378 } |
379 }*/ |
379 } |
380 } |
380 |
381 |
381 |
382 |
382 // ----------------------------------------------------------------------------- |
383 // ----------------------------------------------------------------------------- |
383 // From class CCoeControl. |
384 // From class CCoeControl. |
404 if(iLinkText) |
405 if(iLinkText) |
405 { |
406 { |
406 TInt tempWidth = iFont->TextWidthInPixels( *( iLinkText ) ); |
407 TInt tempWidth = iFont->TextWidthInPixels( *( iLinkText ) ); |
407 minWidth = Max( minWidth, tempWidth ); |
408 minWidth = Max( minWidth, tempWidth ); |
408 } |
409 } |
409 TInt rectWidth = 0; |
410 // TInt rectWidth = 0; |
410 |
411 |
411 TAknWindowComponentLayout infoPaneLayout = |
412 /* TAknWindowComponentLayout infoPaneLayout = |
412 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ); |
413 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ); |
413 |
414 |
414 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
415 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
415 AknLayoutScalable_Avkon::popup_battery_window( iVariant ) ); |
416 AknLayoutScalable_Avkon::popup_battery_window( iVariant ) ); |
416 |
417 |
417 TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout ); |
418 TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout ); |
418 |
419 |
419 rectWidth = Max( rectInfoPane.Width(), minWidth ); |
420 rectWidth = Max( rectInfoPane.Width(), minWidth ); |
420 |
421 |
421 TInt rectHeight = rectInfoPane.Height(); |
422 TInt rectHeight = rectInfoPane.Height();*/ |
422 |
423 |
423 return TSize( rectWidth, rectHeight ); |
424 // return TSize( rectWidth, rectHeight ); |
424 } |
425 } |
425 |
426 |
426 |
427 |
427 // ----------------------------------------------------------------------------- |
428 // ----------------------------------------------------------------------------- |
428 // From class CCoeControl. |
429 // From class CCoeControl. |
431 // |
432 // |
432 void CBatteryPopupControl::SizeChanged() |
433 void CBatteryPopupControl::SizeChanged() |
433 { |
434 { |
434 FUNC_LOG |
435 FUNC_LOG |
435 // Get popup window rect |
436 // Get popup window rect |
436 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
437 /* TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
437 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ) ); |
438 AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ) ); |
438 |
439 |
439 // Get pane icon and text layouts |
440 // Get pane icon and text layouts |
440 TAknWindowLineLayout paneIconLayout( |
441 TAknWindowLineLayout paneIconLayout( |
441 AknLayoutScalable_Avkon::popup_battery_window_g1(iVariant)); |
442 AknLayoutScalable_Avkon::popup_battery_window_g1(iVariant)); |
484 |
485 |
485 tempRect = TRect( linkLayout.Rect() ); |
486 tempRect = TRect( linkLayout.Rect() ); |
486 } |
487 } |
487 tempRect.SetWidth( tempWidth ); |
488 tempRect.SetWidth( tempWidth ); |
488 iLinkRect = tempRect; |
489 iLinkRect = tempRect; |
489 } |
490 }*/ |
490 } |
491 } |
491 |
492 |
492 // ----------------------------------------------------------------------------- |
493 // ----------------------------------------------------------------------------- |
493 // RectFromLayout |
494 // RectFromLayout |
494 // ----------------------------------------------------------------------------- |
495 // ----------------------------------------------------------------------------- |
495 // |
496 // |
496 TRect CBatteryPopupControl::RectFromLayout( const TRect& aParent, |
497 /*TRect CBatteryPopupControl::RectFromLayout( const TRect& aParent, |
497 const TAknWindowComponentLayout& aComponentLayout ) const |
498 const TAknWindowComponentLayout& aComponentLayout ) const |
498 { |
499 { |
499 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
500 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
500 TAknLayoutRect layoutRect; |
501 TAknLayoutRect layoutRect; |
501 layoutRect.LayoutRect( aParent, lineLayout ); |
502 layoutRect.LayoutRect( aParent, lineLayout ); |
502 return layoutRect.Rect(); |
503 return layoutRect.Rect(); |
503 } |
504 }*/ |
504 |
505 |
505 // ----------------------------------------------------------------------------- |
506 // ----------------------------------------------------------------------------- |
506 // PopUpWindowRectFromLayout |
507 // PopUpWindowRectFromLayout |
507 // ----------------------------------------------------------------------------- |
508 // ----------------------------------------------------------------------------- |
508 // |
509 // |
509 TRect CBatteryPopupControl::PopUpWindowRectFromLayout( const |
510 /*TRect CBatteryPopupControl::PopUpWindowRectFromLayout( const |
510 TAknWindowComponentLayout& aComponentLayout ) const |
511 TAknWindowComponentLayout& aComponentLayout ) const |
511 { |
512 { |
512 FUNC_LOG |
513 FUNC_LOG |
513 // get popup window width from the widest variety |
514 // get popup window width from the widest variety |
514 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
515 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
517 popup_battery_window( iVariant ).LayoutLine().iW; |
518 popup_battery_window( iVariant ).LayoutLine().iW; |
518 TAknLayoutRect layoutRect; |
519 TAknLayoutRect layoutRect; |
519 layoutRect.LayoutRect( iAvkonAppUi->ApplicationRect(), lineLayout ); |
520 layoutRect.LayoutRect( iAvkonAppUi->ApplicationRect(), lineLayout ); |
520 |
521 |
521 return layoutRect.Rect(); |
522 return layoutRect.Rect(); |
522 } |
523 }*/ |
523 |
524 |
524 // ----------------------------------------------------------------------------- |
525 // ----------------------------------------------------------------------------- |
525 // From class CCoeControl |
526 // From class CCoeControl |
526 // CBatteryPopupControl::HandlePointerEventL |
527 // CBatteryPopupControl::HandlePointerEventL |
527 // ----------------------------------------------------------------------------- |
528 // ----------------------------------------------------------------------------- |
535 if ( iLinkRect.Contains( aPointerEvent.iPosition ) ) |
536 if ( iLinkRect.Contains( aPointerEvent.iPosition ) ) |
536 { |
537 { |
537 if ( !iHighlightedItem ) |
538 if ( !iHighlightedItem ) |
538 { |
539 { |
539 iHighlightedItem = ETrue; |
540 iHighlightedItem = ETrue; |
540 DrawNow( iLinkRect ); |
541 // DrawNow( iLinkRect ); |
541 } |
542 } |
542 #ifdef RD_TACTILE_FEEDBACK |
543 #ifdef RD_TACTILE_FEEDBACK |
543 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
544 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
544 { |
545 { |
545 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
546 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
551 } |
552 } |
552 #endif // RD_TACTILE_FEEDBACK |
553 #endif // RD_TACTILE_FEEDBACK |
553 // Nofity command observer |
554 // Nofity command observer |
554 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
555 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
555 { |
556 { |
556 iCommandObserver->ProcessCommandL( ELinkFirst ); |
557 // iCommandObserver->ProcessCommandL( ELinkFirst ); |
557 iHighlightedItem = EFalse; |
558 iHighlightedItem = EFalse; |
558 } |
559 } |
559 } |
560 } |
560 } |
561 } |
561 } |
562 } |
575 fp->Set( KBIPPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
576 fp->Set( KBIPPluginIconDirAndName, &KDC_BITMAP_DIR, NULL ); |
576 |
577 |
577 delete iIcon; |
578 delete iIcon; |
578 iIcon = NULL; |
579 iIcon = NULL; |
579 |
580 |
580 iIcon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
581 /* iIcon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
581 KAknsIIDQgnPropBatteryIcon, |
582 KAknsIIDQgnPropBatteryIcon, |
582 fp->FullName(), |
583 fp->FullName(), |
583 EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate, |
584 EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate, |
584 EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate_mask ); |
585 EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate_mask ); |
585 |
586 */ |
586 CleanupStack::PopAndDestroy( fp ); |
587 CleanupStack::PopAndDestroy( fp ); |
587 } |
588 } |
588 // End of File |
589 // End of File |