|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * The main UI container element of the Speeddial Control Utility |
|
16 * that contains the 3x3 grid of speeddial entries. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
26 #include <uikon/eikctrlstatus.h> |
|
27 #endif |
|
28 #include <eikdialg.h> |
|
29 #include <avkon.hrh> |
|
30 #include <aknlists.h> |
|
31 #include <aknkeys.h> |
|
32 |
|
33 #include <eikapp.h> |
|
34 #include <eikbtgpc.h> |
|
35 #include <eikmenub.h> |
|
36 |
|
37 #include <eiklbx.h> |
|
38 #include <gulicon.h> |
|
39 #include <eikclbd.h> |
|
40 |
|
41 #include <aknlayoutscalable_apps.cdl.h> |
|
42 #include <layoutmetadata.cdl.h> |
|
43 #include <SpdCtrl.rsg> |
|
44 #include "SpdiaControl.hrh" |
|
45 #include "speeddialprivate.h" |
|
46 #include "SpdiaGridDlgVPbk.h" |
|
47 #include "SpdiaGridVPbk.h" |
|
48 #include "Speeddial.laf" |
|
49 |
|
50 const TUint KShortcutKey0('0'); |
|
51 const TInt KMaxIndex(8); |
|
52 // ================= MEMBER FUNCTIONS ======================= |
|
53 // --------------------------------------------------------- |
|
54 // CSpdiaGridDlgVPbk::NewL() |
|
55 // |
|
56 // --------------------------------------------------------- |
|
57 CSpdiaGridDlgVPbk* CSpdiaGridDlgVPbk::NewL(TInt& aDial, const CSpeedDialPrivate& aControl) |
|
58 { |
|
59 CSpdiaGridDlgVPbk* self = new (ELeave) CSpdiaGridDlgVPbk(aDial, aControl); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CSpdiaGridDlgVPbk::~CSpdiaGridDlgVPbk() |
|
65 // |
|
66 // --------------------------------------------------------- |
|
67 CSpdiaGridDlgVPbk::~CSpdiaGridDlgVPbk() |
|
68 { |
|
69 |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // C++ default constructor can NOT contain any code, that |
|
74 // might leave. |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CSpdiaGridDlgVPbk::CSpdiaGridDlgVPbk(TInt& aDial, const CSpeedDialPrivate& aControl): iDial(aDial) |
|
78 { |
|
79 iControl = CONST_CAST(CSpeedDialPrivate*, &aControl); |
|
80 iCbaID = R_AVKON_SOFTKEYS_BACK; |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------- |
|
84 // CSpdiaGridDlgVPbk::PreLayoutDynInitL |
|
85 // |
|
86 // ---------------------------------------------------- |
|
87 // |
|
88 void CSpdiaGridDlgVPbk::PreLayoutDynInitL() |
|
89 { |
|
90 iGrid = STATIC_CAST(CSpdiaGridVPbk*, Control(ESpdGridItem)); |
|
91 |
|
92 CDesCArray* itemArray = STATIC_CAST(CDesCArray*, |
|
93 iGrid->Model()->ItemTextArray()); |
|
94 |
|
95 itemArray->Reset(); |
|
96 iControl->CreateDataL(*iGrid); |
|
97 |
|
98 // Set the Obsever |
|
99 // CPbkContactEngine* pbkEngine = iControl->PbkEngine(); |
|
100 // iPbkNotifier = pbkEngine->CreateContactChangeNotifierL(this); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------- |
|
104 // CSpdiaGridDlgVPbk::PostLayoutDynInitL |
|
105 // |
|
106 // ---------------------------------------------------- |
|
107 // |
|
108 void CSpdiaGridDlgVPbk::PostLayoutDynInitL() |
|
109 { |
|
110 iControl->SetLayout(Rect()); |
|
111 if(AknLayoutUtils::LayoutMirrored()) |
|
112 { |
|
113 iGrid->SetCurrentDataIndex(0); |
|
114 LoadCbaL(); |
|
115 } |
|
116 HandleResourceChange(KEikDynamicLayoutVariantSwitch); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CSpdiaGridDlgVPbk::CreateCustomControlL |
|
121 // |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 SEikControlInfo CSpdiaGridDlgVPbk::CreateCustomControlL(TInt aControlType) |
|
125 { |
|
126 SEikControlInfo ctrlInfo; |
|
127 ctrlInfo.iControl=NULL; |
|
128 ctrlInfo.iTrailerTextId=0; |
|
129 ctrlInfo.iFlags = EEikControlHasEars; |
|
130 if (aControlType == ESpdiaGrid) |
|
131 { |
|
132 ctrlInfo.iControl = CSpdiaGridVPbk::NewL(*iControl); |
|
133 } |
|
134 return ctrlInfo; |
|
135 } |
|
136 // --------------------------------------------------------- |
|
137 // CSpdiaGridDlgVPbk::OkToExitL |
|
138 // |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 TBool CSpdiaGridDlgVPbk::OkToExitL(TInt aButtonId) // Pressed button id |
|
142 { |
|
143 TBool result(ETrue); |
|
144 if (aButtonId == EAknSoftkeyOk) |
|
145 { |
|
146 iDial = iControl->Number(iGrid->CurrentDataIndex()); |
|
147 TInt index(iGrid->CurrentDataIndex()); |
|
148 if (iControl->VMBoxPosition() == index) |
|
149 { |
|
150 result = EFalse; |
|
151 } |
|
152 } |
|
153 return result; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // CSpdiaGridDlgVPbk::OfferKeyEventL |
|
158 // |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 TKeyResponse CSpdiaGridDlgVPbk::OfferKeyEventL |
|
162 (const TKeyEvent& aKeyEvent, |
|
163 TEventCode aType) |
|
164 { |
|
165 TBool keyConsumed(EFalse); |
|
166 if (iGrid != NULL) |
|
167 { |
|
168 TChar code(aKeyEvent.iCode); |
|
169 if(AknLayoutUtils::LayoutMirrored()) |
|
170 { |
|
171 if(code == EKeyLeftArrow) |
|
172 { |
|
173 TInt index = iGrid->CurrentDataIndex(); |
|
174 if(index == KMaxIndex) |
|
175 { |
|
176 iGrid->SetCurrentDataIndex(0); |
|
177 LoadCbaL(); |
|
178 return EKeyWasConsumed; |
|
179 } |
|
180 } |
|
181 if(code == EKeyRightArrow) |
|
182 { |
|
183 TInt index = iGrid->CurrentDataIndex(); |
|
184 if(index == 0) |
|
185 { |
|
186 iGrid->SetCurrentDataIndex(KMaxIndex); |
|
187 LoadCbaL(); |
|
188 return EKeyWasConsumed; |
|
189 } |
|
190 } |
|
191 } |
|
192 else |
|
193 { |
|
194 if(code == EKeyRightArrow) |
|
195 { |
|
196 TInt index = iGrid->CurrentDataIndex(); |
|
197 if(index == KMaxIndex) |
|
198 { |
|
199 iGrid->SetCurrentDataIndex(0); |
|
200 LoadCbaL(); |
|
201 return EKeyWasConsumed; |
|
202 } |
|
203 } |
|
204 if(code == EKeyLeftArrow) |
|
205 { |
|
206 TInt index = iGrid->CurrentDataIndex(); |
|
207 if(index == 0) |
|
208 { |
|
209 iGrid->SetCurrentDataIndex(KMaxIndex); |
|
210 LoadCbaL(); |
|
211 return EKeyWasConsumed; |
|
212 } |
|
213 } |
|
214 } |
|
215 TKeyResponse exitCode( |
|
216 iGrid->OfferKeyEventL(aKeyEvent, aType)); |
|
217 if (exitCode != EKeyWasNotConsumed) |
|
218 { |
|
219 if (code.IsDigit()) |
|
220 { |
|
221 if (aKeyEvent.iCode - KShortcutKey0 > 0) |
|
222 { |
|
223 iGrid->SetCurrentDataIndex( |
|
224 iControl->Index(aKeyEvent.iCode - KShortcutKey0)); |
|
225 LoadCbaL(); |
|
226 keyConsumed = ETrue; |
|
227 } |
|
228 } |
|
229 else if (aKeyEvent.iCode == EKeyLeftArrow || |
|
230 aKeyEvent.iCode == EKeyRightArrow || |
|
231 aKeyEvent.iCode == EKeyUpArrow || |
|
232 aKeyEvent.iCode == EKeyDownArrow) |
|
233 { |
|
234 LoadCbaL(); |
|
235 keyConsumed = ETrue; |
|
236 } |
|
237 |
|
238 if (aKeyEvent.iCode == EKeyOK) |
|
239 { |
|
240 TryExitL(EAknSoftkeyOk); |
|
241 keyConsumed = ETrue; |
|
242 } |
|
243 else if (aKeyEvent.iCode == EKeyEscape) |
|
244 { |
|
245 TryExitL(EAknSoftkeyBack); |
|
246 keyConsumed = ETrue; |
|
247 } |
|
248 } |
|
249 } |
|
250 |
|
251 if (keyConsumed) |
|
252 { |
|
253 return EKeyWasConsumed; |
|
254 } |
|
255 |
|
256 return CEikDialog::OfferKeyEventL(aKeyEvent, aType); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------- |
|
260 // CSpdiaGridDlgVPbk::FocusChanged() |
|
261 // Changes focus. |
|
262 // --------------------------------------------------------- |
|
263 // |
|
264 void CSpdiaGridDlgVPbk::FocusChanged(TDrawNow aDrawNow) |
|
265 { |
|
266 if (IsFocused() && aDrawNow == EDrawNow && iControl->UpdateFlag()) |
|
267 { |
|
268 TRAP_IGNORE(iControl->CreateDataL(*iGrid)); |
|
269 iControl->SetUpdateFlag(EFalse); |
|
270 } |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CSpdiaGridDlgVPbk::LoadCbaL() |
|
275 // Loads CBA buttons. |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CSpdiaGridDlgVPbk::LoadCbaL() |
|
279 { |
|
280 TInt id(R_AVKON_SOFTKEYS_BACK); |
|
281 if (iGrid->CurrentDataIndex() != iControl->VMBoxPosition()) |
|
282 { |
|
283 id = R_SPDCTRL_SOFTKEYS_ASSIGN_BACK_ASSIGN; |
|
284 } |
|
285 if (id != iCbaID) |
|
286 { |
|
287 iCbaID = id; |
|
288 ButtonGroupContainer().SetCommandSetL(id); |
|
289 ButtonGroupContainer().DrawNow(); |
|
290 } |
|
291 iPrevIndex = iGrid->CurrentDataIndex(); |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------- |
|
295 // CSpdiaGridDlgVPbk::HandleResourceChange() |
|
296 // Handle layout and skin change event. |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 void CSpdiaGridDlgVPbk::HandleResourceChange(TInt aType) |
|
300 { |
|
301 TRect mainPaneRect ; |
|
302 TRect statusPaneRect; |
|
303 |
|
304 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
305 { |
|
306 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
307 { |
|
308 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
|
309 } |
|
310 else |
|
311 { |
|
312 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
|
313 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect); |
|
314 mainPaneRect.iTl= statusPaneRect.iTl; |
|
315 } |
|
316 SetRect(mainPaneRect); |
|
317 DrawNow(); |
|
318 } |
|
319 else |
|
320 { |
|
321 CAknDialog::HandleResourceChange(aType); |
|
322 } |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------- |
|
326 // CSpdiaGridDlg::HandleDialogPageEventL() |
|
327 // Handles the events on the dialog page (for Touch) |
|
328 // --------------------------------------------------------- |
|
329 // |
|
330 void CSpdiaGridDlgVPbk::HandleDialogPageEventL(TInt /*aEventId*/) |
|
331 { |
|
332 //Get the current Index |
|
333 TInt index(iGrid->CurrentDataIndex()); |
|
334 //If current index is the previous index, then try opening it |
|
335 if(index == iPrevIndex) |
|
336 { |
|
337 |
|
338 TryExitL(EAknSoftkeyOk); |
|
339 } |
|
340 else //else load the cba buttons |
|
341 { |
|
342 LoadCbaL(); |
|
343 } |
|
344 |
|
345 } |
|
346 // End of File |