|
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 <centralrepository.h> |
|
38 #include <telvmbxsettingscrkeys.h> |
|
39 #include <voicemailboxdomaincrkeys.h> |
|
40 #include <eiklbx.h> |
|
41 #include <gulicon.h> |
|
42 #include <eikclbd.h> |
|
43 #include <CPbkContactChangeNotifier.h> |
|
44 #include <CPbkContactEngine.h> // phonebook engine |
|
45 #include <aknlayoutscalable_apps.cdl.h> |
|
46 #include <layoutmetadata.cdl.h> |
|
47 #include <Spdctrl.rsg> |
|
48 #include "SpdiaControl.hrh" |
|
49 #include "SpdiaControl.h" |
|
50 #include "SpdiaGridDlg.h" |
|
51 #include "SpdiaGrid.h" |
|
52 #include "Speeddial.laf" |
|
53 |
|
54 const TUint KShortcutKey0('0'); |
|
55 const TInt KMaxIndex(8); |
|
56 const TInt KNullIndexData(-1); |
|
57 // ================= MEMBER FUNCTIONS ======================= |
|
58 // --------------------------------------------------------- |
|
59 // CSpdiaGridDlg::NewL() |
|
60 // |
|
61 // --------------------------------------------------------- |
|
62 CSpdiaGridDlg* CSpdiaGridDlg::NewL(TInt& aDial, const CSpdiaControl& aControl) |
|
63 { |
|
64 CSpdiaGridDlg* self = new (ELeave) CSpdiaGridDlg(aDial, aControl); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CSpdiaGridDlg::~CSpdiaGridDlg() |
|
70 // |
|
71 // --------------------------------------------------------- |
|
72 CSpdiaGridDlg::~CSpdiaGridDlg() |
|
73 { |
|
74 delete iPbkNotifier; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // C++ default constructor can NOT contain any code, that |
|
79 // might leave. |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 CSpdiaGridDlg::CSpdiaGridDlg(TInt& aDial, const CSpdiaControl& aControl): iDial(aDial) |
|
83 { |
|
84 iControl = CONST_CAST(CSpdiaControl*, &aControl); |
|
85 iCbaID = R_AVKON_SOFTKEYS_BACK; |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------- |
|
89 // CSpdiaGridDlg::PreLayoutDynInitL |
|
90 // |
|
91 // ---------------------------------------------------- |
|
92 // |
|
93 void CSpdiaGridDlg::PreLayoutDynInitL() |
|
94 { |
|
95 iGrid = STATIC_CAST(CSpdiaGrid*, Control(ESpdGridItem)); |
|
96 |
|
97 CDesCArray* itemArray = STATIC_CAST(CDesCArray*, |
|
98 iGrid->Model()->ItemTextArray()); |
|
99 |
|
100 itemArray->Reset(); |
|
101 iControl->CreateDataL(*iGrid); // |
|
102 |
|
103 // Obsever |
|
104 CPbkContactEngine* pbkEngine = iControl->PbkEngine(); |
|
105 iPbkNotifier = pbkEngine->CreateContactChangeNotifierL(this); |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------- |
|
109 // CSpdiaGridDlg::PostLayoutDynInitL |
|
110 // |
|
111 // ---------------------------------------------------- |
|
112 // |
|
113 void CSpdiaGridDlg::PostLayoutDynInitL() |
|
114 { |
|
115 iControl->SetLayout(Rect()); |
|
116 if ( AknLayoutUtils::LayoutMirrored() ) |
|
117 { |
|
118 iGrid->SetCurrentDataIndex(0); |
|
119 LoadCbaL(); |
|
120 } |
|
121 HandleResourceChange( KEikDynamicLayoutVariantSwitch ); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CSpdiaGridDlg::CreateCustomControlL |
|
126 // |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 SEikControlInfo CSpdiaGridDlg::CreateCustomControlL(TInt aControlType) |
|
130 { |
|
131 SEikControlInfo ctrlInfo; |
|
132 ctrlInfo.iControl=NULL; |
|
133 ctrlInfo.iTrailerTextId=0; |
|
134 ctrlInfo.iFlags = EEikControlHasEars; |
|
135 if (aControlType == ESpdiaGrid) |
|
136 { |
|
137 ctrlInfo.iControl = CSpdiaGrid::NewL(*iControl); |
|
138 } |
|
139 return ctrlInfo; |
|
140 } |
|
141 // --------------------------------------------------------- |
|
142 // CSpdiaGridDlg::OkToExitL |
|
143 // |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 TBool CSpdiaGridDlg::OkToExitL(TInt aButtonId) // Pressed button id |
|
147 { |
|
148 TBool result(ETrue); |
|
149 if (aButtonId == EAknSoftkeyOk) |
|
150 { |
|
151 TInt vmbxSupport = 0; |
|
152 CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox ); |
|
153 vmbxSupported->Get( KVideoMbxSupport, vmbxSupport ); |
|
154 delete vmbxSupported; |
|
155 |
|
156 TInt vmbxPos; |
|
157 CRepository* vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox ); |
|
158 vmbxKey2->Get( KTelVideoMbxKey, vmbxPos ); |
|
159 TInt vdoIndex( iControl->Index( vmbxPos ) ); |
|
160 delete vmbxKey2; |
|
161 |
|
162 iDial = iControl->Number(iGrid->CurrentDataIndex()); |
|
163 TInt index(iGrid->CurrentDataIndex()); |
|
164 |
|
165 if ( iControl->VMBoxPosition() == index || ( vmbxSupport && vdoIndex == index ) ) |
|
166 { |
|
167 result = EFalse; |
|
168 } |
|
169 } |
|
170 return result; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CSpdiaGridDlg::OfferKeyEventL |
|
175 // |
|
176 // --------------------------------------------------------- |
|
177 // |
|
178 TKeyResponse CSpdiaGridDlg::OfferKeyEventL |
|
179 ( const TKeyEvent& aKeyEvent, |
|
180 TEventCode aType ) |
|
181 { |
|
182 TBool keyConsumed( EFalse ); |
|
183 if ( iGrid != NULL ) |
|
184 { |
|
185 TChar code( aKeyEvent.iCode ); |
|
186 |
|
187 TInt language = User::Language(); |
|
188 // When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order |
|
189 // is not followed. Instead, the browsing order is the same as in Western variants. |
|
190 if ( language == ELangUrdu /*|| language == ELangArabic*/ ) |
|
191 { |
|
192 if ( code == EKeyLeftArrow ) |
|
193 { |
|
194 TInt index = iGrid->CurrentDataIndex(); |
|
195 if ( index == KMaxIndex ) |
|
196 { |
|
197 iGrid->SetCurrentDataIndex( 0 ); |
|
198 LoadCbaL(); |
|
199 return EKeyWasConsumed; |
|
200 } |
|
201 } |
|
202 if ( code == EKeyRightArrow ) |
|
203 { |
|
204 TInt index = iGrid->CurrentDataIndex(); |
|
205 if ( index == 0 ) |
|
206 { |
|
207 iGrid->SetCurrentDataIndex(KMaxIndex); |
|
208 LoadCbaL(); |
|
209 return EKeyWasConsumed; |
|
210 } |
|
211 } |
|
212 } |
|
213 else |
|
214 { |
|
215 if ( code == EKeyRightArrow ) |
|
216 { |
|
217 TInt index = iGrid->CurrentDataIndex(); |
|
218 if(index == KMaxIndex) |
|
219 { |
|
220 iGrid->SetCurrentDataIndex(0); |
|
221 LoadCbaL(); |
|
222 return EKeyWasConsumed; |
|
223 } |
|
224 } |
|
225 if ( code == EKeyLeftArrow ) |
|
226 { |
|
227 TInt index = iGrid->CurrentDataIndex(); |
|
228 if ( index == 0 ) |
|
229 { |
|
230 iGrid->SetCurrentDataIndex(KMaxIndex); |
|
231 LoadCbaL(); |
|
232 return EKeyWasConsumed; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 if ( aKeyEvent.iScanCode == EStdKeyYes ) |
|
238 { |
|
239 return EKeyWasConsumed; |
|
240 } |
|
241 TKeyResponse exitCode( |
|
242 iGrid->OfferKeyEventL( aKeyEvent, aType) ); |
|
243 if ( exitCode != EKeyWasNotConsumed ) |
|
244 { |
|
245 if ( code.IsDigit() ) |
|
246 { |
|
247 if ( aKeyEvent.iCode - KShortcutKey0 > 0 ) |
|
248 { |
|
249 iGrid->SetCurrentDataIndex( |
|
250 iControl->Index(aKeyEvent.iCode - KShortcutKey0)); |
|
251 LoadCbaL(); |
|
252 keyConsumed = ETrue; |
|
253 } |
|
254 } |
|
255 else if (aKeyEvent.iCode == EKeyLeftArrow || |
|
256 aKeyEvent.iCode == EKeyRightArrow || |
|
257 aKeyEvent.iCode == EKeyUpArrow || |
|
258 aKeyEvent.iCode == EKeyDownArrow) |
|
259 { |
|
260 LoadCbaL(); |
|
261 keyConsumed = ETrue; |
|
262 } |
|
263 |
|
264 if ( aKeyEvent.iCode == EKeyEnter ) |
|
265 { |
|
266 TryExitL(EAknSoftkeyOk); |
|
267 keyConsumed = ETrue; |
|
268 } |
|
269 else if (aKeyEvent.iCode == EKeyEscape) |
|
270 { |
|
271 TryExitL(EAknSoftkeyBack); |
|
272 keyConsumed = ETrue; |
|
273 } |
|
274 } |
|
275 } |
|
276 |
|
277 if ( keyConsumed ) |
|
278 { |
|
279 return EKeyWasConsumed; |
|
280 } |
|
281 |
|
282 return CEikDialog::OfferKeyEventL(aKeyEvent, aType); |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------- |
|
286 // CSpdiaContainer::HandleDatabaseEventL |
|
287 // Handles an database event of type aEventType. |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 void CSpdiaGridDlg::HandleDatabaseEventL( |
|
291 TContactDbObserverEvent aEvent) |
|
292 { |
|
293 switch(aEvent.iType) |
|
294 { |
|
295 case EContactDbObserverEventContactChanged: |
|
296 case EContactDbObserverEventContactDeleted: |
|
297 case EContactDbObserverEventContactAdded: |
|
298 break; |
|
299 case EContactDbObserverEventSpeedDialsChanged: |
|
300 iNeedUpdate = ETrue; |
|
301 break; |
|
302 default: |
|
303 break; |
|
304 } |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CSpdiaGridDlg::FocusChanged() |
|
309 // Changes focus. |
|
310 // --------------------------------------------------------- |
|
311 // |
|
312 void CSpdiaGridDlg::FocusChanged(TDrawNow aDrawNow) |
|
313 { |
|
314 if (IsFocused() && aDrawNow == EDrawNow && iNeedUpdate) |
|
315 { |
|
316 TRAP_IGNORE(iControl->CreateDataL(*iGrid)); |
|
317 iNeedUpdate = EFalse; |
|
318 } |
|
319 } |
|
320 |
|
321 // --------------------------------------------------------- |
|
322 // CSpdiaGridDlg::LoadCbaL() |
|
323 // Loads CBA buttons. |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 void CSpdiaGridDlg::LoadCbaL() |
|
327 { |
|
328 TInt id(R_AVKON_SOFTKEYS_BACK); |
|
329 |
|
330 TInt vmbxSupport = 0; |
|
331 CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox ); |
|
332 vmbxSupported->Get( KVideoMbxSupport, vmbxSupport ); |
|
333 delete vmbxSupported; |
|
334 |
|
335 TInt vmbxPos; |
|
336 CRepository* vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox ); |
|
337 vmbxKey2->Get( KTelVideoMbxKey, vmbxPos ); |
|
338 TInt vdoIndex( iControl->Index( vmbxPos ) ); |
|
339 delete vmbxKey2; |
|
340 |
|
341 if ( iGrid->CurrentDataIndex() != iControl->VMBoxPosition() && |
|
342 ( !vmbxSupport || iGrid->CurrentDataIndex() != vdoIndex ) ) |
|
343 { |
|
344 id = R_SPDCTRL_SOFTKEYS_ASSIGN_BACK_ASSIGN; |
|
345 } |
|
346 if (id != iCbaID) |
|
347 { |
|
348 iCbaID = id; |
|
349 ButtonGroupContainer().SetCommandSetL(id); |
|
350 ButtonGroupContainer().DrawNow(); |
|
351 } |
|
352 iPrevIndex = iGrid->CurrentDataIndex(); |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------- |
|
356 // CSpdiaGridDlg::HandleResourceChange() |
|
357 // Handle layout and skin change event. |
|
358 // --------------------------------------------------------- |
|
359 // |
|
360 void CSpdiaGridDlg::HandleResourceChange( TInt aType ) |
|
361 { |
|
362 TRect mainPaneRect ; |
|
363 TRect statusPaneRect; |
|
364 |
|
365 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
366 { |
|
367 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
368 { |
|
369 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,mainPaneRect ); |
|
370 } |
|
371 else |
|
372 { |
|
373 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
374 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect ); |
|
375 mainPaneRect.iTl = statusPaneRect.iTl; |
|
376 } |
|
377 SetRect( mainPaneRect ); |
|
378 DrawNow(); |
|
379 } |
|
380 else if ( aType == KAknsMessageSkinChange ) |
|
381 { |
|
382 TRAP_IGNORE( iControl->CreateGridDataL( iGrid, KNullIndexData ) ); |
|
383 CAknDialog::HandleResourceChange( aType ); |
|
384 } |
|
385 else |
|
386 { |
|
387 CAknDialog::HandleResourceChange( aType ); |
|
388 } |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------- |
|
392 // CSpdiaGridDlg::HandleDialogPageEventL() |
|
393 // Handles the events on the dialog page (for Touch) |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 void CSpdiaGridDlg::HandleDialogPageEventL(TInt /*aEventId*/) |
|
397 { |
|
398 // When clicking on grid, the function will simulate the event |
|
399 // just like clicking on LSK |
|
400 TryExitL( EAknSoftkeyOk ); |
|
401 } |
|
402 // End of File |