stifui/avkon/stifui/src/StartCasesContainer.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 CStartCasesContainer class 
       
    15 * definition
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknlists.h>   // ListBox
       
    21 #include <AknIconArray.h> // CAknIconArray
       
    22 #include <aknnotewrappers.h>
       
    23 
       
    24 #include <eikclbd.h> // CColumnListBoxData
       
    25 
       
    26 #include "StartCasesContainer.h"
       
    27 #include "StartCasesView.h"
       
    28 #include <Stifui.rsg>
       
    29 #include "Stifui.hrh"
       
    30 #include "AppUIAppUi.h"
       
    31 
       
    32 #include "Container.h"
       
    33 #include "MenuListBox.h"
       
    34 
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 // ----------------------------------------------------------------------------
       
    38 // CStartCasesContainer::ConstructL
       
    39 // 
       
    40 // Symbian OS two phased constructor.
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 void CStartCasesContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
       
    44     {
       
    45     ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ConstructL"));
       
    46 
       
    47 	iParentView = (CStartCasesView*)aListBoxObserver;
       
    48     CreateWindowL();
       
    49 
       
    50     iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
       
    51 
       
    52     iTestCasesInView.Reset();
       
    53         //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: iTCInV Reset"));
       
    54     
       
    55 	iListBox = CMenuListBox::NewL(EStartCaseMenuViewId);
       
    56 	iListBox->SetContainerWindowL( *this );
       
    57 	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
       
    58     iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
       
    59 
       
    60     ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox constructed"));
       
    61 
       
    62     //Create Scroller control for ListBox and set its visibility
       
    63     iListBox->CreateScrollBarFrameL(ETrue);
       
    64     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
    65 	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
    66 
       
    67     if ( iUIStore )
       
    68         {
       
    69         RRefArray<CTestInfo> allCases;
       
    70         TInt ret = iUIStore->TestCases( allCases );
       
    71         if( KErrNone != ret )
       
    72             {
       
    73             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->TestCases() fails"));
       
    74             allCases.Reset();
       
    75             allCases.Close();
       
    76             User::Leave( ret );
       
    77             }
       
    78 
       
    79         const TInt KTestCaseCount = allCases.Count();
       
    80         for (TInt i=0; i < KTestCaseCount; i++)
       
    81             {
       
    82             ret = iTestCasesInView.Append( &allCases[i] );
       
    83             if( ret != KErrNone )
       
    84             	{
       
    85             	((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("Test case append fails with: %d"), ret );
       
    86     			User::Leave( ret );
       
    87 	            }
       
    88             }
       
    89 
       
    90         iListBoxModel = CTestCaseListBoxModel::NewL(&iTestCasesInView);
       
    91              ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model"));
       
    92 
       
    93         iListBox->Model()->SetItemTextArray(iListBoxModel);
       
    94              ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model set"));
       
    95 
       
    96         allCases.Reset();
       
    97         allCases.Close();
       
    98         }
       
    99     else
       
   100         {
       
   101         User::Leave( KErrGeneral );
       
   102         }
       
   103 
       
   104     // Creates graphic.
       
   105     SetGraphicIconL( iListBox );
       
   106        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: icons created"));
       
   107 
       
   108     iListBox->ActivateL();
       
   109     ((CMenuListBox*)iListBox)->SetPreviousFocus();
       
   110 
       
   111     SetRect(aRect);
       
   112     ActivateL();
       
   113     }
       
   114 
       
   115 // ----------------------------------------------------------------------------
       
   116 // CStartCasesContainer::~CStartCasesContainer
       
   117 // 
       
   118 // Destructor
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 CStartCasesContainer::~CStartCasesContainer()
       
   122     {
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CStartCasesContainer::SizeChanged
       
   127 // 
       
   128 // Called by framework when the view size is changed.
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 void CStartCasesContainer::SizeChanged()
       
   132     {
       
   133     if ( iListBox )
       
   134 		{
       
   135 		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
       
   136 		}
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CStartCasesContainer::CountComponentControls
       
   141 // 
       
   142 // Gets a count of the component controls of this list box control.
       
   143 // ----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CStartCasesContainer::CountComponentControls() const
       
   146     {
       
   147     return 1; // return nbr of controls inside this container
       
   148     }
       
   149 
       
   150 // ----------------------------------------------------------------------------
       
   151 // CStartCasesContainer::ComponentControl
       
   152 // 
       
   153 // Gets a pointer to the specified component control.
       
   154 // ----------------------------------------------------------------------------
       
   155 //
       
   156 CCoeControl* CStartCasesContainer::ComponentControl(TInt aIndex) const
       
   157     {
       
   158     switch ( aIndex )
       
   159         {
       
   160 		case 0: 
       
   161 			return iListBox;
       
   162         default:
       
   163             return NULL;
       
   164         }
       
   165     }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CStartCasesContainer::Draw
       
   169 // 
       
   170 // Draw a control, called by window server.
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 void CStartCasesContainer::Draw(const TRect& /*aRect*/) const
       
   174     {
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // CStartCasesContainer::OfferKeyEventL
       
   179 // 
       
   180 // Handles key events.
       
   181 // ----------------------------------------------------------------------------
       
   182 //
       
   183 TKeyResponse CStartCasesContainer::OfferKeyEventL(
       
   184 	const TKeyEvent& aKeyEvent, TEventCode aType )
       
   185     {
       
   186 	if (aType != EEventKey)
       
   187 	    {
       
   188 		return EKeyWasNotConsumed;
       
   189 	    }
       
   190 
       
   191 	if (iListBox)
       
   192 		{
       
   193 		//if multiple items selected
       
   194 		if ( iListBox->SelectionIndexes()->Count() > 0 )
       
   195 			{
       
   196 			TUint mask = 0x40488;
       
   197 			
       
   198 			//if event is enter key,
       
   199 			//donīt send it to listbox
       
   200 			if ( aKeyEvent.iScanCode == 0xa7 
       
   201 				&& ( aKeyEvent.iModifiers & mask ) == 0 )
       
   202 				{
       
   203 				iParentView->HandleListBoxEventL( iListBox, MEikListBoxObserver::EEventEnterKeyPressed );
       
   204 				return EKeyWasConsumed;	
       
   205 				}
       
   206 			}
       
   207 			
       
   208 		return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   209 		}
       
   210 	else
       
   211 		{
       
   212 		return EKeyWasNotConsumed;
       
   213 		}
       
   214     }
       
   215 
       
   216 // ----------------------------------------------------------------------------
       
   217 // CStartCasesContainer:::SaveActiveLine
       
   218 //
       
   219 // Makes the iListBox member save its focus position
       
   220 // ----------------------------------------------------------------------------
       
   221 //
       
   222 void CStartCasesContainer::SaveActiveLine()
       
   223 	{
       
   224 	((CMenuListBox*)iListBox)->SaveFocusPosition();
       
   225 	}
       
   226 
       
   227 // End of File