|
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 CStartedCasesMenuContainer |
|
15 * class definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "StartedCasesMenuContainer.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 // CStartedCasesMenuContainer::ConstructL |
|
35 // |
|
36 // Symbian OS default constructor. |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 void CStartedCasesMenuContainer::ConstructL( |
|
40 const TRect& aRect ) |
|
41 { |
|
42 CreateWindowL(); |
|
43 |
|
44 iListBox = CMenuListBox::NewL(EStartedCasesMenuViewId); |
|
45 iListBox->SetContainerWindowL( *this ); |
|
46 TResourceReader reader; |
|
47 iCoeEnv->CreateResourceReaderLC( reader, R_STARTED_CASES_MENU_LISTBOX ); |
|
48 iListBox->SetListBoxObserver( this ); // jos peritty MEikListBoxObserver:sta |
|
49 //iListBox->SetObserver( this /*iMainMenuObserver*/ ); //jos peritty MCoeControlObserver:sta |
|
50 iListBox->ConstructFromResourceL( reader ); |
|
51 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
52 |
|
53 //Create Scroller control for ListBox and set its visibility |
|
54 iListBox->CreateScrollBarFrameL(ETrue); |
|
55 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
56 |
|
57 ((CMenuListBox*)iListBox)->SetPreviousFocus(); |
|
58 iListBox->ActivateL(); |
|
59 |
|
60 SetRect(aRect); |
|
61 ActivateL(); |
|
62 } |
|
63 |
|
64 // Destructor |
|
65 CStartedCasesMenuContainer::~CStartedCasesMenuContainer() |
|
66 { |
|
67 if ( iListBox ) |
|
68 { |
|
69 iListBox->Reset(); |
|
70 delete iListBox; |
|
71 } |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CStartedCasesMenuContainer::SizeChanged |
|
76 // |
|
77 // Called by framework when the view size is changed. |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CStartedCasesMenuContainer::SizeChanged() |
|
81 { |
|
82 if ( iListBox ) |
|
83 { |
|
84 iListBox->SetRect( Rect() ); // Sets rectangle of listbox. |
|
85 } |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CStartedCasesMenuContainer::CountComponentControls |
|
90 // |
|
91 // Gets a count of the component controls of this list box control. |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CStartedCasesMenuContainer::CountComponentControls() const |
|
95 { |
|
96 return 1; // return nbr of controls inside this container |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CStartedCasesMenuContainer::ComponentControl |
|
101 // |
|
102 // Gets a pointer to the specified component control. |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 CCoeControl* CStartedCasesMenuContainer::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 // CStartedCasesMenuContainer::Draw |
|
118 // |
|
119 // Draw a control, called by window server. |
|
120 // ---------------------------------------------------------------------------- |
|
121 // |
|
122 void CStartedCasesMenuContainer::Draw(const TRect& /*aRect*/) const |
|
123 { |
|
124 // CWindowGc& gc = SystemGc(); |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CStartedCasesMenuContainer::HandleListBoxEventL |
|
129 // |
|
130 // Handles list box events. |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 void CStartedCasesMenuContainer::HandleListBoxEventL( |
|
134 CEikListBox* aListBox, |
|
135 TListBoxEvent aEventType ) |
|
136 { |
|
137 |
|
138 if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) ) |
|
139 { |
|
140 HandleSelectedListItemL( aListBox->CurrentItemIndex() ); |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // CStartedCasesMenuContainer::HandleSelectedListItemL |
|
148 // |
|
149 // Method HandleSelectedListItemL handles valid index. |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CStartedCasesMenuContainer::HandleSelectedListItemL( TInt aIndex ) |
|
153 { |
|
154 TInt selection = aIndex; |
|
155 |
|
156 switch ( selection ) |
|
157 { |
|
158 case 0: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowAllStartedCases); |
|
159 break; |
|
160 case 1: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowOngoingCases); |
|
161 break; |
|
162 case 2: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowPausedCases); |
|
163 break; |
|
164 case 3: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowPassedCases); |
|
165 break; |
|
166 case 4: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowFailedCases); |
|
167 break; |
|
168 case 5: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowCrashedAbortedCases); |
|
169 break; |
|
170 case 6: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowStatistics); |
|
171 break; |
|
172 default: |
|
173 break; |
|
174 } |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // CStartedCasesMenuContainer::OfferKeyEventL |
|
179 // |
|
180 // Handles key events. |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 TKeyResponse CStartedCasesMenuContainer::OfferKeyEventL( |
|
184 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
185 { |
|
186 if (aType != EEventKey) |
|
187 { |
|
188 return EKeyWasNotConsumed; |
|
189 } |
|
190 |
|
191 switch ( aKeyEvent.iCode ) |
|
192 { |
|
193 case EKeyLeftArrow: |
|
194 case EKeyRightArrow: |
|
195 { /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */ |
|
196 return EKeyWasNotConsumed; |
|
197 //break; |
|
198 } |
|
199 default: |
|
200 { |
|
201 //Muut Key eventit valitetaan listboxille, joka hoitaa ne |
|
202 if (iListBox) |
|
203 { |
|
204 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
205 } |
|
206 } |
|
207 } |
|
208 return EKeyWasNotConsumed; |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CStartedCasesMenuContainer::GetActiveLine |
|
213 // |
|
214 // Get currently selected items index. |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 TInt CStartedCasesMenuContainer::GetActiveLine() |
|
218 { |
|
219 return iListBox->CurrentItemIndex(); |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CStartedCasesMenuContainer:::SaveActiveLine |
|
224 // |
|
225 // Makes the iListBox member save its focus position |
|
226 // ---------------------------------------------------------------------------- |
|
227 // |
|
228 void CStartedCasesMenuContainer::SaveActiveLine() |
|
229 { |
|
230 ((CMenuListBox*)iListBox)->SaveFocusPosition(); |
|
231 } |
|
232 |
|
233 |
|
234 // End of File |