author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2008 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <barsread.h> //resourcereader |
|
20 |
#include <lcdui.rsg> |
|
21 |
#include <lcdui.mbg> |
|
22 |
||
23 |
#include <aknbutton.h> |
|
24 |
#include <aknconsts.h> |
|
25 |
#include <gulicon.h> |
|
26 |
||
27 |
#include <layoutmetadata.cdl.h> |
|
28 |
#include <aknlayoutscalable_avkon.cdl.h> |
|
29 |
#include <data_caging_path_literals.hrh> |
|
30 |
#include <s60commonutils.h> |
|
31 |
||
32 |
#ifdef RD_TACTILE_FEEDBACK |
|
33 |
#include <touchfeedback.h> |
|
34 |
#endif // RD_TACTILE_FEEDBACK |
|
35 |
||
36 |
#include "CMIDCanvasKeypad.h" |
|
37 |
#include "CMIDDisplayable.h" |
|
38 |
#include "CMIDCanvas.h" |
|
39 |
#include "CMIDMenuHandler.h" |
|
40 |
||
41 |
#include <j2me/jdebug.h> |
|
42 |
||
43 |
_LIT(KLcduiBitmapResourceFileName, "lcdui.mif"); |
|
44 |
||
45 |
||
46 |
||
47 |
//Pointer Drag event dismiss rate (for performance reasons) |
|
48 |
const TInt KDragEventHandlingRate = 3;//every third drag event is handled |
|
49 |
//Alpha value for keypad/canvas separator lines |
|
50 |
const TInt KAlphaValue = 50; |
|
51 |
// Keyboard delays and repeat periods |
|
52 |
const TInt KFirstTimerExpiryInterval = KAknKeyboardRepeatInitialDelay; |
|
53 |
// For second time onwards ,the duration of the time interval. |
|
54 |
const TInt KTimerExpiryInterval = KAknStandardKeyboardRepeatRate; |
|
55 |
||
56 |
// Constants for tap timers, interval timer |
|
57 |
const TInt KFirstTapTimerExpiryInterval = 10000; // 10 ms |
|
58 |
const TInt KTapTimerExpiryInterval = 10000; // 10 ms |
|
59 |
// Max tap counter KTapMaxCnt*KTapTimerExpiryInterval |
|
60 |
const TInt KTapMaxCnt = 8; |
|
61 |
||
62 |
CMIDCanvasKeypad::~CMIDCanvasKeypad() |
|
63 |
{ |
|
64 |
DeleteButtons(); |
|
65 |
iButtonData.Close(); |
|
66 |
iCurrentButtonData.Close(); |
|
67 |
iButtonStack.Close(); |
|
68 |
||
69 |
if (iRepeatTimer) |
|
70 |
{ |
|
71 |
iRepeatTimer->Cancel(); |
|
72 |
delete iRepeatTimer; |
|
73 |
iRepeatTimer = NULL; |
|
74 |
} |
|
75 |
// stop and destroy event timer |
|
76 |
if (iTapTimer) |
|
77 |
{ |
|
78 |
iTapTimer->Cancel(); |
|
79 |
delete iTapTimer; |
|
80 |
iTapTimer = NULL; |
|
81 |
} |
|
82 |
||
83 |
iOSKInBackground = EFalse; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
84 |
if (iBackgroundCC) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
85 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
86 |
delete iBackgroundCC; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
87 |
iBackgroundCC = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
88 |
} |
66 | 89 |
} |
90 |
TInt CMIDCanvasKeypad::CountComponentControls() const |
|
91 |
{ |
|
92 |
return iCurrentButtonData.Count(); |
|
93 |
} |
|
94 |
||
95 |
CCoeControl* CMIDCanvasKeypad::ComponentControl(TInt aIndex) const |
|
96 |
{ |
|
97 |
if (aIndex < iCurrentButtonData.Count()) |
|
98 |
{ |
|
99 |
return iCurrentButtonData[aIndex]->iButton; |
|
100 |
} |
|
101 |
return NULL; |
|
102 |
} |
|
103 |
||
104 |
void CMIDCanvasKeypad::SizeChanged() |
|
105 |
{ |
|
106 |
SetRectForAllButtons(); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
107 |
if (iBackgroundCC) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
108 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
109 |
delete iBackgroundCC; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
110 |
iBackgroundCC = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
111 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
112 |
TRAP_IGNORE(iBackgroundCC = CAknsBasicBackgroundControlContext::NewL( |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
113 |
KAknsIIDQsnBgScreen, |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
114 |
Rect(), |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
115 |
EFalse)); |
66 | 116 |
} |
117 |
||
118 |
void CMIDCanvasKeypad::ButtonPriorityQueue(TInt aIdx) |
|
119 |
{ |
|
120 |
// Argument aIdx stored index of last pressed key on OSK. |
|
121 |
// Key was hit on the last is set to first in iButtonStack array. |
|
122 |
// Loop started from index aIdx. |
|
123 |
if (aIdx < iButtonStack.Count()) |
|
124 |
{ |
|
125 |
for (TInt i = aIdx; i > 0 ; i--) |
|
126 |
{ |
|
127 |
TInt tmp = iButtonStack[i]; |
|
128 |
iButtonStack[i] = iButtonStack[i-1]; |
|
129 |
iButtonStack[i-1] = tmp; |
|
130 |
} |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
void CMIDCanvasKeypad::HandlePointerEventL(const TPointerEvent &aPointerEvent) |
|
135 |
{ |
|
136 |
// Because of performance reasons we do not handle all the drag events |
|
137 |
if (aPointerEvent.iType == TPointerEvent::EDrag) |
|
138 |
{ |
|
139 |
if (iDrag < KDragEventHandlingRate) |
|
140 |
{ |
|
141 |
iDrag++; |
|
142 |
return; |
|
143 |
} |
|
144 |
else |
|
145 |
{ |
|
146 |
iDrag = 0; |
|
147 |
} |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
iDrag = 0; |
|
152 |
} |
|
153 |
if (iOSKInBackground) |
|
154 |
{ |
|
155 |
return; |
|
156 |
} |
|
157 |
TButtonData* oldRockerKey = iCurrentRockerKey; |
|
158 |
TButtonData* newRockerKey = NULL; |
|
159 |
// Indicates which area of the keypad (ERockerKey, EOtherKey or ENoneKey) |
|
160 |
// should handle the pointer event. |
|
161 |
TButtonPress keypadArea = ENoneKey; |
|
162 |
||
163 |
// Rocker keys are: up, down, left right and fire. |
|
164 |
// Other keys are: Game_A, Game_B, Game_C, Game_D, LSK and RSK. |
|
165 |
// 'Rocker keys' are handled differently than 'other keys' |
|
166 |
// When 'Other key' is pressed all the events are delivered to it |
|
167 |
// until the 'Other key' is released. When rocker key is pressed dragging |
|
168 |
// the pointer between rocker keys will also cause changes in button states. |
|
169 |
||
170 |
// If any of the 'Other keys' is not pressed already, |
|
171 |
// then we find out which On Screen Keypad key (if any) was hit by pointer event. |
|
172 |
if (!iCurrentOtherKey) |
|
173 |
{ |
|
174 |
TInt buttonCount = iCurrentButtonData.Count(); |
|
175 |
TInt i; |
|
176 |
||
177 |
// Array iButtonStack stored indexes of all OSK buttons. |
|
178 |
// Because of performance reasons we used iButtonStack array |
|
179 |
// for priority level sets. Key was hit on the last is set to first. |
|
180 |
for (i = 0; i < buttonCount ; i++) |
|
181 |
{ |
|
182 |
if (iCurrentButtonData[ iButtonStack[i] ]->keyType < ENavigationKeysNumberOfButtons) |
|
183 |
{ |
|
184 |
const MCoeControlHitTest* buttonHitArea = iCurrentButtonData[ iButtonStack[i] ]->iButton->HitTest(); |
|
185 |
||
186 |
// Select rocker key. Method HitRegionContains recognized which button pressed. |
|
187 |
if (iRockerRect.Contains(aPointerEvent.iPosition) && |
|
188 |
buttonHitArea->HitRegionContains(aPointerEvent.iPosition, *this)) |
|
189 |
{ |
|
190 |
keypadArea = ERockerKey; |
|
191 |
newRockerKey = iCurrentButtonData[ iButtonStack[i] ]; |
|
192 |
break; |
|
193 |
} |
|
194 |
} |
|
195 |
else if (iCurrentButtonData[ iButtonStack[i] ]->keyType > ENavigationKeysNumberOfButtons) |
|
196 |
{ |
|
197 |
// Select other key. Method Contains from Rect() recognized which button pressed. |
|
198 |
if (iCurrentButtonData[ iButtonStack[i] ]->iButton->Rect().Contains(aPointerEvent.iPosition)) |
|
199 |
{ |
|
200 |
if (iCurrentRockerKey) |
|
201 |
{ |
|
202 |
// Pointer event hits 'Other key', but because currently some rocker key is active |
|
203 |
// the pointer event is handled in the rocker keys. |
|
204 |
keypadArea = ERockerKey; |
|
205 |
} |
|
206 |
else if (!iCurrentRockerKey && |
|
207 |
aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
208 |
{ |
|
209 |
keypadArea = EOtherKey; |
|
210 |
iCurrentOtherKey = iCurrentButtonData[ iButtonStack[i] ]; |
|
211 |
} |
|
212 |
break; |
|
213 |
} |
|
214 |
} |
|
215 |
||
216 |
} |
|
217 |
||
218 |
ButtonPriorityQueue(i); |
|
219 |
} |
|
220 |
else // This means that 'Other key' is already pressed so this event is handled there. |
|
221 |
{ |
|
222 |
keypadArea = EOtherKey; |
|
223 |
} |
|
224 |
||
225 |
TKeyResponse response = EKeyWasNotConsumed; |
|
226 |
||
227 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
228 |
iDragBetweenArrowKeys = EFalse; |
|
229 |
iDragOutsideArrowKeys = EFalse; |
|
230 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
231 |
||
232 |
switch (keypadArea) |
|
233 |
{ |
|
234 |
case ENoneKey: |
|
235 |
{ |
|
236 |
// Rocker key is released when pointer is dragged outside rocker keys area |
|
237 |
if (iCurrentRockerKey) |
|
238 |
{ |
|
239 |
iRepeatTimer->Cancel(); |
|
240 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
241 |
iDragOutsideArrowKeys = ETrue; |
|
242 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
243 |
response = RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent, EEventKeyUp); |
|
244 |
iCurrentRockerKey->iKeyEvent_2.iRepeats = 0; |
|
245 |
iCurrentRockerKey->iButton->SetCurrentState(0, ETrue); |
|
246 |
iCurrentRockerKey = NULL; |
|
247 |
return; |
|
248 |
} |
|
249 |
break; |
|
250 |
} |
|
251 |
case ERockerKey: |
|
252 |
{ |
|
253 |
//Fire button:Ignore drag from rocker arrows to Fire button i.e. drag allowed only among rocker arrow keys |
|
254 |
if (newRockerKey && newRockerKey->keyType == ENavigationKeysFire && |
|
255 |
aPointerEvent.iType == TPointerEvent::EDrag) |
|
256 |
{ |
|
257 |
return; |
|
258 |
} |
|
259 |
// Rocker key changes from one to another, so we cancel the timer and post up event for the old rocker key etc. |
|
260 |
if (iCurrentRockerKey && newRockerKey != iCurrentRockerKey) |
|
261 |
{ |
|
262 |
iRepeatTimer->Cancel(); |
|
263 |
oldRockerKey = iCurrentRockerKey; |
|
264 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
265 |
iDragBetweenArrowKeys = ETrue; |
|
266 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
267 |
response = RaiseOfferKeyEventL(oldRockerKey->iKeyEvent, EEventKeyUp); |
|
268 |
oldRockerKey->iKeyEvent_2.iRepeats = 0; |
|
269 |
//change button state, refresh rocker keys area |
|
270 |
ChangeStatus(EFalse, oldRockerKey); |
|
271 |
} |
|
272 |
//Fire button:iCurrentRockerKey is changed only for arrow rocker keys |
|
273 |
if (newRockerKey && |
|
274 |
!(newRockerKey->keyType == ENavigationKeysFire && |
|
275 |
aPointerEvent.iType == TPointerEvent::EButton1Up)) |
|
276 |
{ |
|
277 |
iCurrentRockerKey = newRockerKey; |
|
278 |
} |
|
279 |
// New rocker key pressed. Posts EEventKeyDown and EEventKey events and then starts repeating. |
|
280 |
if ((aPointerEvent.iType == TPointerEvent::EButton1Down || |
|
281 |
aPointerEvent.iType == TPointerEvent::EDrag) && |
|
282 |
iCurrentRockerKey && (oldRockerKey != iCurrentRockerKey)) |
|
283 |
{ |
|
284 |
iRepeatTimer->Cancel(); |
|
285 |
// If fire button pressed in normal mode Canvas, then we try to execute a Command |
|
286 |
if (iCurrentRockerKey->keyType == ENavigationKeysFire && !iIsFullScreenMode && !iSelectionKeyCompatibility) |
|
287 |
{ |
|
288 |
response = RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent, EEventKeyDown); |
|
289 |
||
290 |
//change button state, refresh rocker keys area |
|
291 |
ChangeStatus(ETrue, iCurrentRockerKey); |
|
292 |
} |
|
293 |
else |
|
294 |
{ |
|
295 |
iStoreKeyDownEvent = aPointerEvent; |
|
296 |
RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent, EEventKeyDown); |
|
297 |
response = RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent_2, EEventKey, EFalse); |
|
298 |
||
299 |
if (response == EKeyWasNotConsumed) |
|
300 |
{ |
|
301 |
iCurrentRockerKey->iKeyEvent_2.iRepeats = 1; |
|
302 |
iRepeatTimer->Start(KFirstTimerExpiryInterval, KTimerExpiryInterval, |
|
303 |
TCallBack(RepeatTimerCallbackL, this)); |
|
304 |
} |
|
305 |
//change button state, refresh rocker keys area |
|
306 |
ChangeStatus(ETrue, iCurrentRockerKey); |
|
307 |
} |
|
308 |
} |
|
309 |
||
310 |
// Rocker key released. Cancels (possible) repeating and then posts corresponding key up event. |
|
311 |
else if (aPointerEvent.iType == TPointerEvent::EButton1Up && iCurrentRockerKey) |
|
312 |
{ |
|
313 |
iRepeatTimer->Cancel(); |
|
314 |
response = RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent, EEventKeyUp); |
|
315 |
iCurrentRockerKey->iKeyEvent_2.iRepeats = 0; |
|
316 |
//change button state, refresh rocker keys area |
|
317 |
ChangeStatus(EFalse, iCurrentRockerKey); |
|
318 |
iCurrentRockerKey = NULL; |
|
319 |
} |
|
320 |
break; |
|
321 |
} |
|
322 |
case EOtherKey: |
|
323 |
{ |
|
324 |
// Drag events are not handled at all. |
|
325 |
if (aPointerEvent.iType == TPointerEvent::EDrag) |
|
326 |
{ |
|
327 |
return; |
|
328 |
} |
|
329 |
||
330 |
// Other key is pressed. Posts EEventKeyDown and EEventKey events and then starts repeating. |
|
331 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
332 |
{ |
|
333 |
iStoreKeyDownEvent = aPointerEvent; |
|
334 |
iRepeatTimer->Cancel(); |
|
335 |
RaiseOfferKeyEventL(iCurrentOtherKey->iKeyEvent, EEventKeyDown); |
|
336 |
response = RaiseOfferKeyEventL(iCurrentOtherKey->iKeyEvent_2, EEventKey, EFalse); |
|
337 |
||
338 |
if (response == EKeyWasNotConsumed) |
|
339 |
{ |
|
340 |
iCurrentOtherKey->iKeyEvent_2.iRepeats = 1; |
|
341 |
iRepeatTimer->Start(KFirstTimerExpiryInterval, KTimerExpiryInterval, |
|
342 |
TCallBack(RepeatTimerCallbackL, this)); |
|
343 |
} |
|
344 |
} |
|
345 |
// Other key is released. Cancels (possible) repeating and then posts corresponding key up event etc. |
|
346 |
else if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
347 |
{ |
|
348 |
iRepeatTimer->Cancel(); |
|
349 |
response = RaiseOfferKeyEventL(iCurrentOtherKey->iKeyEvent, EEventKeyUp); |
|
350 |
iCurrentOtherKey->iKeyEvent_2.iRepeats = 0; |
|
351 |
iCurrentOtherKey = NULL; |
|
352 |
} |
|
353 |
||
354 |
// Forwards pointer event to CCoeControl if we did not consume the event. |
|
355 |
if (response == EKeyWasNotConsumed) |
|
356 |
{ |
|
357 |
CCoeControl::HandlePointerEventL(aPointerEvent); |
|
358 |
} |
|
359 |
break; |
|
360 |
} |
|
361 |
default: |
|
362 |
{ |
|
363 |
return; |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
} |
|
368 |
||
369 |
void CMIDCanvasKeypad::UpdateVisualAppearanceL(CMIDCanvas& aCanvas, TInt aKeypadType, MMIDDisplayable& aDisplayable) |
|
370 |
{ |
|
371 |
if (aKeypadType <= EKeypadValueNo) |
|
372 |
{ |
|
373 |
return; |
|
374 |
} |
|
375 |
||
376 |
TRect screenRect; |
|
377 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect); |
|
378 |
||
379 |
iCanvas = static_cast<CMIDCanvas*>(&aCanvas); |
|
380 |
iSelectionKeyCompatibility = iCanvas->SelectionKeyCompatibility(); |
|
381 |
iKeypadType = aKeypadType; |
|
382 |
iDisplayable = static_cast<CMIDDisplayable*>(&aDisplayable); |
|
383 |
SetMopParent(iDisplayable); |
|
384 |
iIsFullScreenMode = iDisplayable->IsFullScreenMode(); |
|
385 |
ResetButtons(); |
|
386 |
TBool oldIsPortrait = iIsPortrait; |
|
387 |
UpdateKeypadPaneRect(); |
|
388 |
||
389 |
if ((iScreenRect != screenRect) || (oldIsPortrait != iIsPortrait)) |
|
390 |
{ |
|
391 |
iScreenRect = screenRect; |
|
392 |
} |
|
393 |
SetRectForAllButtons();//Needed for updating OSK-buttons when closing/opening hw-keyboard |
|
394 |
CreateButtonsL(); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
395 |
InitializeKeys(); |
66 | 396 |
ActivateL(); // Window owning control draws all children (buttons) |
397 |
MakeVisible(ETrue); |
|
398 |
DrawDeferred(); |
|
399 |
iOSKInBackground = EFalse; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
400 |
if (iBackgroundCC) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
401 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
402 |
delete iBackgroundCC; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
403 |
iBackgroundCC = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
404 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
405 |
TRAP_IGNORE(iBackgroundCC = CAknsBasicBackgroundControlContext::NewL( |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
406 |
KAknsIIDQsnBgScreen, |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
407 |
Rect(), |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
408 |
EFalse)); |
66 | 409 |
} |
410 |
||
411 |
void CMIDCanvasKeypad::Draw(const TRect& /*aRect*/) const |
|
412 |
{ |
|
413 |
CWindowGc& gc = SystemGc(); |
|
414 |
//Drawing skin |
|
415 |
gc.SetBrushColor(TRgb(0x0)); //black |
|
416 |
if (!iIsFullScreenMode) //normal mode |
|
417 |
{ |
|
418 |
AknsDrawUtils::DrawBackground(AknsUtils::SkinInstance(), |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
419 |
iBackgroundCC, |
66 | 420 |
NULL, |
421 |
gc, |
|
422 |
TPoint(0,0), |
|
423 |
Rect(), |
|
424 |
KAknsDrawParamDefault); |
|
425 |
gc.SetPenColor(TRgb(0x0, KAlphaValue)); |
|
426 |
} |
|
427 |
else //full screen mode |
|
428 |
{ |
|
429 |
AknsDrawUtils::DrawBackground(NULL, |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
430 |
iBackgroundCC, |
66 | 431 |
NULL, |
432 |
gc, |
|
433 |
TPoint(0,0), |
|
434 |
Rect(), |
|
435 |
KAknsDrawParamDefault); |
|
436 |
gc.SetPenColor(TRgb(0xFF, KAlphaValue)); |
|
437 |
} |
|
438 |
||
439 |
//Drawing separator lines |
|
440 |
if (iIsPortrait) |
|
441 |
{ |
|
442 |
gc.DrawLine(TPoint(0,0), TPoint(Size().iWidth,0)); |
|
443 |
} |
|
444 |
else //landscape |
|
445 |
{ |
|
446 |
//left separator |
|
447 |
if (iCanvas->PositionRelativeToScreen().iX > 0) |
|
448 |
{ |
|
449 |
gc.DrawLine(TPoint(iCanvas->PositionRelativeToScreen().iX - 1, 0), |
|
450 |
TPoint(iCanvas->PositionRelativeToScreen().iX - 1, |
|
451 |
iCanvas->Size().iHeight)); |
|
452 |
} |
|
453 |
//right separator |
|
454 |
gc.DrawLine(TPoint(iCanvas->PositionRelativeToScreen().iX + iCanvas->Size().iWidth, 0), |
|
455 |
TPoint(iCanvas->PositionRelativeToScreen().iX + iCanvas->Size().iWidth, |
|
456 |
iCanvas->Size().iHeight)); |
|
457 |
} |
|
458 |
} |
|
459 |
||
460 |
CMIDCanvasKeypad* CMIDCanvasKeypad::NewL(MMIDDisplayable* aDisplayable) |
|
461 |
{ |
|
462 |
if (!aDisplayable) |
|
463 |
{ |
|
464 |
User::Leave(KErrArgument); |
|
465 |
} |
|
466 |
CMIDCanvasKeypad* self = new(ELeave) CMIDCanvasKeypad(); |
|
467 |
CleanupStack::PushL(self); |
|
468 |
self->ConstructL(aDisplayable); |
|
469 |
CleanupStack::Pop(self); |
|
470 |
return self; |
|
471 |
} |
|
472 |
||
473 |
void CMIDCanvasKeypad::ConstructL(MMIDDisplayable* aDisplayable) |
|
474 |
{ |
|
475 |
iDisplayable = static_cast< CMIDDisplayable* >(aDisplayable); |
|
476 |
// Timer for implementing key repeat feature. |
|
477 |
iRepeatTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
478 |
// Timer for implementing tap counter feature. |
|
479 |
iTapTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
480 |
iTapCnt = -1; |
|
481 |
CreateWindowL(); |
|
482 |
SetComponentsToInheritVisibility(ETrue); |
|
483 |
Window().SetPointerGrab(ETrue); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
484 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
485 |
TRAP_IGNORE(iBackgroundCC = CAknsBasicBackgroundControlContext::NewL( |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
486 |
KAknsIIDQsnBgScreen, |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
487 |
Rect(), |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
488 |
EFalse)); |
66 | 489 |
} |
490 |
||
491 |
CMIDCanvasKeypad::CMIDCanvasKeypad() |
|
492 |
{ |
|
493 |
} |
|
494 |
||
495 |
void CMIDCanvasKeypad::DeleteButtons() |
|
496 |
{ |
|
497 |
TInt buttonCount = iButtonData.Count(); |
|
498 |
||
499 |
for (TInt i = 0; i < buttonCount; i++) |
|
500 |
{ |
|
501 |
delete iButtonData[i].iButton; |
|
502 |
iButtonData[i].iButton = NULL; |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
void CMIDCanvasKeypad::CreateButtonsL() |
|
507 |
{ |
|
508 |
DeleteButtons(); |
|
509 |
iButtonData.Reset(); |
|
510 |
iCurrentButtonData.Reset(); |
|
511 |
||
512 |
if (iKeypadType != EKeypadValueLskRsk) |
|
513 |
{ |
|
514 |
TResourceReader reader; |
|
515 |
CCoeEnv::Static()->CreateResourceReaderLC(reader, R_ONSCREEN_KEYBOARD_ROCKER_BUTTONS); |
|
516 |
TInt numButtons(reader.ReadInt16()); |
|
517 |
||
518 |
for (TInt i = 0; i < numButtons; i++) |
|
519 |
{ |
|
520 |
TButtonData buttonData; |
|
521 |
buttonData.iButton = CAknButton::NewL(); |
|
522 |
CleanupStack::PushL(buttonData.iButton); |
|
523 |
buttonData.iButton->ConstructFromResourceL(reader); |
|
524 |
buttonData.iButton->SetContainerWindowL(*this); |
|
525 |
buttonData.iButton->SetExtent(iRockerRect.iTl, iRockerRect.Size()); |
|
526 |
buttonData.iButton->ActivateL(); |
|
527 |
InitializeKeyEvents(TKeypadKeys(i), &buttonData); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
528 |
iButtonData.Append(buttonData); |
66 | 529 |
CleanupStack::Pop(buttonData.iButton); |
530 |
} |
|
531 |
CleanupStack::PopAndDestroy(); // reader; |
|
532 |
} |
|
533 |
||
534 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
535 |
CFbsBitmap* bitmap(NULL); |
|
536 |
CFbsBitmap* mask(NULL); |
|
537 |
// Get icon ids. |
|
538 |
TAknsItemID skinItemId(KAknsIIDNone); |
|
539 |
||
540 |
TFileName fileName; |
|
541 |
fileName.Append(KDC_APP_BITMAP_DIR); |
|
542 |
fileName.Append(KLcduiBitmapResourceFileName); |
|
543 |
fileName = java::util::S60CommonUtils::VerifiedFileNameL(fileName); |
|
544 |
||
545 |
if (iKeypadType == EKeypadValueGameActions) |
|
546 |
{ |
|
547 |
//GameA |
|
548 |
AknsUtils::CreateColorIconLC( |
|
549 |
skin, |
|
550 |
skinItemId, |
|
551 |
KAknsIIDQsnIconColors, |
|
552 |
EAknsCIQsnIconColorsCG30, |
|
553 |
bitmap, |
|
554 |
mask, |
|
555 |
fileName, |
|
556 |
EMbmLcduiQgn_indi_game_a, |
|
557 |
EMbmLcduiQgn_indi_game_a_mask, |
|
558 |
KRgbBlack |
|
559 |
); |
|
560 |
||
561 |
CGulIcon* iconA = CGulIcon::NewL(bitmap, mask); |
|
562 |
//Ownership of bitmap and mask transferred |
|
563 |
CleanupStack::Pop(2); //bitmap, mask |
|
564 |
CleanupStack::PushL(iconA); |
|
565 |
TButtonData buttonDataGameA; |
|
566 |
buttonDataGameA.iButton = CAknButton::NewL( |
|
567 |
iconA , // ownership taken |
|
568 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
569 |
buttonDataGameA.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
570 |
buttonDataGameA.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
571 |
CleanupStack::Pop(iconA); |
|
572 |
||
573 |
||
574 |
buttonDataGameA.iButton->SetContainerWindowL(*this); |
|
575 |
buttonDataGameA.iButton->SetExtent(iGameARect.iTl, iGameARect.Size()); |
|
576 |
buttonDataGameA.iButton->ActivateL(); |
|
577 |
InitializeKeyEvents(EGameA, &buttonDataGameA); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
578 |
iButtonData.Append(buttonDataGameA); |
66 | 579 |
|
580 |
//GameB |
|
581 |
bitmap = NULL; |
|
582 |
mask =NULL; |
|
583 |
AknsUtils::CreateColorIconLC( |
|
584 |
skin, |
|
585 |
skinItemId, |
|
586 |
KAknsIIDQsnIconColors, |
|
587 |
EAknsCIQsnIconColorsCG30, |
|
588 |
bitmap, |
|
589 |
mask, |
|
590 |
fileName, |
|
591 |
EMbmLcduiQgn_indi_game_b, |
|
592 |
EMbmLcduiQgn_indi_game_b_mask, |
|
593 |
KRgbBlack |
|
594 |
); |
|
595 |
||
596 |
CGulIcon* iconB = CGulIcon::NewL(bitmap, mask); |
|
597 |
//Ownership of bitmap and mask transferred |
|
598 |
CleanupStack::Pop(2); //bitmap, mask |
|
599 |
CleanupStack::PushL(iconB); |
|
600 |
TButtonData buttonDataGameB; |
|
601 |
buttonDataGameB.iButton = CAknButton::NewL( |
|
602 |
iconB , // ownership taken |
|
603 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
604 |
buttonDataGameB.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
605 |
buttonDataGameB.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
606 |
CleanupStack::Pop(iconB); |
|
607 |
||
608 |
||
609 |
buttonDataGameB.iButton->SetContainerWindowL(*this); |
|
610 |
buttonDataGameB.iButton->SetExtent(iGameBRect.iTl, iGameBRect.Size()); |
|
611 |
buttonDataGameB.iButton->ActivateL(); |
|
612 |
InitializeKeyEvents(EGameB, &buttonDataGameB); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
613 |
iButtonData.Append(buttonDataGameB); |
66 | 614 |
|
615 |
//GameC |
|
616 |
bitmap = NULL; |
|
617 |
mask =NULL; |
|
618 |
AknsUtils::CreateColorIconLC( |
|
619 |
skin, |
|
620 |
skinItemId, |
|
621 |
KAknsIIDQsnIconColors, |
|
622 |
EAknsCIQsnIconColorsCG30, |
|
623 |
bitmap, |
|
624 |
mask, |
|
625 |
fileName, |
|
626 |
EMbmLcduiQgn_indi_game_c, |
|
627 |
EMbmLcduiQgn_indi_game_c_mask, |
|
628 |
KRgbBlack |
|
629 |
); |
|
630 |
||
631 |
CGulIcon* iconC = CGulIcon::NewL(bitmap, mask); |
|
632 |
//Ownership of bitmap and mask transferred |
|
633 |
CleanupStack::Pop(2); //bitmap, mask |
|
634 |
CleanupStack::PushL(iconC); |
|
635 |
TButtonData buttonDataGameC; |
|
636 |
buttonDataGameC.iButton = CAknButton::NewL( |
|
637 |
iconC , // ownership taken |
|
638 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
639 |
buttonDataGameC.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
640 |
buttonDataGameC.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
641 |
CleanupStack::Pop(iconC); |
|
642 |
||
643 |
||
644 |
buttonDataGameC.iButton->SetContainerWindowL(*this); |
|
645 |
buttonDataGameC.iButton->SetExtent(iGameCRect.iTl, iGameCRect.Size()); |
|
646 |
buttonDataGameC.iButton->ActivateL(); |
|
647 |
InitializeKeyEvents(EGameC, &buttonDataGameC); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
648 |
iButtonData.Append(buttonDataGameC); |
66 | 649 |
|
650 |
//GameD |
|
651 |
bitmap = NULL; |
|
652 |
mask =NULL; |
|
653 |
AknsUtils::CreateColorIconLC( |
|
654 |
skin, |
|
655 |
skinItemId, |
|
656 |
KAknsIIDQsnIconColors, |
|
657 |
EAknsCIQsnIconColorsCG30, |
|
658 |
bitmap, |
|
659 |
mask, |
|
660 |
fileName, |
|
661 |
EMbmLcduiQgn_indi_game_d, |
|
662 |
EMbmLcduiQgn_indi_game_d_mask, |
|
663 |
KRgbBlack |
|
664 |
); |
|
665 |
||
666 |
CGulIcon* iconD = CGulIcon::NewL(bitmap, mask); |
|
667 |
//Ownership of bitmap and mask transferred |
|
668 |
CleanupStack::Pop(2); //bitmap, mask |
|
669 |
CleanupStack::PushL(iconD); |
|
670 |
TButtonData buttonDataGameD; |
|
671 |
buttonDataGameD.iButton = CAknButton::NewL( |
|
672 |
iconD , // ownership taken |
|
673 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
674 |
buttonDataGameD.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
675 |
buttonDataGameD.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
676 |
CleanupStack::Pop(iconD); |
|
677 |
||
678 |
buttonDataGameD.iButton->SetContainerWindowL(*this); |
|
679 |
buttonDataGameD.iButton->SetExtent(iGameDRect.iTl, iGameDRect.Size()); |
|
680 |
buttonDataGameD.iButton->ActivateL(); |
|
681 |
InitializeKeyEvents(EGameD, &buttonDataGameD); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
682 |
iButtonData.Append(buttonDataGameD); |
66 | 683 |
} |
684 |
||
685 |
//LSK & RSK buttons |
|
686 |
TButtonData buttonDataLSK; |
|
687 |
TButtonData buttonDataRSK; |
|
688 |
||
689 |
if (iIsPortrait) |
|
690 |
{ |
|
691 |
//LSK |
|
692 |
bitmap = NULL; |
|
693 |
mask =NULL; |
|
694 |
AknsUtils::CreateColorIconLC( |
|
695 |
skin, |
|
696 |
skinItemId, |
|
697 |
KAknsIIDQsnIconColors, |
|
698 |
EAknsCIQsnIconColorsCG30, |
|
699 |
bitmap, |
|
700 |
mask, |
|
701 |
fileName, |
|
702 |
EMbmLcduiQgn_indi_lsk_horizontal, |
|
703 |
EMbmLcduiQgn_indi_lsk_horizontal_mask, |
|
704 |
KRgbBlack |
|
705 |
); |
|
706 |
||
707 |
CGulIcon* iconLsk = CGulIcon::NewL(bitmap, mask); |
|
708 |
//Ownership of bitmap and mask transferred |
|
709 |
CleanupStack::Pop(2); //bitmap, mask |
|
710 |
CleanupStack::PushL(iconLsk); |
|
711 |
buttonDataLSK.iButton = CAknButton::NewL( |
|
712 |
iconLsk , // ownership taken |
|
713 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
714 |
buttonDataLSK.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
715 |
buttonDataLSK.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
716 |
CleanupStack::Pop(iconLsk); |
|
717 |
||
718 |
//RSK |
|
719 |
bitmap = NULL; |
|
720 |
mask =NULL; |
|
721 |
AknsUtils::CreateColorIconLC( |
|
722 |
skin, |
|
723 |
skinItemId, |
|
724 |
KAknsIIDQsnIconColors, |
|
725 |
EAknsCIQsnIconColorsCG30, |
|
726 |
bitmap, |
|
727 |
mask, |
|
728 |
fileName, |
|
729 |
EMbmLcduiQgn_indi_rsk_horizontal, |
|
730 |
EMbmLcduiQgn_indi_rsk_horizontal_mask, |
|
731 |
KRgbBlack |
|
732 |
); |
|
733 |
||
734 |
CGulIcon* iconRsk = CGulIcon::NewL(bitmap, mask); |
|
735 |
//Ownership of bitmap and mask transferred |
|
736 |
CleanupStack::Pop(2); //bitmap, mask |
|
737 |
CleanupStack::PushL(iconRsk); |
|
738 |
buttonDataRSK.iButton = CAknButton::NewL( |
|
739 |
iconRsk , // ownership taken |
|
740 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
741 |
buttonDataRSK.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
742 |
buttonDataRSK.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
743 |
CleanupStack::Pop(iconRsk); |
|
744 |
} |
|
745 |
else //landscape |
|
746 |
{ |
|
747 |
if (iKeypadType == EKeypadValueLskRsk) |
|
748 |
{ |
|
749 |
//LSK |
|
750 |
bitmap = NULL; |
|
751 |
mask =NULL; |
|
752 |
AknsUtils::CreateColorIconLC( |
|
753 |
skin, |
|
754 |
skinItemId, |
|
755 |
KAknsIIDQsnIconColors, |
|
756 |
EAknsCIQsnIconColorsCG30, |
|
757 |
bitmap, |
|
758 |
mask, |
|
759 |
fileName, |
|
760 |
(iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysBottom ? |
|
761 |
EMbmLcduiQgn_indi_lsk_horizontal : EMbmLcduiQgn_indi_lsk_vertical), |
|
762 |
(iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysBottom ? |
|
763 |
EMbmLcduiQgn_indi_lsk_horizontal_mask : EMbmLcduiQgn_indi_lsk_vertical_mask), |
|
764 |
KRgbBlack |
|
765 |
); |
|
766 |
} |
|
767 |
else |
|
768 |
{ |
|
769 |
//LSK |
|
770 |
bitmap = NULL; |
|
771 |
mask =NULL; |
|
772 |
AknsUtils::CreateColorIconLC( |
|
773 |
skin, |
|
774 |
skinItemId, |
|
775 |
KAknsIIDQsnIconColors, |
|
776 |
EAknsCIQsnIconColorsCG30, |
|
777 |
bitmap, |
|
778 |
mask, |
|
779 |
fileName, |
|
780 |
EMbmLcduiQgn_indi_lsk_vertical, |
|
781 |
EMbmLcduiQgn_indi_lsk_vertical_mask, |
|
782 |
KRgbBlack |
|
783 |
); |
|
784 |
} |
|
785 |
||
786 |
CGulIcon* iconLsk = CGulIcon::NewL(bitmap, mask); |
|
787 |
//Ownership of bitmap and mask transferred |
|
788 |
CleanupStack::Pop(2); //bitmap, mask |
|
789 |
CleanupStack::PushL(iconLsk); |
|
790 |
//TButtonData buttonDataLSK; |
|
791 |
buttonDataLSK.iButton = CAknButton::NewL( |
|
792 |
iconLsk , // ownership taken |
|
793 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
794 |
buttonDataLSK.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
795 |
buttonDataLSK.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
796 |
CleanupStack::Pop(iconLsk); |
|
797 |
||
798 |
if (iKeypadType == EKeypadValueLskRsk) |
|
799 |
{ |
|
800 |
//RSK |
|
801 |
bitmap = NULL; |
|
802 |
mask =NULL; |
|
803 |
AknsUtils::CreateColorIconLC( |
|
804 |
skin, |
|
805 |
skinItemId, |
|
806 |
KAknsIIDQsnIconColors, |
|
807 |
EAknsCIQsnIconColorsCG30, |
|
808 |
bitmap, |
|
809 |
mask, |
|
810 |
fileName, |
|
811 |
(iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysBottom ? |
|
812 |
EMbmLcduiQgn_indi_rsk_horizontal : EMbmLcduiQgn_indi_rsk_vertical), |
|
813 |
(iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysBottom ? |
|
814 |
EMbmLcduiQgn_indi_rsk_horizontal_mask : EMbmLcduiQgn_indi_rsk_vertical_mask), |
|
815 |
KRgbBlack |
|
816 |
); |
|
817 |
} |
|
818 |
else |
|
819 |
{ |
|
820 |
//RSK |
|
821 |
bitmap = NULL; |
|
822 |
mask =NULL; |
|
823 |
AknsUtils::CreateColorIconLC( |
|
824 |
skin, |
|
825 |
skinItemId, |
|
826 |
KAknsIIDQsnIconColors, |
|
827 |
EAknsCIQsnIconColorsCG30, |
|
828 |
bitmap, |
|
829 |
mask, |
|
830 |
fileName, |
|
831 |
EMbmLcduiQgn_indi_rsk_vertical, |
|
832 |
EMbmLcduiQgn_indi_rsk_vertical_mask, |
|
833 |
KRgbBlack |
|
834 |
); |
|
835 |
} |
|
836 |
||
837 |
CGulIcon* iconRsk = CGulIcon::NewL(bitmap, mask); |
|
838 |
//Ownership of bitmap and mask transferred |
|
839 |
CleanupStack::Pop(2); //bitmap, mask |
|
840 |
CleanupStack::PushL(iconRsk); |
|
841 |
//TButtonData buttonDataRSK; |
|
842 |
buttonDataRSK.iButton = CAknButton::NewL( |
|
843 |
iconRsk , // ownership taken |
|
844 |
NULL, NULL, NULL, _L(""), _L(""), 0, 0); |
|
845 |
buttonDataRSK.iButton->SetIconScaleMode(EAspectRatioPreserved); |
|
846 |
buttonDataRSK.iButton->SetMargins(TMargins8(0,0,0,0)); |
|
847 |
CleanupStack::Pop(iconRsk); |
|
848 |
} |
|
849 |
||
850 |
buttonDataLSK.iButton->SetContainerWindowL(*this); |
|
851 |
buttonDataLSK.iButton->SetExtent(iLskRect.iTl, iLskRect.Size()); |
|
852 |
buttonDataLSK.iButton->ActivateL(); |
|
853 |
InitializeKeyEvents(ELsk, &buttonDataLSK); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
854 |
iButtonData.Append(buttonDataLSK); |
66 | 855 |
|
856 |
buttonDataRSK.iButton->SetContainerWindowL(*this); |
|
857 |
buttonDataRSK.iButton->SetExtent(iRskRect.iTl, iRskRect.Size()); |
|
858 |
buttonDataRSK.iButton->ActivateL(); |
|
859 |
InitializeKeyEvents(ERsk, &buttonDataRSK); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
860 |
iButtonData.Append(buttonDataRSK); |
66 | 861 |
|
862 |
} |
|
863 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
864 |
void CMIDCanvasKeypad::InitializeKeys() |
66 | 865 |
{ |
866 |
TInt buttonCount = iButtonData.Count(); |
|
867 |
iCurrentButtonData.Reset(); |
|
868 |
iButtonStack.Reset(); |
|
869 |
||
870 |
for (TInt i=0; i < buttonCount; i++) |
|
871 |
{ |
|
872 |
iButtonData[i].iButton->ResetState(); |
|
873 |
// Rocker keys |
|
874 |
if (iButtonData[i].keyType < ENavigationKeysNumberOfButtons) |
|
875 |
{ |
|
876 |
if (iButtonData[i].iButton) |
|
877 |
{ |
|
878 |
iButtonData[i].iButton->SetPosition(iRockerRect.iTl); |
|
879 |
iButtonData[i].iButton->SetSize(iRockerRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
880 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
881 |
iButtonStack.Append(i); |
66 | 882 |
} |
883 |
} |
|
884 |
// Other keys |
|
885 |
else |
|
886 |
{ |
|
887 |
// Game A, B, C, D keys |
|
888 |
if (iKeypadType == EKeypadValueGameActions) |
|
889 |
{ |
|
890 |
if (iButtonData[i].keyType == EGameA) |
|
891 |
{ |
|
892 |
iButtonData[i].iButton->SetPosition(iGameARect.iTl); |
|
893 |
iButtonData[i].iButton->SetSize(iGameARect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
894 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
895 |
iButtonStack.Append(i); |
66 | 896 |
} |
897 |
else if (iButtonData[i].keyType == EGameB) |
|
898 |
{ |
|
899 |
iButtonData[i].iButton->SetPosition(iGameBRect.iTl); |
|
900 |
iButtonData[i].iButton->SetSize(iGameBRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
901 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
902 |
iButtonStack.Append(i); |
66 | 903 |
} |
904 |
else if (iButtonData[i].keyType == EGameC) |
|
905 |
{ |
|
906 |
iButtonData[i].iButton->SetPosition(iGameCRect.iTl); |
|
907 |
iButtonData[i].iButton->SetSize(iGameCRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
908 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
909 |
iButtonStack.Append(i); |
66 | 910 |
} |
911 |
else if (iButtonData[i].keyType == EGameD) |
|
912 |
{ |
|
913 |
iButtonData[i].iButton->SetPosition(iGameDRect.iTl); |
|
914 |
iButtonData[i].iButton->SetSize(iGameDRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
915 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
916 |
iButtonStack.Append(i); |
66 | 917 |
} |
918 |
} |
|
919 |
||
920 |
// LSK and RSK |
|
921 |
if (iButtonData[i].keyType == ELsk && iIsFullScreenMode) |
|
922 |
{ |
|
923 |
iButtonData[i].iButton->SetExtent(iLskRect.iTl, iLskRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
924 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
925 |
iButtonStack.Append(i); |
66 | 926 |
} |
927 |
else if (iButtonData[i].keyType == ERsk && iIsFullScreenMode) |
|
928 |
{ |
|
929 |
iButtonData[i].iButton->SetExtent(iRskRect.iTl, iRskRect.Size()); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
930 |
iCurrentButtonData.Append(&iButtonData[i]); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
931 |
iButtonStack.Append(i); |
66 | 932 |
} |
933 |
} |
|
934 |
} |
|
935 |
} |
|
936 |
||
937 |
void CMIDCanvasKeypad::InitializeKeyEvents(TKeypadKeys aKeypadKeys, TButtonData* aButtonData) |
|
938 |
{ |
|
939 |
aButtonData->iKeyEvent.iCode = 0; |
|
940 |
aButtonData->iKeyEvent.iModifiers = 0; |
|
941 |
aButtonData->iKeyEvent.iScanCode = 0; |
|
942 |
aButtonData->iKeyEvent.iRepeats = 0; |
|
943 |
aButtonData->iKeyEvent_2.iRepeats = 0; |
|
944 |
||
945 |
switch (aKeypadKeys) |
|
946 |
{ |
|
947 |
case ENavigationKeysFire: |
|
948 |
{ |
|
949 |
aButtonData->iKeyEvent.iScanCode = EStdKeyDevice3; |
|
950 |
aButtonData->iKeyEvent_2.iCode = EKeyDevice3; |
|
951 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
952 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyDevice3; |
|
953 |
aButtonData->keyType = ENavigationKeysFire; |
|
954 |
break; |
|
955 |
} |
|
956 |
case ENavigationKeysRight: |
|
957 |
{ |
|
958 |
aButtonData->iKeyEvent.iScanCode = EStdKeyRightArrow; |
|
959 |
aButtonData->iKeyEvent_2.iCode = EKeyRightArrow; |
|
960 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
961 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyRightArrow; |
|
962 |
aButtonData->keyType = ENavigationKeysRight; |
|
963 |
break; |
|
964 |
} |
|
965 |
case ENavigationKeysLeft: |
|
966 |
{ |
|
967 |
aButtonData->iKeyEvent.iScanCode = EStdKeyLeftArrow; |
|
968 |
aButtonData->iKeyEvent_2.iCode = EKeyLeftArrow; |
|
969 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
970 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyLeftArrow; |
|
971 |
aButtonData->keyType = ENavigationKeysLeft; |
|
972 |
break; |
|
973 |
} |
|
974 |
case ENavigationKeysUp: |
|
975 |
{ |
|
976 |
aButtonData->iKeyEvent.iScanCode = EStdKeyUpArrow; |
|
977 |
aButtonData->iKeyEvent_2.iCode = EKeyUpArrow; |
|
978 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
979 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyUpArrow; |
|
980 |
aButtonData->keyType = ENavigationKeysUp; |
|
981 |
break; |
|
982 |
} |
|
983 |
case ENavigationKeysDown: |
|
984 |
{ |
|
985 |
aButtonData->iKeyEvent.iScanCode = EStdKeyDownArrow; |
|
986 |
aButtonData->iKeyEvent_2.iCode = EKeyDownArrow; |
|
987 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
988 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyDownArrow; |
|
989 |
aButtonData->keyType = ENavigationKeysDown; |
|
990 |
break; |
|
991 |
} |
|
992 |
case ELsk: |
|
993 |
{ |
|
994 |
aButtonData->iKeyEvent.iScanCode = EStdKeyDevice0; |
|
995 |
aButtonData->iKeyEvent_2.iCode = EKeyDevice0; |
|
996 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
997 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyDevice0; |
|
998 |
aButtonData->keyType = ELsk; |
|
999 |
break; |
|
1000 |
} |
|
1001 |
case ERsk: |
|
1002 |
{ |
|
1003 |
aButtonData->iKeyEvent.iScanCode = EStdKeyDevice1; |
|
1004 |
aButtonData->iKeyEvent_2.iCode = EKeyDevice1; |
|
1005 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
1006 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyDevice1; |
|
1007 |
aButtonData->keyType = ERsk; |
|
1008 |
break; |
|
1009 |
} |
|
1010 |
case EGameA: |
|
1011 |
{ |
|
1012 |
aButtonData->iKeyEvent.iScanCode = '7'; |
|
1013 |
aButtonData->iKeyEvent_2.iCode = '7'; |
|
1014 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
1015 |
aButtonData->iKeyEvent_2.iScanCode = '7'; |
|
1016 |
aButtonData->keyType = EGameA; |
|
1017 |
break; |
|
1018 |
} |
|
1019 |
case EGameB: |
|
1020 |
{ |
|
1021 |
aButtonData->iKeyEvent.iScanCode = '9'; |
|
1022 |
aButtonData->iKeyEvent_2.iCode = '9'; |
|
1023 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
1024 |
aButtonData->iKeyEvent_2.iScanCode = '9'; |
|
1025 |
aButtonData->keyType = EGameB; |
|
1026 |
break; |
|
1027 |
} |
|
1028 |
case EGameC: |
|
1029 |
{ |
|
1030 |
aButtonData->iKeyEvent.iScanCode = EStdKeyNkpAsterisk; |
|
1031 |
aButtonData->iKeyEvent_2.iCode = '*'; |
|
1032 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
1033 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyNkpAsterisk; |
|
1034 |
aButtonData->keyType = EGameC; |
|
1035 |
break; |
|
1036 |
} |
|
1037 |
case EGameD: |
|
1038 |
{ |
|
1039 |
aButtonData->iKeyEvent.iScanCode = EStdKeyHash; |
|
1040 |
aButtonData->iKeyEvent_2.iCode = '#'; |
|
1041 |
aButtonData->iKeyEvent_2.iModifiers = EModifierAutorepeatable; |
|
1042 |
aButtonData->iKeyEvent_2.iScanCode = EStdKeyHash; |
|
1043 |
aButtonData->keyType = EGameD; |
|
1044 |
break; |
|
1045 |
} |
|
1046 |
default: |
|
1047 |
break; |
|
1048 |
} |
|
1049 |
} |
|
1050 |
||
1051 |
void CMIDCanvasKeypad::SetRectForAllButtons() |
|
1052 |
{ |
|
1053 |
TRect screenRect; |
|
1054 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect); |
|
1055 |
TInt layoutVariantForRockerKeys=0; |
|
1056 |
TInt layoutVariantForGameGrid=0; |
|
1057 |
TInt layoutVariantForSKLeft=0; |
|
1058 |
TInt layoutVariantForSKRight=0; |
|
1059 |
TInt layoutVariantForGameCell = 0; |
|
1060 |
||
1061 |
switch (iKeypadType) |
|
1062 |
{ |
|
1063 |
case EKeypadValueNo: |
|
1064 |
break; |
|
1065 |
case EKeypadValueNavigationKeys: |
|
1066 |
{ |
|
1067 |
if (iIsFullScreenMode) |
|
1068 |
{ |
|
1069 |
if (iIsPortrait) |
|
1070 |
{ |
|
1071 |
layoutVariantForRockerKeys = 0; |
|
1072 |
layoutVariantForSKLeft = 0; |
|
1073 |
layoutVariantForSKRight = 0; |
|
1074 |
} |
|
1075 |
else //landscape |
|
1076 |
{ |
|
1077 |
layoutVariantForRockerKeys = 2; |
|
1078 |
layoutVariantForSKLeft = 9; |
|
1079 |
layoutVariantForSKRight = 8; |
|
1080 |
layoutVariantForGameCell = 1; |
|
1081 |
} |
|
1082 |
} |
|
1083 |
else //normal mode |
|
1084 |
{ |
|
1085 |
if (iIsPortrait) |
|
1086 |
{ |
|
1087 |
layoutVariantForRockerKeys = 4; |
|
1088 |
} |
|
1089 |
else //landscape |
|
1090 |
{ |
|
1091 |
layoutVariantForRockerKeys = 6; |
|
1092 |
layoutVariantForGameCell = 2; |
|
1093 |
} |
|
1094 |
} |
|
1095 |
break; |
|
1096 |
} |
|
1097 |
case EKeypadValueGameActions: |
|
1098 |
{ |
|
1099 |
if (iIsFullScreenMode) |
|
1100 |
{ |
|
1101 |
if (iIsPortrait) |
|
1102 |
{ |
|
1103 |
layoutVariantForRockerKeys = 1; |
|
1104 |
layoutVariantForGameGrid = 0; |
|
1105 |
layoutVariantForSKLeft = 1; |
|
1106 |
layoutVariantForSKRight = 1; |
|
1107 |
} |
|
1108 |
else //landscape |
|
1109 |
{ |
|
1110 |
layoutVariantForRockerKeys = 2; |
|
1111 |
layoutVariantForGameGrid = 1; |
|
1112 |
layoutVariantForSKLeft = 9; |
|
1113 |
layoutVariantForSKRight = 8; |
|
1114 |
layoutVariantForGameCell = 1; |
|
1115 |
} |
|
1116 |
} |
|
1117 |
else //normal mode |
|
1118 |
{ |
|
1119 |
if (iIsPortrait) |
|
1120 |
{ |
|
1121 |
layoutVariantForRockerKeys = 5; |
|
1122 |
layoutVariantForGameGrid = 0; |
|
1123 |
} |
|
1124 |
else//landscape |
|
1125 |
{ |
|
1126 |
layoutVariantForRockerKeys = 6; |
|
1127 |
layoutVariantForGameGrid = 3; |
|
1128 |
layoutVariantForGameCell = 2; |
|
1129 |
} |
|
1130 |
} |
|
1131 |
break; |
|
1132 |
} |
|
1133 |
case EKeypadValueLskRsk: |
|
1134 |
{ |
|
1135 |
if (iIsFullScreenMode) |
|
1136 |
{ |
|
1137 |
if (iIsPortrait) |
|
1138 |
{ |
|
1139 |
layoutVariantForSKLeft = 12; |
|
1140 |
layoutVariantForSKRight = 11; |
|
1141 |
} |
|
1142 |
else //landscape |
|
1143 |
{ |
|
1144 |
if (iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysRight) |
|
1145 |
{ |
|
1146 |
layoutVariantForSKLeft = 11; |
|
1147 |
layoutVariantForSKRight = 10; |
|
1148 |
} |
|
1149 |
else //default mode:Softkeys bottom |
|
1150 |
{ |
|
1151 |
layoutVariantForSKLeft = 10; |
|
1152 |
layoutVariantForSKRight = 9; |
|
1153 |
} |
|
1154 |
} |
|
1155 |
} |
|
1156 |
break; |
|
1157 |
} |
|
1158 |
default: |
|
1159 |
break; |
|
1160 |
} |
|
1161 |
||
1162 |
if (iKeypadType != EKeypadValueLskRsk) |
|
1163 |
{ |
|
1164 |
//Rocker keys rect |
|
1165 |
TAknLayoutRect layRectRocker; |
|
1166 |
layRectRocker.LayoutRect(Rect(), AknLayoutScalable_Avkon:: |
|
1167 |
midp_keyp_rocker_pane(layoutVariantForRockerKeys).LayoutLine()); |
|
1168 |
iRockerRect = layRectRocker.Rect(); |
|
1169 |
||
1170 |
//set game a,b,c,d |
|
1171 |
TAknLayoutRect gameRect; |
|
1172 |
gameRect.LayoutRect(Rect(), AknLayoutScalable_Avkon:: |
|
1173 |
midp_keyp_game_grid_pane(layoutVariantForGameGrid).LayoutLine()); |
|
1174 |
||
1175 |
TAknLayoutRect gamePaneButtonA; |
|
1176 |
if (iIsPortrait) |
|
1177 |
{ //variety, column, row |
|
1178 |
gamePaneButtonA.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1179 |
keyp_game_cell_pane(0,0,0).LayoutLine()); |
|
1180 |
} |
|
1181 |
else |
|
1182 |
{ |
|
1183 |
gamePaneButtonA.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1184 |
keyp_game_cell_pane(layoutVariantForGameCell,0,0).LayoutLine()); |
|
1185 |
} |
|
1186 |
iGameARect = gamePaneButtonA.Rect(); |
|
1187 |
||
1188 |
TAknLayoutRect gamePaneButtonB; |
|
1189 |
if (iIsPortrait) |
|
1190 |
{ |
|
1191 |
gamePaneButtonB.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1192 |
keyp_game_cell_pane(0,1,0).LayoutLine()); |
|
1193 |
} |
|
1194 |
else |
|
1195 |
{ |
|
1196 |
gamePaneButtonB.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1197 |
keyp_game_cell_pane(layoutVariantForGameCell,0,1).LayoutLine()); |
|
1198 |
} |
|
1199 |
iGameBRect = gamePaneButtonB.Rect(); |
|
1200 |
||
1201 |
TAknLayoutRect gamePaneButtonC; |
|
1202 |
if (iIsPortrait) |
|
1203 |
{ |
|
1204 |
gamePaneButtonC.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1205 |
keyp_game_cell_pane(0,2,0).LayoutLine()); |
|
1206 |
} |
|
1207 |
else |
|
1208 |
{ |
|
1209 |
gamePaneButtonC.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1210 |
keyp_game_cell_pane(layoutVariantForGameCell,0,2).LayoutLine()); |
|
1211 |
} |
|
1212 |
iGameCRect = gamePaneButtonC.Rect(); |
|
1213 |
||
1214 |
TAknLayoutRect gamePaneButtonD; |
|
1215 |
if (iIsPortrait) |
|
1216 |
{ |
|
1217 |
gamePaneButtonD.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1218 |
keyp_game_cell_pane(0,3,0).LayoutLine()); |
|
1219 |
} |
|
1220 |
else |
|
1221 |
{ |
|
1222 |
gamePaneButtonD.LayoutRect(gameRect.Rect(), AknLayoutScalable_Avkon:: |
|
1223 |
keyp_game_cell_pane(layoutVariantForGameCell,0,3).LayoutLine()); |
|
1224 |
} |
|
1225 |
||
1226 |
iGameDRect = gamePaneButtonD.Rect(); |
|
1227 |
} |
|
1228 |
||
1229 |
//set midp_keyp_sk_left |
|
1230 |
TAknLayoutRect layRectSKLeft; |
|
1231 |
layRectSKLeft.LayoutRect(Rect(), AknLayoutScalable_Avkon:: |
|
1232 |
midp_keyp_sk_left_pane(layoutVariantForSKLeft).LayoutLine()); |
|
1233 |
TAknLayoutRect layRectLsk; |
|
1234 |
layRectLsk.LayoutRect(layRectSKLeft.Rect(), AknLayoutScalable_Avkon:: |
|
1235 |
bg_button_pane_cp03(0).LayoutLine()); |
|
1236 |
iLskRect = layRectLsk.Rect(); |
|
1237 |
||
1238 |
//set midp_keyp_sk_right |
|
1239 |
TAknLayoutRect layRectSKRight; |
|
1240 |
layRectSKRight.LayoutRect(Rect(), AknLayoutScalable_Avkon:: |
|
1241 |
midp_keyp_sk_right_pane(layoutVariantForSKRight).LayoutLine()); |
|
1242 |
TAknLayoutRect layRectRsk; |
|
1243 |
layRectRsk.LayoutRect(layRectSKRight.Rect(), AknLayoutScalable_Avkon:: |
|
1244 |
bg_button_pane_cp04(0).LayoutLine()); |
|
1245 |
iRskRect = layRectRsk.Rect(); |
|
1246 |
} |
|
1247 |
||
1248 |
void CMIDCanvasKeypad::UpdateKeypadPaneRect() |
|
1249 |
{ |
|
1250 |
TRect screen; |
|
1251 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screen); |
|
1252 |
TAknLayoutRect layRect; |
|
1253 |
TInt layoutVariantForKeypadRect = 0; |
|
1254 |
||
1255 |
TAknLayoutRect mainPane; |
|
1256 |
TAknLayoutRect mainMidpPane; |
|
1257 |
mainPane.LayoutRect(screen, AknLayoutScalable_Avkon::main_pane(3).LayoutLine()); |
|
1258 |
mainMidpPane.LayoutRect(mainPane.Rect(), |
|
1259 |
AknLayoutScalable_Avkon::main_midp_pane(0).LayoutLine()); |
|
1260 |
||
1261 |
if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
1262 |
{ |
|
1263 |
iIsPortrait = EFalse; |
|
1264 |
} |
|
1265 |
else //portrait |
|
1266 |
{ |
|
1267 |
iIsPortrait = ETrue; |
|
1268 |
} |
|
1269 |
||
1270 |
switch (iKeypadType) |
|
1271 |
{ |
|
1272 |
case EKeypadValueNo: |
|
1273 |
break; |
|
1274 |
case EKeypadValueNavigationKeys: |
|
1275 |
{ |
|
1276 |
if (iIsFullScreenMode) |
|
1277 |
{ |
|
1278 |
if (iIsPortrait) |
|
1279 |
{ |
|
1280 |
layoutVariantForKeypadRect = 0; |
|
1281 |
} |
|
1282 |
else //landscape |
|
1283 |
{ |
|
1284 |
layoutVariantForKeypadRect = 7; |
|
1285 |
} |
|
1286 |
} |
|
1287 |
else //normal mode |
|
1288 |
{ |
|
1289 |
if (iIsPortrait) |
|
1290 |
{ |
|
1291 |
screen = mainMidpPane.Rect(); |
|
1292 |
layoutVariantForKeypadRect = 3; |
|
1293 |
} |
|
1294 |
else //landscape |
|
1295 |
{ |
|
1296 |
mainPane.LayoutRect(screen, |
|
1297 |
AknLayoutScalable_Avkon::main_pane(4).LayoutLine()); |
|
1298 |
mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon:: |
|
1299 |
main_midp_pane(0).LayoutLine()); |
|
1300 |
screen = mainMidpPane.Rect(); |
|
1301 |
layoutVariantForKeypadRect = 5; |
|
1302 |
} |
|
1303 |
} |
|
1304 |
break; |
|
1305 |
} |
|
1306 |
case EKeypadValueGameActions: |
|
1307 |
{ |
|
1308 |
if (iIsFullScreenMode) |
|
1309 |
{ |
|
1310 |
if (iIsPortrait) |
|
1311 |
{ |
|
1312 |
layoutVariantForKeypadRect = 1; |
|
1313 |
} |
|
1314 |
else //landscape |
|
1315 |
{ |
|
1316 |
layoutVariantForKeypadRect = 2; |
|
1317 |
} |
|
1318 |
} |
|
1319 |
else //normal mode |
|
1320 |
{ |
|
1321 |
if (iIsPortrait) |
|
1322 |
{ |
|
1323 |
screen = mainMidpPane.Rect(); |
|
1324 |
layoutVariantForKeypadRect = 4; |
|
1325 |
} |
|
1326 |
else//landscape |
|
1327 |
{ |
|
1328 |
mainPane.LayoutRect(screen, |
|
1329 |
AknLayoutScalable_Avkon::main_pane(4).LayoutLine()); |
|
1330 |
mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon:: |
|
1331 |
main_midp_pane(0).LayoutLine()); |
|
1332 |
screen = mainMidpPane.Rect(); |
|
1333 |
layoutVariantForKeypadRect = 5; |
|
1334 |
} |
|
1335 |
} |
|
1336 |
break; |
|
1337 |
} |
|
1338 |
case EKeypadValueLskRsk: |
|
1339 |
{ |
|
1340 |
if (iIsFullScreenMode) |
|
1341 |
{ |
|
1342 |
if (iIsPortrait) |
|
1343 |
{ |
|
1344 |
layoutVariantForKeypadRect = 10; |
|
1345 |
} |
|
1346 |
else //landscape |
|
1347 |
{ |
|
1348 |
if (iDisplayable->GetSKPositionForOSK() == CMIDDisplayable::ESoftkeysRight) |
|
1349 |
{ |
|
1350 |
layoutVariantForKeypadRect = 9; |
|
1351 |
} |
|
1352 |
else //default mode:Softkeys bottom |
|
1353 |
{ |
|
1354 |
layoutVariantForKeypadRect = 8; |
|
1355 |
} |
|
1356 |
} |
|
1357 |
} |
|
1358 |
break; |
|
1359 |
} |
|
1360 |
default: |
|
1361 |
break; |
|
1362 |
} |
|
1363 |
||
1364 |
layRect.LayoutRect(screen, AknLayoutScalable_Avkon:: |
|
1365 |
midp_keypad_pane(layoutVariantForKeypadRect).LayoutLine()); |
|
1366 |
||
1367 |
if (iKeypadPaneRect != layRect.Rect()) |
|
1368 |
{ |
|
1369 |
iKeypadPaneRect = layRect.Rect(); |
|
1370 |
SetRect(iKeypadPaneRect); |
|
1371 |
} |
|
1372 |
else |
|
1373 |
{ |
|
1374 |
return; |
|
1375 |
} |
|
1376 |
} |
|
1377 |
||
1378 |
TKeyResponse CMIDCanvasKeypad::RaiseOfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType, TBool aFeedbckRpt) |
|
1379 |
{ |
|
1380 |
#ifdef RD_TACTILE_FEEDBACK |
|
1381 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1382 |
||
1383 |
if (feedback) |
|
1384 |
{ |
|
1385 |
switch (aType) |
|
1386 |
{ |
|
1387 |
case EEventKeyDown: |
|
1388 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
1389 |
if (iDragBetweenArrowKeys) |
|
1390 |
{ |
|
1391 |
feedback->InstantFeedback(ETouchFeedbackSensitiveButton); |
|
1392 |
} |
|
1393 |
else |
|
1394 |
{ |
|
1395 |
feedback->InstantFeedback(ETouchFeedbackBasicButton); |
|
1396 |
} |
|
1397 |
#else |
|
1398 |
feedback->InstantFeedback(ETouchFeedbackBasic); |
|
1399 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
1400 |
break; |
|
1401 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
1402 |
case EEventKeyUp: |
|
1403 |
if (!(iDragBetweenArrowKeys || iDragOutsideArrowKeys)) |
|
1404 |
{ |
|
1405 |
//Feedback on release shouldn't be in two cases: |
|
1406 |
//- if pointer was dragged between arrow keys |
|
1407 |
//- if pointer was dragged outside the keypad |
|
1408 |
feedback->InstantFeedback(ETouchFeedbackBasicButton); |
|
1409 |
} |
|
1410 |
break; |
|
1411 |
case EEventKey: |
|
1412 |
if (aFeedbckRpt) |
|
1413 |
{ |
|
1414 |
feedback->InstantFeedback(ETouchFeedbackSensitiveButton); |
|
1415 |
} |
|
1416 |
break; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1417 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
66 | 1418 |
} |
1419 |
} |
|
1420 |
#endif // RD_TACTILE_FEEDBACK |
|
1421 |
||
1422 |
(void)aFeedbckRpt; // Just to remove a compiler warning |
|
1423 |
||
1424 |
// Posts event to Canvas. |
|
1425 |
return iCanvas->OfferKeyEventL(aEvent, aType); |
|
1426 |
} |
|
1427 |
||
1428 |
TInt CMIDCanvasKeypad::RepeatTimerCallbackL(TAny* aThis) |
|
1429 |
{ |
|
1430 |
CMIDCanvasKeypad* observer = static_cast<CMIDCanvasKeypad*>(aThis); |
|
1431 |
observer->HandleRepeatTimerEventL(); |
|
1432 |
return 0; |
|
1433 |
} |
|
1434 |
||
1435 |
void CMIDCanvasKeypad::HandleRepeatTimerEventL() |
|
1436 |
{ |
|
1437 |
DEBUG("CMIDCanvasKeypad::HandleTimerEvent +"); |
|
1438 |
if (iCurrentRockerKey && iCurrentRockerKey->iKeyEvent_2.iRepeats == 1) |
|
1439 |
{ |
|
1440 |
// Posts repeat event |
|
1441 |
RaiseOfferKeyEventL(iCurrentRockerKey->iKeyEvent_2, EEventKey); |
|
1442 |
} |
|
1443 |
else if (iCurrentOtherKey && iCurrentOtherKey->iKeyEvent_2.iRepeats == 1) |
|
1444 |
{ |
|
1445 |
// Posts repeat event |
|
1446 |
RaiseOfferKeyEventL(iCurrentOtherKey->iKeyEvent_2, EEventKey); |
|
1447 |
} |
|
1448 |
// Change rocker key status and refresh, while button is pressed |
|
1449 |
// down for KTimerExpiryInterval time interval |
|
1450 |
if (iCurrentRockerKey && iCurrentRockerKey->iButton && iCurrentRockerKey->iButton->StateIndex() <= 0) |
|
1451 |
{ |
|
1452 |
iOldTapCnt = -1; |
|
1453 |
ChangeStatus(ETrue, iCurrentRockerKey); |
|
1454 |
} |
|
1455 |
DEBUG("CMIDCanvasKeypad::HandleTimerEvent -"); |
|
1456 |
} |
|
1457 |
||
1458 |
void CMIDCanvasKeypad::ResetButtons() |
|
1459 |
{ |
|
1460 |
// If a timer exists, we need stop it. |
|
1461 |
if (iRepeatTimer) |
|
1462 |
{ |
|
1463 |
iRepeatTimer->Cancel(); |
|
1464 |
} |
|
1465 |
||
1466 |
// If there is a key pressed currently, we just update visual |
|
1467 |
// state and set the current key to null. |
|
1468 |
// Notice that, we don't try to send key up event to CMIDCanvas. |
|
1469 |
if (iCurrentRockerKey) |
|
1470 |
{ |
|
1471 |
iCurrentRockerKey->iKeyEvent_2.iRepeats = 0; |
|
1472 |
iCurrentRockerKey->iButton->SetCurrentState(0, ETrue); |
|
1473 |
iCurrentRockerKey->iButton->ResetState(); |
|
1474 |
iCurrentRockerKey = NULL; |
|
1475 |
} |
|
1476 |
else if (iCurrentOtherKey) |
|
1477 |
{ |
|
1478 |
iCurrentOtherKey->iKeyEvent_2.iRepeats = 0; |
|
1479 |
iCurrentOtherKey->iButton->SetCurrentState(0, ETrue); |
|
1480 |
iCurrentOtherKey->iButton->ResetState(); |
|
1481 |
iCurrentOtherKey = NULL; |
|
1482 |
} |
|
1483 |
||
1484 |
} |
|
1485 |
||
1486 |
void CMIDCanvasKeypad::HandleApplicationBackground() |
|
1487 |
{ |
|
1488 |
// This code stops On-Screen Keypad timer repeating keyevents |
|
1489 |
// if current application goes to background. |
|
1490 |
ResetButtons(); |
|
1491 |
} |
|
1492 |
||
1493 |
void CMIDCanvasKeypad::ChangeStatus(TInt aState, TButtonData* aDataButton) |
|
1494 |
{ |
|
1495 |
// Rocker key down, change skin and refresh for aState > 0. |
|
1496 |
if (aState) |
|
1497 |
{ |
|
1498 |
if (iTapTimer) |
|
1499 |
{ |
|
1500 |
if (iTapTimer->IsActive()) |
|
1501 |
{ |
|
1502 |
// Stop tap timer |
|
1503 |
iTapTimer->Cancel(); |
|
1504 |
} |
|
1505 |
||
1506 |
iOldTapCnt = iTapCnt; |
|
1507 |
||
1508 |
// Set button down and refresh recker keys area when tap cunter is greater |
|
1509 |
// then KTapMaxCnt. Tap counter increases every KTapTimerExpiryInterval. |
|
1510 |
if (iTapCnt > KTapMaxCnt || iTapCnt == -1) |
|
1511 |
{ |
|
1512 |
aDataButton->iButton->SetCurrentState(1, ETrue); |
|
1513 |
} |
|
1514 |
||
1515 |
iTapCnt = 0; |
|
1516 |
||
1517 |
// Start timer for evry rocker key down with KTapTimerExpiryInterval time interval. |
|
1518 |
iTapTimer->Start(KFirstTapTimerExpiryInterval, KTapTimerExpiryInterval, |
|
1519 |
TCallBack(TapTimerCallbackL, this)); |
|
1520 |
} |
|
1521 |
} |
|
1522 |
// Rocker key up, change skin and refresh for aState == 0 |
|
1523 |
else |
|
1524 |
{ |
|
1525 |
// Set button up and refresh recker keys area when tap cunter |
|
1526 |
// is greater then KTapMaxCnt |
|
1527 |
if (iOldTapCnt > KTapMaxCnt || iOldTapCnt == -1) |
|
1528 |
{ |
|
1529 |
aDataButton->iButton->SetCurrentState(0, ETrue); |
|
1530 |
} |
|
1531 |
} |
|
1532 |
} |
|
1533 |
||
1534 |
// Tap timer callback method |
|
1535 |
TInt CMIDCanvasKeypad::TapTimerCallbackL(TAny* aThis) |
|
1536 |
{ |
|
1537 |
if (aThis) |
|
1538 |
{ |
|
1539 |
CMIDCanvasKeypad* observer = static_cast<CMIDCanvasKeypad*>(aThis); |
|
1540 |
observer->HandleTapTimerEventL(); |
|
1541 |
} |
|
1542 |
||
1543 |
return 0; |
|
1544 |
} |
|
1545 |
||
1546 |
// Counter of mouse tap events EEventKeyDown, increased every KTapTimerExpiryInterval |
|
1547 |
// time interval. When iTapCnt > KTapMaxCnt timer was stopped. |
|
1548 |
void CMIDCanvasKeypad::HandleTapTimerEventL() |
|
1549 |
{ |
|
1550 |
++iTapCnt; |
|
1551 |
||
1552 |
if (iTapTimer && iTapCnt > KTapMaxCnt) |
|
1553 |
{ |
|
1554 |
iTapTimer->Cancel(); |
|
1555 |
} |
|
1556 |
} |
|
1557 |
// Send EButton1Up event and stoped repeat timer if OSK in background |
|
1558 |
void CMIDCanvasKeypad::OSKInBackground(TBool aOSKInBackground) |
|
1559 |
{ |
|
1560 |
if (aOSKInBackground) |
|
1561 |
{ |
|
1562 |
iStoreKeyDownEvent.iType = TPointerEvent::EButton1Up; |
|
1563 |
||
1564 |
TRAPD(error, HandlePointerEventL(iStoreKeyDownEvent)); |
|
1565 |
if (error != KErrNone) |
|
1566 |
{ |
|
1567 |
ResetButtons(); |
|
1568 |
} |
|
1569 |
} |
|
1570 |
||
1571 |
iOSKInBackground = aOSKInBackground; |
|
1572 |
} |
|
1573 |
// End of File |