author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 68 | 9da50d567e3c |
permissions | -rw-r--r-- |
63 | 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> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
47 |
#include <SpdCtrl.rsg> |
63 | 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 |
iButton1DownIndex = 0; |
|
87 |
} |
|
88 |
||
89 |
// ---------------------------------------------------- |
|
90 |
// CSpdiaGridDlg::PreLayoutDynInitL |
|
91 |
// |
|
92 |
// ---------------------------------------------------- |
|
93 |
// |
|
94 |
void CSpdiaGridDlg::PreLayoutDynInitL() |
|
95 |
{ |
|
96 |
iGrid = STATIC_CAST(CSpdiaGrid*, Control(ESpdGridItem)); |
|
97 |
||
98 |
CDesCArray* itemArray = STATIC_CAST(CDesCArray*, |
|
99 |
iGrid->Model()->ItemTextArray()); |
|
100 |
||
101 |
itemArray->Reset(); |
|
102 |
iControl->CreateDataL(*iGrid); // |
|
103 |
||
104 |
// Obsever |
|
105 |
CPbkContactEngine* pbkEngine = iControl->PbkEngine(); |
|
106 |
iPbkNotifier = pbkEngine->CreateContactChangeNotifierL(this); |
|
107 |
} |
|
108 |
||
109 |
// ---------------------------------------------------- |
|
110 |
// CSpdiaGridDlg::PostLayoutDynInitL |
|
111 |
// |
|
112 |
// ---------------------------------------------------- |
|
113 |
// |
|
114 |
void CSpdiaGridDlg::PostLayoutDynInitL() |
|
115 |
{ |
|
116 |
iControl->SetLayout(Rect()); |
|
117 |
if ( AknLayoutUtils::LayoutMirrored() ) |
|
118 |
{ |
|
119 |
iGrid->SetCurrentDataIndex(0); |
|
120 |
LoadCbaL(); |
|
121 |
} |
|
122 |
HandleResourceChange( KEikDynamicLayoutVariantSwitch ); |
|
123 |
} |
|
124 |
||
125 |
// --------------------------------------------------------- |
|
126 |
// CSpdiaGridDlg::CreateCustomControlL |
|
127 |
// |
|
128 |
// --------------------------------------------------------- |
|
129 |
// |
|
130 |
SEikControlInfo CSpdiaGridDlg::CreateCustomControlL(TInt aControlType) |
|
131 |
{ |
|
132 |
SEikControlInfo ctrlInfo; |
|
133 |
ctrlInfo.iControl=NULL; |
|
134 |
ctrlInfo.iTrailerTextId=0; |
|
135 |
ctrlInfo.iFlags = EEikControlHasEars; |
|
136 |
if (aControlType == ESpdiaGrid) |
|
137 |
{ |
|
138 |
ctrlInfo.iControl = CSpdiaGrid::NewL(*iControl); |
|
139 |
} |
|
140 |
return ctrlInfo; |
|
141 |
} |
|
142 |
// --------------------------------------------------------- |
|
143 |
// CSpdiaGridDlg::OkToExitL |
|
144 |
// |
|
145 |
// --------------------------------------------------------- |
|
146 |
// |
|
147 |
TBool CSpdiaGridDlg::OkToExitL(TInt aButtonId) // Pressed button id |
|
148 |
{ |
|
149 |
TBool result(ETrue); |
|
150 |
if (aButtonId == EAknSoftkeyOk) |
|
151 |
{ |
|
152 |
TInt vmbxSupport = 0; |
|
153 |
CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox ); |
|
154 |
vmbxSupported->Get( KVideoMbxSupport, vmbxSupport ); |
|
155 |
delete vmbxSupported; |
|
156 |
||
157 |
TInt vmbxPos; |
|
158 |
CRepository* vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox ); |
|
159 |
vmbxKey2->Get( KTelVideoMbxKey, vmbxPos ); |
|
160 |
TInt vdoIndex( iControl->Index( vmbxPos ) ); |
|
161 |
delete vmbxKey2; |
|
162 |
||
163 |
iDial = iControl->Number(iGrid->CurrentDataIndex()); |
|
164 |
TInt index(iGrid->CurrentDataIndex()); |
|
165 |
||
166 |
if ( iControl->VMBoxPosition() == index || ( vmbxSupport && vdoIndex == index ) ) |
|
167 |
{ |
|
168 |
result = EFalse; |
|
169 |
} |
|
170 |
} |
|
171 |
return result; |
|
172 |
} |
|
173 |
||
174 |
// --------------------------------------------------------- |
|
175 |
// CSpdiaGridDlg::OfferKeyEventL |
|
176 |
// |
|
177 |
// --------------------------------------------------------- |
|
178 |
// |
|
179 |
TKeyResponse CSpdiaGridDlg::OfferKeyEventL |
|
180 |
( const TKeyEvent& aKeyEvent, |
|
181 |
TEventCode aType ) |
|
182 |
{ |
|
183 |
TBool keyConsumed( EFalse ); |
|
184 |
if ( iGrid != NULL ) |
|
185 |
{ |
|
186 |
TChar code( aKeyEvent.iCode ); |
|
187 |
||
188 |
TInt language = User::Language(); |
|
189 |
// When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order |
|
190 |
// is not followed. Instead, the browsing order is the same as in Western variants. |
|
191 |
if ( language == ELangUrdu /*|| language == ELangArabic*/ ) |
|
192 |
{ |
|
193 |
if ( code == EKeyLeftArrow ) |
|
194 |
{ |
|
195 |
TInt index = iGrid->CurrentDataIndex(); |
|
196 |
if ( index == KMaxIndex ) |
|
197 |
{ |
|
198 |
iGrid->SetCurrentDataIndex( 0 ); |
|
199 |
LoadCbaL(); |
|
200 |
return EKeyWasConsumed; |
|
201 |
} |
|
202 |
} |
|
203 |
if ( code == EKeyRightArrow ) |
|
204 |
{ |
|
205 |
TInt index = iGrid->CurrentDataIndex(); |
|
206 |
if ( index == 0 ) |
|
207 |
{ |
|
208 |
iGrid->SetCurrentDataIndex(KMaxIndex); |
|
209 |
LoadCbaL(); |
|
210 |
return EKeyWasConsumed; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
if ( code == EKeyRightArrow ) |
|
217 |
{ |
|
218 |
TInt index = iGrid->CurrentDataIndex(); |
|
219 |
if(index == KMaxIndex) |
|
220 |
{ |
|
221 |
iGrid->SetCurrentDataIndex(0); |
|
222 |
LoadCbaL(); |
|
223 |
return EKeyWasConsumed; |
|
224 |
} |
|
225 |
} |
|
226 |
if ( code == EKeyLeftArrow ) |
|
227 |
{ |
|
228 |
TInt index = iGrid->CurrentDataIndex(); |
|
229 |
if ( index == 0 ) |
|
230 |
{ |
|
231 |
iGrid->SetCurrentDataIndex(KMaxIndex); |
|
232 |
LoadCbaL(); |
|
233 |
return EKeyWasConsumed; |
|
234 |
} |
|
235 |
} |
|
236 |
} |
|
237 |
||
238 |
if ( aKeyEvent.iScanCode == EStdKeyYes ) |
|
239 |
{ |
|
240 |
return EKeyWasConsumed; |
|
241 |
} |
|
242 |
TKeyResponse exitCode( |
|
243 |
iGrid->OfferKeyEventL( aKeyEvent, aType) ); |
|
244 |
if ( exitCode != EKeyWasNotConsumed ) |
|
245 |
{ |
|
246 |
if ( code.IsDigit() ) |
|
247 |
{ |
|
248 |
if ( aKeyEvent.iCode - KShortcutKey0 > 0 ) |
|
249 |
{ |
|
250 |
iGrid->SetCurrentDataIndex( |
|
251 |
iControl->Index(aKeyEvent.iCode - KShortcutKey0)); |
|
252 |
LoadCbaL(); |
|
253 |
keyConsumed = ETrue; |
|
254 |
} |
|
255 |
} |
|
256 |
else if (aKeyEvent.iCode == EKeyLeftArrow || |
|
257 |
aKeyEvent.iCode == EKeyRightArrow || |
|
258 |
aKeyEvent.iCode == EKeyUpArrow || |
|
259 |
aKeyEvent.iCode == EKeyDownArrow) |
|
260 |
{ |
|
261 |
LoadCbaL(); |
|
262 |
keyConsumed = ETrue; |
|
263 |
} |
|
264 |
||
265 |
if ( aKeyEvent.iCode == EKeyEnter ) |
|
266 |
{ |
|
267 |
TryExitL(EAknSoftkeyOk); |
|
268 |
keyConsumed = ETrue; |
|
269 |
} |
|
270 |
else if (aKeyEvent.iCode == EKeyEscape) |
|
271 |
{ |
|
272 |
TryExitL(EAknSoftkeyBack); |
|
273 |
keyConsumed = ETrue; |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
277 |
||
278 |
if ( keyConsumed ) |
|
279 |
{ |
|
280 |
return EKeyWasConsumed; |
|
281 |
} |
|
282 |
||
283 |
return CEikDialog::OfferKeyEventL(aKeyEvent, aType); |
|
284 |
} |
|
285 |
||
286 |
// --------------------------------------------------------- |
|
287 |
// CSpdiaContainer::HandleDatabaseEventL |
|
288 |
// Handles an database event of type aEventType. |
|
289 |
// --------------------------------------------------------- |
|
290 |
// |
|
291 |
void CSpdiaGridDlg::HandleDatabaseEventL( |
|
292 |
TContactDbObserverEvent aEvent) |
|
293 |
{ |
|
294 |
switch(aEvent.iType) |
|
295 |
{ |
|
296 |
case EContactDbObserverEventContactChanged: |
|
297 |
case EContactDbObserverEventContactDeleted: |
|
298 |
case EContactDbObserverEventContactAdded: |
|
299 |
break; |
|
300 |
case EContactDbObserverEventSpeedDialsChanged: |
|
301 |
iNeedUpdate = ETrue; |
|
302 |
break; |
|
303 |
default: |
|
304 |
break; |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
// --------------------------------------------------------- |
|
309 |
// CSpdiaGridDlg::FocusChanged() |
|
310 |
// Changes focus. |
|
311 |
// --------------------------------------------------------- |
|
312 |
// |
|
313 |
void CSpdiaGridDlg::FocusChanged(TDrawNow aDrawNow) |
|
314 |
{ |
|
315 |
if (IsFocused() && aDrawNow == EDrawNow && iNeedUpdate) |
|
316 |
{ |
|
317 |
TRAP_IGNORE(iControl->CreateDataL(*iGrid)); |
|
318 |
iNeedUpdate = EFalse; |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
// --------------------------------------------------------- |
|
323 |
// CSpdiaGridDlg::LoadCbaL() |
|
324 |
// Loads CBA buttons. |
|
325 |
// --------------------------------------------------------- |
|
326 |
// |
|
327 |
void CSpdiaGridDlg::LoadCbaL() |
|
328 |
{ |
|
329 |
TInt id(R_AVKON_SOFTKEYS_BACK); |
|
330 |
||
331 |
TInt vmbxSupport = 0; |
|
332 |
CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox ); |
|
333 |
vmbxSupported->Get( KVideoMbxSupport, vmbxSupport ); |
|
334 |
delete vmbxSupported; |
|
335 |
||
336 |
TInt vmbxPos; |
|
337 |
CRepository* vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox ); |
|
338 |
vmbxKey2->Get( KTelVideoMbxKey, vmbxPos ); |
|
339 |
TInt vdoIndex( iControl->Index( vmbxPos ) ); |
|
340 |
delete vmbxKey2; |
|
341 |
||
342 |
if ( iGrid->CurrentDataIndex() != iControl->VMBoxPosition() && |
|
343 |
( !vmbxSupport || iGrid->CurrentDataIndex() != vdoIndex ) ) |
|
344 |
{ |
|
345 |
id = R_SPDCTRL_SOFTKEYS_ASSIGN_BACK_ASSIGN; |
|
346 |
} |
|
347 |
if (id != iCbaID) |
|
348 |
{ |
|
349 |
iCbaID = id; |
|
350 |
ButtonGroupContainer().SetCommandSetL(id); |
|
351 |
ButtonGroupContainer().DrawNow(); |
|
352 |
} |
|
353 |
iPrevIndex = iGrid->CurrentDataIndex(); |
|
354 |
} |
|
355 |
||
356 |
// --------------------------------------------------------- |
|
357 |
// CSpdiaGridDlg::HandleResourceChange() |
|
358 |
// Handle layout and skin change event. |
|
359 |
// --------------------------------------------------------- |
|
360 |
// |
|
361 |
void CSpdiaGridDlg::HandleResourceChange( TInt aType ) |
|
362 |
{ |
|
363 |
TRect mainPaneRect ; |
|
364 |
TRect statusPaneRect; |
|
365 |
||
366 |
if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
367 |
{ |
|
368 |
CEikStatusPane* StatusPane = |
|
369 |
( ( CAknAppUi* ) CEikonEnv::Static()->EikAppUi() )->StatusPane(); |
|
370 |
||
371 |
if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
372 |
{ |
|
373 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,mainPaneRect ); |
|
374 |
StatusPane->DrawNow(); |
|
375 |
} |
|
376 |
else |
|
377 |
{ |
|
378 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
379 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect ); |
|
380 |
mainPaneRect.iTl = statusPaneRect.iTl; |
|
381 |
} |
|
382 |
SetRect( mainPaneRect ); |
|
383 |
DrawNow(); |
|
384 |
} |
|
385 |
else if ( aType == KAknsMessageSkinChange ) |
|
386 |
{ |
|
387 |
TRAP_IGNORE( iControl->CreateGridDataL( iGrid, KNullIndexData ) ); |
|
388 |
CAknDialog::HandleResourceChange( aType ); |
|
389 |
} |
|
390 |
else |
|
391 |
{ |
|
392 |
CAknDialog::HandleResourceChange( aType ); |
|
393 |
} |
|
394 |
} |
|
395 |
||
396 |
// --------------------------------------------------------- |
|
397 |
// CSpdiaGridDlg::HandlePointerEventL() |
|
398 |
// Handle the pointer events on the dialog page, instead of HandleDialogPageEventL. |
|
399 |
// Because HandleDialogPageEventL() can not handle the different pointer events. |
|
400 |
// Only when the index button down is the same with the index button up, assign is right action. |
|
401 |
// --------------------------------------------------------- |
|
402 |
// |
|
403 |
void CSpdiaGridDlg::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
404 |
{ |
|
405 |
iGrid->HandlePointerEventL( aPointerEvent ); |
|
406 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
407 |
{ |
|
408 |
iGrid->View()->XYPosToItemIndex( aPointerEvent.iPosition, iButton1DownIndex ); |
|
409 |
} |
|
410 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
411 |
{ |
|
412 |
TInt button1UpIndex = -1; |
|
413 |
iGrid->View()->XYPosToItemIndex( aPointerEvent.iPosition, button1UpIndex ); |
|
414 |
if( iButton1DownIndex == button1UpIndex ) |
|
415 |
{ |
|
416 |
TryExitL( EAknSoftkeyOk ); |
|
417 |
} |
|
418 |
} |
|
419 |
} |
|
420 |
// End of File |