stifui/avkon/stifui/src/TestSetBaseMenuContainer.cpp
branchRCL_3
changeset 18 48060abbbeaf
parent 17 d40e813b23c0
child 19 b3cee849fa46
equal deleted inserted replaced
17:d40e813b23c0 18:48060abbbeaf
     1 /*
       
     2 * Copyright (c) 2009 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 file contains CTestSetBaseMenuContainer class 
       
    15 * definition.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "TestSetBaseMenuContainer.h"
       
    21 #include "Stifui.hrh"
       
    22 
       
    23 #include <Stifui.rsg>
       
    24 
       
    25 #include <aknlists.h>  //ListBox
       
    26 #include <barsread.h> // for TResourceReader
       
    27 
       
    28 #include <aknnotewrappers.h>
       
    29 
       
    30 #include "MenuListBox.h"
       
    31 
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 // ----------------------------------------------------------------------------
       
    35 // CTestSetBaseMenuContainer::ConstructL
       
    36 // 
       
    37 // Symbian OS two phased constructor.
       
    38 // ----------------------------------------------------------------------------
       
    39 //
       
    40 void CTestSetBaseMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
       
    41     {
       
    42     CreateWindowL();
       
    43      
       
    44 	iListBox = CMenuListBox::NewL(ETestSetMenuViewId);
       
    45 	iListBox->SetContainerWindowL( *this );
       
    46 	TResourceReader reader;
       
    47 	iCoeEnv->CreateResourceReaderLC( reader, R_TESTSETBASE_MENU_LISTBOX );
       
    48 	iListBox->SetListBoxObserver( aListBoxObserver );
       
    49 	iListBox->ConstructFromResourceL( reader );
       
    50 	CleanupStack::PopAndDestroy(); // resource stuffs. 
       
    51 
       
    52     // Create Scroller control for ListBox and set its visibility
       
    53     // !!! Not needed yet because there are only two items in list box.
       
    54     // If items are added later, scroller may be taken to use
       
    55     //iListBox->CreateScrollBarFrameL(ETrue);
       
    56     //iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
    57     
       
    58     iListBox->ActivateL();
       
    59     ((CMenuListBox*)iListBox)->SetPreviousFocus();
       
    60     
       
    61     SetRect(aRect);
       
    62     ActivateL();
       
    63     }
       
    64 
       
    65 // ----------------------------------------------------------------------------
       
    66 // CTestSetBaseMenuContainer::~CTestSetBaseMenuContainer
       
    67 // 
       
    68 // Destructor.
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 CTestSetBaseMenuContainer::~CTestSetBaseMenuContainer()
       
    72     {
       
    73     if ( iListBox )
       
    74 		{
       
    75 		iListBox->Reset();
       
    76     	delete iListBox;
       
    77     	}	
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CTestSetBaseMenuContainer::SizeChanged
       
    82 // 
       
    83 // Called by framework when the view size is changed.
       
    84 // ----------------------------------------------------------------------------
       
    85 //
       
    86 void CTestSetBaseMenuContainer::SizeChanged()
       
    87     {
       
    88     if ( iListBox )
       
    89 		{
       
    90 		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
       
    91 		}
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CTestSetBaseMenuContainer::CountComponentControls
       
    96 // 
       
    97 // Gets a count of the component controls of this list box control.
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 TInt CTestSetBaseMenuContainer::CountComponentControls() const
       
   101     {
       
   102     return 1; // return nbr of controls inside this container
       
   103     }
       
   104 
       
   105 // ----------------------------------------------------------------------------
       
   106 // CTestSetBaseMenuContainer::ComponentControl
       
   107 // 
       
   108 // Gets a pointer to the specified component control.
       
   109 // ----------------------------------------------------------------------------
       
   110 //
       
   111 CCoeControl* CTestSetBaseMenuContainer::ComponentControl(TInt aIndex) const
       
   112     {
       
   113     switch ( aIndex )
       
   114         {
       
   115 		case 0: 
       
   116 			return iListBox;
       
   117         default:
       
   118             return NULL;
       
   119         }
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CTestSetBaseMenuContainer::Draw
       
   124 // 
       
   125 // Draw a control, called by window server.
       
   126 // ----------------------------------------------------------------------------
       
   127 //
       
   128 void CTestSetBaseMenuContainer::Draw(const TRect& /*aRect*/) const
       
   129     {
       
   130     // CWindowGc& gc = SystemGc();
       
   131     }
       
   132 
       
   133 // ----------------------------------------------------------------------------
       
   134 // CTestSetBaseMenuContainer::OfferKeyEventL
       
   135 // 
       
   136 // Handles key events..
       
   137 // ----------------------------------------------------------------------------
       
   138 //
       
   139 TKeyResponse CTestSetBaseMenuContainer::OfferKeyEventL(
       
   140 	const TKeyEvent& aKeyEvent, TEventCode aType)
       
   141     {
       
   142 	if (aType != EEventKey)
       
   143 	{
       
   144 		return EKeyWasNotConsumed;
       
   145 	}
       
   146 	
       
   147     switch ( aKeyEvent.iCode )
       
   148         {
       
   149         case EKeyLeftArrow:
       
   150         case EKeyRightArrow:
       
   151 			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
       
   152 			return EKeyWasNotConsumed;
       
   153             //break;
       
   154             }
       
   155         default:
       
   156 			{
       
   157 			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
       
   158 			if (iListBox)
       
   159 				{
       
   160 				return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   161 				}
       
   162 	    	}
       
   163         }     
       
   164     return EKeyWasNotConsumed;        
       
   165 }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CTestSetBaseMenuContainer::GetActiveLine
       
   169 // 
       
   170 // Get currently selected items index.
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 TInt CTestSetBaseMenuContainer::GetActiveLine()
       
   174 	{
       
   175 	return iListBox->CurrentItemIndex();
       
   176 	}
       
   177 
       
   178 // ----------------------------------------------------------------------------
       
   179 // CTestSetBaseMenuContainer::SaveActiveLine
       
   180 //
       
   181 // Makes the iListBox member save its focus position
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 void CTestSetBaseMenuContainer::SaveActiveLine()
       
   185 	{
       
   186 	((CMenuListBox*)iListBox)->SaveFocusPosition();
       
   187 	}
       
   188 
       
   189 // End of File