stifui/avkon/stifui/src/CreatedTestSetMenuContainer.cpp
branchRCL_3
changeset 20 48060abbbeaf
parent 19 d40e813b23c0
child 21 b3cee849fa46
equal deleted inserted replaced
19:d40e813b23c0 20: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 fiole contains CreatedTestSetMenuContainer 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 "CreatedTestSetMenuContainer.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 // CreatedTestSetMenuContainer::ConstructL
       
    39 // 
       
    40 // Symbian OS two phased constructor.
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 void CCreatedTestSetMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
       
    44     {
       
    45     ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ConstructL"));
       
    46 
       
    47 	iParentView = (CCreatedTestSetMenuView*)aListBoxObserver;
       
    48     CreateWindowL();
       
    49 
       
    50     iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
       
    51 
       
    52     iTestCasesInView.Reset();
       
    53     
       
    54 	iListBox = CMenuListBox::NewL(ECreatedTestSetMenuViewId);
       
    55 	iListBox->SetContainerWindowL( *this );
       
    56 	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // 
       
    57     iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
       
    58 
       
    59     ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ListBox constructed"));
       
    60 
       
    61     //Create Scroller control for ListBox and set its visibility
       
    62     iListBox->CreateScrollBarFrameL(ETrue);
       
    63     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
    64 	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
    65 
       
    66     if ( iUIStore )
       
    67         {
       
    68         CDesCArray* items = static_cast<CDesCArray*> (iListBox->Model()->ItemTextArray());
       
    69         
       
    70         //Create list of available Test Set
       
    71         RRefArray<TDesC>    allSet;      
       
    72         RRefArray<CTestInfo> allCases;
       
    73         TInt ret = iUIStore->GetTestSetsList( allSet );
       
    74         if( KErrNone != ret )
       
    75             {
       
    76             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->GetTestSetsList() fails"));
       
    77             allSet.Reset();
       
    78             allSet.Close();
       
    79             User::Leave( ret );
       
    80             }
       
    81 
       
    82         const TInt KTestCaseCount = allSet.Count();
       
    83         for (TInt i=0; i <KTestCaseCount; i++)
       
    84             {
       
    85             _LIT(KItemFromat, "0\t%S\t\t");
       
    86      
       
    87            RBuf tmp;
       
    88            tmp.Create(allSet[i].Length() + 6);
       
    89            tmp.Format( KItemFromat, &allSet[i] );
       
    90            items->AppendL( tmp );
       
    91            tmp.Close();
       
    92            }
       
    93        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ListBox model"));         
       
    94        iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
    95        iListBox->HandleItemAdditionL();
       
    96  
       
    97         allSet.Reset();
       
    98         allSet.Close();
       
    99         }
       
   100     else
       
   101         {
       
   102         User::Leave( KErrGeneral );
       
   103         }
       
   104 
       
   105     // Creates graphic.
       
   106     SetGraphicIconL( iListBox );
       
   107        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: icons created"));
       
   108 
       
   109     iListBox->ActivateL();
       
   110     ((CMenuListBox*)iListBox)->SetPreviousFocus();
       
   111 
       
   112     SetRect(aRect);
       
   113     ActivateL();
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 //CreatedTestSetMenuContainer::~CStartCasesContainer
       
   118 // 
       
   119 // Destructor
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 CCreatedTestSetMenuContainer::~CCreatedTestSetMenuContainer()
       
   123     {
       
   124     }
       
   125 
       
   126 // ----------------------------------------------------------------------------
       
   127 // CreatedTestSetMenuContainer::SizeChanged
       
   128 // 
       
   129 // Called by framework when the view size is changed.
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 void CCreatedTestSetMenuContainer::SizeChanged()
       
   133     {
       
   134     
       
   135     if ( iListBox )
       
   136 		{
       
   137 		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
       
   138 		}
       
   139     }
       
   140 
       
   141 // ----------------------------------------------------------------------------
       
   142 //CreatedTestSetMenuContainer::CountComponentControls
       
   143 // 
       
   144 // Gets a count of the component controls of this list box control.
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 TInt CCreatedTestSetMenuContainer::CountComponentControls() const
       
   148     {
       
   149     return 1; // return nbr of controls inside this container
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------------------------
       
   153 // CreatedTestSetMenuContainer::ComponentControl
       
   154 // 
       
   155 // Gets a pointer to the specified component control.
       
   156 // ----------------------------------------------------------------------------
       
   157 //
       
   158 CCoeControl* CCreatedTestSetMenuContainer::ComponentControl(TInt aIndex) const
       
   159     {
       
   160     switch ( aIndex )
       
   161         {
       
   162 		case 0: 
       
   163 			return iListBox;
       
   164         default:
       
   165             return NULL;
       
   166         }
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CreatedTestSetMenuContainer::Draw
       
   171 // 
       
   172 // Draw a control, called by window server.
       
   173 // ----------------------------------------------------------------------------
       
   174 //
       
   175 void CCreatedTestSetMenuContainer::Draw(const TRect& /*aRect*/) const
       
   176     {
       
   177     }
       
   178 
       
   179 // ----------------------------------------------------------------------------
       
   180 // CreatedTestSetMenuContainer::OfferKeyEventL
       
   181 // 
       
   182 // Handles key events.
       
   183 // ----------------------------------------------------------------------------
       
   184 //
       
   185 TKeyResponse CCreatedTestSetMenuContainer::OfferKeyEventL(
       
   186 	const TKeyEvent& aKeyEvent, TEventCode aType )
       
   187     {
       
   188 	if (iListBox)
       
   189 		{
       
   190 	
       
   191 		return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   192 		}
       
   193 	else
       
   194 		{
       
   195 		return EKeyWasNotConsumed;
       
   196 		}
       
   197     }
       
   198 
       
   199 // ----------------------------------------------------------------------------
       
   200 // CreatedTestSetMenuContainer:::SaveActiveLine
       
   201 //
       
   202 // Makes the iListBox member save its focus position
       
   203 // ----------------------------------------------------------------------------
       
   204 //
       
   205 void CCreatedTestSetMenuContainer::SaveActiveLine()
       
   206 	{
       
   207 	((CMenuListBox*)iListBox)->SaveFocusPosition();
       
   208 	}
       
   209 
       
   210 // End of File