|
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 public: // Functions from base classes |
|
192 |
|
193 /** |
|
194 * From MCoeControlObserver. |
|
195 * Handles events from Avkon Buttons |
|
196 */ |
|
197 void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); |
|
198 /** |
|
199 * From CCoeControl ?member_description. |
|
200 * @param aKeyEvent : Key event details |
|
201 * @param aType : EEventKeyDown || EEventKey || EEventKeyUp |
|
202 * @return EKeyWasConsumed : Key event was used |
|
203 * EKeyWasNotConsumed : Key event was not used |
|
204 */ |
|
205 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
206 |
|
207 /** |
|
208 *Refresh with latest button Icons when the skin change event has occured. |
|
209 */ |
|
210 void RefreshButtonIcons(); |
|
211 |
|
212 /** |
|
213 * CCalcFuncmapSubPane::GetButtonBitmapControl |
|
214 * This function is called when the size changes. |
|
215 * |
|
216 */ |
|
217 CAknButton* GetButtonBitmapControl(TInt aIndex); //Return iButtons |
|
218 |
|
219 /** |
|
220 * From CCoeControl : Handling pointer event |
|
221 * Handles all pen input events on function pane. |
|
222 * |
|
223 */ |
|
224 void HandlePointerEventL |
|
225 ( const TPointerEvent& aKeyEvent ); |
|
226 /** |
|
227 * FunctionPaneRect |
|
228 * Gets the layout of function pane. |
|
229 */ |
|
230 TRect FunctionPaneRect(); |
|
231 |
|
232 /** |
|
233 * HandleMiddleSoftKeyOREKeyOK |
|
234 * Called to handle MSK or EKeyOk |
|
235 */ |
|
236 void HandleMiddleSoftKeyOREKeyOKL(); |
|
237 |
|
238 /** |
|
239 * GetChangeSignButtonState |
|
240 * Gets the state of the Sign Button |
|
241 */ |
|
242 TBool GetChangeSignButtonState(); |
|
243 |
|
244 |
|
245 /** |
|
246 * GetSqrtButtonState |
|
247 * Gets the state of the Squareroot Button |
|
248 */ |
|
249 TBool GetSqrtButtonState(); |
|
250 |
|
251 |
|
252 /** |
|
253 * GetSqrtButtonState |
|
254 * Gets the state of the Percent Button |
|
255 */ |
|
256 TBool GetPercentButtonState(); |
|
257 |
|
258 /** |
|
259 * GetClearButtonState |
|
260 * Gets the state of the Clear Button |
|
261 */ |
|
262 TBool GetClearButtonState(); |
|
263 |
|
264 /** |
|
265 * GetSelectedButtonId |
|
266 * returns the id of current button |
|
267 */ |
|
268 TInt GetSelectedButtonId(); |
|
269 |
|
270 /** |
|
271 * SetHighlightButton |
|
272 * set highlight button |
|
273 */ |
|
274 void SetHighlightButton( TUint aOldId, TUint aNewId ); |
|
275 |
|
276 /** |
|
277 * GetKeyboardType |
|
278 * returns the type of keyboard |
|
279 */ |
|
280 TInt GetKeyboardType(); |
|
281 |
|
282 private: // New functions |
|
283 /** |
|
284 * C++ default constructor. |
|
285 */ |
|
286 CCalcFuncmapSubPane(); |
|
287 |
|
288 /** |
|
289 * Second-phase constructor |
|
290 * @param aContainer : Pointer of CCalcContainer class |
|
291 */ |
|
292 void ConstructL(CCalcContainer* aContainer); |
|
293 |
|
294 /** |
|
295 * Redraw scroll-up button on scrolling enable. |
|
296 * @param aEnable : Flag of scroll-up enable |
|
297 */ |
|
298 void SetScrollupEnable(TBool aEnable); |
|
299 |
|
300 /** |
|
301 * Redraw scroll-down button on scrolling enable. |
|
302 * @param aEnable : Flag of scroll-down enable |
|
303 */ |
|
304 void SetScrolldownEnable(TBool aEnable); |
|
305 |
|
306 /** |
|
307 * Set next cursor position whwn pressing uparrow key. |
|
308 */ |
|
309 void SetNextCursorPosForUpArrow(TInt aOldPos); |
|
310 |
|
311 /** |
|
312 * Set next cursor position whwn pressing downarrow key. |
|
313 */ |
|
314 void SetNextCursorPosForDownArrow(TInt aOldPos); |
|
315 |
|
316 /** |
|
317 * An old highlight rectangle and |
|
318 * a new highlight rectangle are redrawn. |
|
319 * @param aOldId : The button chosen before |
|
320 * @param aNewId : The button chosen newly |
|
321 */ |
|
322 void RedrawHighlight(TUint aOldId, TUint aNewId) const; |
|
323 |
|
324 /** |
|
325 * Set functionmap button layout. |
|
326 */ |
|
327 void SetLayout(); |
|
328 /** |
|
329 * MapNumericChar. |
|
330 */ |
|
331 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
332 TBool MapNumericCharL( TKeyEvent aKeyEvent ); |
|
333 TBool MapNumerics( TKeyEvent aKeyEvent ); |
|
334 #else |
|
335 TBool MapNumericCharL(TPtiKey aKey, TPtiTextCase aCase); |
|
336 TBool MapNumerics(TPtiKey aKey, TPtiTextCase aCase); |
|
337 #endif |
|
338 |
|
339 /** |
|
340 * MapDataForChrShiftKey. |
|
341 */ |
|
342 void MapDataForChrShiftKey( TDes& aOperators, TInt& aFirstOperator, TInt& aSecondOperator); |
|
343 |
|
344 /** |
|
345 * MapOperators. |
|
346 */ |
|
347 TBool MapOperators( TUint16 aOperator, TInt& aResult); |
|
348 |
|
349 |
|
350 private: // Functions from base classes |
|
351 /** |
|
352 * From CCoeControl : Return count of controls contained |
|
353 * in a compound control. |
|
354 * @return Count of buttons in FunctionMap Subpane |
|
355 */ |
|
356 TInt CountComponentControls() const; |
|
357 |
|
358 /** |
|
359 * From CCoeControl : Get the components of a compound control |
|
360 * @param aIndex |
|
361 * @return Control of argument aIndex |
|
362 */ |
|
363 CCoeControl* ComponentControl(TInt aIndex) const; |
|
364 |
|
365 /** |
|
366 * From CCoeControl : This is called when control size is changed. |
|
367 */ |
|
368 void SizeChanged(); |
|
369 |
|
370 /** |
|
371 * From CCoeControl : This is called when control size is changed. |
|
372 */ |
|
373 TInt CalculatingCorrectButton(const TPointerEvent& aPointerEvent); |
|
374 |
|
375 private: // Data |
|
376 CAknButton* iButtons[KCountOfButtonsTouch]; // Array of buttons |
|
377 TInt iSelected; // Index of the selected button |
|
378 |
|
379 TBool iDecimalPoint; |
|
380 |
|
381 TUint iLastKeyCode; // The key code inputted at the last. |
|
382 CCalcContainer* iContainer; // Pointer of CCalcContainer class |
|
383 CCalcAppEnv* iCalcAppEnv; // Not own |
|
384 RProperty iQwertyModeStatusProperty; // To check the Qwerty keypad active |
|
385 |
|
386 TPtiTextCase iShiftKeyPressed; |
|
387 CPtiEngine* iEngine; |
|
388 CRepository* iCRKey; |
|
389 CPtiCoreLanguage* iCoreLanguage; |
|
390 CPtiQwertyKeyMappings* iQwertyKeyMappings; |
|
391 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
392 CPtiHalfQwertyKeyMappings* iHalfQwertyKeyMappings; |
|
393 #endif |
|
394 |
|
395 TInt iLanguage; |
|
396 TInt iUiLanguage; |
|
397 TInt iShiftKey; |
|
398 TBool iValue; |
|
399 TInt iCountOfButtons; //keeps track of the count of buttons |
|
400 TInt iButtonsInRow; //Number of buttons in the row |
|
401 TInt iButtonsInColumn; //Number of buttons in the Column |
|
402 TBool iIsSqrtDimmed; //Holds the state of the squareroot button |
|
403 TBool iIsPercentDimmed; //Holds the state of the percent button |
|
404 TBool iIsChangeSignDimmed; //Checks if the change sign button is dimmed or not |
|
405 TBool iIsOfferKeyEvent; //checks if the event on select is from Offer key or pointer |
|
406 TBool iIsClearKeyEnabled; //Checks if the Clear button is Enabled or not |
|
407 TBool iIsKeyLongPress; //Checks if the button is Long Pressed or not |
|
408 TInt iKeyboardType; |
|
409 TBool iIsShiftKeyPressed; |
|
410 }; |
|
411 |
|
412 #endif // CALCFUNC_H |
|
413 |
|
414 // End of File |