1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The Function-Map subpane class, CCalcFuncmapSubPane |
|
15 * Derived from CCoeControl. |
|
16 * CCalcFuncmapSubPane is container class of CCalcCommandButton. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <AknUtils.h> |
|
25 #include <aknViewAppUi.h> |
|
26 |
|
27 #include <AknsSkinInstance.h> |
|
28 #include <aknpopuplayout.h> |
|
29 #include <Calcsoft.rsg> |
|
30 #include <layoutmetadata.cdl.h> |
|
31 #include "CalcFunc.h" |
|
32 //#include "CalcCmdBtn.h" |
|
33 #include "CalcEnv.h" |
|
34 #include "CalcCont.h" |
|
35 #include "CalcView.h" |
|
36 #include "CalcOutSheet.h" |
|
37 #include "calc.hrh" |
|
38 #include "CalcDrawingConst.laf" |
|
39 #include "CalcView.h" |
|
40 #include <applayout.cdl.h> |
|
41 #include <aknlayoutscalable_apps.cdl.h> |
|
42 #include <AvkonInternalCRKeys.h> |
|
43 #include <PtiDefs.h> |
|
44 #include <PtiEngine.h> |
|
45 #include <PtiKeyMappings.h> |
|
46 #include <AknFepInternalCRKeys.h> |
|
47 #include <aknbutton.h> |
|
48 #include <AknsDrawUtils.h> |
|
49 #include <aknnotewrappers.h> |
|
50 #include <featmgr.h> // Feature Manager |
|
51 |
|
52 //enum to hold the values of button states |
|
53 enum |
|
54 { |
|
55 EnNormal = 0, |
|
56 EnPressed, |
|
57 EnDimmed |
|
58 }; |
|
59 // LOCAL CONSTANTS AND MACROS |
|
60 const TInt KButtonsInColumn(2); // The number of column of a button |
|
61 const TInt KButtonsInRow(KCountOfButtons / KButtonsInColumn); |
|
62 const TInt KButtonsInColumnTouch(4); // The number of column of a button in Touch layout |
|
63 const TInt KButtonsInRowTouch(KCountOfButtonsTouch / KButtonsInColumnTouch); |
|
64 // The number of row of a button |
|
65 const TInt KButtonsIdTblTouch[] = // The command ID of a button in Touch Layout |
|
66 { |
|
67 ECalcCmdCancel, // C |
|
68 ECalcCmdSeven, // 7 |
|
69 ECalcCmdFour, // 4 |
|
70 ECalcCmdOne, // 1 |
|
71 ECalcCmdZero, // 0 |
|
72 ECalcCmdSqrt, // Sqrt |
|
73 ECalcCmdEight, // 8 |
|
74 ECalcCmdFive, // 5 |
|
75 ECalcCmdTwo, // 2 |
|
76 ECalcCmdSeparator, // . |
|
77 ECalcCmdPercent, // % |
|
78 ECalcCmdNine, // 9 |
|
79 ECalcCmdSix, // 6 |
|
80 ECalcCmdThree, // 3 |
|
81 ECalcCmdChangeSign, // +/- |
|
82 ECalcCmdDivide, // / |
|
83 ECalcCmdMultiply, // * |
|
84 ECalcCmdSubtract, // - |
|
85 ECalcCmdAdd, // + |
|
86 ECalcCmdResult // = |
|
87 }; |
|
88 |
|
89 const TInt KButtonsIdTbl[] = // The command ID of a button in non Touch Layout |
|
90 { |
|
91 ECalcCmdAdd, // + |
|
92 ECalcCmdSubtract, // - |
|
93 ECalcCmdMultiply, // * |
|
94 ECalcCmdDivide, // / |
|
95 ECalcCmdChangeSign, // +/- |
|
96 ECalcCmdResult, // = |
|
97 ECalcCmdSqrt, // Sqrt |
|
98 ECalcCmdPercent, // % |
|
99 ECalcCmdScrollUp, // Scroll-up |
|
100 ECalcCmdScrollDown // Scroll-down |
|
101 }; |
|
102 |
|
103 |
|
104 // If const TChar is used, complie error occurs in THUMB build. |
|
105 // To avoid this, #define is used. |
|
106 #define KCalcAsteriskBtn '*' |
|
107 |
|
108 |
|
109 // ================= MEMBER FUNCTIONS ======================= |
|
110 |
|
111 // Two-phased constructor. |
|
112 CCalcFuncmapSubPane* CCalcFuncmapSubPane::NewL( |
|
113 CCalcContainer* aContainer) |
|
114 { |
|
115 CCalcFuncmapSubPane* self = new (ELeave) CCalcFuncmapSubPane(); |
|
116 CleanupStack::PushL(self); |
|
117 self->ConstructL(aContainer); |
|
118 CleanupStack::Pop(self); |
|
119 return self; |
|
120 } |
|
121 |
|
122 |
|
123 // Destructor |
|
124 CCalcFuncmapSubPane::~CCalcFuncmapSubPane() |
|
125 { |
|
126 for (TInt count(0); count < KCountOfButtonsTouch; count++) |
|
127 { |
|
128 if(iButtons[count]) |
|
129 { |
|
130 delete iButtons[count]; |
|
131 } |
|
132 |
|
133 } |
|
134 |
|
135 // delete of button controls |
|
136 iQwertyModeStatusProperty.Close(); |
|
137 delete iEngine; |
|
138 delete iCRKey; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CCalcFuncmapSubPane::SetScrollupEnable |
|
143 // \ scroll up and down button on scrolling enable. |
|
144 // (other items were commented in a header). |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CCalcFuncmapSubPane::RedrawScrollButtons() |
|
148 { |
|
149 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
150 SetScrollupEnable(outputSheet->CanUp()); |
|
151 SetScrolldownEnable(outputSheet->CanDown()); |
|
152 } |
|
153 |
|
154 |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // CCalcFuncmapSubPane::SetChangeSignEnable |
|
158 // Redraw ChangeSign button on ChangeSign enable. |
|
159 // (other items were commented in a header). |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 void CCalcFuncmapSubPane::SetChangeSignEnable |
|
163 (TBool aEnable) |
|
164 { |
|
165 |
|
166 /*Get the selected pointer |
|
167 button -> different layouts, different values*/ |
|
168 CAknButton* button = NULL; |
|
169 if( AknLayoutUtils::PenEnabled() ) |
|
170 { |
|
171 button = iButtons[ECmdTChangeSign]; |
|
172 } |
|
173 else |
|
174 { |
|
175 button = iButtons[EChangeSignButton]; |
|
176 } |
|
177 |
|
178 //Set to dimmed state |
|
179 button->SetDimmed( !aEnable ); |
|
180 button->DrawNow(); |
|
181 iIsChangeSignDimmed = aEnable; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------- |
|
185 // CCalcFuncmapSubPane::SetClearKeyEnable |
|
186 // Redraw ClearKey button on ClearKey enable. |
|
187 // (other items were commented in a header). |
|
188 // --------------------------------------------------------- |
|
189 // |
|
190 void CCalcFuncmapSubPane::SetClearKeyEnable( TBool aEnable ) |
|
191 { |
|
192 if ( AknLayoutUtils::PenEnabled() ) |
|
193 { |
|
194 CAknButton* button = NULL; |
|
195 button = iButtons[ECmdTCancel]; |
|
196 |
|
197 if ( button ) |
|
198 { |
|
199 button->SetDimmed( !aEnable ); |
|
200 button->DrawNow(); |
|
201 } |
|
202 } |
|
203 iIsClearKeyEnabled = aEnable; |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // CCalcFuncmapSubPane::NotifyTimeoutL |
|
208 // If no key is pressed until timeout of *-key, |
|
209 // this function is called. |
|
210 // (other items were commented in a header). |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CCalcFuncmapSubPane::NotifyTimeoutL() |
|
214 { |
|
215 |
|
216 /*Get the selected pointer |
|
217 button -> different layouts, different values*/ |
|
218 CAknButton* button = iButtons[iSelected]; |
|
219 if( !AknLayoutUtils::PenEnabled() ) |
|
220 { |
|
221 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
222 if ( iKeyboardType == EPtiKeyboardHalfQwerty ) |
|
223 { |
|
224 if( ( iLastKeyCode == EStdKeyLeftShift && iDecimalPoint ) || ( iLastKeyCode == EStdKeyLeftFunc && iDecimalPoint )) |
|
225 { |
|
226 iContainer->SetSeparatorFromTouchL(); |
|
227 } |
|
228 else |
|
229 { |
|
230 iContainer->View()->HandleCommandL( KButtonsIdTbl[iSelected] ); |
|
231 } |
|
232 } |
|
233 else |
|
234 #endif |
|
235 { |
|
236 iContainer->View()->HandleCommandL( KButtonsIdTbl[iSelected] ); |
|
237 } |
|
238 } |
|
239 else |
|
240 { |
|
241 iContainer->View()->HandleCommandL( KButtonsIdTblTouch[iSelected] ); |
|
242 } |
|
243 |
|
244 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
245 if ( iKeyboardType == EPtiKeyboardHalfQwerty ) |
|
246 { |
|
247 iLastKeyCode = 0; |
|
248 } |
|
249 #endif |
|
250 |
|
251 //Set to dimmed state |
|
252 button->SetDimmed( EFalse ); |
|
253 DrawDeferred(); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // CCalcFuncmapSubPane::NotifyReleaseKeyL |
|
258 // Notify any key is released. If pressed button exists. |
|
259 // command which is releated is executed. |
|
260 // (other items were commented in a header). |
|
261 // --------------------------------------------------------- |
|
262 // |
|
263 void CCalcFuncmapSubPane::NotifyReleaseKeyL() |
|
264 { |
|
265 /*Get the selected pointer |
|
266 button -> different layouts, different values*/ |
|
267 CAknButton* button = iButtons[iSelected]; |
|
268 CAknButtonState* state = button->State(EnNormal); |
|
269 |
|
270 if(state->Flags() == EnPressed) |
|
271 { |
|
272 TKeyEvent aKeyEvent; |
|
273 aKeyEvent.iScanCode = EStdKeyEnter; |
|
274 TEventCode aType = EEventKeyUp; |
|
275 //trigger offerkeyeventl to this button |
|
276 button->OfferKeyEventL(aKeyEvent,aType); |
|
277 state->SetFlags(EnNormal); |
|
278 button->DrawNow(); |
|
279 } |
|
280 if( !AknLayoutUtils::PenEnabled() ) |
|
281 { |
|
282 if(iSelected == EScrollUp) |
|
283 { |
|
284 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
285 if(!outputSheet->CanUp()) |
|
286 { |
|
287 RedrawHighlight(EScrollUp,EScrollDown); |
|
288 iSelected = EScrollDown; |
|
289 } |
|
290 } |
|
291 |
|
292 if(iSelected == EScrollDown) |
|
293 { |
|
294 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
295 if(!outputSheet->CanDown()) |
|
296 { |
|
297 RedrawHighlight(EScrollDown,EScrollUp); |
|
298 iSelected = EScrollUp; |
|
299 } |
|
300 } |
|
301 |
|
302 } |
|
303 |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------- |
|
307 // CCalcFuncmapSubPane::NotifyOtherThanOkKeyPressed |
|
308 // If key other than OK-key is pressed this function is called. |
|
309 // (other items were commented in a header). |
|
310 // --------------------------------------------------------- |
|
311 // |
|
312 void CCalcFuncmapSubPane::NotifyOtherThanOkKeyPressed() |
|
313 { |
|
314 //for (TInt cnt(0); cnt < iCountOfButtons; cnt++) |
|
315 { |
|
316 //Get the pointer for the button |
|
317 CAknButton* button = iButtons[iSelected]; |
|
318 CAknButtonState* state = button->State(EnNormal); |
|
319 if(state->Flags() == EnPressed) |
|
320 { |
|
321 state->SetFlags(EnNormal); |
|
322 button->DrawNow(); |
|
323 } |
|
324 } |
|
325 |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------- |
|
329 // CCalcFuncmapSubPane::NotifyLangChange |
|
330 // Called if language is changed. |
|
331 // Change layout according to the language. |
|
332 // (other items were commented in a header). |
|
333 // --------------------------------------------------------- |
|
334 // |
|
335 void CCalcFuncmapSubPane::NotifyLangChange() |
|
336 { |
|
337 // Write code here. |
|
338 SetLayout(); |
|
339 DrawNow(); |
|
340 } |
|
341 |
|
342 |
|
343 // --------------------------------------------------------- |
|
344 // CCalcFuncmapSubPane::IsQwertyKeypadActive |
|
345 // Called to check qwerty keypad is active or not |
|
346 // (other items were commented in a header). |
|
347 // --------------------------------------------------------- |
|
348 // |
|
349 TInt CCalcFuncmapSubPane::IsQwertyKeypadActive() |
|
350 { |
|
351 TInt value = 0; |
|
352 |
|
353 iQwertyModeStatusProperty.Get(value); |
|
354 |
|
355 return value; |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------- |
|
359 // CCalcFuncmapSubPane::HandleControlEventL |
|
360 // Observer event from avkon button change |
|
361 // (other items were commented in a header). |
|
362 // --------------------------------------------------------- |
|
363 void CCalcFuncmapSubPane::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType) |
|
364 { |
|
365 iIsKeyLongPress = EFalse; |
|
366 if ( aEventType != EEventStateChanged && aEventType != CAknButton::ELongPressEvent ) |
|
367 { |
|
368 return; |
|
369 } |
|
370 else if ( aEventType == CAknButton::ELongPressEvent ) |
|
371 { |
|
372 iIsKeyLongPress = ETrue; |
|
373 } |
|
374 |
|
375 //Get the selected button |
|
376 CAknButton* button = (CAknButton*)aControl; |
|
377 |
|
378 for ( TInt i = 0; i < KCountOfButtons; ++i ) |
|
379 { |
|
380 if ( button == iButtons[i] ) |
|
381 { |
|
382 if(iSelected != i) |
|
383 return; |
|
384 |
|
385 //break; |
|
386 } |
|
387 } |
|
388 |
|
389 // Check if the button has been pressed. |
|
390 CAknButtonState* state = button->State(EnNormal); |
|
391 if ( aEventType == EEventStateChanged && state->Flags() == EnNormal ) |
|
392 { |
|
393 iInputData = ETrue; |
|
394 } |
|
395 |
|
396 if ( !button->IsDimmed() ) |
|
397 { |
|
398 //handles all the commands for the buttons |
|
399 if( !AknLayoutUtils::PenEnabled() ) |
|
400 { |
|
401 iContainer->View()->HandleCommandL(KButtonsIdTbl[iSelected]); |
|
402 if(iSelected == EScrollUp) |
|
403 { |
|
404 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
405 if(!outputSheet->CanUp()) |
|
406 { |
|
407 RedrawHighlight(EScrollUp,EScrollDown); |
|
408 iSelected = EScrollDown; |
|
409 } |
|
410 } |
|
411 else if(iSelected == EScrollDown) |
|
412 { |
|
413 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
414 if(!outputSheet->CanDown()) |
|
415 { |
|
416 RedrawHighlight(EScrollDown,EScrollUp); |
|
417 iSelected = EScrollUp; |
|
418 } |
|
419 } |
|
420 } |
|
421 else |
|
422 { |
|
423 // Input data if the button has been pressed or long pressed. |
|
424 if ( iInputData || iIsKeyLongPress ) |
|
425 { |
|
426 iContainer->View()->HandleCommandL(KButtonsIdTblTouch[iSelected]); |
|
427 iInputData = EFalse; |
|
428 } |
|
429 } |
|
430 |
|
431 } |
|
432 if( iErrorCode != KErrNone ) |
|
433 { |
|
434 ErrorMsgL( iErrorCode ); |
|
435 iErrorCode = KErrNone; |
|
436 } |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // CCalcFuncmapSubPane::OfferKeyEventL |
|
441 // This function is called by CCalcContainer::OfferKeyEventL |
|
442 // (other items were commented in a header). |
|
443 // --------------------------------------------------------- |
|
444 // |
|
445 TKeyResponse CCalcFuncmapSubPane::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
446 { |
|
447 TKeyResponse exitCode(EKeyWasNotConsumed); |
|
448 |
|
449 TPtiKey keyQwertyValue = (TPtiKey)aKeyEvent.iScanCode; |
|
450 |
|
451 if(IsQwertyKeypadActive()) |
|
452 { |
|
453 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
454 if ( iKeyboardType == EPtiKeyboardHalfQwerty ) |
|
455 { |
|
456 TBuf<KMaxNumCharsPerCase> keys; |
|
457 TInt firstoperator(-1); |
|
458 TInt secondoperator(-1); |
|
459 |
|
460 TInt oldSelect( iSelected ); |
|
461 |
|
462 if ( ( aKeyEvent.iScanCode == EStdKeyLeftFunc && aType == EEventKeyDown ) || |
|
463 ( aKeyEvent.iScanCode == EStdKeyLeftShift && aType == EEventKeyDown ) ) |
|
464 { |
|
465 iEngine->MappingDataForKey( keyQwertyValue, keys, EPtiCaseFnLower ); |
|
466 MapDataForChrShiftKey( keys, firstoperator, secondoperator); |
|
467 if ( (secondoperator == -1) && (firstoperator != -1)) |
|
468 { |
|
469 if ( AknLayoutUtils::PenEnabled() ) |
|
470 { |
|
471 iSelected = firstoperator; |
|
472 } |
|
473 else |
|
474 { |
|
475 if ( firstoperator == ECmdTSeparator ) |
|
476 { |
|
477 iDecimalPoint = ETrue; |
|
478 } |
|
479 else |
|
480 { |
|
481 iSelected = firstoperator; |
|
482 iDecimalPoint = EFalse; |
|
483 } |
|
484 } |
|
485 } |
|
486 else if ( (firstoperator == -1) && (secondoperator != -1) ) |
|
487 { |
|
488 if ( AknLayoutUtils::PenEnabled() ) |
|
489 { |
|
490 iSelected = secondoperator; |
|
491 } |
|
492 else |
|
493 { |
|
494 if ( secondoperator == ECmdTSeparator ) |
|
495 { |
|
496 iDecimalPoint = ETrue; |
|
497 } |
|
498 else |
|
499 { |
|
500 iSelected = secondoperator; |
|
501 iDecimalPoint = EFalse; |
|
502 } |
|
503 } |
|
504 } |
|
505 else if ( (firstoperator != -1) && (secondoperator != -1) ) |
|
506 { |
|
507 if ( iLastKeyCode == aKeyEvent.iScanCode ) |
|
508 { |
|
509 if ( AknLayoutUtils::PenEnabled() ) |
|
510 { |
|
511 if ( iSelected == firstoperator ) |
|
512 { |
|
513 iSelected = secondoperator; |
|
514 } |
|
515 else |
|
516 { |
|
517 iSelected = firstoperator; |
|
518 } |
|
519 } |
|
520 else |
|
521 { |
|
522 if ( firstoperator == ECmdTSeparator || secondoperator == ECmdTSeparator ) |
|
523 { |
|
524 if ( iDecimalPoint ) |
|
525 { |
|
526 iDecimalPoint = EFalse; |
|
527 if ( firstoperator == ECmdTSeparator ) |
|
528 { |
|
529 iSelected = secondoperator; |
|
530 } |
|
531 else |
|
532 { |
|
533 iSelected = firstoperator; |
|
534 } |
|
535 } |
|
536 else |
|
537 { |
|
538 iDecimalPoint = ETrue; |
|
539 } |
|
540 } |
|
541 else |
|
542 { |
|
543 if ( iSelected == firstoperator ) |
|
544 { |
|
545 iSelected = secondoperator; |
|
546 } |
|
547 else |
|
548 { |
|
549 iSelected = firstoperator; |
|
550 } |
|
551 } |
|
552 } |
|
553 } |
|
554 else |
|
555 { |
|
556 if ( AknLayoutUtils::PenEnabled() ) |
|
557 { |
|
558 iSelected = firstoperator; |
|
559 } |
|
560 else |
|
561 { |
|
562 if ( firstoperator == ECmdTSeparator ) |
|
563 { |
|
564 iDecimalPoint = ETrue; |
|
565 } |
|
566 else |
|
567 { |
|
568 iSelected = firstoperator; |
|
569 iDecimalPoint = EFalse; |
|
570 } |
|
571 } |
|
572 |
|
573 } |
|
574 } |
|
575 RedrawHighlight( oldSelect, iSelected ); |
|
576 iLastKeyCode = aKeyEvent.iScanCode; |
|
577 exitCode = EKeyWasConsumed; |
|
578 |
|
579 iIsShiftKeyPressed = ETrue; |
|
580 } |
|
581 } |
|
582 else |
|
583 #endif |
|
584 { |
|
585 //For Multiplication operator in Qwerty keypad |
|
586 if(((aKeyEvent.iScanCode == EStdKeyLeftShift) || (aKeyEvent.iScanCode == EStdKeyRightShift)) && aType == EEventKeyDown) |
|
587 { |
|
588 if(iShiftKeyPressed == EPtiCaseLower ) |
|
589 { |
|
590 iShiftKeyPressed = EPtiCaseUpper; |
|
591 iShiftKey = 0; |
|
592 iValue = ETrue; |
|
593 } |
|
594 |
|
595 else |
|
596 { |
|
597 iShiftKeyPressed = EPtiCaseLower; |
|
598 } |
|
599 exitCode = EKeyWasConsumed; |
|
600 |
|
601 iIsShiftKeyPressed = ETrue; |
|
602 } |
|
603 else if((aKeyEvent.iScanCode == EStdKeyLeftShift || aKeyEvent.iScanCode == EStdKeyRightShift)&& aType == EEventKeyUp) |
|
604 { |
|
605 /*if(((iLanguage == ELangFrench) || (iLanguage == ELangTaiwanChinese) || |
|
606 (iLanguage == ELangCzech) || (iLanguage == ELangSlovak))&& iShiftKey >= 1)*/ |
|
607 if( iShiftKey >= 1 ) |
|
608 { |
|
609 iShiftKeyPressed = EPtiCaseLower; |
|
610 } |
|
611 iValue = EFalse; |
|
612 exitCode = EKeyWasConsumed; |
|
613 |
|
614 iIsShiftKeyPressed = ETrue; |
|
615 } |
|
616 } |
|
617 //else |
|
618 if ( !iIsShiftKeyPressed ) |
|
619 { |
|
620 if (aType != EEventKey) |
|
621 { |
|
622 if (aType == EEventKeyDown) |
|
623 { |
|
624 iIsOfferKeyEvent = ETrue; |
|
625 } |
|
626 else if (aType == EEventKeyUp) |
|
627 { |
|
628 iIsOfferKeyEvent = EFalse; |
|
629 } |
|
630 // when users press send key, EKeyWasNotConsumed is returned to system |
|
631 // to open dialer |
|
632 if ( aKeyEvent.iScanCode == EStdKeyYes ) |
|
633 { |
|
634 return EKeyWasNotConsumed; |
|
635 } |
|
636 return EKeyWasConsumed; |
|
637 } |
|
638 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
639 if( MapNumericCharL( aKeyEvent ) ) |
|
640 { |
|
641 exitCode = EKeyWasConsumed; |
|
642 iShiftKeyPressed = EPtiCaseLower; |
|
643 } |
|
644 #else |
|
645 if(MapNumericCharL(keyQwertyValue,iShiftKeyPressed)) |
|
646 { |
|
647 exitCode = EKeyWasConsumed; |
|
648 iShiftKeyPressed = EPtiCaseLower; |
|
649 } |
|
650 #endif |
|
651 else |
|
652 { |
|
653 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
654 if( MapNumerics( aKeyEvent ) || aKeyEvent.iCode == EKeyBackspace ) |
|
655 { |
|
656 exitCode = EKeyWasNotConsumed; |
|
657 iShiftKeyPressed = EPtiCaseLower; |
|
658 |
|
659 /*if((iLanguage == ELangFrench) || (iLanguage == ELangTaiwanChinese) || |
|
660 (iLanguage == ELangCzech) || (iLanguage == ELangSlovak))*/ |
|
661 { |
|
662 if( !iValue ) |
|
663 iShiftKeyPressed = EPtiCaseLower; |
|
664 |
|
665 else |
|
666 iShiftKeyPressed = EPtiCaseUpper; |
|
667 iShiftKey++; |
|
668 } |
|
669 } |
|
670 #else |
|
671 if(MapNumerics(keyQwertyValue,iShiftKeyPressed) || aKeyEvent.iCode == EKeyBackspace) |
|
672 { |
|
673 exitCode = EKeyWasNotConsumed; |
|
674 iShiftKeyPressed = EPtiCaseLower; |
|
675 |
|
676 /*if((iLanguage == ELangFrench) || (iLanguage == ELangTaiwanChinese) || |
|
677 (iLanguage == ELangCzech) || (iLanguage == ELangSlovak))*/ |
|
678 { |
|
679 if(!iValue) |
|
680 iShiftKeyPressed = EPtiCaseLower; |
|
681 |
|
682 else |
|
683 iShiftKeyPressed = EPtiCaseUpper; |
|
684 iShiftKey++; |
|
685 } |
|
686 } |
|
687 #endif |
|
688 else |
|
689 { |
|
690 exitCode = EKeyWasConsumed; |
|
691 iShiftKeyPressed = EPtiCaseLower; |
|
692 } |
|
693 |
|
694 } |
|
695 |
|
696 } |
|
697 |
|
698 // handle Enter key event |
|
699 if ( aKeyEvent.iCode == EKeyEnter ) |
|
700 { |
|
701 exitCode = EKeyWasConsumed; |
|
702 HandleMiddleSoftKeyOREKeyOKL(); |
|
703 iShiftKeyPressed = EPtiCaseLower; |
|
704 return exitCode; |
|
705 } |
|
706 |
|
707 iIsShiftKeyPressed = EFalse; |
|
708 |
|
709 } |
|
710 |
|
711 /* if(aKeyEvent.iCode == EKeyOK) |
|
712 { |
|
713 |
|
714 HandleMiddleSoftKeyOREKeyOKL(); |
|
715 exitCode = EKeyWasConsumed; |
|
716 } |
|
717 else if (aType == EEventKey)*/ |
|
718 if (aType == EEventKey) |
|
719 { |
|
720 TInt oldSelect(iSelected); |
|
721 TInt row(iSelected % iButtonsInRow); |
|
722 TInt column(iSelected / iButtonsInRow); |
|
723 iIsOfferKeyEvent = EFalse; |
|
724 switch(aKeyEvent.iCode) |
|
725 { |
|
726 case EKeyLeftArrow: |
|
727 { |
|
728 |
|
729 do |
|
730 { |
|
731 |
|
732 column--; |
|
733 |
|
734 if(column < 0) |
|
735 { |
|
736 column = iButtonsInColumn -1; |
|
737 row--; |
|
738 |
|
739 if( row < 0 ) |
|
740 { |
|
741 row = iButtonsInRow -1; |
|
742 } |
|
743 } |
|
744 |
|
745 iSelected = row + column * iButtonsInRow; |
|
746 |
|
747 }while( iButtons[iSelected]->IsDimmed() ); |
|
748 |
|
749 RedrawHighlight( oldSelect, iSelected, ETrue ); |
|
750 |
|
751 exitCode = EKeyWasConsumed; |
|
752 break; |
|
753 } |
|
754 |
|
755 case EKeyRightArrow: |
|
756 { |
|
757 |
|
758 do |
|
759 { |
|
760 column++; |
|
761 |
|
762 if(column == iButtonsInColumn) |
|
763 { |
|
764 column = 0; |
|
765 row++; |
|
766 |
|
767 if( row >= iButtonsInRow ) |
|
768 { |
|
769 row = 0; |
|
770 } |
|
771 } |
|
772 |
|
773 iSelected = row + column * iButtonsInRow; |
|
774 |
|
775 }while( iButtons[iSelected]->IsDimmed() ); |
|
776 |
|
777 RedrawHighlight( oldSelect, iSelected, ETrue ); |
|
778 exitCode = EKeyWasConsumed; |
|
779 break; |
|
780 } |
|
781 |
|
782 case EKeyUpArrow: |
|
783 { |
|
784 |
|
785 SetNextCursorPosForUpArrow(oldSelect); |
|
786 |
|
787 RedrawHighlight( oldSelect, iSelected, ETrue ); |
|
788 exitCode = EKeyWasConsumed; |
|
789 break; |
|
790 } |
|
791 |
|
792 case EKeyDownArrow: |
|
793 { |
|
794 |
|
795 SetNextCursorPosForDownArrow(oldSelect); |
|
796 |
|
797 RedrawHighlight( oldSelect, iSelected, ETrue ); |
|
798 exitCode = EKeyWasConsumed; |
|
799 break; |
|
800 } |
|
801 |
|
802 case EKeyOK: |
|
803 { |
|
804 if ( !AknLayoutUtils::PenEnabled() ) |
|
805 { |
|
806 // get and judge the state of button |
|
807 CAknButton* button = iButtons[iSelected]; |
|
808 CAknButtonState* state = button->State( EnNormal ); |
|
809 if ( ( iSelected == EScrollUp || iSelected == EScrollDown ) |
|
810 && ( state->Flags() == EnPressed ) ) |
|
811 { |
|
812 iContainer->View()->HandleCommandL( KButtonsIdTbl[iSelected] ); |
|
813 // when the history arrives the top or bottom,the button should be set dimmed |
|
814 CCalcOutputSheet* outputSheet = iContainer->OutputSheet(); |
|
815 if ( !( outputSheet->CanDown() ) && iSelected == EScrollDown ) |
|
816 { |
|
817 button->SetDimmed( ETrue ); |
|
818 DrawDeferred(); |
|
819 } |
|
820 if ( !( outputSheet->CanUp() ) && iSelected == EScrollUp ) |
|
821 { |
|
822 button->SetDimmed( ETrue ); |
|
823 DrawDeferred(); |
|
824 } |
|
825 } |
|
826 } |
|
827 break; |
|
828 } |
|
829 default: |
|
830 { |
|
831 if(!IsQwertyKeypadActive()) |
|
832 { |
|
833 if(aKeyEvent.iCode == KCalcAsteriskBtn) |
|
834 { |
|
835 if(iLastKeyCode == aKeyEvent.iCode) |
|
836 { |
|
837 row++; |
|
838 |
|
839 if(row == iButtonsInRow - 1) // Equal is not contained in a loop. |
|
840 { |
|
841 row = 0; |
|
842 } |
|
843 iSelected = row + column * iButtonsInRow; |
|
844 } |
|
845 else |
|
846 { |
|
847 if(AknLayoutUtils::PenEnabled()) |
|
848 { |
|
849 iSelected = ECmdTAdd; |
|
850 } |
|
851 else |
|
852 { |
|
853 iSelected = EPlusButton; |
|
854 } |
|
855 |
|
856 } |
|
857 RedrawHighlight( oldSelect, iSelected); |
|
858 exitCode = EKeyWasConsumed; |
|
859 } |
|
860 } |
|
861 break; |
|
862 } |
|
863 } |
|
864 iLastKeyCode = aKeyEvent.iCode; |
|
865 |
|
866 } |
|
867 else if (aType == EEventKeyDown) |
|
868 { |
|
869 iIsOfferKeyEvent = ETrue; |
|
870 // If the enter key has been pressed, set the button and input data. |
|
871 if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter ) |
|
872 { |
|
873 exitCode = EKeyWasConsumed; |
|
874 HandleMiddleSoftKeyOREKeyOKL(); |
|
875 iShiftKeyPressed = EPtiCaseLower; |
|
876 return exitCode; |
|
877 } |
|
878 } |
|
879 else if (aType == EEventKeyUp) |
|
880 { |
|
881 iIsOfferKeyEvent = EFalse; |
|
882 // Release the button when enter key released. |
|
883 if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter ) |
|
884 { |
|
885 NotifyReleaseKeyL(); |
|
886 } |
|
887 } |
|
888 |
|
889 |
|
890 return exitCode; |
|
891 } |
|
892 |
|
893 |
|
894 // C++ default constructor can NOT contain any code, that |
|
895 // might leave. |
|
896 // |
|
897 CCalcFuncmapSubPane::CCalcFuncmapSubPane() |
|
898 { |
|
899 } |
|
900 |
|
901 |
|
902 // default constructor can leave. |
|
903 void CCalcFuncmapSubPane::ConstructL |
|
904 (CCalcContainer* aContainer) |
|
905 { |
|
906 iSelected = 0; |
|
907 iContainer = aContainer; |
|
908 iIsOfferKeyEvent = EFalse; |
|
909 iErrorCode = KErrNone; |
|
910 iShowDrawHight = EFalse; |
|
911 iInputData = EFalse; |
|
912 SetContainerWindowL(*iContainer); |
|
913 // Read character sequence tables, such as -, +. |
|
914 iCalcAppEnv = CCalcAppEnv::Static(); |
|
915 iIsChangeSignDimmed = ETrue; |
|
916 |
|
917 if( AknLayoutUtils::PenEnabled() ) |
|
918 { |
|
919 iCountOfButtons = KCountOfButtonsTouch; |
|
920 iButtonsInRow = KButtonsInRowTouch; |
|
921 iButtonsInColumn = KButtonsInColumnTouch; |
|
922 |
|
923 } |
|
924 else |
|
925 { |
|
926 iCountOfButtons = KCountOfButtons; |
|
927 iButtonsInRow = KButtonsInRow; |
|
928 iButtonsInColumn = KButtonsInColumn; |
|
929 |
|
930 } |
|
931 |
|
932 |
|
933 for (TInt count = 0; count < iCountOfButtons; count++) |
|
934 { |
|
935 //Create the AknButtons |
|
936 if(AknLayoutUtils::PenEnabled()) |
|
937 { |
|
938 iButtons[count] = CAknButton::NewL( |
|
939 iCalcAppEnv->UnpressedButtonBmp(count), |
|
940 NULL, |
|
941 NULL, |
|
942 NULL, |
|
943 _L(""), |
|
944 _L(""), |
|
945 // Report the observer when the button recieve the key down event. |
|
946 KAknButtonReportOnKeyDown, |
|
947 0 |
|
948 ); |
|
949 |
|
950 } |
|
951 else |
|
952 { |
|
953 |
|
954 iButtons[count] = CAknButton::NewL( |
|
955 iCalcAppEnv->UnpressedButtonBmp(count), |
|
956 NULL, |
|
957 iCalcAppEnv->PressedButtonBmp(count), |
|
958 NULL, |
|
959 _L(""), |
|
960 _L(""), |
|
961 // Report the observer when the button recieve the key down event. |
|
962 KAknButtonReportOnKeyDown, |
|
963 0 |
|
964 ); |
|
965 /*if((count == ESqrtButton) && !iIsChangeSignDimmed) |
|
966 { |
|
967 iButtons[count]->SetDimmed(ETrue); |
|
968 }*/ |
|
969 |
|
970 } |
|
971 |
|
972 iButtons[count]->SetContainerWindowL( *this ); |
|
973 iButtons[count]->SetObserver( this ); |
|
974 } |
|
975 |
|
976 if ( AknLayoutUtils::PenEnabled() ) |
|
977 { |
|
978 iButtons[ECmdTCancel]->SetButtonFlags( KAknButtonReportOnLongPress ); |
|
979 } |
|
980 iSelected = 0; |
|
981 RedrawHighlight( iSelected, iSelected ); |
|
982 |
|
983 User::LeaveIfError(iQwertyModeStatusProperty.Attach(KCRUidAvkon, KAknQwertyInputModeActive)); |
|
984 |
|
985 iShiftKeyPressed = EPtiCaseLower; |
|
986 iShiftKey = 0; |
|
987 |
|
988 // Try to get the English key mappings. If those are not available, use the |
|
989 // mappings of the current input language. The order is this because all mappings |
|
990 // do not necessarily contain all characters neeeded by the Calculator. |
|
991 iLanguage = ELangEnglish; |
|
992 iEngine = CPtiEngine::NewL(ETrue); |
|
993 iCoreLanguage = static_cast<CPtiCoreLanguage*>(iEngine->GetLanguage( iLanguage )); |
|
994 |
|
995 if( !iCoreLanguage ) |
|
996 { |
|
997 iCRKey = CRepository::NewL(KCRUidAknFep); |
|
998 TInt ret = iCRKey->Get(KAknFepInputTxtLang,iLanguage); |
|
999 if( ret!= KErrNone ) |
|
1000 { |
|
1001 //Exit application if server is busy( Error Raised ) |
|
1002 iAvkonViewAppUi->Exit(); |
|
1003 } |
|
1004 iCoreLanguage = static_cast<CPtiCoreLanguage*>(iEngine->GetLanguage(iLanguage)); |
|
1005 } |
|
1006 |
|
1007 RProperty::Get( KCRUidAvkon, KAknKeyBoardLayout, iKeyboardType ); |
|
1008 |
|
1009 if( iCoreLanguage ) |
|
1010 { |
|
1011 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1012 if ( iKeyboardType == EPtiKeyboardHalfQwerty) |
|
1013 { |
|
1014 iHalfQwertyKeyMappings = static_cast<CPtiHalfQwertyKeyMappings*>(iCoreLanguage->GetHalfQwertyKeymappings()); |
|
1015 } |
|
1016 else |
|
1017 #endif |
|
1018 { |
|
1019 iQwertyKeyMappings = static_cast<CPtiQwertyKeyMappings*>(iCoreLanguage->GetQwertyKeymappings()); |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 // UI language is used to determine the used number format. |
|
1024 iUiLanguage = User::Language(); |
|
1025 |
|
1026 |
|
1027 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1028 |
|
1029 if ( iKeyboardType == EPtiKeyboardHalfQwerty ) |
|
1030 { |
|
1031 iEngine->ActivateLanguageL( iLanguage, EPtiEngineHalfQwerty ); |
|
1032 } |
|
1033 else if ( IsQwertyKeypadActive()) |
|
1034 { |
|
1035 iEngine->ActivateLanguageL( iLanguage, EPtiEngineQwerty ); |
|
1036 } |
|
1037 |
|
1038 // RProperty::Get( KCRUidAvkon, KAknKeyBoardLayout, iKeyboardType ); |
|
1039 iEngine->SetKeyboardType( TPtiKeyboardType (iKeyboardType )); |
|
1040 |
|
1041 #endif |
|
1042 |
|
1043 iIsShiftKeyPressed = EFalse; |
|
1044 |
|
1045 } |
|
1046 |
|
1047 // --------------------------------------------------------- |
|
1048 // CCalcFuncmapSubPane::RefreshButtonIcons |
|
1049 // This function is called by CCalcContainer::OfferKeyEventL |
|
1050 // (other items were commented in a header). |
|
1051 // --------------------------------------------------------- |
|
1052 // |
|
1053 void CCalcFuncmapSubPane::RefreshButtonIcons() |
|
1054 { |
|
1055 /*for (TInt count(0); count < iCountOfButtons; count++) |
|
1056 { |
|
1057 iButtons[count]->SetBitmapIcons(iCalcAppEnv->UnpressedButtonBmp(count), |
|
1058 iCalcAppEnv->PressedButtonBmp(count), |
|
1059 iCalcAppEnv->InactiveButtonBmp(count)); |
|
1060 }*/ |
|
1061 } |
|
1062 // --------------------------------------------------------- |
|
1063 // CCalcFuncmapSubPane::SetScrollupEnable |
|
1064 // Redraw scroll-up button on scrolling enable. |
|
1065 // (other items were commented in a header). |
|
1066 // --------------------------------------------------------- |
|
1067 // |
|
1068 void CCalcFuncmapSubPane::SetScrollupEnable |
|
1069 (TBool aEnable) |
|
1070 { |
|
1071 //Enabling/Disabling of scroll up buttons only for Non-Touch |
|
1072 if(!AknLayoutUtils::PenEnabled()) |
|
1073 { |
|
1074 CAknButton* scrollUp = iButtons[EScrollUp]; |
|
1075 scrollUp->SetDimmed( !aEnable ); |
|
1076 scrollUp->DrawNow(); |
|
1077 } |
|
1078 |
|
1079 } |
|
1080 |
|
1081 |
|
1082 // --------------------------------------------------------- |
|
1083 // CCalcFuncmapSubPane::SetScrolldownEnable |
|
1084 // Redraw scroll-down button on scrolling enable. |
|
1085 // (other items were commented in a header). |
|
1086 // --------------------------------------------------------- |
|
1087 // |
|
1088 void CCalcFuncmapSubPane::SetScrolldownEnable |
|
1089 (TBool aEnable) |
|
1090 { |
|
1091 //Enabling/Disabling of scroll down buttons only for Non-Touch |
|
1092 if(!AknLayoutUtils::PenEnabled()) |
|
1093 { |
|
1094 CAknButton* scrollDown = iButtons[EScrollDown]; |
|
1095 scrollDown->SetDimmed( !aEnable ); |
|
1096 scrollDown->DrawNow(); |
|
1097 } |
|
1098 } |
|
1099 |
|
1100 |
|
1101 // --------------------------------------------------------- |
|
1102 // CCalcFuncmapSubPane::SetNextCursorPosForUpArrow |
|
1103 // Set next cursor position whwn pressing uparrow key. |
|
1104 // (other items were commented in a header). |
|
1105 // --------------------------------------------------------- |
|
1106 // |
|
1107 void CCalcFuncmapSubPane::SetNextCursorPosForUpArrow(TInt aOldPos) |
|
1108 { |
|
1109 |
|
1110 TInt row(aOldPos % iButtonsInRow); |
|
1111 TInt column(aOldPos / iButtonsInRow); |
|
1112 |
|
1113 do |
|
1114 { row--; |
|
1115 |
|
1116 if(row < 0) |
|
1117 { |
|
1118 column--; |
|
1119 |
|
1120 if(column < 0) |
|
1121 { |
|
1122 column = iButtonsInColumn -1; |
|
1123 } |
|
1124 row = iButtonsInRow - 1; |
|
1125 } |
|
1126 iSelected = row + column * iButtonsInRow; |
|
1127 |
|
1128 }while( iButtons[iSelected]->IsDimmed() ); |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------- |
|
1132 // CCalcFuncmapSubPane::SetNextCursorPosForDownArrow |
|
1133 // Set next cursor position whwn pressing downarrow key. |
|
1134 // (other items were commented in a header). |
|
1135 // --------------------------------------------------------- |
|
1136 // |
|
1137 void CCalcFuncmapSubPane::SetNextCursorPosForDownArrow(TInt aOldPos) |
|
1138 { |
|
1139 TInt row(aOldPos % iButtonsInRow); |
|
1140 TInt column(aOldPos / iButtonsInRow); |
|
1141 |
|
1142 do |
|
1143 { row++; |
|
1144 |
|
1145 if(row == iButtonsInRow) // KButtonsInRow is equal to "number of rows in column" |
|
1146 { |
|
1147 row = 0; |
|
1148 |
|
1149 //move focus from last item to first item, column should be added one |
|
1150 column++; |
|
1151 |
|
1152 if( column == iButtonsInColumn ) |
|
1153 { |
|
1154 column = 0; |
|
1155 } |
|
1156 } |
|
1157 iSelected = row + column * iButtonsInRow; |
|
1158 |
|
1159 }while( iButtons[iSelected]->IsDimmed() ); |
|
1160 } |
|
1161 |
|
1162 |
|
1163 // --------------------------------------------------------- |
|
1164 // CCalcFuncmapSubPane::RedrawHighlight |
|
1165 // An old highlight rectangle is erased and |
|
1166 // a new highlight rectangle is drawn. |
|
1167 // (other items were commented in a header). |
|
1168 // --------------------------------------------------------- |
|
1169 // |
|
1170 void CCalcFuncmapSubPane::RedrawHighlight |
|
1171 (TUint aOldId, // The button chosen before |
|
1172 TUint aNewId) // The button chosen newly |
|
1173 { |
|
1174 // The State of each button is set. |
|
1175 CAknButton* button = iButtons[aOldId]; |
|
1176 CAknButtonState* state = button->State(EnNormal); |
|
1177 |
|
1178 if(state->Flags() == EnPressed) |
|
1179 { |
|
1180 TKeyEvent aKeyEvent; |
|
1181 aKeyEvent.iScanCode = EStdKeyEnter; |
|
1182 TEventCode aType = EEventKeyUp; |
|
1183 //trigger offerkeyeventl to this button |
|
1184 TRAP_IGNORE(button->OfferKeyEventL(aKeyEvent,aType)); |
|
1185 state->SetFlags(EnNormal); |
|
1186 } |
|
1187 |
|
1188 if( aOldId != aNewId ) |
|
1189 { |
|
1190 button->SetFocus( EFalse, EDrawNow ); |
|
1191 button = iButtons[aNewId]; |
|
1192 } |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------- |
|
1196 // CCalcFuncmapSubPane::RedrawHighlight |
|
1197 // An old highlight rectangle is erased and |
|
1198 // a new highlight rectangle is drawn. |
|
1199 // (other items were commented in a header). |
|
1200 // --------------------------------------------------------- |
|
1201 // |
|
1202 void CCalcFuncmapSubPane::RedrawHighlight |
|
1203 (TUint aOldId, // The button chosen before |
|
1204 TUint aNewId, |
|
1205 TBool aShowHightlight) // The button chosen newly |
|
1206 { |
|
1207 // The State of each button is set. |
|
1208 CAknButton* button = iButtons[aOldId]; |
|
1209 CAknButtonState* state = button->State(EnNormal); |
|
1210 iShowDrawHight = ETrue; |
|
1211 if( state->Flags() == EnPressed ) |
|
1212 { |
|
1213 TKeyEvent aKeyEvent; |
|
1214 aKeyEvent.iScanCode = EStdKeyEnter; |
|
1215 TEventCode aType = EEventKeyUp; |
|
1216 //trigger offerkeyeventl to this button |
|
1217 TRAP_IGNORE(button->OfferKeyEventL(aKeyEvent,aType)); |
|
1218 state->SetFlags(EnNormal); |
|
1219 } |
|
1220 if( aOldId != aNewId ) |
|
1221 { |
|
1222 button->SetFocus( EFalse, EDrawNow ); |
|
1223 button = iButtons[aNewId]; |
|
1224 button->SetFocus( ETrue, EDrawNow ); |
|
1225 } |
|
1226 } |
|
1227 // --------------------------------------------------------- |
|
1228 // CCalcFuncmapSubPane::SetLayout |
|
1229 // Set functionmap button layout. |
|
1230 // (other items were commented in a header). |
|
1231 // --------------------------------------------------------- |
|
1232 // |
|
1233 |
|
1234 |
|
1235 void CCalcFuncmapSubPane::SetLayout() |
|
1236 { |
|
1237 TRect parentRect(Rect()); |
|
1238 |
|
1239 TInt t = 0; |
|
1240 if( AknLayoutUtils::PenEnabled() ) |
|
1241 { |
|
1242 for (TInt count(0); count < KButtonsInColumnTouch; count++) |
|
1243 { |
|
1244 for (TInt row(0); row < 5; row++) |
|
1245 { |
|
1246 |
|
1247 TAknWindowLineLayout area; |
|
1248 TAknWindowLineLayout area1; |
|
1249 |
|
1250 TAknWindowLineLayout areaG2; |
|
1251 TAknWindowLineLayout areaGraphics; |
|
1252 |
|
1253 area= AknLayoutScalable_Apps::toolbar_button_pane_cp01(1).LayoutLine(); |
|
1254 areaG2= AknLayoutScalable_Apps::cell_calc_pane_g2(1).LayoutLine(); |
|
1255 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
1256 { |
|
1257 area1 = AknLayoutScalable_Apps::cell_calc_pane(count,row,enTouch_with_prt).LayoutLine(); |
|
1258 } |
|
1259 else |
|
1260 { |
|
1261 area1 = AknLayoutScalable_Apps::cell_calc_pane(count,row,enTouch_enabled).LayoutLine(); |
|
1262 } |
|
1263 |
|
1264 areaGraphics = area1; |
|
1265 areaGraphics.iW = areaGraphics.iW - areaG2.il - areaG2.ir; |
|
1266 areaGraphics.iH = areaG2.iH; |
|
1267 |
|
1268 area1.il = area1.il + area.il; |
|
1269 area1.ir = area1.ir - area.ir; |
|
1270 area1.it = area1.it + area.it; |
|
1271 area1.ib = area1.ib - area.ib; |
|
1272 area1.iW = area1.iW - area.il - area.ir; |
|
1273 area1.iH = area1.iH - area.it - area.ib; |
|
1274 |
|
1275 |
|
1276 //A change in values here |
|
1277 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1278 { |
|
1279 AknLayoutUtils::LayoutControl( |
|
1280 iButtons[t], parentRect,/*AknLayoutScalable_Apps::cell_calc_pane(count,Row,enTouch_with_prt).LayoutLine()*/area1 ); |
|
1281 } |
|
1282 else |
|
1283 { |
|
1284 AknLayoutUtils::LayoutControl( |
|
1285 iButtons[t], parentRect,/*AknLayoutScalable_Apps::cell_calc_pane(count,Row,enTouch_enabled).LayoutLine()*/area1 ); |
|
1286 } |
|
1287 |
|
1288 TSize iconSize( areaGraphics.iW, areaGraphics.iH ); |
|
1289 iButtons[t]->SetIconSize( iconSize ); |
|
1290 TRect rect = iButtons[t]->Rect(); |
|
1291 rect.iBr.iX += 5; |
|
1292 rect.iBr.iY += 5; |
|
1293 rect.iTl.iX -= 5; |
|
1294 rect.iTl.iY -= 5; |
|
1295 |
|
1296 if ( FeatureManager::FeatureSupported( KFeatureIdRockerKey ) ) |
|
1297 { |
|
1298 iButtons[t]->SetHighlightRect( rect ); |
|
1299 } |
|
1300 t++; |
|
1301 } |
|
1302 } |
|
1303 |
|
1304 } |
|
1305 |
|
1306 |
|
1307 else |
|
1308 { |
|
1309 for (TInt count(0); count < KButtonsInColumn; count++) |
|
1310 { |
|
1311 for (TInt row(0); row < 5; row++) |
|
1312 { |
|
1313 AknLayoutUtils::LayoutControl( |
|
1314 iButtons[t], parentRect, AknLayoutScalable_Apps::cell_calc_pane( count, row ).LayoutLine()); |
|
1315 iButtons[t]->SetHighlightRect( iButtons[t]->Rect() ); |
|
1316 t++; |
|
1317 } |
|
1318 |
|
1319 } |
|
1320 } |
|
1321 |
|
1322 |
|
1323 } |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 // --------------------------------------------------------- |
|
1329 // CCalcFuncmapSubPane::CountComponentControls |
|
1330 // The count of child control is returned. |
|
1331 // (other items were commented in a header). |
|
1332 // --------------------------------------------------------- |
|
1333 // |
|
1334 TInt CCalcFuncmapSubPane::CountComponentControls() const |
|
1335 { |
|
1336 return iCountOfButtons; |
|
1337 } |
|
1338 |
|
1339 // --------------------------------------------------------- |
|
1340 // CCalcFuncmapSubPane::ComponentControl |
|
1341 // Child control's pointer corresponding to the specified index is returned. |
|
1342 // (other items were commented in a header). |
|
1343 // --------------------------------------------------------- |
|
1344 // |
|
1345 CCoeControl* CCalcFuncmapSubPane::ComponentControl |
|
1346 (TInt aIndex) const |
|
1347 { |
|
1348 return iButtons[aIndex]; |
|
1349 } |
|
1350 |
|
1351 // --------------------------------------------------------- |
|
1352 // CCalcFuncmapSubPane::GetButtonBitmapControl |
|
1353 // This function is called when the size changes. |
|
1354 // (other items were commented in a header). |
|
1355 // --------------------------------------------------------- |
|
1356 // |
|
1357 /*CCalcCommandButton*/CAknButton* CCalcFuncmapSubPane::GetButtonBitmapControl |
|
1358 (TInt aIndex) |
|
1359 { |
|
1360 return iButtons[aIndex]; |
|
1361 } |
|
1362 |
|
1363 // --------------------------------------------------------- |
|
1364 // CCalcFuncmapSubPane::SizeChanged |
|
1365 // This function is called when the size changes. |
|
1366 // (other items were commented in a header). |
|
1367 // --------------------------------------------------------- |
|
1368 // |
|
1369 void CCalcFuncmapSubPane::SizeChanged() |
|
1370 { |
|
1371 SetLayout(); |
|
1372 } |
|
1373 |
|
1374 |
|
1375 // --------------------------------------------------------- |
|
1376 // CCalcFuncmapSubPane::SetSqrtEnable |
|
1377 // Redraw square root button, either normal or dimmed. |
|
1378 // (other items were commented in a header). |
|
1379 // --------------------------------------------------------- |
|
1380 // |
|
1381 void CCalcFuncmapSubPane::SetSqrtEnable(TBool aEnable) |
|
1382 { |
|
1383 //Get the sqrt button |
|
1384 CAknButton* button = NULL; |
|
1385 if( !AknLayoutUtils::PenEnabled() ) |
|
1386 { |
|
1387 button = iButtons[ESqrtButton]; |
|
1388 } |
|
1389 else |
|
1390 { |
|
1391 button = iButtons[ECmdTSqrt]; |
|
1392 } |
|
1393 if( button ) |
|
1394 { |
|
1395 button->SetDimmed(!aEnable); |
|
1396 button->DrawNow(); |
|
1397 } |
|
1398 iIsSqrtDimmed = aEnable; |
|
1399 } |
|
1400 |
|
1401 |
|
1402 // --------------------------------------------------------- |
|
1403 // CCalcFuncmapSubPane::SetPercentEnable |
|
1404 // Redraw percent button, either normal or dimmed. |
|
1405 // (other items were commented in a header). |
|
1406 // --------------------------------------------------------- |
|
1407 // |
|
1408 void CCalcFuncmapSubPane::SetPercentEnable(TBool aEnable) |
|
1409 { |
|
1410 //Get the percent button |
|
1411 CAknButton* button = NULL; |
|
1412 if( !AknLayoutUtils::PenEnabled() ) |
|
1413 { |
|
1414 button = iButtons[EPercentButton]; |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 button = iButtons[ECmdTPercent]; |
|
1419 } |
|
1420 if( button ) |
|
1421 { |
|
1422 button->SetDimmed(!aEnable); |
|
1423 button->DrawNow(); |
|
1424 } |
|
1425 iIsPercentDimmed = aEnable; |
|
1426 } |
|
1427 |
|
1428 // --------------------------------------------------------- |
|
1429 // CCalcFuncmapSubPane::MapNumericChar |
|
1430 // Redraw percent button, either normal or dimmed. |
|
1431 // (other items were commented in a header). |
|
1432 // --------------------------------------------------------- |
|
1433 // |
|
1434 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1435 TBool CCalcFuncmapSubPane::MapNumericCharL( TKeyEvent aKeyEvent ) |
|
1436 { |
|
1437 TBuf<KMaxNumCharsPerCase> keys; |
|
1438 |
|
1439 TPtiKey aKey = ( TPtiKey )aKeyEvent.iScanCode; |
|
1440 |
|
1441 |
|
1442 if( !keys.Length() ) |
|
1443 { |
|
1444 keys.Append( aKeyEvent.iCode ); |
|
1445 } |
|
1446 |
|
1447 if ( keys.Length() > 0 ) |
|
1448 { |
|
1449 TUint16 firstChar = keys[0]; |
|
1450 switch ( firstChar ) |
|
1451 { |
|
1452 case KPtiPinyinMarker: |
|
1453 case KPtiStrokeMarker: |
|
1454 case KPtiZhuyinMarker: |
|
1455 case KPtiCangjieMarker: |
|
1456 case KPtiGetAllMarker: |
|
1457 if ( keys.Length() > 1 ) |
|
1458 { |
|
1459 firstChar = keys[1]; |
|
1460 } |
|
1461 default: |
|
1462 break; |
|
1463 } |
|
1464 |
|
1465 TInt loc1 = KAllowedOperatorPlus().Locate( firstChar ); |
|
1466 if ( loc1 != KErrNotFound ) |
|
1467 { |
|
1468 iContainer->View()->HandleCommandL( KButtonsIdTbl[0] ); |
|
1469 return ETrue; |
|
1470 } |
|
1471 TInt loc2 = KAllowedOperatorMinus().Locate( firstChar ); |
|
1472 if ( loc2 != KErrNotFound ) |
|
1473 { |
|
1474 iContainer->View()->HandleCommandL( KButtonsIdTbl[1] ); |
|
1475 return ETrue; |
|
1476 } |
|
1477 TInt loc3 = KAllowedOperatorStar().Locate( firstChar ); |
|
1478 if ( loc3 != KErrNotFound ) |
|
1479 { |
|
1480 iContainer->View()->HandleCommandL( KButtonsIdTbl[2] ); |
|
1481 return ETrue; |
|
1482 } |
|
1483 TInt loc4 = KAllowedOperatorDivide().Locate( firstChar ); |
|
1484 if ( loc4 != KErrNotFound ) |
|
1485 { |
|
1486 iContainer->View()->HandleCommandL( KButtonsIdTbl[3] ); |
|
1487 return ETrue; |
|
1488 } |
|
1489 TInt loc5 = KAllowedOperatorEquals().Locate( firstChar ); |
|
1490 if ( loc5 != KErrNotFound ) |
|
1491 { |
|
1492 iContainer->View()->HandleCommandL( KButtonsIdTbl[5] ); |
|
1493 return ETrue; |
|
1494 } |
|
1495 TInt loc6 = KAllowedOperatorPercent().Locate( firstChar ); |
|
1496 if ( loc6 != KErrNotFound && GetPercentButtonState() ) |
|
1497 { |
|
1498 iContainer->View()->HandleCommandL( KButtonsIdTbl[7] ); |
|
1499 return ETrue; |
|
1500 } |
|
1501 |
|
1502 } |
|
1503 |
|
1504 return EFalse; |
|
1505 } |
|
1506 |
|
1507 #else |
|
1508 TBool CCalcFuncmapSubPane::MapNumericCharL( TPtiKey aKey, TPtiTextCase aCase ) |
|
1509 { |
|
1510 TBuf<KMaxNumCharsPerCase> keys; |
|
1511 |
|
1512 iQwertyKeyMappings->GetDataForKey( aKey, keys, aCase ); |
|
1513 |
|
1514 if ( keys.Length() > 0 ) |
|
1515 { |
|
1516 TUint16 firstChar = keys[0]; |
|
1517 switch ( firstChar ) |
|
1518 { |
|
1519 case KPtiPinyinMarker: |
|
1520 case KPtiStrokeMarker: |
|
1521 case KPtiZhuyinMarker: |
|
1522 case KPtiCangjieMarker: |
|
1523 case KPtiGetAllMarker: |
|
1524 if ( keys.Length() > 1 ) |
|
1525 { |
|
1526 firstChar = keys[1]; |
|
1527 } |
|
1528 default: |
|
1529 break; |
|
1530 } |
|
1531 |
|
1532 TInt loc1 = KAllowedOperatorPlus().Locate( firstChar ); |
|
1533 if ( loc1 != KErrNotFound ) |
|
1534 { |
|
1535 iContainer->View()->HandleCommandL( KButtonsIdTbl[0] ); |
|
1536 return ETrue; |
|
1537 } |
|
1538 TInt loc2 = KAllowedOperatorMinus().Locate( firstChar ); |
|
1539 if ( loc2 != KErrNotFound ) |
|
1540 { |
|
1541 iContainer->View()->HandleCommandL( KButtonsIdTbl[1] ); |
|
1542 return ETrue; |
|
1543 } |
|
1544 TInt loc3 = KAllowedOperatorStar().Locate( firstChar ); |
|
1545 if ( loc3 != KErrNotFound ) |
|
1546 { |
|
1547 iContainer->View()->HandleCommandL( KButtonsIdTbl[2] ); |
|
1548 return ETrue; |
|
1549 } |
|
1550 TInt loc4 = KAllowedOperatorDivide().Locate( firstChar ); |
|
1551 if ( loc4 != KErrNotFound ) |
|
1552 { |
|
1553 iContainer->View()->HandleCommandL( KButtonsIdTbl[3] ); |
|
1554 return ETrue; |
|
1555 } |
|
1556 TInt loc5 = KAllowedOperatorEquals().Locate( firstChar ); |
|
1557 if ( loc5 != KErrNotFound ) |
|
1558 { |
|
1559 iContainer->View()->HandleCommandL( KButtonsIdTbl[5] ); |
|
1560 return ETrue; |
|
1561 } |
|
1562 TInt loc6 = KAllowedOperatorPercent().Locate( firstChar ); |
|
1563 if ( loc6 != KErrNotFound && GetPercentButtonState() ) |
|
1564 { |
|
1565 iContainer->View()->HandleCommandL( KButtonsIdTbl[7] ); |
|
1566 return ETrue; |
|
1567 } |
|
1568 |
|
1569 } |
|
1570 |
|
1571 return EFalse; |
|
1572 } |
|
1573 #endif |
|
1574 |
|
1575 // --------------------------------------------------------- |
|
1576 // CCalcFuncmapSubPane::MapNumericChar |
|
1577 // Redraw percent button, either normal or dimmed. |
|
1578 // (other items were commented in a header). |
|
1579 // --------------------------------------------------------- |
|
1580 // |
|
1581 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1582 TBool CCalcFuncmapSubPane::MapNumerics( TKeyEvent aKeyEvent ) |
|
1583 { |
|
1584 |
|
1585 TBuf<KMaxNumCharsPerCase> keys; |
|
1586 |
|
1587 TPtiKey aKey = ( TPtiKey )aKeyEvent.iScanCode; |
|
1588 |
|
1589 if ( !keys.Length() ) |
|
1590 { |
|
1591 keys.Append( aKeyEvent.iCode ); |
|
1592 } |
|
1593 |
|
1594 if ( keys.Length() > 0 ) |
|
1595 { |
|
1596 TUint16 firstChar = keys[0]; |
|
1597 switch ( firstChar ) |
|
1598 { |
|
1599 case KPtiPinyinMarker: |
|
1600 case KPtiStrokeMarker: |
|
1601 case KPtiZhuyinMarker: |
|
1602 case KPtiCangjieMarker: |
|
1603 case KPtiGetAllMarker: |
|
1604 if ( keys.Length() > 1 ) |
|
1605 { |
|
1606 firstChar = keys[1]; |
|
1607 } |
|
1608 default: |
|
1609 break; |
|
1610 } |
|
1611 TInt loc = KAllowedNumericChars().Locate( firstChar ); |
|
1612 if ( loc != KErrNotFound ) |
|
1613 { |
|
1614 return ETrue; |
|
1615 } |
|
1616 } |
|
1617 return EFalse; |
|
1618 } |
|
1619 |
|
1620 #else |
|
1621 TBool CCalcFuncmapSubPane::MapNumerics( TPtiKey aKey, TPtiTextCase aCase ) |
|
1622 { |
|
1623 |
|
1624 TBuf<KMaxNumCharsPerCase> keys; |
|
1625 |
|
1626 iQwertyKeyMappings->GetDataForKey( aKey, keys, aCase ); |
|
1627 |
|
1628 if ( keys.Length() > 0 ) |
|
1629 { |
|
1630 TUint16 firstChar = keys[0]; |
|
1631 switch ( firstChar ) |
|
1632 { |
|
1633 case KPtiPinyinMarker: |
|
1634 case KPtiStrokeMarker: |
|
1635 case KPtiZhuyinMarker: |
|
1636 case KPtiCangjieMarker: |
|
1637 case KPtiGetAllMarker: |
|
1638 if ( keys.Length() > 1 ) |
|
1639 { |
|
1640 firstChar = keys[1]; |
|
1641 } |
|
1642 default: |
|
1643 break; |
|
1644 } |
|
1645 TInt loc = KAllowedNumericChars().Locate( firstChar ); |
|
1646 if ( loc != KErrNotFound ) |
|
1647 { |
|
1648 return ETrue; |
|
1649 } |
|
1650 } |
|
1651 return EFalse; |
|
1652 } |
|
1653 #endif |
|
1654 |
|
1655 // --------------------------------------------------------- |
|
1656 // CCalcFuncmapSubPane::HandlePointerEventL |
|
1657 // Handles apen input in Function Pane. . |
|
1658 // (other items were commented in a header). |
|
1659 // --------------------------------------------------------- |
|
1660 // |
|
1661 void CCalcFuncmapSubPane::HandlePointerEventL |
|
1662 ( const TPointerEvent& aPointerEvent ) |
|
1663 { |
|
1664 if ( !AknLayoutUtils::PenEnabled() ) |
|
1665 { |
|
1666 return; |
|
1667 } |
|
1668 TInt oldSelect( iSelected ); |
|
1669 TInt buttonValue = CalculatingCorrectButton( aPointerEvent ); |
|
1670 if ( !iButtons[buttonValue]->IsDimmed() ) |
|
1671 { |
|
1672 iSelected = buttonValue; |
|
1673 if ( iButtons[buttonValue]->Rect().Contains( aPointerEvent.iPosition ) ) |
|
1674 { |
|
1675 RedrawHighlight( oldSelect, iSelected ); |
|
1676 } |
|
1677 else |
|
1678 { |
|
1679 //when user drag outside of button,the Button Up event is missed always. |
|
1680 //Because the pointer is out of the button and it can't get the pointer |
|
1681 //event any more. We simulate the button up event to release the button |
|
1682 //when user drag out of button |
|
1683 if( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
1684 { |
|
1685 TPointerEvent event = aPointerEvent; |
|
1686 event.iType = TPointerEvent::EButton1Up; |
|
1687 iInputData = EFalse; |
|
1688 if( iErrorCode != KErrNone ) |
|
1689 { |
|
1690 ErrorMsgL( iErrorCode ); |
|
1691 iErrorCode = KErrNone; |
|
1692 } |
|
1693 CCoeControl::HandlePointerEventL( event ); |
|
1694 return; |
|
1695 } |
|
1696 } |
|
1697 |
|
1698 |
|
1699 if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1700 { |
|
1701 iInputData = EFalse; |
|
1702 if( iErrorCode != KErrNone ) |
|
1703 { |
|
1704 ErrorMsgL( iErrorCode ); |
|
1705 iErrorCode = KErrNone; |
|
1706 } |
|
1707 } |
|
1708 } |
|
1709 |
|
1710 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1711 |
|
1712 } |
|
1713 |
|
1714 // --------------------------------------------------------- |
|
1715 // CCalcFuncmapSubPane::SetErrorCode |
|
1716 // Call from container when an error code is display. |
|
1717 // --------------------------------------------------------- |
|
1718 // |
|
1719 void CCalcFuncmapSubPane::SetErrorCode(TInt aError) |
|
1720 { |
|
1721 iErrorCode = aError; |
|
1722 } |
|
1723 |
|
1724 // --------------------------------------------------------- |
|
1725 // CCalcFuncmapSubPane::ErrorMsgL |
|
1726 // Call when there is an error release event. |
|
1727 // --------------------------------------------------------- |
|
1728 // |
|
1729 void CCalcFuncmapSubPane::ErrorMsgL(TInt aErrorCode) |
|
1730 { |
|
1731 TInt resourceId(0); |
|
1732 |
|
1733 switch (aErrorCode) |
|
1734 { |
|
1735 case KErrOverflow: |
|
1736 { |
|
1737 resourceId = R_CALC_ERROR_OUTOFRANGE; |
|
1738 break; |
|
1739 } |
|
1740 case KErrDivideByZero: |
|
1741 { |
|
1742 resourceId = R_CALC_ERROR_DIVISIONBYZERO; |
|
1743 |
|
1744 // UpdateState( EOperator ); |
|
1745 break; |
|
1746 } |
|
1747 case KErrNotSupported: |
|
1748 { |
|
1749 resourceId = R_CALC_ERROR_NEGATIVEVALUESQRT; |
|
1750 break; |
|
1751 } |
|
1752 default: |
|
1753 { |
|
1754 return; |
|
1755 } |
|
1756 } |
|
1757 |
|
1758 //Localisation of scalable UI. |
|
1759 HBufC* message = iCoeEnv->AllocReadResourceLC( resourceId ) ; |
|
1760 CAknErrorNote* note = new (ELeave) CAknErrorNote(); |
|
1761 note->ExecuteLD( *message ); |
|
1762 CleanupStack::PopAndDestroy( message ); |
|
1763 |
|
1764 } |
|
1765 // --------------------------------------------------------- |
|
1766 // CCalcFuncmapSubPane::FunctionPaneRect |
|
1767 // This function gives the layout of Function Pnae. |
|
1768 // (other items were commented in a header). |
|
1769 // --------------------------------------------------------- |
|
1770 // |
|
1771 |
|
1772 TRect CCalcFuncmapSubPane::FunctionPaneRect() |
|
1773 { |
|
1774 TRect parentRect(Rect()); |
|
1775 return parentRect; |
|
1776 } |
|
1777 |
|
1778 // --------------------------------------------------------- |
|
1779 // CCalcFuncmapSubPane::CalculatingCorrectButton |
|
1780 // Handled when there is Pen Input. |
|
1781 // (other items were commented in a header). |
|
1782 // --------------------------------------------------------- |
|
1783 // |
|
1784 |
|
1785 TInt CCalcFuncmapSubPane::CalculatingCorrectButton |
|
1786 (const TPointerEvent& aPointerEvent) |
|
1787 { |
|
1788 TInt selected = iSelected; |
|
1789 |
|
1790 //Function that calculates the correct button where the pointer event had occurred |
|
1791 for(TInt i = 0; i<iCountOfButtons; i++) |
|
1792 { |
|
1793 if(iButtons[i]->Rect().Contains(aPointerEvent.iPosition)) |
|
1794 { |
|
1795 selected = i; |
|
1796 } |
|
1797 } |
|
1798 return selected; |
|
1799 } |
|
1800 |
|
1801 // --------------------------------------------------------- |
|
1802 // CCalcFuncmapSubPane::HandleMiddleSoftKeyOREKeyOK |
|
1803 // Handled when MSK or EKeyOk is selected. |
|
1804 // --------------------------------------------------------- |
|
1805 // |
|
1806 |
|
1807 void CCalcFuncmapSubPane::HandleMiddleSoftKeyOREKeyOKL() |
|
1808 { |
|
1809 //get the selected button id |
|
1810 CAknButton* button = iButtons[iSelected]; |
|
1811 //put the button in the pressed state |
|
1812 CAknButtonState* state = button->State(EnNormal); |
|
1813 //Put the button in pressed state |
|
1814 |
|
1815 TKeyEvent aKeyEvent; |
|
1816 aKeyEvent.iScanCode = EStdKeyEnter; |
|
1817 TEventCode aType = EEventKeyDown; |
|
1818 button->OfferKeyEventL(aKeyEvent,aType); |
|
1819 |
|
1820 //put to pressed state |
|
1821 state->SetFlags(EnPressed); |
|
1822 button->DrawNow(); |
|
1823 |
|
1824 } |
|
1825 |
|
1826 // --------------------------------------------------------- |
|
1827 // CCalcFuncmapSubPane::GetChangeSignButtonState |
|
1828 // Returns the state of change sign button |
|
1829 // --------------------------------------------------------- |
|
1830 // |
|
1831 TBool CCalcFuncmapSubPane::GetChangeSignButtonState() |
|
1832 { |
|
1833 return(iIsChangeSignDimmed); |
|
1834 } |
|
1835 |
|
1836 // --------------------------------------------------------- |
|
1837 // CCalcFuncmapSubPane::GetClearButtonState |
|
1838 // Returns the state of Clear button |
|
1839 // --------------------------------------------------------- |
|
1840 // |
|
1841 TBool CCalcFuncmapSubPane::GetClearButtonState() |
|
1842 { |
|
1843 return( iIsClearKeyEnabled ); |
|
1844 } |
|
1845 |
|
1846 // --------------------------------------------------------- |
|
1847 // CCalcFuncmapSubPane::GetSqrtButtonState |
|
1848 // Returns the state of square root button |
|
1849 // --------------------------------------------------------- |
|
1850 // |
|
1851 TBool CCalcFuncmapSubPane::GetSqrtButtonState() |
|
1852 { |
|
1853 return(iIsSqrtDimmed); |
|
1854 } |
|
1855 |
|
1856 // --------------------------------------------------------- |
|
1857 // CCalcFuncmapSubPane::GetPercentButtonState |
|
1858 // returns the state of percent button |
|
1859 // --------------------------------------------------------- |
|
1860 // |
|
1861 TBool CCalcFuncmapSubPane::GetPercentButtonState() |
|
1862 { |
|
1863 return(iIsPercentDimmed); |
|
1864 } |
|
1865 |
|
1866 // --------------------------------------------------------- |
|
1867 // CCalcFuncmapSubPane::GetSelectedButtonId |
|
1868 // returns the id of current button |
|
1869 // --------------------------------------------------------- |
|
1870 // |
|
1871 TInt CCalcFuncmapSubPane::GetSelectedButtonId() |
|
1872 { |
|
1873 return iSelected; |
|
1874 } |
|
1875 |
|
1876 // --------------------------------------------------------- |
|
1877 // CCalcFuncmapSubPane::SetHighlightButton |
|
1878 // set highlight button |
|
1879 // --------------------------------------------------------- |
|
1880 // |
|
1881 void CCalcFuncmapSubPane::SetHighlightButton( TUint aOldId, TUint aNewId ) |
|
1882 { |
|
1883 iSelected = aNewId; |
|
1884 RedrawHighlight( aOldId, aNewId ); |
|
1885 } |
|
1886 |
|
1887 // --------------------------------------------------------- |
|
1888 // CCalcFuncmapSubPane::IsClearKeyLongPressed |
|
1889 // Find Clear is long Pressed. |
|
1890 // --------------------------------------------------------- |
|
1891 // |
|
1892 TBool CCalcFuncmapSubPane::IsKeyLongPressed() |
|
1893 { |
|
1894 return iIsKeyLongPress; |
|
1895 } |
|
1896 |
|
1897 // --------------------------------------------------------- |
|
1898 // CCalcFuncmapSubPane::MapDataForChrShiftKey |
|
1899 // Redraw percent button, either normal or dimmed. |
|
1900 // --------------------------------------------------------- |
|
1901 // |
|
1902 void CCalcFuncmapSubPane::MapDataForChrShiftKey( TDes& aOperators, TInt& aFirstOperator, TInt& aSecondOperator) |
|
1903 { |
|
1904 if( aOperators.Length() > 0 ) |
|
1905 { |
|
1906 TUint16 firstChar = aOperators[0]; |
|
1907 TUint16 secondChar = firstChar; |
|
1908 |
|
1909 if ( aOperators.Length() > 1 ) |
|
1910 { |
|
1911 secondChar = aOperators[1]; |
|
1912 } |
|
1913 |
|
1914 switch ( firstChar ) |
|
1915 { |
|
1916 case KPtiPinyinMarker: |
|
1917 case KPtiStrokeMarker: |
|
1918 case KPtiZhuyinMarker: |
|
1919 case KPtiCangjieMarker: |
|
1920 case KPtiGetAllMarker: |
|
1921 if ( aOperators.Length() > 2 ) |
|
1922 { |
|
1923 firstChar = aOperators[1]; |
|
1924 secondChar = aOperators[2]; |
|
1925 } |
|
1926 else |
|
1927 { |
|
1928 firstChar = aOperators[1]; |
|
1929 secondChar = firstChar; |
|
1930 } |
|
1931 break; |
|
1932 default: |
|
1933 break; |
|
1934 |
|
1935 } |
|
1936 |
|
1937 MapOperators( firstChar, aFirstOperator ); |
|
1938 |
|
1939 MapOperators( secondChar, aSecondOperator ); |
|
1940 |
|
1941 } |
|
1942 } |
|
1943 |
|
1944 // --------------------------------------------------------- |
|
1945 // CCalcFuncmapSubPane::MapOperators |
|
1946 // Redraw percent button, either normal or dimmed. |
|
1947 // --------------------------------------------------------- |
|
1948 // |
|
1949 TBool CCalcFuncmapSubPane::MapOperators( TUint16 aOperator, TInt& aResult) |
|
1950 { |
|
1951 TInt loc1 = KAllowedOperatorPlus().Locate( aOperator ); |
|
1952 if ( loc1 != KErrNotFound ) |
|
1953 { |
|
1954 if ( AknLayoutUtils::PenEnabled() ) |
|
1955 { |
|
1956 aResult = ECmdTAdd; |
|
1957 } |
|
1958 else |
|
1959 { |
|
1960 aResult = EPlusButton; |
|
1961 } |
|
1962 return ETrue; |
|
1963 } |
|
1964 TInt loc2 = KAllowedOperatorMinus().Locate( aOperator ); |
|
1965 if ( loc2 != KErrNotFound ) |
|
1966 { |
|
1967 if ( AknLayoutUtils::PenEnabled() ) |
|
1968 { |
|
1969 aResult = ECmdTSubtract; |
|
1970 } |
|
1971 else |
|
1972 { |
|
1973 aResult = EMinusButton; |
|
1974 } |
|
1975 return ETrue; |
|
1976 } |
|
1977 TInt loc3 = KAllowedOperatorStar().Locate( aOperator ); |
|
1978 if ( loc3 != KErrNotFound ) |
|
1979 { |
|
1980 if ( AknLayoutUtils::PenEnabled() ) |
|
1981 { |
|
1982 aResult = ECmdTMultiply; |
|
1983 } |
|
1984 else |
|
1985 { |
|
1986 aResult = EMultiplyButton; |
|
1987 } |
|
1988 return ETrue; |
|
1989 } |
|
1990 TInt loc4 = KAllowedOperatorDivide().Locate( aOperator ); |
|
1991 if ( loc4 != KErrNotFound ) |
|
1992 { |
|
1993 if ( AknLayoutUtils::PenEnabled() ) |
|
1994 { |
|
1995 aResult = ECmdTDivide; |
|
1996 } |
|
1997 else |
|
1998 { |
|
1999 aResult = EDivideButton; |
|
2000 } |
|
2001 return ETrue; |
|
2002 } |
|
2003 TInt loc5 = KAllowedOperatorEquals().Locate( aOperator ); |
|
2004 if ( loc5 != KErrNotFound ) |
|
2005 { |
|
2006 if ( AknLayoutUtils::PenEnabled() ) |
|
2007 { |
|
2008 aResult = ECmdTResult; |
|
2009 } |
|
2010 else |
|
2011 { |
|
2012 aResult = EEqualButton; |
|
2013 } |
|
2014 return ETrue; |
|
2015 } |
|
2016 TInt loc6 = KAllowedOperatorPercent().Locate( aOperator ); |
|
2017 if ( loc6 != KErrNotFound ) |
|
2018 { |
|
2019 if ( AknLayoutUtils::PenEnabled() ) |
|
2020 { |
|
2021 aResult = ECmdTPercent; |
|
2022 } |
|
2023 else |
|
2024 { |
|
2025 aResult = EPercentButton; |
|
2026 } |
|
2027 return ETrue; |
|
2028 } |
|
2029 TInt loc7 = KAllowedOperatorDecimal().Locate( aOperator ); |
|
2030 if ( loc7 != KErrNotFound ) |
|
2031 { |
|
2032 aResult = ECmdTSeparator; |
|
2033 return ETrue; |
|
2034 } |
|
2035 return EFalse; |
|
2036 } |
|
2037 |
|
2038 // --------------------------------------------------------- |
|
2039 // CCalcFuncmapSubPane::GetKeyboardType |
|
2040 // Returns the type of keyboard |
|
2041 // --------------------------------------------------------- |
|
2042 // |
|
2043 TBool CCalcFuncmapSubPane::GetKeyboardType() |
|
2044 { |
|
2045 return iKeyboardType; |
|
2046 } |
|
2047 |
|
2048 // End of file |
|