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