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