|
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 #ifndef CALCFUNC_H |
|
22 #define CALCFUNC_H |
|
23 |
|
24 |
|
25 // INCLUDES |
|
26 #include <coecntrl.h> |
|
27 #include <e32property.h> |
|
28 #include <PtiDefs.h> |
|
29 |
|
30 #include <centralrepository.h> |
|
31 #include <cenrepnotifyhandler.h> |
|
32 // CONSTANTS |
|
33 const TInt KCountOfButtons(10); // Number of buttons |
|
34 const TInt KCountOfButtonsTouch(20); // Number of buttons for touch UI layout |
|
35 _LIT(KAllowedNumericChars, "0123456789.,"); |
|
36 _LIT(KAllowedOperatorPlus, "+"); |
|
37 _LIT(KAllowedOperatorMinus, "-"); |
|
38 _LIT(KAllowedOperatorStar, "*"); |
|
39 _LIT(KAllowedOperatorDivide, "/"); |
|
40 _LIT(KAllowedOperatorEquals, "="); |
|
41 _LIT(KAllowedOperatorPercent, "%"); |
|
42 _LIT(KAllowedOperatorDecimal, "."); |
|
43 const TInt KMaxNumCharsPerCase = 50; |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 //class CCalcCommandButton; |
|
47 //Use of new AknButtons |
|
48 class CAknButton; |
|
49 class CCalcContainer; |
|
50 class CCalcAppEnv; |
|
51 class CPtiEngine; |
|
52 class CPtiQwertyKeyMappings; |
|
53 class CPtiCoreLanguage; |
|
54 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
55 class CPtiHalfQwertyKeyMappings; |
|
56 #endif |
|
57 |
|
58 // CLASS DEFINITIONS |
|
59 |
|
60 /** |
|
61 CCalcFuncmapSubPane : 'FunctionMap Sub-Pane' class |
|
62 : Class also derived from MCoeControlObserver to get events |
|
63 from Avkon buttons |
|
64 */ |
|
65 class CCalcFuncmapSubPane |
|
66 :public CCoeControl , public MCoeControlObserver |
|
67 { |
|
68 public: |
|
69 |
|
70 enum TButtonTID// ButtonIDs for Touch Layout |
|
71 { |
|
72 ECmdTCancel = 0, |
|
73 ECmdTSeven, |
|
74 ECmdTFour, |
|
75 ECmdTOne, |
|
76 ECmdTZero, |
|
77 ECmdTSqrt, |
|
78 ECmdTEight, |
|
79 ECmdTFive, |
|
80 ECmdTTwo, |
|
81 ECmdTSeparator, |
|
82 ECmdTPercent, |
|
83 ECmdTNine, |
|
84 ECmdTSix, |
|
85 ECmdTThree, |
|
86 ECmdTChangeSign, |
|
87 ECmdTDivide, |
|
88 ECmdTMultiply, |
|
89 ECmdTSubtract, |
|
90 ECmdTAdd, |
|
91 ECmdTResult, |
|
92 ECmdTScrollUp, |
|
93 ECmdTScrollDown |
|
94 }; |
|
95 |
|
96 |
|
97 |
|
98 enum TButtonID // ButtonID for non touch Layout |
|
99 { |
|
100 EPlusButton, // + |
|
101 EMinusButton, // - |
|
102 EMultiplyButton, // * |
|
103 EDivideButton, // / |
|
104 EChangeSignButton, // +/- |
|
105 EEqualButton, // = |
|
106 ESqrtButton, // sqrt |
|
107 EPercentButton, // % |
|
108 EScrollUp, // << |
|
109 EScrollDown // >> |
|
110 }; |
|
111 public: // Constructors and destructor |
|
112 /** |
|
113 * Two-phased constructor. |
|
114 * @param aContainer : Pointer of CCalcContainer class |
|
115 */ |
|
116 static CCalcFuncmapSubPane* NewL(CCalcContainer* aContainer); |
|
117 |
|
118 /** |
|
119 * Destructor. |
|
120 */ |
|
121 virtual ~CCalcFuncmapSubPane(); |
|
122 |
|
123 |
|
124 public: // New functions |
|
125 /** |
|
126 * Redraw scroll up and down button on scrolling enable. |
|
127 */ |
|
128 void RedrawScrollButtons(); |
|
129 |
|
130 /** |
|
131 * Redraw ChangeSign button on ChangeSign enable. |
|
132 * @param aEnable : Flag of ChangeSign enable |
|
133 */ |
|
134 void SetChangeSignEnable(TBool aEnable); |
|
135 |
|
136 /** |
|
137 * Redraw Sqrt button on Sqrt enable. |
|
138 * @param aEnable : Flag of SqrtEnable enable |
|
139 */ |
|
140 void SetSqrtEnable (TBool aEnable); |
|
141 |
|
142 /** |
|
143 * Redraw Clear button on Clear enable. |
|
144 * @param aEnable : Flag of ClearEnable enable |
|
145 */ |
|
146 void SetClearKeyEnable( TBool aEnable ); |
|
147 |
|
148 /** |
|
149 * Redraw Sqrt button on Percent enable. |
|
150 * @param aEnable : Flag of PercentEnable enable |
|
151 */ |
|
152 void SetPercentEnable(TBool aEnable); |
|
153 |
|
154 /** |
|
155 * If no key is pressed until timeout of *-key, |
|
156 * this function is called. |
|
157 */ |
|
158 void NotifyTimeoutL(); |
|
159 |
|
160 /** |
|
161 * Notify any key is released. If pressed button exists. |
|
162 * command which is releated is executed. |
|
163 */ |
|
164 void NotifyReleaseKeyL(); |
|
165 |
|
166 /** |
|
167 * If key other than OK-key is pressed this function is called. |
|
168 */ |
|
169 void NotifyOtherThanOkKeyPressed(); |
|
170 |
|
171 /** |
|
172 * Called if language is changed. |
|
173 * Change layout according to the language. |
|
174 */ |
|
175 void NotifyLangChange(); |
|
176 |
|
177 |
|
178 /** |
|
179 * Called to find key pad is Active. |
|
180 * |
|
181 */ |
|
182 TInt IsQwertyKeypadActive(); |
|
183 |
|
184 /** |
|
185 * Called to find Key is long Pressed. |
|
186 * |
|
187 */ |
|
188 TBool IsKeyLongPressed(); |
|
189 |
|
190 /** |
|
191 * Called when an error is displayed. |
|
192 * @param aErrorCode : an error code from CCalcContainer |
|
193 */ |
|
194 void SetErrorCode(TInt aErrorCode); |
|
195 |
|
196 /** |
|
197 * Called when there is a release event . |
|
198 * @param aErrorCode : an error code ,it used to display dialog |
|
199 */ |
|
200 void ErrorMsgL(TInt aErrorCode); |
|
201 public: // Functions from base classes |
|
202 |
|
203 /** |
|
204 * From MCoeControlObserver. |
|
205 * Handles events from Avkon Buttons |
|
206 */ |
|
207 void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); |
|
208 /** |
|
209 * From CCoeControl ?member_description. |
|
210 * @param aKeyEvent : Key event details |
|
211 * @param aType : EEventKeyDown || EEventKey || EEventKeyUp |
|
212 * @return EKeyWasConsumed : Key event was used |
|
213 * EKeyWasNotConsumed : Key event was not used |
|
214 */ |
|
215 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
216 |
|
217 /** |
|
218 *Refresh with latest button Icons when the skin change event has occured. |
|
219 */ |
|
220 void RefreshButtonIcons(); |
|
221 |
|
222 /** |
|
223 * CCalcFuncmapSubPane::GetButtonBitmapControl |
|
224 * This function is called when the size changes. |
|
225 * |
|
226 */ |
|
227 CAknButton* GetButtonBitmapControl(TInt aIndex); //Return iButtons |
|
228 |
|
229 /** |
|
230 * From CCoeControl : Handling pointer event |
|
231 * Handles all pen input events on function pane. |
|
232 * |
|
233 */ |
|
234 void HandlePointerEventL |
|
235 ( const TPointerEvent& aKeyEvent ); |
|
236 /** |
|
237 * FunctionPaneRect |
|
238 * Gets the layout of function pane. |
|
239 */ |
|
240 TRect FunctionPaneRect(); |
|
241 |
|
242 /** |
|
243 * HandleMiddleSoftKeyOREKeyOK |
|
244 * Called to handle MSK or EKeyOk |
|
245 */ |
|
246 void HandleMiddleSoftKeyOREKeyOKL(); |
|
247 |
|
248 /** |
|
249 * GetChangeSignButtonState |
|
250 * Gets the state of the Sign Button |
|
251 */ |
|
252 TBool GetChangeSignButtonState(); |
|
253 |
|
254 |
|
255 /** |
|
256 * GetSqrtButtonState |
|
257 * Gets the state of the Squareroot Button |
|
258 */ |
|
259 TBool GetSqrtButtonState(); |
|
260 |
|
261 |
|
262 /** |
|
263 * GetSqrtButtonState |
|
264 * Gets the state of the Percent Button |
|
265 */ |
|
266 TBool GetPercentButtonState(); |
|
267 |
|
268 /** |
|
269 * GetClearButtonState |
|
270 * Gets the state of the Clear Button |
|
271 */ |
|
272 TBool GetClearButtonState(); |
|
273 |
|
274 /** |
|
275 * GetSelectedButtonId |
|
276 * returns the id of current button |
|
277 */ |
|
278 TInt GetSelectedButtonId(); |
|
279 |
|
280 /** |
|
281 * SetHighlightButton |
|
282 * set highlight button |
|
283 */ |
|
284 void SetHighlightButton( TUint aOldId, TUint aNewId ); |
|
285 |
|
286 /** |
|
287 * GetKeyboardType |
|
288 * returns the type of keyboard |
|
289 */ |
|
290 TInt GetKeyboardType(); |
|
291 |
|
292 private: // New functions |
|
293 /** |
|
294 * C++ default constructor. |
|
295 */ |
|
296 CCalcFuncmapSubPane(); |
|
297 |
|
298 /** |
|
299 * Second-phase constructor |
|
300 * @param aContainer : Pointer of CCalcContainer class |
|
301 */ |
|
302 void ConstructL(CCalcContainer* aContainer); |
|
303 |
|
304 /** |
|
305 * Redraw scroll-up button on scrolling enable. |
|
306 * @param aEnable : Flag of scroll-up enable |
|
307 */ |
|
308 void SetScrollupEnable(TBool aEnable); |
|
309 |
|
310 /** |
|
311 * Redraw scroll-down button on scrolling enable. |
|
312 * @param aEnable : Flag of scroll-down enable |
|
313 */ |
|
314 void SetScrolldownEnable(TBool aEnable); |
|
315 |
|
316 /** |
|
317 * Set next cursor position whwn pressing uparrow key. |
|
318 */ |
|
319 void SetNextCursorPosForUpArrow(TInt aOldPos); |
|
320 |
|
321 /** |
|
322 * Set next cursor position whwn pressing downarrow key. |
|
323 */ |
|
324 void SetNextCursorPosForDownArrow(TInt aOldPos); |
|
325 |
|
326 /** |
|
327 * An old highlight rectangle and |
|
328 * a new highlight rectangle are redrawn. |
|
329 * @param aOldId : The button chosen before |
|
330 * @param aNewId : The button chosen newly |
|
331 */ |
|
332 void RedrawHighlight(TUint aOldId, TUint aNewId) ; |
|
333 |
|
334 /** |
|
335 * An old highlight rectangle and |
|
336 * a new highlight rectangle are redrawn. |
|
337 * @param aOldId : The button chosen before |
|
338 * @param aNewId : The button chosen newly |
|
339 * @param aShowHightlight: control hightlight display |
|
340 */ |
|
341 void RedrawHighlight(TUint aOldId, TUint aNewId,TBool aShowHightlight) ; |
|
342 |
|
343 /** |
|
344 * Set functionmap button layout. |
|
345 */ |
|
346 void SetLayout(); |
|
347 /** |
|
348 * MapNumericChar. |
|
349 */ |
|
350 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
351 TBool MapNumericCharL( TKeyEvent aKeyEvent ); |
|
352 TBool MapNumerics( TKeyEvent aKeyEvent ); |
|
353 #else |
|
354 TBool MapNumericCharL(TPtiKey aKey, TPtiTextCase aCase); |
|
355 TBool MapNumerics(TPtiKey aKey, TPtiTextCase aCase); |
|
356 #endif |
|
357 |
|
358 /** |
|
359 * MapDataForChrShiftKey. |
|
360 */ |
|
361 void MapDataForChrShiftKey( TDes& aOperators, TInt& aFirstOperator, TInt& aSecondOperator); |
|
362 |
|
363 /** |
|
364 * MapOperators. |
|
365 */ |
|
366 TBool MapOperators( TUint16 aOperator, TInt& aResult); |
|
367 |
|
368 |
|
369 private: // Functions from base classes |
|
370 /** |
|
371 * From CCoeControl : Return count of controls contained |
|
372 * in a compound control. |
|
373 * @return Count of buttons in FunctionMap Subpane |
|
374 */ |
|
375 TInt CountComponentControls() const; |
|
376 |
|
377 /** |
|
378 * From CCoeControl : Get the components of a compound control |
|
379 * @param aIndex |
|
380 * @return Control of argument aIndex |
|
381 */ |
|
382 CCoeControl* ComponentControl(TInt aIndex) const; |
|
383 |
|
384 /** |
|
385 * From CCoeControl : This is called when control size is changed. |
|
386 */ |
|
387 void SizeChanged(); |
|
388 |
|
389 /** |
|
390 * From CCoeControl : This is called when control size is changed. |
|
391 */ |
|
392 TInt CalculatingCorrectButton(const TPointerEvent& aPointerEvent); |
|
393 |
|
394 private: // Data |
|
395 CAknButton* iButtons[KCountOfButtonsTouch]; // Array of buttons |
|
396 TInt iSelected; // Index of the selected button |
|
397 |
|
398 TBool iDecimalPoint; |
|
399 |
|
400 TUint iLastKeyCode; // The key code inputted at the last. |
|
401 CCalcContainer* iContainer; // Pointer of CCalcContainer class |
|
402 CCalcAppEnv* iCalcAppEnv; // Not own |
|
403 RProperty iQwertyModeStatusProperty; // To check the Qwerty keypad active |
|
404 |
|
405 TPtiTextCase iShiftKeyPressed; |
|
406 CPtiEngine* iEngine; |
|
407 CRepository* iCRKey; |
|
408 CPtiCoreLanguage* iCoreLanguage; |
|
409 CPtiQwertyKeyMappings* iQwertyKeyMappings; |
|
410 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
411 CPtiHalfQwertyKeyMappings* iHalfQwertyKeyMappings; |
|
412 #endif |
|
413 |
|
414 TInt iLanguage; |
|
415 TInt iUiLanguage; |
|
416 TInt iShiftKey; |
|
417 TBool iValue; |
|
418 TInt iCountOfButtons; //keeps track of the count of buttons |
|
419 TInt iButtonsInRow; //Number of buttons in the row |
|
420 TInt iButtonsInColumn; //Number of buttons in the Column |
|
421 TBool iIsSqrtDimmed; //Holds the state of the squareroot button |
|
422 TBool iIsPercentDimmed; //Holds the state of the percent button |
|
423 TBool iIsChangeSignDimmed; //Checks if the change sign button is dimmed or not |
|
424 TBool iIsOfferKeyEvent; //checks if the event on select is from Offer key or pointer |
|
425 TBool iIsClearKeyEnabled; //Checks if the Clear button is Enabled or not |
|
426 TBool iIsKeyLongPress; //Checks if the button is Long Pressed or not |
|
427 TInt iKeyboardType; |
|
428 TBool iIsShiftKeyPressed; |
|
429 TInt iErrorCode; |
|
430 TBool iShowDrawHight; |
|
431 TBool iInputData; |
|
432 }; |
|
433 |
|
434 #endif // CALCFUNC_H |
|
435 |
|
436 // End of File |