mediasettings/mpsettbase/src/MPSettingsBaseContainer.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 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:   Base class for MediaSettings view containers.*
       
    15 */
       
    16 
       
    17 
       
    18 // Version : %version: 2 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include    <aknappui.h>
       
    25 #include    <akntitle.h>
       
    26 #include    <barsread.h>
       
    27 #include    <eikspane.h>
       
    28 #include    <aknlists.h> 
       
    29 #include    "MPSettingsBaseContainer.h" 
       
    30 #include	"mpxlog.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CMPSettingsBaseContainer::CMPSettingsBaseContainer
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CMPSettingsBaseContainer::CMPSettingsBaseContainer()
       
    41     {
       
    42     MPX_DEBUG1(_L("#MS# CMPSettingsBaseContainer::CMPSettingsBaseContainer()"));
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMPSettingsBaseContainer::ConstructL
       
    47 // Symbian 2nd phase constructor can leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C void CMPSettingsBaseContainer::ConstructL(const TRect& aRect)
       
    51     {
       
    52     MPX_DEBUG1(_L("#MS# CMPSettingsBaseContainer::ConstructL()"));
       
    53     CEikStatusPane* sp = static_cast<CAknAppUi*>(iCoeEnv->AppUi())->StatusPane();
       
    54 
       
    55     CAknTitlePane* title = static_cast<CAknTitlePane*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
    56 
       
    57     TResourceReader rReader;
       
    58     iCoeEnv->CreateResourceReaderLC(rReader, TitleResourceId());
       
    59     title->SetFromResourceL(rReader);
       
    60     CleanupStack::PopAndDestroy(); //rReader
       
    61       
       
    62     CreateWindowL(); // Makes the control a window-owning control
       
    63  
       
    64     // Construct and initialize control(s)
       
    65     ConstructComponentControlsL();
       
    66 
       
    67     SetRect(aRect);
       
    68     ActivateL();
       
    69     }
       
    70    
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMPSettingsBaseContainer::~CMPSettingsBaseContainer
       
    73 // Destructor
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C CMPSettingsBaseContainer::~CMPSettingsBaseContainer()
       
    77     {
       
    78     MPX_DEBUG1(_L("#MS# CMPSettingsBaseContainer::~CMPSettingsBaseContainer()"));
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CMPSettingsBaseContainer::ListBox
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C CEikTextListBox* CMPSettingsBaseContainer::ListBox()
       
    86     {
       
    87     return iListBox;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CMPSettingsBaseContainer::SizeChanged()
       
    92 // Called by framwork when the view size is changed
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CMPSettingsBaseContainer::SizeChanged()
       
    96     {
       
    97     if (iComponentControl)
       
    98         {
       
    99         iComponentControl->SetRect(Rect());
       
   100         }
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CMPSettingsBaseContainer::CountComponentControls() const
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C TInt CMPSettingsBaseContainer::CountComponentControls() const
       
   108     {
       
   109     return 1; //magic
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // CMPSettingsBaseContainer::ComponentControl(TInt aIndex) const
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C CCoeControl* CMPSettingsBaseContainer::ComponentControl(TInt /*aIndex*/) const
       
   117     {
       
   118     return iComponentControl;
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CMPSettingsBaseContainer::HandleResourceChange
       
   123 // Handles a resource relative event 
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 EXPORT_C void CMPSettingsBaseContainer::HandleResourceChange( TInt aType )
       
   127     {
       
   128     MPX_DEBUG2(_L("#MS# CMPSettingsBaseContainer::HandleResourceChange(0x%X)"),aType);
       
   129     if ( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation
       
   130         {
       
   131         TRect mainPaneRect;
       
   132         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   133         SetRect( mainPaneRect );
       
   134 		DrawNow();
       
   135 		}
       
   136     CCoeControl::HandleResourceChange( aType );    
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CMPSettingsBaseContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   141 // Called when a key is pressed.
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TKeyResponse  CMPSettingsBaseContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   145     {
       
   146     MPX_DEBUG4(_L("#MS# CMPSettingsBaseContainer::OfferKeyEventL() iCode(0x%X) iScanCode(0x%X) aType(0x%X)"),
       
   147 				 aKeyEvent.iCode,aKeyEvent.iScanCode,aType);
       
   148     TKeyResponse response = EKeyWasNotConsumed;
       
   149 
       
   150     if (iComponentControl &&
       
   151         aKeyEvent.iCode != EKeyLeftArrow &&
       
   152         aKeyEvent.iCode != EKeyRightArrow)
       
   153         {
       
   154         response = iComponentControl->OfferKeyEventL(aKeyEvent, aType); 
       
   155         }
       
   156 
       
   157     return response;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CMPSettingsBaseContainer::SetSelectedItem()
       
   162 //
       
   163 //
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C void CMPSettingsBaseContainer::SetSelectedItem( TInt aIndex )
       
   167     {
       
   168     MPX_DEBUG2(_L("#MS# CMPSettingsBaseContainer::SetSelectedItem(%d)"),aIndex);
       
   169     if( iListBox && aIndex >= 0 )
       
   170         {
       
   171         iListBox->SetCurrentItemIndexAndDraw( aIndex );
       
   172         }
       
   173     }
       
   174 
       
   175 //  End of File