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 CTestCaseOutputContainer class |
|
15 * definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "TestCaseOutputContainer.h" |
|
21 #include <Stifui.rsg> |
|
22 #include "Stifui.hrh" |
|
23 #include "AppUIAppUi.h" |
|
24 |
|
25 #include <aknlists.h> // ListBox |
|
26 #include <AknIconArray.h> // CAknIconArray |
|
27 #include <badesca.h> // CDesCArray |
|
28 #include <eikclbd.h> // CColumnListBoxData |
|
29 #include <aknnotewrappers.h> |
|
30 |
|
31 //#include "UIStoreIf.h" |
|
32 //#include "UIStore.h" |
|
33 //#include "UIEngine.h" |
|
34 //#include "UIEngineContainer.h" |
|
35 |
|
36 #include <stifinternal/UIStoreIf.h> |
|
37 #include <stifinternal/UIStore.h> |
|
38 #include <stifinternal/UIEngine.h> |
|
39 #include <stifinternal/UIEngineContainer.h> |
|
40 |
|
41 #include "MenuListBox.h" |
|
42 |
|
43 //#include <gdi.h> |
|
44 |
|
45 |
|
46 // ================= MEMBER FUNCTIONS ======================= |
|
47 // ---------------------------------------------------------------------------- |
|
48 // CTestCaseOutputContainer::ConstructL |
|
49 // |
|
50 // Symbian OS two phased constructor. |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 void CTestCaseOutputContainer::ConstructL(const TRect& aRect, CStartedTestCase* aStartedTestCase ) //TInt aExecutedTestCaseCount ) |
|
54 { |
|
55 CreateWindowL(); |
|
56 |
|
57 iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler(); |
|
58 |
|
59 iListBox = CMenuListBox::NewL(ETestCaseOutputViewId); |
|
60 iListBox->SetContainerWindowL( *this ); |
|
61 iListBox->SetListBoxObserver( this ); |
|
62 iListBox->ConstructL(this, EAknListBoxSelectionList); |
|
63 |
|
64 //Create Scroller control for ListBox and set its visibility |
|
65 iListBox->CreateScrollBarFrameL(ETrue); |
|
66 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
67 |
|
68 if( iUIStore ) |
|
69 { |
|
70 iListBoxModel = CTestOutputListBoxModel::NewL( aStartedTestCase ); |
|
71 iListBox->Model()->SetItemTextArray( iListBoxModel ); |
|
72 } |
|
73 else |
|
74 { |
|
75 //User::Leave( syy?? ) |
|
76 } |
|
77 iListBox->ActivateL(); |
|
78 ((CMenuListBox*)iListBox)->SetPreviousFocus(); |
|
79 |
|
80 SetRect(aRect); |
|
81 ActivateL(); |
|
82 |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // CTestCaseOutputContainer::~CTestCaseOutputContainer |
|
87 // |
|
88 // Destructor. |
|
89 // ---------------------------------------------------------------------------- |
|
90 // |
|
91 CTestCaseOutputContainer::~CTestCaseOutputContainer() |
|
92 { |
|
93 // Discard and destroy the font |
|
94 //CWindowGc* listBoxGc = iListBox->View()->ItemDrawer()->Gc(); |
|
95 //listBoxGc->DiscardFont(); |
|
96 |
|
97 //CWindowGc& gc = SystemGc(); |
|
98 //gc.DiscardFont(); |
|
99 |
|
100 //iCoeEnv->ScreenDevice()->ReleaseFont(iListBoxFont); |
|
101 |
|
102 delete iListBox; |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CTestCaseOutputContainer::SizeChanged |
|
107 // |
|
108 // Called by framework when the view size is changed. |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CTestCaseOutputContainer::SizeChanged() |
|
112 { |
|
113 if ( iListBox ) |
|
114 { |
|
115 iListBox->SetRect( Rect() ); // Sets rectangle of listbox. |
|
116 } |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CTestCaseOutputContainer::CountComponentControls |
|
121 // |
|
122 // Gets a count of the component controls of this list box control. |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CTestCaseOutputContainer::CountComponentControls() const |
|
126 { |
|
127 return 1; // return nbr of controls inside this container |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CTestCaseOutputContainer::ComponentControl |
|
132 // |
|
133 // Gets a pointer to the specified component control. |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 CCoeControl* CTestCaseOutputContainer::ComponentControl(TInt aIndex) const |
|
137 { |
|
138 switch ( aIndex ) |
|
139 { |
|
140 case 0: |
|
141 return iListBox; |
|
142 default: |
|
143 return NULL; |
|
144 } |
|
145 } |
|
146 |
|
147 // ---------------------------------------------------------------------------- |
|
148 // CTestCaseOutputContainer::Draw |
|
149 // |
|
150 // Draw a control, called by window server. |
|
151 // ---------------------------------------------------------------------------- |
|
152 // |
|
153 void CTestCaseOutputContainer::Draw(const TRect& /*aRect*/) const |
|
154 { |
|
155 // CWindowGc& gc = SystemGc(); |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------------------------------- |
|
159 // CTestCaseOutputContainer::HandleListBoxEventL |
|
160 // |
|
161 // Handles list box events. |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 void CTestCaseOutputContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
165 { |
|
166 if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) ) |
|
167 { |
|
168 //TBuf<200> outputLine; |
|
169 //CAknNoteDialog* outputLineNote = new (ELeave) CAknNoteDialog; |
|
170 //outputLineNote->SetTextL( iListBoxModel->MdcaPoint(iListBox->CurrentItemIndex()) ); |
|
171 //outputLineNote->RunDlgLD(); |
|
172 |
|
173 |
|
174 |
|
175 //CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
176 //informationNote->SetTextL( iListBoxModel->MdcaPoint(iListBox->CurrentItemIndex()) ); |
|
177 //informationNote->SetTextPluralityL( ETrue ); |
|
178 //informationNote->SetTextL( _L("Number of cases: %d") ); |
|
179 //informationNote->SetTextNumberL( count ); |
|
180 //informationNote->ExecuteLD(); |
|
181 } |
|
182 } |
|
183 |
|
184 // ---------------------------------------------------------------------------- |
|
185 // CTestCaseOutputContainer::OfferKeyEventL |
|
186 // |
|
187 // Handles key events. |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 TKeyResponse CTestCaseOutputContainer::OfferKeyEventL( |
|
191 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
192 { |
|
193 if (aType != EEventKey) |
|
194 { |
|
195 return EKeyWasNotConsumed; |
|
196 } |
|
197 |
|
198 if (iListBox) |
|
199 { |
|
200 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
201 } |
|
202 else |
|
203 { |
|
204 return EKeyWasNotConsumed; |
|
205 } |
|
206 |
|
207 /* |
|
208 switch ( aKeyEvent.iCode ) |
|
209 { |
|
210 case EKeyLeftArrow: |
|
211 case EKeyRightArrow: |
|
212 { */ /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */ |
|
213 /* return EKeyWasNotConsumed; |
|
214 break; |
|
215 } |
|
216 default: |
|
217 { |
|
218 //Muut Key eventit valitetaan listboxille, joka hoitaa ne |
|
219 if (iListBox) |
|
220 { |
|
221 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
222 } |
|
223 else |
|
224 { |
|
225 return EKeyWasNotConsumed; |
|
226 } |
|
227 break; |
|
228 } |
|
229 }*/ |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CTestCaseOutputContainer::OutputUpdateL |
|
234 // |
|
235 // Handles addition of item to list box. |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 void CTestCaseOutputContainer::OutputUpdateL() |
|
239 { |
|
240 if ( iListBox ) |
|
241 { |
|
242 iListBox->HandleItemAdditionL(); |
|
243 iListBox->DrawNow(); |
|
244 } |
|
245 } |
|
246 |
|
247 |
|
248 // ================= MEMBER FUNCTIONS ======================= |
|
249 |
|
250 // ---------------------------------------------------------------------------- |
|
251 // CTestOutputListBoxModel::NewL |
|
252 // |
|
253 // Two-phased constructor. |
|
254 // ---------------------------------------------------------------------------- |
|
255 // |
|
256 CTestOutputListBoxModel* CTestOutputListBoxModel::NewL(CStartedTestCase* aStartedTestCase /*, HBufC* aBuffer*/) |
|
257 { |
|
258 |
|
259 CTestOutputListBoxModel* self = new ( ELeave ) CTestOutputListBoxModel(); |
|
260 CleanupStack::PushL( self ); |
|
261 //self->ConstructL(); |
|
262 //self->iBuffer = aBuffer; |
|
263 self->iBuffer = HBufC::NewL( 150 ); |
|
264 self->iStartedTestCase = aStartedTestCase; |
|
265 CleanupStack::Pop(); |
|
266 return self; |
|
267 |
|
268 } |
|
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CTestOutputListBoxModel::ConstructL |
|
272 // |
|
273 // Symbian OS two phased constructor. |
|
274 // Completes the construction of the object. |
|
275 // ---------------------------------------------------------------------------- |
|
276 // |
|
277 void CTestOutputListBoxModel::ConstructL() |
|
278 { |
|
279 //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 ); |
|
280 } |
|
281 |
|
282 // ---------------------------------------------------------------------------- |
|
283 // CTestOutputListBoxModel::~CTestCaseOutputContainer |
|
284 // |
|
285 // Destructor. |
|
286 // ---------------------------------------------------------------------------- |
|
287 // |
|
288 CTestOutputListBoxModel::~CTestOutputListBoxModel() |
|
289 { |
|
290 delete iBuffer; |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // CTestOutputListBoxModel::MdcaCount |
|
295 // |
|
296 // Returns the number of descriptor elements in the array. |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 TInt CTestOutputListBoxModel::MdcaCount() const |
|
300 { |
|
301 |
|
302 TInt rows = iStartedTestCase->PrintArray().Count(); |
|
303 return rows; |
|
304 |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // CTestOutputListBoxModel::MdcaPoint |
|
309 // |
|
310 // Indexes into a descriptor array. |
|
311 // ---------------------------------------------------------------------------- |
|
312 // |
|
313 TPtrC CTestOutputListBoxModel::MdcaPoint(TInt aIndex) const |
|
314 { |
|
315 const RPointerArray<CTestProgress> printArray = iStartedTestCase->PrintArray(); |
|
316 |
|
317 TPtr buffer( iBuffer->Des() ); |
|
318 buffer.Zero(); |
|
319 buffer.Append(_L("\t")); |
|
320 buffer.Append(printArray[aIndex]->iDescription); |
|
321 buffer.Append(_L(" ")); |
|
322 buffer.Append(printArray[aIndex]->iText); |
|
323 |
|
324 return *iBuffer; |
|
325 |
|
326 } |
|
327 |
|
328 // End of File |
|