uifw/AvKon/src/aknemptycontrol.cpp
changeset 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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:  Implementation for an empty control, which only draws the
       
    15 *                background, to be used on empty areas of status pane.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <bacntf.h>
       
    22 #include <eikspane.h>
       
    23 #include <aknconsts.h>
       
    24 #include <AknsDrawUtils.h>
       
    25 #include <AknsUtils.h>
       
    26 #include <AknUtils.h>
       
    27 #include <aknnavi.h>
       
    28 #include <aknnavide.h>
       
    29 #include <aknlayoutscalable_avkon.cdl.h>
       
    30 #include <AknTasHook.h>
       
    31 
       
    32 #include "aknemptycontrol.h"
       
    33 #include "AknStatuspaneUtils.h"
       
    34 
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS =============================
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CAknEmptyControl::CAknEmptyControl
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CAknEmptyControl::CAknEmptyControl()
       
    45 	{
       
    46 	AKNTASHOOK_ADD( this, "CAknEmptyControl" );
       
    47     iIsActiveIdle = AknStatuspaneUtils::IsActiveIdle();
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Destructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CAknEmptyControl::~CAknEmptyControl()
       
    56 	{
       
    57 	AKNTASHOOK_REMOVE();
       
    58 	AknsUtils::DeregisterControlPosition( this );
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CAknEmptyControl::ConstructFromResourceL
       
    64 // (other items were commented in a header).
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CAknEmptyControl::ConstructFromResourceL( TResourceReader& /*aReader*/ )
       
    68     {
       
    69     MakeVisible( ETrue );
       
    70   	}
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CAknEmptyControl::HandlePointerEventL
       
    75 // (other items were commented in a header).
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CAknEmptyControl::HandlePointerEventL(
       
    79     const TPointerEvent& aPointerEvent )
       
    80     {
       
    81     if ( !PassPointerEventToAdjacentControlL( aPointerEvent ) )
       
    82         {
       
    83         CAknControl::HandlePointerEventL( aPointerEvent );
       
    84         }
       
    85     }
       
    86 
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CAknEmptyControl::SizeChanged
       
    90 // (other items were commented in a header).
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CAknEmptyControl::SizeChanged()
       
    94     {
       
    95     // No fading if staconpane is active.
       
    96     Window().SetNonFading( AknStatuspaneUtils::StaconPaneActive() );
       
    97 
       
    98     AknsUtils::RegisterControlPosition( this );
       
    99     DrawableWindow()->SetOrdinalPosition( -1 ); // Send to back
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CAknEmptyControl::Draw
       
   105 // (other items were commented in a header).
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CAknEmptyControl::Draw( const TRect& /*aRect*/ ) const
       
   109     {
       
   110     if ( iIsActiveIdle )
       
   111         {
       
   112         return;
       
   113         }
       
   114 
       
   115     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   116 
       
   117     CWindowGc& gc = SystemGc();
       
   118     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   119     TRect rect( Rect() );
       
   120     AknsDrawUtils::Background( skin, cc, this, gc, rect );
       
   121     }
       
   122 
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CAknEmptyControl::PassPointerEventToAdjacentControlL
       
   126 // (other items were commented in a header).
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 TBool CAknEmptyControl::PassPointerEventToAdjacentControlL(
       
   130     const TPointerEvent& aPointerEvent )
       
   131     {
       
   132     TBool pointerEventPassedOn( EFalse );
       
   133 
       
   134     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   135     if ( statusPane )
       
   136         {
       
   137         TInt currentLayoutResId( statusPane->CurrentLayoutResId() );
       
   138 
       
   139         switch ( currentLayoutResId )
       
   140             {
       
   141             case R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL:
       
   142             case R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE:
       
   143                 {
       
   144                 TRect statusPaneRect;
       
   145                 AknLayoutUtils::LayoutMetricsRect(
       
   146                     AknLayoutUtils::EStatusPane, statusPaneRect );
       
   147 
       
   148                 // Check if the pointer event happened in the navi
       
   149                 // pane touch responsive area.
       
   150                 TAknLayoutRect layoutRect;
       
   151                 layoutRect.LayoutRect(
       
   152                     statusPaneRect,
       
   153                     AknLayoutScalable_Avkon::aid_touch_navi_pane() );
       
   154                 TRect naviPaneTouchRect( layoutRect.Rect() );
       
   155 
       
   156                 if ( naviPaneTouchRect.Contains( aPointerEvent.iPosition ) )
       
   157                     {
       
   158                     CAknNavigationControlContainer* naviPane =
       
   159                     static_cast<CAknNavigationControlContainer*>(
       
   160                         statusPane->ControlL(
       
   161                             TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   162                     if ( naviPane )
       
   163                         {
       
   164                         // Pass the event directly to the decorator
       
   165                         // because navi pane doesn't handle the events.
       
   166                         CAknNavigationDecorator* naviPaneControl =
       
   167                             static_cast<CAknNavigationDecorator*>(
       
   168                                 naviPane->Top() );
       
   169 
       
   170                         if ( naviPaneControl )
       
   171                             {
       
   172                             // The position of the pointer event position
       
   173                             // needs to be modified so that it's relative
       
   174                             // to the navi pane area.
       
   175                             TRect naviPaneRect( naviPaneControl->Rect() );
       
   176 
       
   177                             TPointerEvent naviPaneRelativePointerEvent(
       
   178                                 aPointerEvent );
       
   179 
       
   180                             naviPaneRelativePointerEvent.iPosition.iX =
       
   181                                 naviPaneRelativePointerEvent.iPosition.iX -
       
   182                                     naviPaneTouchRect.iTl.iX -
       
   183                                     Rect().iTl.iX;
       
   184 
       
   185                             naviPaneRelativePointerEvent.iPosition.iY -=
       
   186                                 ( naviPaneTouchRect.iBr.iY -
       
   187                                   naviPaneRect.Height() );
       
   188 
       
   189                             // Pass the modified event to the navi decorator.
       
   190                             naviPaneControl->HandlePointerEventL(
       
   191                                 naviPaneRelativePointerEvent );
       
   192                             pointerEventPassedOn = ETrue;
       
   193                             }
       
   194                         }
       
   195                     }
       
   196                 break;
       
   197                 }
       
   198             default:
       
   199                 {
       
   200                 break;
       
   201                 }
       
   202             }
       
   203         }
       
   204 
       
   205     return pointerEventPassedOn;
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CAknEmptyControl::HandleResourceChange
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void CAknEmptyControl::HandleResourceChange( TInt aType ) 
       
   213     {
       
   214     CCoeControl::HandleResourceChange( aType );
       
   215     
       
   216     if ( aType == KEikDynamicLayoutVariantSwitch ||
       
   217          aType == KAknsMessageSkinChange )
       
   218         {      
       
   219         DrawDeferred();
       
   220         }
       
   221     }
       
   222 //  End of File