author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:33:39 +0300 | |
branch | RCL_3 |
changeset 29 | 9d6a662e71d9 |
parent 24 | 10c6e6d6e4d9 |
permissions | -rw-r--r-- |
24 | 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: Source file of "CCalcContainer", CCalcContainer class |
|
15 |
* which derived from CCoeControl class. Role of this class |
|
16 |
* is to update the calculator data and display on user's input. |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <aknkeys.h> |
|
23 |
#include <AknUtils.h> // AknLayoutUtils::LayoutControl |
|
24 |
#include <Calcsoft.rsg> |
|
25 |
||
26 |
#include <layoutmetadata.cdl.h> |
|
27 |
||
28 |
// For skin support. |
|
29 |
#include <AknsDrawUtils.h> |
|
30 |
#include <AknsConstants.h> |
|
31 |
#include <AknsUtils.h> |
|
32 |
#include <AknsBasicBackgroundControlContext.h> |
|
33 |
#include <applayout.cdl.h> |
|
34 |
#include <aknlayoutscalable_apps.cdl.h> |
|
35 |
#include <csxhelp/calc.hlp.hrh> // for help context of Calculator |
|
36 |
#include "CalcApp.h" |
|
37 |
||
38 |
#include "CalcAppUi.h" |
|
39 |
#include "CalcCont.h" |
|
40 |
#include "CalcDoc.h" |
|
41 |
#include "CalcEdit.h" |
|
42 |
#include "CalcFunc.h" |
|
43 |
#include "CalcOutSheet.h" |
|
44 |
#include "calc.hrh" |
|
45 |
#include "CalcView.h" |
|
46 |
#include "CalcEnv.h" |
|
47 |
#include "CalcHistory.h" |
|
48 |
#include "CalcDrawingConst.laf" // for layout information |
|
49 |
||
50 |
||
51 |
#include <AknDef.h> |
|
52 |
#include <eiksbfrm.h> |
|
53 |
#include <eikscrlb.h> |
|
54 |
||
55 |
||
56 |
#define KEY_CODE_VAL 57 //for all number inputs |
|
57 |
#define ASCII_ZERO 48 |
|
58 |
||
59 |
// LOCAL CONSTANTS AND MACROS |
|
60 |
const TInt KCallBackDelay(1000000); // In microseconds |
|
61 |
const TInt KCallBackInterval(1000000); // In microseconds |
|
62 |
const TInt KCallBackPriority(CActive::EPriorityUserInput); |
|
63 |
||
64 |
// Count of controls in Calculator. |
|
65 |
// Controls are editor pane, output sheet, and function map. |
|
66 |
// Therefore, this count is 3. |
|
67 |
const TInt KCalcCountOfControls(3); |
|
68 |
||
69 |
// Define index of control |
|
70 |
enum TCalcControlIndex |
|
71 |
{ |
|
72 |
ECalcControlFunctionMap, |
|
73 |
ECalcControlOutputSheet, |
|
74 |
ECalcControlEditorPane |
|
75 |
}; |
|
76 |
||
77 |
// If const TChar is used, complie error occurs in THUMB build. |
|
78 |
// To avoid this, #define is used. |
|
79 |
#define KCalcAsteriskBtn '*' |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
80 |
//define a Comma as decimal separator |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
#define KCommaSeparator ',' |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
82 |
//define a dot as decimal separator |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
83 |
#define KDotSeparator '.' |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
84 |
//define a '#' as input decimal separator by conventional 12 phone keypad. |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
85 |
#define KHashSeparator '#' |
24 | 86 |
// ================= MEMBER FUNCTIONS ======================= |
87 |
||
88 |
// Two-phased constructor. |
|
89 |
CCalcContainer* CCalcContainer::NewL( |
|
90 |
CCalcView* aView) |
|
91 |
{ |
|
92 |
CCalcContainer* self = new (ELeave) CCalcContainer(); |
|
93 |
CleanupStack::PushL(self); |
|
94 |
self->ConstructL(aView); |
|
95 |
CleanupStack::Pop(self); |
|
96 |
return self; |
|
97 |
} |
|
98 |
||
99 |
||
100 |
// Destructor |
|
101 |
CCalcContainer::~CCalcContainer() |
|
102 |
{ |
|
103 |
delete iEditorPane; |
|
104 |
delete iFuncmapPane; |
|
105 |
delete iSheetPane; |
|
106 |
||
107 |
delete iTimeout; |
|
108 |
||
109 |
if ( iTimeoutChr ) |
|
110 |
{ |
|
111 |
delete iTimeoutChr; |
|
112 |
iTimeoutChr = NULL; |
|
113 |
} |
|
114 |
if ( iTimeoutShift ) |
|
115 |
{ |
|
116 |
delete iTimeoutShift; |
|
117 |
iTimeoutShift = NULL; |
|
118 |
} |
|
119 |
||
120 |
delete iSkinContext; |
|
121 |
} |
|
122 |
||
123 |
// --------------------------------------------------------- |
|
124 |
// CCalcContainer::ProcessPreinputL |
|
125 |
// This function is called when decimal point or a digit is inputted. |
|
126 |
// (other items were commented in a header). |
|
127 |
// --------------------------------------------------------- |
|
128 |
// |
|
129 |
void CCalcContainer::ProcessPreinputL() |
|
130 |
{ |
|
131 |
TInt currentState = iView->State(); |
|
132 |
CCalcView::TKindOfInput latestInput(iView->LatestInput()); |
|
133 |
||
134 |
if (currentState == CCalcView::ESelectResult) |
|
135 |
// State 5 : User has selected result |
|
136 |
{ |
|
137 |
iEditorPane->ResetL(); // Set editline "0" |
|
138 |
iView->UpdateState(CCalcView::EAllClear); |
|
139 |
iCalcDocument->AddEmptyLine(); |
|
140 |
iSheetPane->ScrollToBottomL(); |
|
141 |
ScrollArrowUpdate(); |
|
142 |
} |
|
143 |
else if (currentState == CCalcView::EOperandAndOperator || |
|
144 |
// State 3 : operand and operator |
|
145 |
latestInput == CCalcView::EMemoryRecall || |
|
146 |
latestInput == CCalcView::EMemorySave) |
|
147 |
{ |
|
148 |
iEditorPane->ClearOperand(); |
|
149 |
} |
|
150 |
} |
|
151 |
||
152 |
// --------------------------------------------------------- |
|
153 |
// CCalcContainer::InputClearL |
|
154 |
// This function should be called when editor is cleared. |
|
155 |
// (other items were commented in a header). |
|
156 |
// --------------------------------------------------------- |
|
157 |
// |
|
158 |
void CCalcContainer::InputClearL() |
|
159 |
{ |
|
160 |
iEditorPane->ResetL(); |
|
161 |
iView->UpdateState(CCalcView::EAllClear); |
|
162 |
||
163 |
const TCalcEditLine lastLine((*(iCalcDocument->History()))[0]); |
|
164 |
// Get latest historical line. |
|
165 |
const TPtrC number(lastLine.NumberString()); |
|
166 |
||
167 |
// If latest historical line is not empty, |
|
168 |
// empty line is added in the history and the history is shown. |
|
169 |
if ( number.Length() ) |
|
170 |
{ |
|
171 |
iCalcDocument->AddEmptyLine(); |
|
172 |
iSheetPane->ScrollToBottomL(); |
|
173 |
ScrollArrowUpdate(); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
// --------------------------------------------------------- |
|
178 |
// CCalcContainer::ScrollArrowUpdate |
|
179 |
// This function should be called when OutputSheet is scrolled |
|
180 |
// or history is added. |
|
181 |
// (other items were commented in a header). |
|
182 |
// --------------------------------------------------------- |
|
183 |
// |
|
184 |
void CCalcContainer::ScrollArrowUpdate() |
|
185 |
{ |
|
186 |
iFuncmapPane->RedrawScrollButtons(); |
|
187 |
} |
|
188 |
||
189 |
// --------------------------------------------------------- |
|
190 |
// CCalcContainer::SetChangeSignEnableL |
|
191 |
// This function is called when number of editor is changed. |
|
192 |
// (other items were commented in a header). |
|
193 |
// --------------------------------------------------------- |
|
194 |
// |
|
195 |
void CCalcContainer::SetChangeSignEnableL() |
|
196 |
{ |
|
197 |
TCalcEditLine editLine(iEditorPane->EditLine()); |
|
198 |
TBool changeSignEnable(ETrue); |
|
199 |
||
200 |
if (editLine.NumberL() == 0.0) |
|
201 |
{ |
|
202 |
changeSignEnable = EFalse; |
|
203 |
} |
|
204 |
||
205 |
iFuncmapPane->SetChangeSignEnable(changeSignEnable); |
|
206 |
} |
|
207 |
||
208 |
// --------------------------------------------------------- |
|
209 |
// CCalcContainer::SetClearKeyEnable |
|
210 |
// This function is called when number of editor is changed. |
|
211 |
// (other items were commented in a header). |
|
212 |
// --------------------------------------------------------- |
|
213 |
// |
|
214 |
void CCalcContainer::SetClearKeyEnable() |
|
215 |
{ |
|
216 |
TCalcEditLine editLine( iEditorPane->EditLine() ); |
|
217 |
TBool clearKeyEnable( ETrue ); |
|
218 |
||
219 |
// eitline's number is 0.0 and length is 1 and the no operator |
|
220 |
TRAP_IGNORE( |
|
221 |
{ |
|
222 |
if ( editLine.CheckZeroL() && ( editLine.Operator() == |
|
223 |
TCalcEditLine::ECalcOperatorNone ) ) |
|
224 |
{ |
|
225 |
clearKeyEnable = EFalse; |
|
226 |
} |
|
227 |
} |
|
228 |
) |
|
229 |
iFuncmapPane->SetClearKeyEnable( clearKeyEnable ); |
|
230 |
} |
|
231 |
||
232 |
// --------------------------------------------------------- |
|
233 |
// CCalcContainer::SetChangeSignDisable |
|
234 |
// This function is called when Operator +, - , *, / key is pressed. |
|
235 |
// (other items were commented in a header). |
|
236 |
// --------------------------------------------------------- |
|
237 |
// |
|
238 |
void CCalcContainer::SetChangeSignDisable() |
|
239 |
{ |
|
240 |
||
241 |
TBool changeSignEnable(EFalse); |
|
242 |
iFuncmapPane->SetChangeSignEnable(changeSignEnable); |
|
243 |
||
244 |
} |
|
245 |
||
246 |
// --------------------------------------------------------- |
|
247 |
// CCalcContainer::SetSqrtEnableL |
|
248 |
// This function is called when number of editor is changed. |
|
249 |
// (other items were commented in a header). |
|
250 |
// --------------------------------------------------------- |
|
251 |
// |
|
252 |
void CCalcContainer::SetSqrtEnableL() |
|
253 |
{ |
|
254 |
TCalcEditLine editLine(iEditorPane->EditLine()); |
|
255 |
TBool sqrtEnable(ETrue); |
|
256 |
||
257 |
if ( editLine.NumberL() == 0.0 ) |
|
258 |
{ |
|
259 |
sqrtEnable = EFalse; |
|
260 |
} |
|
261 |
iFuncmapPane->SetSqrtEnable(sqrtEnable); |
|
262 |
} |
|
263 |
||
264 |
// --------------------------------------------------------- |
|
265 |
// CCalcContainer::SetPercentEnableL |
|
266 |
// This function is called when number of editor is changed. |
|
267 |
// (other items were commented in a header). |
|
268 |
// --------------------------------------------------------- |
|
269 |
// |
|
270 |
void CCalcContainer::SetPercentEnableL() |
|
271 |
{ |
|
272 |
TCalcEditLine editLine(iEditorPane->EditLine()); |
|
273 |
TBool percentEnable(ETrue); |
|
274 |
||
275 |
if (editLine.NumberL() == 0.0) |
|
276 |
{ |
|
277 |
percentEnable = EFalse; |
|
278 |
} |
|
279 |
iFuncmapPane->SetPercentEnable(percentEnable); |
|
280 |
} |
|
281 |
||
282 |
||
283 |
// --------------------------------------------------------- |
|
284 |
// CCalcContainer::TimeoutCallbackL |
|
285 |
// If no key is pressed after pressing *-button and a few time |
|
286 |
// passes, this function is called |
|
287 |
// (other items were commented in a header). |
|
288 |
// --------------------------------------------------------- |
|
289 |
// |
|
290 |
TInt CCalcContainer::TimeoutCallbackL( |
|
291 |
TAny* aObject) |
|
292 |
{ |
|
293 |
STATIC_CAST(CCalcContainer*, aObject)->DoTimeoutL(); |
|
294 |
return 0; |
|
295 |
} |
|
296 |
||
297 |
// --------------------------------------------------------- |
|
298 |
// CCalcContainer::TimeoutCallbackL |
|
299 |
// If no key is pressed after pressing */button and a few time |
|
300 |
// passes, this function is called |
|
301 |
// (other items were commented in a header). |
|
302 |
// --------------------------------------------------------- |
|
303 |
// |
|
304 |
TInt CCalcContainer::TimeoutCallbackChrL( |
|
305 |
TAny* aObject) |
|
306 |
{ |
|
307 |
STATIC_CAST( CCalcContainer*, aObject )->DoTimeoutChrL(); |
|
308 |
return 0; |
|
309 |
} |
|
310 |
// --------------------------------------------------------- |
|
311 |
// CCalcContainer::TimeoutCallbackL |
|
312 |
// If no key is pressed after pressing +#button and a few time |
|
313 |
// passes, this function is called |
|
314 |
// (other items were commented in a header). |
|
315 |
// --------------------------------------------------------- |
|
316 |
// |
|
317 |
TInt CCalcContainer::TimeoutCallbackShiftL( |
|
318 |
TAny* aObject) |
|
319 |
{ |
|
320 |
STATIC_CAST(CCalcContainer*, aObject)->DoTimeoutShiftL(); |
|
321 |
return 0; |
|
322 |
} |
|
323 |
||
324 |
// --------------------------------------------------------- |
|
325 |
// CCalcContainer::NotifyChangeDecimal |
|
326 |
// Call when decimal separator is changed. |
|
327 |
// (other items were commented in a header). |
|
328 |
// --------------------------------------------------------- |
|
329 |
// |
|
330 |
void CCalcContainer::NotifyChangeDecimal(TChar aOld, TChar aNew) |
|
331 |
{ |
|
332 |
iEditorPane->NotifyChangeDecimal(aOld, aNew); |
|
333 |
iSheetPane->DrawNow(); |
|
334 |
} |
|
335 |
||
336 |
// --------------------------------------------------------- |
|
337 |
// CCalcContainer::SetErrorCode |
|
338 |
// Call from view when an error code is display. |
|
339 |
// --------------------------------------------------------- |
|
340 |
// |
|
341 |
void CCalcContainer::SetErrorCode(TInt aError) |
|
342 |
{ |
|
343 |
iFuncmapPane->SetErrorCode( aError ); |
|
344 |
} |
|
345 |
||
346 |
// --------------------------------------------------------- |
|
347 |
// CCalcContainer::GetHelpContext |
|
348 |
// This function is called when Help application is launched. |
|
349 |
// (other items were commented in a header). |
|
350 |
// --------------------------------------------------------- |
|
351 |
// |
|
352 |
void CCalcContainer::GetHelpContext( |
|
353 |
TCoeHelpContext& aContext) const |
|
354 |
{ |
|
355 |
aContext.iMajor = KUidCalc; |
|
356 |
aContext.iContext = KCALC_HLP_MAIN; |
|
357 |
} |
|
358 |
||
359 |
// C++ default constructor can NOT contain any code, that |
|
360 |
// might leave. |
|
361 |
// |
|
362 |
CCalcContainer::CCalcContainer(): |
|
363 |
iPrevInput(EKeyNull) |
|
364 |
{ |
|
365 |
} |
|
366 |
||
367 |
// Second-phase constructor |
|
368 |
void CCalcContainer::ConstructL( |
|
369 |
CCalcView* aView) |
|
370 |
{ |
|
371 |
iView = aView; |
|
372 |
CCalcAppUi* appui = CCalcAppEnv::Static()->AppUi(); |
|
373 |
iCalcDocument = STATIC_CAST(CCalcDocument*, appui->Document()); |
|
374 |
||
375 |
// Make a window-owning control. |
|
376 |
CreateWindowL(); |
|
377 |
||
378 |
||
379 |
||
380 |
iFuncmapPane = CCalcFuncmapSubPane::NewL(this); |
|
381 |
iSheetPane = CCalcOutputSheet::NewL(this); |
|
382 |
iEditorPane = CCalcEditorSubPane::NewL(this); |
|
383 |
||
384 |
iTimeout = CPeriodic::NewL(KCallBackPriority); |
|
385 |
||
386 |
iTimeoutChr = CPeriodic::NewL( KCallBackPriority ); |
|
387 |
iTimeoutShift = CPeriodic::NewL( KCallBackPriority ); |
|
388 |
||
389 |
TRect rect(0, 0, 0, 0); |
|
390 |
// Temporary rect is passed. Correct rect is set in SizeChanged. |
|
391 |
iSkinContext = CAknsBasicBackgroundControlContext::NewL( |
|
392 |
KAknsIIDQsnBgAreaMainCalc, rect, EFalse); |
|
393 |
iValue = 0; |
|
394 |
||
395 |
// Set status pane layout usual. |
|
396 |
CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
397 |
} |
|
398 |
||
399 |
void CCalcContainer::ActivateL() |
|
400 |
{ |
|
401 |
||
402 |
CCoeControl::ActivateL(); |
|
403 |
SetChangeSignEnableL(); |
|
404 |
SetSqrtEnableL(); |
|
405 |
SetPercentEnableL(); |
|
406 |
ScrollArrowUpdate(); |
|
407 |
SetClearKeyEnable(); |
|
408 |
} |
|
409 |
||
410 |
||
411 |
// --------------------------------------------------------- |
|
412 |
// CCalcContainer::DoTimeoutL |
|
413 |
// If no key is pressed until timeout of *-key, |
|
414 |
// this function is called. |
|
415 |
// (other items were commented in a header). |
|
416 |
// --------------------------------------------------------- |
|
417 |
// |
|
418 |
void CCalcContainer::DoTimeoutL() |
|
419 |
{ |
|
420 |
iTimeout->Cancel(); |
|
421 |
iFuncmapPane->NotifyTimeoutL(); |
|
422 |
} |
|
423 |
||
424 |
// --------------------------------------------------------- |
|
425 |
// CCalcContainer::DoTimeoutL |
|
426 |
// If no key is pressed until timeout of */key, |
|
427 |
// this function is called. |
|
428 |
// (other items were commented in a header). |
|
429 |
// --------------------------------------------------------- |
|
430 |
// |
|
431 |
void CCalcContainer::DoTimeoutChrL() |
|
432 |
{ |
|
433 |
iTimeoutChr->Cancel(); |
|
434 |
iFuncmapPane->NotifyTimeoutL(); |
|
435 |
} |
|
436 |
// --------------------------------------------------------- |
|
437 |
// CCalcContainer::DoTimeoutL |
|
438 |
// If no key is pressed until timeout of +#key, |
|
439 |
// this function is called. |
|
440 |
// (other items were commented in a header). |
|
441 |
// --------------------------------------------------------- |
|
442 |
// |
|
443 |
void CCalcContainer::DoTimeoutShiftL() |
|
444 |
{ |
|
445 |
iTimeoutShift->Cancel(); |
|
446 |
iFuncmapPane->NotifyTimeoutL(); |
|
447 |
} |
|
448 |
||
449 |
// --------------------------------------------------------- |
|
450 |
// CCalcContainer::HandleAsterKeyTimeoutForKeyPressL |
|
451 |
// Called when any key is pressed. |
|
452 |
// If timeout notifier for *-key is active, make calculation or |
|
453 |
// stop notifier according to user's input. |
|
454 |
// (other items were commented in a header). |
|
455 |
// --------------------------------------------------------- |
|
456 |
// |
|
457 |
TBool CCalcContainer::HandleAsterKeyTimeoutForKeyPressL( |
|
458 |
const TKeyEvent& aKeyEvent, TEventCode aType) |
|
459 |
{ |
|
460 |
if (!(iTimeout->IsActive())) |
|
461 |
{ |
|
462 |
return EFalse; |
|
463 |
} |
|
464 |
||
465 |
TBool ret(EFalse); |
|
466 |
||
467 |
if (aKeyEvent.iModifiers & EModifierShift) |
|
468 |
{ |
|
469 |
// Stop timer for *-key and make calculaiton. |
|
470 |
DoTimeoutL(); |
|
471 |
} |
|
472 |
||
473 |
if (aType == EEventKey) |
|
474 |
{ |
|
475 |
switch (aKeyEvent.iCode) |
|
476 |
{ |
|
477 |
// Stop timer and no calculation is made |
|
478 |
// if pressed arrow or OK key. |
|
479 |
// This depends on spec of Editing. |
|
480 |
case EKeyLeftArrow: |
|
481 |
case EKeyRightArrow: |
|
482 |
case EKeyUpArrow: |
|
483 |
case EKeyDownArrow: |
|
484 |
case EKeyOK: |
|
485 |
{ |
|
486 |
DoTimeoutL(); |
|
487 |
ret = ETrue; |
|
488 |
break; |
|
489 |
} |
|
490 |
// Stop timer if *-key is pressed. |
|
491 |
// If release *-key, reset timer for the key. |
|
492 |
case KCalcAsteriskBtn: |
|
493 |
{ |
|
494 |
iTimeout->Cancel(); |
|
495 |
break; |
|
496 |
} |
|
497 |
default: |
|
498 |
{ |
|
499 |
// Stop timer for *-key and make calculaiton. |
|
500 |
DoTimeoutL(); |
|
501 |
break; |
|
502 |
} |
|
503 |
} |
|
504 |
} |
|
505 |
return ret; |
|
506 |
} |
|
507 |
||
508 |
// --------------------------------------------------------- |
|
509 |
// CCalcContainer::HandleAsterKeyTimeoutForKeyPressL |
|
510 |
// Called when any key is pressed. |
|
511 |
// If timeout notifier for */key is active, make calculation or |
|
512 |
// stop notifier according to user's input. |
|
513 |
// (other items were commented in a header). |
|
514 |
// --------------------------------------------------------- |
|
515 |
// |
|
516 |
TBool CCalcContainer::HandleChrKeyTimeoutForKeyPressL( |
|
517 |
const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
518 |
{ |
|
519 |
if ( !( iTimeoutChr->IsActive() ) ) |
|
520 |
{ |
|
521 |
return EFalse; |
|
522 |
} |
|
523 |
||
524 |
TBool ret( EFalse ); |
|
525 |
||
526 |
if ( aKeyEvent.iModifiers & EModifierShift ) |
|
527 |
{ |
|
528 |
DoTimeoutChrL(); |
|
529 |
} |
|
530 |
if ( aKeyEvent.iModifiers & EModifierFunc ) |
|
531 |
{ |
|
532 |
// Stop timer for */key and make calculaiton. |
|
533 |
iTimeoutChr->Cancel(); |
|
534 |
} |
|
535 |
||
536 |
if ( aType == EEventKey ) |
|
537 |
{ |
|
538 |
switch ( aKeyEvent.iCode ) |
|
539 |
{ |
|
540 |
// Stop timer and no calculation is made |
|
541 |
// if pressed arrow or OK key. |
|
542 |
// This depends on spec of Editing. |
|
543 |
case EKeyLeftArrow: |
|
544 |
case EKeyRightArrow: |
|
545 |
case EKeyUpArrow: |
|
546 |
case EKeyDownArrow: |
|
547 |
case EKeyOK: |
|
548 |
{ |
|
549 |
DoTimeoutChrL(); |
|
550 |
ret = ETrue; |
|
551 |
break; |
|
552 |
} |
|
553 |
default: |
|
554 |
{ |
|
555 |
// Stop timer for */key and make calculaiton. |
|
556 |
DoTimeoutChrL(); |
|
557 |
break; |
|
558 |
} |
|
559 |
} |
|
560 |
} |
|
561 |
return ret; |
|
562 |
} |
|
563 |
// --------------------------------------------------------- |
|
564 |
// CCalcContainer::HandleAsterKeyTimeoutForKeyPressL |
|
565 |
// Called when any key is pressed. |
|
566 |
// If timeout notifier for +#key is active, make calculation or |
|
567 |
// stop notifier according to user's input. |
|
568 |
// (other items were commented in a header). |
|
569 |
// --------------------------------------------------------- |
|
570 |
// |
|
571 |
TBool CCalcContainer::HandleShiftKeyTimeoutForKeyPressL( |
|
572 |
const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
573 |
{ |
|
574 |
if ( !( iTimeoutShift->IsActive() ) ) |
|
575 |
{ |
|
576 |
return EFalse; |
|
577 |
} |
|
578 |
||
579 |
TBool ret( EFalse ); |
|
580 |
||
581 |
if ( aKeyEvent.iModifiers & EModifierShift ) |
|
582 |
{ |
|
583 |
// Stop timer for +#key and make calculaiton. |
|
584 |
iTimeoutShift->Cancel(); |
|
585 |
} |
|
586 |
if ( aKeyEvent.iModifiers & EModifierFunc ) |
|
587 |
{ |
|
588 |
DoTimeoutShiftL(); |
|
589 |
} |
|
590 |
||
591 |
if ( aType == EEventKey ) |
|
592 |
{ |
|
593 |
switch ( aKeyEvent.iCode ) |
|
594 |
{ |
|
595 |
// Stop timer and no calculation is made |
|
596 |
// if pressed arrow or OK key. |
|
597 |
// This depends on spec of Editing. |
|
598 |
case EKeyLeftArrow: |
|
599 |
case EKeyRightArrow: |
|
600 |
case EKeyUpArrow: |
|
601 |
case EKeyDownArrow: |
|
602 |
case EKeyOK: |
|
603 |
{ |
|
604 |
DoTimeoutShiftL(); |
|
605 |
ret = ETrue; |
|
606 |
break; |
|
607 |
} |
|
608 |
default: |
|
609 |
{ |
|
610 |
// Stop timer for +#key and make calculaiton. |
|
611 |
DoTimeoutShiftL(); |
|
612 |
break; |
|
613 |
} |
|
614 |
} |
|
615 |
} |
|
616 |
return ret; |
|
617 |
} |
|
618 |
||
619 |
// --------------------------------------------------------- |
|
620 |
// CCalcContainer::CountComponentControls |
|
621 |
// Return count of control components. |
|
622 |
// (other items were commented in a header). |
|
623 |
// --------------------------------------------------------- |
|
624 |
// |
|
625 |
TInt CCalcContainer::CountComponentControls() const |
|
626 |
{ |
|
627 |
return KCalcCountOfControls ; |
|
628 |
} |
|
629 |
||
630 |
// --------------------------------------------------------- |
|
631 |
// CCalcContainer::ComponentControl |
|
632 |
// Return control pointer which correspond to argument aIndex |
|
633 |
// (other items were commented in a header). |
|
634 |
// --------------------------------------------------------- |
|
635 |
// |
|
636 |
CCoeControl* CCalcContainer::ComponentControl |
|
637 |
( TInt aIndex ) const |
|
638 |
{ |
|
639 |
CCoeControl* control = NULL; |
|
640 |
||
641 |
switch (aIndex) |
|
642 |
{ |
|
643 |
case ECalcControlEditorPane: |
|
644 |
{ |
|
645 |
control = iEditorPane; |
|
646 |
break; |
|
647 |
} |
|
648 |
case ECalcControlFunctionMap: |
|
649 |
{ |
|
650 |
control = iFuncmapPane; |
|
651 |
break; |
|
652 |
} |
|
653 |
case ECalcControlOutputSheet: |
|
654 |
{ |
|
655 |
control = iSheetPane; |
|
656 |
break; |
|
657 |
} |
|
658 |
default: |
|
659 |
{ |
|
660 |
break; |
|
661 |
} |
|
662 |
} |
|
663 |
||
664 |
return control; |
|
665 |
} |
|
666 |
||
667 |
// --------------------------------------------------------- |
|
668 |
// CCalcContainer::OfferKeyEventL |
|
669 |
// This function is called when a key is pressed. |
|
670 |
// (other items were commented in a header). |
|
671 |
// --------------------------------------------------------- |
|
672 |
// |
|
673 |
TKeyResponse CCalcContainer::OfferKeyEventL |
|
674 |
( const TKeyEvent& aKeyEvent, |
|
675 |
TEventCode aType ) |
|
676 |
{ |
|
677 |
switch (aType) |
|
678 |
{ |
|
679 |
case EEventKeyDown: |
|
680 |
case EEventKey: |
|
681 |
{ |
|
682 |
if (aKeyEvent.iScanCode != EStdKeyLeftArrow && |
|
683 |
aKeyEvent.iScanCode != EStdKeyRightArrow && |
|
684 |
aKeyEvent.iScanCode != EStdKeyUpArrow && |
|
685 |
aKeyEvent.iScanCode != EStdKeyDownArrow && |
|
686 |
aKeyEvent.iCode != EKeyOK && |
|
687 |
aKeyEvent.iCode != EKeyEnter && |
|
688 |
aKeyEvent.iScanCode != EStdKeyEnter ) |
|
689 |
{ |
|
690 |
iFuncmapPane->NotifyOtherThanOkKeyPressed(); |
|
691 |
} |
|
692 |
iPrevInput = aKeyEvent.iCode; |
|
693 |
||
694 |
if(!(iFuncmapPane->IsQwertyKeypadActive())) |
|
695 |
{ |
|
696 |
if (HandleAsterKeyTimeoutForKeyPressL(aKeyEvent, aType)) |
|
697 |
{ |
|
698 |
return EKeyWasConsumed; |
|
699 |
} |
|
700 |
} |
|
701 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
702 |
else |
|
703 |
{ |
|
704 |
if ( iFuncmapPane->GetKeyboardType() == EPtiKeyboardHalfQwerty ) |
|
705 |
{ |
|
706 |
if ( HandleChrKeyTimeoutForKeyPressL( aKeyEvent, aType ) ) |
|
707 |
{ |
|
708 |
return EKeyWasConsumed; |
|
709 |
} |
|
710 |
if ( HandleShiftKeyTimeoutForKeyPressL( aKeyEvent, aType ) ) |
|
711 |
{ |
|
712 |
return EKeyWasConsumed; |
|
713 |
} |
|
714 |
} |
|
715 |
} |
|
716 |
#endif |
|
717 |
iValue =1 ; |
|
718 |
break; |
|
719 |
} |
|
720 |
case EEventKeyUp: |
|
721 |
{ |
|
722 |
if(!(iFuncmapPane->IsQwertyKeypadActive())) |
|
723 |
{ |
|
724 |
||
725 |
if (iPrevInput == KCalcAsteriskBtn && !iTimeout->IsActive() && iValue ==1 ) |
|
726 |
{ |
|
727 |
TCallBack callback(TimeoutCallbackL, this); |
|
728 |
iTimeout->Start((TTimeIntervalMicroSeconds32) KCallBackDelay, |
|
729 |
(TTimeIntervalMicroSeconds32) KCallBackInterval, |
|
730 |
callback); |
|
731 |
} |
|
732 |
} |
|
733 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
734 |
else |
|
735 |
{ |
|
736 |
if ( iFuncmapPane->GetKeyboardType() == EPtiKeyboardHalfQwerty ) |
|
737 |
{ |
|
738 |
if ( aKeyEvent.iScanCode == EStdKeyLeftFunc && !iTimeoutChr->IsActive() && iValue == 1 ) |
|
739 |
{ |
|
740 |
TCallBack callback( TimeoutCallbackChrL, this ); |
|
741 |
iTimeoutChr->Start( ( TTimeIntervalMicroSeconds32 ) KCallBackDelay, |
|
742 |
( TTimeIntervalMicroSeconds32 ) KCallBackInterval, |
|
743 |
callback ); |
|
744 |
} |
|
745 |
if ( aKeyEvent.iScanCode == EStdKeyLeftShift && !iTimeoutShift->IsActive() && iValue == 1 ) |
|
746 |
{ |
|
747 |
TCallBack callback( TimeoutCallbackShiftL, this ); |
|
748 |
iTimeoutShift->Start( ( TTimeIntervalMicroSeconds32 ) KCallBackDelay, |
|
749 |
( TTimeIntervalMicroSeconds32 ) KCallBackInterval, |
|
750 |
callback ); |
|
751 |
} |
|
752 |
} |
|
753 |
} |
|
754 |
#endif |
|
755 |
||
756 |
iFuncmapPane->NotifyReleaseKeyL(); |
|
757 |
iValue =0; |
|
758 |
||
759 |
DrawNow(); //redraw screen when a button up |
|
760 |
break; |
|
761 |
} |
|
762 |
default: |
|
763 |
{ |
|
764 |
break; |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
TKeyResponse keyResponse(iFuncmapPane->OfferKeyEventL(aKeyEvent, aType)); |
|
769 |
if (keyResponse == EKeyWasNotConsumed) |
|
770 |
{ |
|
771 |
if(iFuncmapPane->IsQwertyKeypadActive()) |
|
772 |
{ |
|
773 |
iEditorPane->IsQwertyActive(); |
|
774 |
} |
|
775 |
else |
|
776 |
{ |
|
777 |
iEditorPane->IsQwertyNotActive(); |
|
778 |
} |
|
779 |
// Edit buffer of line |
|
780 |
keyResponse = iEditorPane->OfferKeyEventL(aKeyEvent, aType); |
|
781 |
} |
|
782 |
return keyResponse; |
|
783 |
} |
|
784 |
||
785 |
// --------------------------------------------------------- |
|
786 |
// CCalcContainer::HandleResourceChange |
|
787 |
// Notifier for changing language |
|
788 |
// (other items were commented in a header). |
|
789 |
// --------------------------------------------------------- |
|
790 |
// |
|
791 |
void CCalcContainer::HandleResourceChange(TInt aType) |
|
792 |
{ |
|
793 |
TRAP_IGNORE( HandleResourceChangeCalSoftL( aType ) ); |
|
794 |
} |
|
795 |
||
796 |
// --------------------------------------------------------- |
|
797 |
// CCalcContainer::HandleResourceChange |
|
798 |
// Notifier for changing language |
|
799 |
// (other items were commented in a header). |
|
800 |
// --------------------------------------------------------- |
|
801 |
// |
|
802 |
void CCalcContainer::HandleResourceChangeCalSoftL(TInt aType) |
|
803 |
{ |
|
804 |
if ((aType == KEikDynamicLayoutVariantSwitch) || (aType == KAknsMessageSkinChange) ) |
|
805 |
{ |
|
806 |
||
807 |
TRect mainPaneRect ; |
|
808 |
TRect statusPaneRect; |
|
809 |
TBool signstate = EFalse; |
|
810 |
TBool sqrtstate = EFalse; |
|
811 |
TBool percentstate = EFalse; |
|
812 |
TBool clearstate = EFalse; |
|
813 |
||
814 |
if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
815 |
{ |
|
816 |
// when calculator is in Landscape layout, the statuspane displays |
|
817 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
818 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect ); |
|
819 |
mainPaneRect.iTl = statusPaneRect.iTl; |
|
820 |
} |
|
821 |
else |
|
822 |
{ |
|
823 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
824 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect ); |
|
825 |
mainPaneRect.iTl = statusPaneRect.iTl; |
|
826 |
} |
|
827 |
||
828 |
||
829 |
//check if funcpane already exists |
|
830 |
||
831 |
TInt selected = 0; |
|
832 |
if(iFuncmapPane) |
|
833 |
{ |
|
834 |
//store the states of the buttons |
|
835 |
signstate = iFuncmapPane->GetChangeSignButtonState(); |
|
836 |
sqrtstate = iFuncmapPane->GetSqrtButtonState(); |
|
837 |
percentstate = iFuncmapPane->GetPercentButtonState(); |
|
838 |
||
839 |
selected = iFuncmapPane->GetSelectedButtonId(); |
|
840 |
||
841 |
clearstate = iFuncmapPane->GetClearButtonState(); |
|
842 |
||
843 |
//delete the function pane |
|
844 |
delete(iFuncmapPane); |
|
845 |
iFuncmapPane = NULL; |
|
846 |
||
847 |
} |
|
848 |
//Reload the bitmaps |
|
849 |
(CCalcAppEnv::Static())->SetSkinChangedValue(EFalse); |
|
850 |
(CCalcAppEnv::Static())->UpdateAknConstArrayForFuncMap(); |
|
851 |
(CCalcAppEnv::Static())->LoadFuncMapBitmapL(); |
|
852 |
||
853 |
//Create the new pane |
|
854 |
iFuncmapPane = CCalcFuncmapSubPane::NewL(this); |
|
855 |
||
856 |
if ( AknLayoutUtils::PenEnabled() ) |
|
857 |
{ |
|
858 |
iFuncmapPane->SetHighlightButton( 0, selected ); |
|
859 |
} |
|
860 |
||
861 |
iFuncmapPane->ActivateL(); |
|
862 |
||
863 |
SetRect(mainPaneRect); |
|
864 |
iFuncmapPane->NotifyLangChange(); |
|
865 |
DrawNow(); |
|
866 |
||
867 |
//Restore the states of the buttons |
|
868 |
iFuncmapPane->SetChangeSignEnable(signstate); |
|
869 |
iFuncmapPane->SetSqrtEnable(sqrtstate); |
|
870 |
iFuncmapPane->SetPercentEnable(percentstate); |
|
871 |
iFuncmapPane->SetClearKeyEnable( clearstate ); |
|
872 |
||
873 |
//Update scroll bar here |
|
874 |
ScrollArrowUpdate(); |
|
875 |
iSheetPane->HandleResourceChange(aType); |
|
876 |
} |
|
877 |
else |
|
878 |
{ |
|
879 |
||
880 |
CCoeControl::HandleResourceChange(aType); |
|
881 |
} |
|
882 |
||
883 |
} |
|
884 |
||
885 |
||
886 |
// --------------------------------------------------------- |
|
887 |
// CCalcContainer::SizeChanged |
|
888 |
// Control size is set. |
|
889 |
// This function is called when the size changes. |
|
890 |
// (other items were commented in a header). |
|
891 |
// --------------------------------------------------------- |
|
892 |
// |
|
893 |
void CCalcContainer::SizeChanged() |
|
894 |
{ |
|
895 |
TRect parentRect(Rect()); |
|
896 |
||
897 |
if (iSkinContext) |
|
898 |
{ |
|
899 |
iSkinContext->SetRect(parentRect); |
|
900 |
} |
|
901 |
||
902 |
||
903 |
if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
904 |
{ |
|
905 |
||
906 |
// Set layout of function map subpane, output sheet and editor sub pane. |
|
907 |
if( AknLayoutUtils::PenEnabled() ) |
|
908 |
{ |
|
909 |
if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
910 |
{ |
|
911 |
||
912 |
AknLayoutUtils::LayoutControl( |
|
913 |
iFuncmapPane, parentRect, AknLayoutScalable_Apps::grid_calc_pane(enTouch_with_lsc).LayoutLine()); |
|
914 |
||
915 |
AknLayoutUtils::LayoutControl( |
|
916 |
iSheetPane, parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_lsc).LayoutLine()); |
|
917 |
||
918 |
AknLayoutUtils::LayoutControl( |
|
919 |
iEditorPane, parentRect,AknLayoutScalable_Apps::calc_display_pane(enTouch_with_lsc).LayoutLine()); |
|
920 |
} |
|
921 |
else |
|
922 |
{ |
|
923 |
AknLayoutUtils::LayoutControl( |
|
924 |
iFuncmapPane, parentRect, AknLayoutScalable_Apps::grid_calc_pane(enTouch_with_prt).LayoutLine()); |
|
925 |
||
926 |
AknLayoutUtils::LayoutControl( |
|
927 |
iSheetPane, parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_prt).LayoutLine()); |
|
928 |
||
929 |
AknLayoutUtils::LayoutControl( |
|
930 |
iEditorPane, parentRect,AknLayoutScalable_Apps::calc_display_pane(enTouch_with_prt).LayoutLine()); |
|
931 |
} |
|
932 |
} |
|
933 |
else |
|
934 |
{ |
|
935 |
AknLayoutUtils::LayoutControl( |
|
936 |
iFuncmapPane, parentRect, AknLayoutScalable_Apps::grid_calc_pane(enTouch_disabled).LayoutLine()); |
|
937 |
||
938 |
AknLayoutUtils::LayoutControl( |
|
939 |
iSheetPane, parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_disabled).LayoutLine()); |
|
940 |
||
941 |
AknLayoutUtils::LayoutControl( |
|
942 |
iEditorPane, parentRect,AknLayoutScalable_Apps::calc_display_pane(enTouch_disabled).LayoutLine()); |
|
943 |
||
944 |
} |
|
945 |
||
946 |
} |
|
947 |
else |
|
948 |
{ |
|
949 |
// Set layout of function map subpane. |
|
950 |
AknLayoutUtils::LayoutControl( |
|
951 |
iFuncmapPane, parentRect, AppLayout::grid_calc_pane()); |
|
952 |
||
953 |
||
954 |
// Set layout of output sheet. |
|
955 |
AknLayoutUtils::LayoutControl( |
|
956 |
iSheetPane, parentRect,AppLayout::gqn_graf_calc_paper()); |
|
957 |
||
958 |
// Set layout of editor subpane. |
|
959 |
AknLayoutUtils::LayoutControl( |
|
960 |
iEditorPane, parentRect,AppLayout::Calculator_elements_Line_1()); |
|
961 |
} |
|
962 |
} |
|
963 |
||
964 |
// --------------------------------------------------------- |
|
965 |
// CCalcContainer::Draw |
|
966 |
// Clear whole screen. After this, draw editor, output sheet, |
|
967 |
// and function map. |
|
968 |
// (other items were commented in a header). |
|
969 |
// --------------------------------------------------------- |
|
970 |
// |
|
971 |
void CCalcContainer::Draw(const TRect& aRect) const |
|
972 |
{ |
|
973 |
CWindowGc& gc = SystemGc(); |
|
974 |
gc.Clear(aRect); |
|
975 |
||
976 |
// Drawing skin |
|
977 |
if (iSkinContext) |
|
978 |
{ |
|
979 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
980 |
||
981 |
AknsDrawUtils::Background( |
|
982 |
skin, iSkinContext, this, gc, aRect); |
|
983 |
} |
|
984 |
||
985 |
} |
|
986 |
||
987 |
// --------------------------------------------------------- |
|
988 |
// CCalcContainer::MopSupplyObject() |
|
989 |
// Pass skin information if need. |
|
990 |
// (other items were commented in a header). |
|
991 |
// --------------------------------------------------------- |
|
992 |
// |
|
993 |
TTypeUid::Ptr CCalcContainer::MopSupplyObject(TTypeUid aId) |
|
994 |
{ |
|
995 |
if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext) |
|
996 |
{ |
|
997 |
return MAknsControlContext::SupplyMopObject(aId, iSkinContext); |
|
998 |
} |
|
999 |
||
1000 |
return CCoeControl::MopSupplyObject(aId); |
|
1001 |
} |
|
1002 |
||
1003 |
// --------------------------------------------------------- |
|
1004 |
// CCalcContainer::ShowSqrtButton() |
|
1005 |
// Enable (or disable) the square root button. |
|
1006 |
// (other items were commented in a header). |
|
1007 |
// --------------------------------------------------------- |
|
1008 |
// |
|
1009 |
void CCalcContainer::ShowSqrtButton(TBool aEnable) |
|
1010 |
{ |
|
1011 |
TCalcEditLine editLine( iEditorPane->EditLine() ); |
|
1012 |
TBool sqrtEnable(ETrue); |
|
1013 |
TRAP_IGNORE( |
|
1014 |
if ( editLine.NumberL() == 0 ) |
|
1015 |
{ |
|
1016 |
sqrtEnable = EFalse; |
|
1017 |
} |
|
1018 |
) |
|
1019 |
||
1020 |
iFuncmapPane->SetSqrtEnable( sqrtEnable ); |
|
1021 |
} |
|
1022 |
||
1023 |
// --------------------------------------------------------- |
|
1024 |
// CCalcContainer::ShowPercentButton() |
|
1025 |
// Enable (or disable) the percent button. |
|
1026 |
// (other items were commented in a header). |
|
1027 |
// --------------------------------------------------------- |
|
1028 |
// |
|
1029 |
void CCalcContainer::ShowPercentButton(TBool aEnable) |
|
1030 |
{ |
|
1031 |
iFuncmapPane->SetPercentEnable(aEnable); |
|
1032 |
} |
|
1033 |
||
1034 |
// --------------------------------------------------------- |
|
1035 |
// CCalcContainer::GetState() |
|
1036 |
// Returns the state of the calculator. |
|
1037 |
// (other items were commented in a header). |
|
1038 |
// --------------------------------------------------------- |
|
1039 |
// |
|
1040 |
CCalcView::TStateNo CCalcContainer::GetState() |
|
1041 |
{ |
|
1042 |
return (iView->State()); |
|
1043 |
} |
|
1044 |
||
1045 |
// --------------------------------------------------------- |
|
1046 |
// CCalcContainer::HandlePointerEventL |
|
1047 |
// Handled when pen input occured. |
|
1048 |
// (other items were commented in a header). |
|
1049 |
// --------------------------------------------------------- |
|
1050 |
// |
|
1051 |
void CCalcContainer::HandlePointerEventL |
|
1052 |
( const TPointerEvent& aPointerEvent ) |
|
1053 |
{ |
|
1054 |
CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1055 |
} |
|
1056 |
||
1057 |
||
1058 |
// --------------------------------------------------------- |
|
1059 |
// --------------------------------------------------------- |
|
1060 |
// CCalcContainer::HandleMiddleSoftKey() |
|
1061 |
// Handled when MSK is selected. |
|
1062 |
// --------------------------------------------------------- |
|
1063 |
// |
|
1064 |
void CCalcContainer::HandleMiddleSoftKey() |
|
1065 |
||
1066 |
{ |
|
1067 |
TRAP_IGNORE( iFuncmapPane->HandleMiddleSoftKeyOREKeyOKL() ); |
|
1068 |
} |
|
1069 |
||
1070 |
// --------------------------------------------------------- |
|
1071 |
// --------------------------------------------------------- |
|
1072 |
// SetOperatorFromTouchL |
|
1073 |
// Handle digit inputs |
|
1074 |
// --------------------------------------------------------- |
|
1075 |
// |
|
1076 |
void CCalcContainer::SetOperatorFromTouchL(TInt akey ) |
|
1077 |
{ |
|
1078 |
//Simulate events as events are occurring from the KB Events |
|
1079 |
TKeyEvent eventkey; |
|
1080 |
TEventCode keycode; |
|
1081 |
keycode = EEventKeyDown; |
|
1082 |
eventkey.iCode = 0; |
|
1083 |
eventkey.iScanCode = ASCII_ZERO + akey; |
|
1084 |
||
1085 |
//First send Keydown event |
|
1086 |
OfferKeyEventL(eventkey,keycode); |
|
1087 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1088 |
eventkey.iCode = ASCII_ZERO + akey; |
|
1089 |
#else |
|
1090 |
eventkey.iCode = KEY_CODE_VAL; |
|
1091 |
#endif |
|
1092 |
keycode = EEventKey; |
|
1093 |
||
1094 |
//Next send EventKey |
|
1095 |
OfferKeyEventL(eventkey,keycode); |
|
1096 |
||
1097 |
||
1098 |
//Finally send Keyup |
|
1099 |
eventkey.iScanCode = ASCII_ZERO + akey; |
|
1100 |
keycode = EEventKeyUp; |
|
1101 |
OfferKeyEventL(eventkey,keycode); |
|
1102 |
} |
|
1103 |
||
1104 |
// --------------------------------------------------------- |
|
1105 |
// --------------------------------------------------------- |
|
1106 |
// ClearInputKeyL |
|
1107 |
// Handle 'c' input key from Touch |
|
1108 |
// --------------------------------------------------------- |
|
1109 |
// |
|
1110 |
void CCalcContainer::ClearInputKeyL(TInt aRepeat) |
|
1111 |
{ |
|
1112 |
//Simulate events as events are occurring from the KB Events |
|
1113 |
TKeyEvent eventkey; |
|
1114 |
TEventCode keycode; |
|
1115 |
keycode = EEventKeyDown; |
|
1116 |
eventkey.iCode = 0; |
|
1117 |
eventkey.iScanCode = 1; //for clear input key |
|
1118 |
eventkey.iRepeats = aRepeat; |
|
1119 |
||
1120 |
//First send Keydown event |
|
1121 |
OfferKeyEventL(eventkey,keycode); |
|
1122 |
eventkey.iCode = 8; //clear input key icode |
|
1123 |
keycode = EEventKey; |
|
1124 |
||
1125 |
//Next send EventKey |
|
1126 |
OfferKeyEventL(eventkey,keycode); |
|
1127 |
keycode = EEventKeyUp; |
|
1128 |
||
1129 |
//Finally send Keyup |
|
1130 |
OfferKeyEventL(eventkey,keycode); |
|
1131 |
||
1132 |
} |
|
1133 |
||
1134 |
||
1135 |
// --------------------------------------------------------- |
|
1136 |
// --------------------------------------------------------- |
|
1137 |
// SetSeparatorFromTouch |
|
1138 |
// Handle '.' input key from Touch |
|
1139 |
// --------------------------------------------------------- |
|
1140 |
// |
|
1141 |
void CCalcContainer::SetSeparatorFromTouchL() |
|
1142 |
{ |
|
1143 |
// set the right iCode and iScanCode for |
|
1144 |
// decimal point |
|
1145 |
if ( iFuncmapPane->IsQwertyKeypadActive() ) |
|
1146 |
{ |
|
1147 |
// Simulate events as events are occurring from the KB Events |
|
1148 |
TKeyEvent eventkey; |
|
1149 |
TEventCode keycode = EEventKeyDown; |
|
1150 |
eventkey.iCode = 0; |
|
1151 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1152 |
if ( iFuncmapPane->GetKeyboardType() == EPtiKeyboardHalfQwerty ) |
|
1153 |
{ |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1154 |
eventkey.iScanCode = EStdKeySingleQuote; //scan code for separator |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1155 |
eventkey.iCode = ( TUint )KDotSeparator; // icode for separator |
24 | 1156 |
} |
1157 |
else |
|
1158 |
#endif |
|
1159 |
{ |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1160 |
TLocale locale; |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1161 |
//Get a decimal separator from system for current phone language. |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1162 |
TChar decimalSeparator( locale.DecimalSeparator() ); |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1163 |
|
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1164 |
if ( KCommaSeparator == decimalSeparator ) |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1165 |
{ |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1166 |
//separator is Comma |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1167 |
eventkey.iScanCode = EStdKeyComma; //scan code for separator |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1168 |
} |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1169 |
else |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1170 |
{ |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1171 |
//separator is dot |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1172 |
eventkey.iScanCode = EStdKeyFullStop; //scan code for separator |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1173 |
} |
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1174 |
eventkey.iCode = ( TUint )decimalSeparator; // icode for separator |
24 | 1175 |
} |
1176 |
||
1177 |
// First send Keydown event |
|
1178 |
OfferKeyEventL( eventkey, keycode ); |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1179 |
|
24 | 1180 |
keycode = EEventKey; |
1181 |
||
1182 |
// Next send EventKey |
|
1183 |
OfferKeyEventL( eventkey, keycode ); |
|
1184 |
} |
|
1185 |
else |
|
1186 |
{ |
|
1187 |
// Simulate events as events are occurring from the KB Events |
|
1188 |
TKeyEvent eventkey; |
|
1189 |
TEventCode keycode = EEventKeyDown; |
|
1190 |
eventkey.iCode = 0; |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1191 |
eventkey.iScanCode = EStdKeyHash; // scan code for separator |
24 | 1192 |
|
1193 |
// First send Keydown event |
|
1194 |
OfferKeyEventL( eventkey, keycode ); |
|
29
9d6a662e71d9
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1195 |
eventkey.iCode = ( TUint )KHashSeparator; // icode for separator |
24 | 1196 |
keycode = EEventKey; |
1197 |
||
1198 |
// Next send EventKey |
|
1199 |
OfferKeyEventL( eventkey, keycode ); |
|
1200 |
} |
|
1201 |
} |
|
1202 |
||
1203 |
// End of File CALCCONT_CPP |