uifw/AvKon/src/akncombinedpane.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
child 15 08e69e956a8c
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
       
     1 /*
       
     2 * Copyright (c) 2010 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 the License "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:  Status pane's combined subpane component.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <AknsDrawUtils.h>
       
    19 #include <AknIndicatorContainer.h>
       
    20 #include <aknlayoutscalable_avkon.cdl.h>
       
    21 #include <barsread.h>
       
    22 #include <eikspane.h>
       
    23 #include <avkon.hrh>
       
    24 #include <AknPriv.hrh>
       
    25 #include <AknSmallIndicator.h>
       
    26 #include <aknappui.h>
       
    27 #include <uikon/eikdefmacros.h>
       
    28 
       
    29 #include "akncombinedpane.h"
       
    30 #include "aknstatuspanedatasubscriber.h"
       
    31 
       
    32 // This is used to calculate the amount of pixels that the subpanes are
       
    33 // shifted to bottom and right when they are "pressed down". 
       
    34 const TInt KPressedDownDeltaDivider( 35 ); // 0.3 units
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // Two-phased constructor.
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 CAknCombinedPane* CAknCombinedPane::NewL()
       
    43     {
       
    44     CAknCombinedPane* self = new ( ELeave ) CAknCombinedPane();
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // Destructor
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CAknCombinedPane::~CAknCombinedPane()
       
    57     {
       
    58     iSubPanes.Reset();
       
    59 
       
    60     if ( iAvkonAppUi )
       
    61         {
       
    62         iAvkonAppUi->RemoveFromStack( this );
       
    63         }
       
    64     }
       
    65 
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // Returns number of controls inside this control.
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 TInt CAknCombinedPane::CountComponentControls() const
       
    72     {
       
    73     return iSubPanes.Count();
       
    74     }
       
    75 
       
    76 
       
    77 // ----------------------------------------------------------------------------
       
    78 // Returns a control determined by control index.
       
    79 // ----------------------------------------------------------------------------
       
    80 //
       
    81 CCoeControl* CAknCombinedPane::ComponentControl( TInt aIndex ) const
       
    82     {
       
    83     CCoeControl* control = NULL;
       
    84 
       
    85     if ( iStatusPane && aIndex < iSubPanes.Count() )
       
    86         {
       
    87         TRAP_IGNORE( control = iStatusPane->ContainerControlL(
       
    88             TUid::Uid( iSubPanes[aIndex].iUid ) ) );
       
    89         }
       
    90 
       
    91     return control;
       
    92     }
       
    93 
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // Handles a change to the control's resources.
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 void CAknCombinedPane::HandleResourceChange( TInt aType )
       
   100     {
       
   101     CAknButton::HandleResourceChange( aType );
       
   102 
       
   103     switch ( aType )
       
   104         {
       
   105         case KAknMessageFocusLost:      // fallthrough
       
   106         case KEikMessageFadeAllWindows:
       
   107             {
       
   108             SetSubPanesPressedDown( EFalse );
       
   109             DrawDeferred();
       
   110             break;
       
   111             }
       
   112         
       
   113         case KAknsMessageSkinChange:
       
   114             {
       
   115             DrawDeferred();
       
   116             break;
       
   117             }
       
   118             
       
   119         case KEikDynamicLayoutVariantSwitch:
       
   120             {
       
   121             SetSubPanesPressedDown( EFalse );
       
   122             // Recalculate the pressed down delta pixels on layout change.
       
   123             TAknWindowLineLayout unitValue(
       
   124                 AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine() );
       
   125             iPressedDownDelta = unitValue.iW / KPressedDownDeltaDivider;
       
   126             DrawDeferred();
       
   127             break;
       
   128             }
       
   129             
       
   130         default:
       
   131             {
       
   132             break;
       
   133             }
       
   134         }
       
   135     }
       
   136 
       
   137 
       
   138 // ----------------------------------------------------------------------------
       
   139 // Resource constructor.
       
   140 // ----------------------------------------------------------------------------
       
   141 //
       
   142 void CAknCombinedPane::ConstructFromResourceL( TResourceReader& aReader )
       
   143     {
       
   144     aReader.ReadInt8(); // version
       
   145 
       
   146     TInt count = aReader.ReadInt16(); // amount of subpanes
       
   147 
       
   148     for ( TInt i = 0; i < count; ++i )
       
   149         {
       
   150         TSubPaneData subPane;
       
   151 
       
   152         aReader.ReadInt8(); // version
       
   153         subPane.iUid = aReader.ReadUint32(); // subpane UID
       
   154         subPane.iPressedDown = EFalse; // Isn't specified in the resource.
       
   155         aReader.ReadInt32(); // extension
       
   156 
       
   157         iSubPanes.AppendL( subPane );
       
   158         }
       
   159 
       
   160     aReader.ReadInt32(); // extension
       
   161 
       
   162     iStatusPane = CEikStatusPaneBase::Current();
       
   163     }
       
   164 
       
   165 
       
   166 // ----------------------------------------------------------------------------
       
   167 // Handles pointer events inside the control.
       
   168 // ----------------------------------------------------------------------------
       
   169 //
       
   170 void CAknCombinedPane::HandlePointerEventL(
       
   171     const TPointerEvent& aPointerEvent )
       
   172     {
       
   173     CAknButton::HandlePointerEventL( aPointerEvent );
       
   174 
       
   175     switch ( aPointerEvent.iType )
       
   176         {
       
   177         case TPointerEvent::EButton1Down:
       
   178             {
       
   179             SetSubPanesPressedDown( ETrue );
       
   180             iPointerDownInCombinedArea = ETrue;
       
   181             break;
       
   182             }
       
   183             
       
   184         case TPointerEvent::EButton1Up:
       
   185             {
       
   186             SetSubPanesPressedDown( EFalse );
       
   187             
       
   188             if ( iPointerDownInCombinedArea &&
       
   189                  Rect().Contains( aPointerEvent.iPosition ) )
       
   190                 {
       
   191                 // Display the universal indicator popup.
       
   192                 CAknSmallIndicator* indicatorNotifier =
       
   193                     CAknSmallIndicator::NewLC( TUid::Uid( 0 ) );
       
   194                 indicatorNotifier->HandleIndicatorTapL();
       
   195                 CleanupStack::PopAndDestroy( indicatorNotifier );
       
   196                 }
       
   197             
       
   198             iPointerDownInCombinedArea = EFalse;
       
   199             break;
       
   200             }
       
   201             
       
   202         case TPointerEvent::EDrag:
       
   203             {
       
   204             TRect combinedRect( Rect() );
       
   205             if ( !combinedRect.Contains( aPointerEvent.iPosition ) )
       
   206                 {
       
   207                 SetSubPanesPressedDown( EFalse );
       
   208                 }
       
   209             else if ( iPointerDownInCombinedArea &&
       
   210                       combinedRect.Contains( aPointerEvent.iPosition ) )
       
   211                 {
       
   212                 SetSubPanesPressedDown( ETrue );
       
   213                 }
       
   214             break;
       
   215             }
       
   216             
       
   217         default:
       
   218             {
       
   219             break;
       
   220             }
       
   221         }
       
   222 
       
   223     DrawDeferred();
       
   224     }
       
   225 
       
   226 
       
   227 // ----------------------------------------------------------------------------
       
   228 // Default C++ constructor.
       
   229 // ----------------------------------------------------------------------------
       
   230 //
       
   231 CAknCombinedPane::CAknCombinedPane() : CAknButton( 0 ),
       
   232                                        iStatusPane( NULL )
       
   233     {
       
   234     // Calculate the pressed down delta pixels from layout data,
       
   235     // aid_value_unit2 is a 10ux10u rectangle.
       
   236     TAknWindowLineLayout unitValue(
       
   237         AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine() );
       
   238     // Move the control 0.3 units to right and down for the
       
   239     // "pressed down" effect.
       
   240     iPressedDownDelta = unitValue.iW / KPressedDownDeltaDivider;
       
   241     }
       
   242 
       
   243 
       
   244 // ----------------------------------------------------------------------------
       
   245 // Second-phase constructor.
       
   246 // ----------------------------------------------------------------------------
       
   247 //
       
   248 void CAknCombinedPane::ConstructL()
       
   249     {
       
   250     CAknButton::ConstructL( NULL, NULL, NULL, NULL, KNullDesC, KNullDesC, 0 );
       
   251 
       
   252     // Use the softkey frame graphics so that the bottom area appears
       
   253     // consistent.
       
   254     SetFrameAndCenterIds( KAknsIIDQgnFrSctrlSkButton,
       
   255                           KAknsIIDQgnFrSctrlSkButtonCenter,
       
   256                           KAknsIIDNone,
       
   257                           KAknsIIDNone,
       
   258                           KAknsIIDNone,
       
   259                           KAknsIIDNone,
       
   260                           KAknsIIDQgnFrSctrlSkButtonPressed,
       
   261                           KAknsIIDQgnFrSctrlSkButtonCenterPressed,
       
   262                           KAknsIIDNone,
       
   263                           KAknsIIDNone );
       
   264     
       
   265     // Add to the control stack in order to receive the focus lost events. 
       
   266     iAvkonAppUi->AddToStackL( this, 
       
   267                               ECoeStackPriorityCba,
       
   268                               ECoeStackFlagRefusesAllKeys |
       
   269                               ECoeStackFlagRefusesFocus );
       
   270     }
       
   271 
       
   272 
       
   273 // ----------------------------------------------------------------------------
       
   274 // Sets the pressed down state of the subpanes.
       
   275 // ----------------------------------------------------------------------------
       
   276 //
       
   277 void CAknCombinedPane::SetSubPanesPressedDown( TBool aPressedDown )
       
   278     {
       
   279     TInt delta = aPressedDown ? iPressedDownDelta : -iPressedDownDelta;
       
   280 
       
   281     for ( TInt i = 0; i < iSubPanes.Count(); ++i )
       
   282         {
       
   283         if ( !COMPARE_BOOLS( iSubPanes[i].iPressedDown, aPressedDown ) )
       
   284             {
       
   285             CCoeControl* control = ComponentControl( i );
       
   286             TRect controlRect( control->Rect() );
       
   287             controlRect.Move( delta, delta );
       
   288             control->SetRect( controlRect );
       
   289             iSubPanes[i].iPressedDown = aPressedDown;
       
   290             }
       
   291         }
       
   292     }
       
   293 
       
   294 // End of File