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