clock2/clockui/uilayer/clkdatetimeview/src/clkdatetimeviewcontainer.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 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:   This class implements the function of common "Date & Time" settings dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32base.h>
       
    20 #include <csxhelp/clk.hlp.hrh>
       
    21 #include <layoutmetadata.cdl.h>
       
    22 #include <aknlayoutscalable_apps.cdl.h>
       
    23 
       
    24 // User includes
       
    25 #include "clkdatetimeviewcontainer.h"
       
    26 #include "clock.h"
       
    27 #include "clock.hrh"
       
    28 #include "clkdatetimeview.hrh"
       
    29 #include "clockappui.h"
       
    30 #include "clkdatetimeview.h"
       
    31 
       
    32 // Constants
       
    33 const TInt KControlOne( 1 );
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // CClkDateTimeViewContainer::NewL
       
    37 // rest of the details are commented in the header
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 CClkDateTimeViewContainer* CClkDateTimeViewContainer::NewL( CClkDateTimeView* aView )
       
    41     {
       
    42     CClkDateTimeViewContainer* self = new( ELeave ) CClkDateTimeViewContainer;
       
    43     CleanupStack::PushL( self );
       
    44     
       
    45     self->ConstructL( aView );
       
    46     
       
    47     CleanupStack::Pop( self );
       
    48     
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CClkDateTimeViewContainer::~CClkDateTimeViewContainer
       
    54 // rest of the details are commented in the header
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CClkDateTimeViewContainer::~CClkDateTimeViewContainer()
       
    58     {
       
    59     if( iListBox )
       
    60     	{
       
    61     	delete iListBox;
       
    62     	iListBox = NULL;
       
    63     	}
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CClkDateTimeViewContainer::OfferKeyEventL
       
    68 // rest of the details are commented in the header
       
    69 // ---------------------------------------------------------
       
    70 //
       
    71 TKeyResponse CClkDateTimeViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
    72     {
       
    73     TKeyResponse returnValue( EKeyWasNotConsumed );
       
    74     
       
    75     // We handle key events only for the event key.
       
    76     if( EEventKey == aType )
       
    77         {
       
    78         if( EStdKeyNo == aKeyEvent.iScanCode )
       
    79             {
       
    80             // This indicates that Call End key was pressed.
       
    81             // The application is hidden in the background.
       
    82             if( iView->IsClockInUse() )
       
    83                 {
       
    84                 // CClockAppUi should handle the command.
       
    85                 iView->ClockApplicationUi()->HandleCommandL( EClkSettExitCmd );
       
    86 
       
    87                 return EKeyWasConsumed;
       
    88                 }
       
    89             }
       
    90         
       
    91         // For right arrow and left arrow, we don't need to do anything.
       
    92         if( EKeyLeftArrow == aKeyEvent.iCode || EKeyRightArrow == aKeyEvent.iCode )
       
    93             {
       
    94             if( iView->IsClockInUse() )
       
    95                 {
       
    96                 returnValue = EKeyWasConsumed;
       
    97                 }
       
    98             }
       
    99         // For up/down arrow press, we update the list item focused.
       
   100         else if( iListBox )
       
   101             {
       
   102             if( EKeyUpArrow == aKeyEvent.iCode )
       
   103                 {
       
   104                 iView->DecCurrentItem();
       
   105                 }
       
   106             else if( EKeyDownArrow == aKeyEvent.iCode )
       
   107                 {
       
   108                 iView->IncCurrentItem();
       
   109                 }
       
   110             
       
   111             returnValue = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   112             }
       
   113         }
       
   114     return returnValue;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CClkDateTimeViewContainer::GetHelpContext
       
   119 // rest of the details are commented in the header
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 void CClkDateTimeViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   123     {
       
   124     aContext.iMajor = KClockAppUid;
       
   125     aContext.iContext = KCLK_HLP_SETTINGS;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CClkDateTimeViewContainer::CountComponentControls
       
   130 // rest of the details are commented in the header
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 TInt CClkDateTimeViewContainer::CountComponentControls() const
       
   134     {
       
   135     // We have only one control i.e the listbox.
       
   136     return KControlOne;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CClkDateTimeViewContainer::ComponentControl
       
   141 // rest of the details are commented in the header
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 CCoeControl* CClkDateTimeViewContainer::ComponentControl( TInt aIndex ) const
       
   145     {
       
   146     switch( aIndex )
       
   147         {
       
   148         case 0:
       
   149 			{
       
   150             return iListBox;
       
   151 			}
       
   152         default:
       
   153 			{
       
   154             return NULL;
       
   155 			}
       
   156         }
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // CClkDateTimeViewContainer::SizeChanged
       
   161 // rest of the details are commented in the header
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 void CClkDateTimeViewContainer::SizeChanged()
       
   165     {
       
   166     if( iListBox )
       
   167         {
       
   168         iListBox->SetExtent( TPoint( FALSE, FALSE ), Rect().Size() );
       
   169         }
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------
       
   173 // CClkDateTimeViewContainer::FocusChanged
       
   174 // rest of the details are commented in the header
       
   175 // ---------------------------------------------------------
       
   176 //
       
   177 void CClkDateTimeViewContainer::FocusChanged( TDrawNow /*aDrawNow*/ )
       
   178 	{
       
   179 	// If focus is changed, we allow the listbox to handle the same.
       
   180 	if( iListBox )
       
   181 		{
       
   182 		iListBox->SetFocus( IsFocused() );
       
   183 		}
       
   184 	}
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CClkDateTimeViewContainer::HandleResourceChange
       
   188 // rest of the details are commented in the header
       
   189 // ---------------------------------------------------------
       
   190 //
       
   191 void CClkDateTimeViewContainer::HandleResourceChange( TInt aType )
       
   192 	{
       
   193 	// First the listbox and then the CCoeControl to handle the resource change.
       
   194 	iListBox->HandleResourceChange( aType );
       
   195 	CCoeControl::HandleResourceChange( aType );
       
   196 
       
   197 	if( KEikDynamicLayoutVariantSwitch == aType )
       
   198 		{
       
   199 		TRect mainPaneRect;
       
   200 		AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   201 		SetRect( mainPaneRect );
       
   202 		} 
       
   203 	}
       
   204 	
       
   205 // ---------------------------------------------------------
       
   206 // CClkDateTimeViewContainer::HandlePointerEventL
       
   207 // rest of the details are commented in the header
       
   208 // ---------------------------------------------------------
       
   209 //
       
   210 void CClkDateTimeViewContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   211     {
       
   212     // Check if touch is enabled or not.
       
   213     if( !AknLayoutUtils::PenEnabled() )
       
   214         {
       
   215         return;
       
   216         }
       
   217     
       
   218     // Let the listbox handle the event.
       
   219     iListBox->HandlePointerEventL( aPointerEvent );
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // CClkDateTimeViewContainer::ConstructL
       
   224 // rest of the details are commented in the header
       
   225 // ---------------------------------------------------------
       
   226 //
       
   227 void CClkDateTimeViewContainer::ConstructL( CClkDateTimeView* aView )
       
   228     {
       
   229     CreateWindowL();
       
   230     iView = aView;
       
   231     iTouchFlag = EFalse;
       
   232     }
       
   233    
       
   234 // End of File