psln/PslnFramework/src/PslnFWBaseContainer.cpp
changeset 37 89c890c70182
parent 34 6b5204869ed5
child 45 667edd0b8678
equal deleted inserted replaced
34:6b5204869ed5 37:89c890c70182
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Base container for Psln some views.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "pslnfwbasecontainer.h"
       
    21 
       
    22 // Title and status pane.
       
    23 #include <akntitle.h>
       
    24 #include <eikspane.h>
       
    25 
       
    26 // AVKON App Ui.
       
    27 #include <aknappui.h>
       
    28 #include <AknUtils.h>
       
    29 
       
    30 // Resource reader.
       
    31 #include <barsread.h>
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Base constructor.
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C void CPslnFWBaseContainer::BaseConstructL( const TRect& aRect, 
       
    40                                                 TInt aResTitleId, 
       
    41                                                 TInt aResLbxId )
       
    42     {
       
    43     // Create title if needed.
       
    44     if ( aResTitleId != 0 )
       
    45         {
       
    46         CEikStatusPane* sp = iAvkonAppUi->StatusPane();
       
    47 
       
    48         CAknTitlePane* title = 
       
    49             static_cast<CAknTitlePane*> ( 
       
    50             sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
    51 
       
    52         TResourceReader rReader;
       
    53         iCoeEnv->CreateResourceReaderLC( rReader, aResTitleId );
       
    54         title->SetFromResourceL( rReader );
       
    55         CleanupStack::PopAndDestroy(); // rReader
       
    56         }
       
    57     
       
    58     CreateWindowL(); // Makes the control a window-owning control
       
    59  
       
    60     // Set iListBox to be contained in this container:
       
    61     iListBox->SetContainerWindowL( *this ); 
       
    62 
       
    63     ConstructListBoxL( aResLbxId );
       
    64     
       
    65     iListBox->CreateScrollBarFrameL( ETrue );
       
    66     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
    67         CEikScrollBarFrame::EOff, 
       
    68         CEikScrollBarFrame::EAuto );
       
    69 
       
    70     SetRect( aRect );
       
    71     ActivateL();
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // C++ default constructor.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C CPslnFWBaseContainer::CPslnFWBaseContainer()
       
    79     {
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Destructor
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C CPslnFWBaseContainer::~CPslnFWBaseContainer()
       
    87     {
       
    88     delete iListBox;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Sets observer for MSK label updations.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CPslnFWBaseContainer::SetMiddleSoftkeyObserver( 
       
    96     MPslnFWMSKObserver* aObserver )
       
    97     {
       
    98     if ( !iMSKObserver && aObserver )
       
    99         {        
       
   100         iMSKObserver = aObserver;
       
   101         }
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 //  Construct's ListBox from Resource ID
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CPslnFWBaseContainer::ConstructListBoxL( TInt aResLbxId )
       
   109     {
       
   110     TResourceReader rReader;
       
   111     iCoeEnv->CreateResourceReaderLC( rReader, aResLbxId );
       
   112     iListBox->ConstructFromResourceL( rReader );
       
   113     CleanupStack::PopAndDestroy(); // rReader
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Handles system changes (skin change and layout changes).
       
   118 // ---------------------------------------------------------------------------
       
   119 EXPORT_C void CPslnFWBaseContainer::HandleResourceChange( TInt aType )
       
   120     {
       
   121     CCoeControl::HandleResourceChange( aType );
       
   122     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   123         {
       
   124         TRect mainPaneRect;
       
   125         AknLayoutUtils::LayoutMetricsRect( 
       
   126             AknLayoutUtils::EMainPane,
       
   127             mainPaneRect );
       
   128         SetRect( mainPaneRect );
       
   129         }
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // Called by framework when the view size is changed.
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C void CPslnFWBaseContainer::SizeChanged()
       
   137     {
       
   138     if ( iListBox )
       
   139         {
       
   140         iListBox->SetRect( Rect() );
       
   141         }
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // Count component controls.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C TInt CPslnFWBaseContainer::CountComponentControls() const
       
   149     {
       
   150     return 1;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 //  Returns mathcing component.
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C CCoeControl* CPslnFWBaseContainer::ComponentControl( TInt /*aIndex*/ ) 
       
   158     const
       
   159     {
       
   160     return iListBox;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // Called when a key is pressed.
       
   165 // ---------------------------------------------------------------------------
       
   166 EXPORT_C TKeyResponse CPslnFWBaseContainer::OfferKeyEventL(
       
   167     const TKeyEvent& aKeyEvent, 
       
   168     TEventCode aType )
       
   169     {
       
   170     switch ( aKeyEvent.iCode )
       
   171         {
       
   172         case EKeyNext:
       
   173         case EKeyPrevious:
       
   174         case EKeyUpArrow:
       
   175         case EKeyDownArrow:
       
   176             {
       
   177             TKeyResponse listboxResp = 
       
   178                 iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   179             if ( iMSKObserver )
       
   180                 {
       
   181                 iMSKObserver->CheckMiddleSoftkeyLabelL();
       
   182                 }
       
   183             return listboxResp;
       
   184             }
       
   185         case EKeyLeftArrow:
       
   186         case EKeyRightArrow:
       
   187             // Listbox takes all events even if it doesn't use them
       
   188             return EKeyWasNotConsumed;
       
   189         default:
       
   190             break;
       
   191         }
       
   192     return iListBox->OfferKeyEventL( aKeyEvent, aType ); 
       
   193     }
       
   194     
       
   195 // ---------------------------------------------------------------------------
       
   196 // Handles focus change events.
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C void CPslnFWBaseContainer::FocusChanged( TDrawNow aDrawNow )
       
   200     {
       
   201     // Pass focus changed event to listbox.
       
   202     if ( iListBox )
       
   203         {
       
   204         iListBox->SetFocus( IsFocused(), aDrawNow );
       
   205         }
       
   206     }
       
   207     
       
   208 //  End of File