21
|
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: Header 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 |
#ifndef CALCCONT_H
|
|
22 |
#define CALCCONT_H
|
|
23 |
|
|
24 |
|
|
25 |
// INCLUDES
|
|
26 |
#include <coecntrl.h>
|
|
27 |
|
|
28 |
#include "CalcEditline.h"
|
|
29 |
#include "CalcView.h"
|
|
30 |
|
|
31 |
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class CCalcEditorSubPane;
|
|
34 |
class CCalcFuncmapSubPane;
|
|
35 |
class CCalcOutputSheet;
|
|
36 |
class CCalcView;
|
|
37 |
class CCalcDocument;
|
|
38 |
class CPeriodic;
|
|
39 |
class CAknsBasicBackgroundControlContext;
|
|
40 |
//Enum declarations for touch values
|
|
41 |
enum enlayout_values
|
|
42 |
{
|
|
43 |
enTouch_disabled = 0,
|
|
44 |
enTouch_enabled,
|
|
45 |
enTouch_with_prt,
|
|
46 |
enTouch_with_lsc
|
|
47 |
};
|
|
48 |
// CLASS DEFINITIONS
|
|
49 |
|
|
50 |
/**
|
|
51 |
CCalcContainer : 'Main-Pane' class
|
|
52 |
*/
|
|
53 |
class CCalcContainer
|
|
54 |
:public CCoeControl
|
|
55 |
{
|
|
56 |
public: // Constructors and destructor
|
|
57 |
/**
|
|
58 |
* Two-phased constructor.
|
|
59 |
*/
|
|
60 |
static CCalcContainer* NewL(CCalcView* aView);
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Destructor.
|
|
64 |
*/
|
|
65 |
virtual ~CCalcContainer();
|
|
66 |
|
|
67 |
|
|
68 |
public: // New functions
|
|
69 |
/**
|
|
70 |
* Return pointer of FunctionMap subpane class
|
|
71 |
* @return Pointer of FunctionMap subpane class
|
|
72 |
*/
|
|
73 |
inline CCalcFuncmapSubPane* FuncmapSubPane() const;
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Return pointer of editor subpane.
|
|
77 |
* @return Pointer of Editor subpane class
|
|
78 |
*/
|
|
79 |
inline CCalcEditorSubPane* EditorPane() const;
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Return pointer of OutputSheet.
|
|
83 |
* @return Pointer of OutputSheet class
|
|
84 |
*/
|
|
85 |
inline CCalcOutputSheet* OutputSheet() const;
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Return pointer of CCalcView.
|
|
89 |
* @return Pointer of CCalcView class
|
|
90 |
*/
|
|
91 |
inline CCalcView* View() const;
|
|
92 |
|
|
93 |
/**
|
|
94 |
* The pretreatment of a numerical input is performed.
|
|
95 |
*/
|
|
96 |
void ProcessPreinputL();
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Clear editor,
|
|
100 |
* and if need, empty line is added to calculation history.
|
|
101 |
*/
|
|
102 |
void InputClearL();
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Redraw scroll-up and down button on scrolling enable.
|
|
106 |
*/
|
|
107 |
void ScrollArrowUpdate();
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Redraw ChangeSign button on ChangeSign enable.
|
|
111 |
*/
|
|
112 |
void SetChangeSignEnableL();
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Redraw ChangeSign button on ChangeSign disable.
|
|
116 |
*/
|
|
117 |
void SetChangeSignDisable();
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Redraw Clear button on ClearKey enable.
|
|
121 |
*/
|
|
122 |
void SetClearKeyEnable();
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Show square root button only if no 0 in editor.
|
|
126 |
*/
|
|
127 |
void SetSqrtEnableL();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Show percent button only if no 0 in editor.
|
|
131 |
*/
|
|
132 |
void SetPercentEnableL();
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Redraw square root button.
|
|
136 |
*/
|
|
137 |
void ShowSqrtButton(TBool aEnable);
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Redraw percent button.
|
|
141 |
*/
|
|
142 |
void ShowPercentButton(TBool aEnable);
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Returns the state of the calculator.
|
|
146 |
*/
|
|
147 |
CCalcView::TStateNo GetState();
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Time out CallBack function for *-key press
|
|
151 |
* @param aObject this class.
|
|
152 |
* @return always 0
|
|
153 |
*/
|
|
154 |
static TInt TimeoutCallbackL(TAny* aObject);
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Time out CallBack function for * /key press
|
|
158 |
* @param aObject this class.
|
|
159 |
* @return always 0
|
|
160 |
*/
|
|
161 |
static TInt TimeoutCallbackChrL( TAny* aObject );
|
|
162 |
/**
|
|
163 |
* Time out CallBack function for +#key press
|
|
164 |
* @param aObject this class.
|
|
165 |
* @return always 0
|
|
166 |
*/
|
|
167 |
static TInt TimeoutCallbackShiftL( TAny* aObject );
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Notify changing decimal separator.
|
|
171 |
* @param aOld : Old decimal separator
|
|
172 |
* @param aNew : New decimal separator
|
|
173 |
*/
|
|
174 |
void NotifyChangeDecimal(TChar aOld, TChar aNew);
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Called when an error is displayed.
|
|
178 |
* @param aErrorCode : an error code from CCalcContainer
|
|
179 |
*/
|
|
180 |
void SetErrorCode(TInt aErrorCode);
|
|
181 |
|
|
182 |
public: // Functions from base classes
|
|
183 |
/**
|
|
184 |
* From CCoeControl : Get help context
|
|
185 |
* @param aContext : help context.
|
|
186 |
*/
|
|
187 |
void GetHelpContext(TCoeHelpContext& aContext) const;
|
|
188 |
|
|
189 |
/**
|
|
190 |
*Returns functionMap subpane
|
|
191 |
*/
|
|
192 |
inline CCalcFuncmapSubPane* FunctionSubPane() const;
|
|
193 |
|
|
194 |
/**
|
|
195 |
* HandleMiddleSoftKey
|
|
196 |
* Handled when MSK is selected
|
|
197 |
*/
|
|
198 |
void HandleMiddleSoftKey();
|
|
199 |
|
|
200 |
/**
|
|
201 |
* SetOperatorFromTouch
|
|
202 |
* To handle the addition of Touch Input values for digits
|
|
203 |
*/
|
|
204 |
void SetOperatorFromTouchL(TInt akey);
|
|
205 |
|
|
206 |
/**
|
|
207 |
* ClearInputKey
|
|
208 |
* To handle the clear input key through the touch UI
|
|
209 |
*/
|
|
210 |
void ClearInputKeyL(TInt aRepeat = 0);
|
|
211 |
|
|
212 |
/**
|
|
213 |
* ClearInputKey
|
|
214 |
* To handle the '.' key press
|
|
215 |
*/
|
|
216 |
|
|
217 |
void SetSeparatorFromTouchL();
|
|
218 |
|
|
219 |
// From CCoeControl
|
|
220 |
void ActivateL();
|
|
221 |
private: // New functions
|
|
222 |
/**
|
|
223 |
* C++ default constructor.
|
|
224 |
* @param aView : Pointer of CCalcView
|
|
225 |
*/
|
|
226 |
CCalcContainer();
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Second-phase constructor.
|
|
230 |
*/
|
|
231 |
void ConstructL(CCalcView* aView);
|
|
232 |
|
|
233 |
/**
|
|
234 |
* If no key is pressed until timeout of *-key,
|
|
235 |
* this function is called.
|
|
236 |
*/
|
|
237 |
void DoTimeoutL();
|
|
238 |
|
|
239 |
/**
|
|
240 |
* If no key is pressed until timeout of * /key,
|
|
241 |
* this function is called.
|
|
242 |
*/
|
|
243 |
void DoTimeoutChrL();
|
|
244 |
/**
|
|
245 |
* If no key is pressed until timeout of +#key,
|
|
246 |
* this function is called.
|
|
247 |
*/
|
|
248 |
void DoTimeoutShiftL();
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Called when any key is pressed.
|
|
252 |
* If timeout notifier for *-key is active, make calculation or
|
|
253 |
* stop notifier according to user's input.
|
|
254 |
* @param aKeyEvent : The key event
|
|
255 |
* @param aType : The type of the event
|
|
256 |
* @return : If ETrue, the key event is used only for *-key timeout.
|
|
257 |
* If EFalse, the key event is used not only for *-key
|
|
258 |
* timeout but also for other effect of each key.
|
|
259 |
*/
|
|
260 |
TBool HandleAsterKeyTimeoutForKeyPressL(
|
|
261 |
const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
262 |
|
|
263 |
/**
|
|
264 |
* Called when any key is pressed.
|
|
265 |
* If timeout notifier for * /key is active, make calculation or
|
|
266 |
* stop notifier according to user's input.
|
|
267 |
* @param aKeyEvent : The key event
|
|
268 |
* @param aType : The type of the event
|
|
269 |
* @return : If ETrue, the key event is used only for * /key timeout.
|
|
270 |
* If EFalse, the key event is used not only for *+key
|
|
271 |
* timeout but also for other effect of each key.
|
|
272 |
*/
|
|
273 |
TBool HandleChrKeyTimeoutForKeyPressL(
|
|
274 |
const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
275 |
/**
|
|
276 |
* Called when any key is pressed.
|
|
277 |
* If timeout notifier for +#key is active, make calculation or
|
|
278 |
* stop notifier according to user's input.
|
|
279 |
* @param aKeyEvent : The key event
|
|
280 |
* @param aType : The type of the event
|
|
281 |
* @return : If ETrue, the key event is used only for +#key timeout.
|
|
282 |
* If EFalse, the key event is used not only for +#key
|
|
283 |
* timeout but also for other effect of each key.
|
|
284 |
*/
|
|
285 |
TBool HandleShiftKeyTimeoutForKeyPressL(
|
|
286 |
const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
287 |
|
|
288 |
private: // Functions from base classes
|
|
289 |
/**
|
|
290 |
* From CCoeControl : Return count of controls contained in a compound control.
|
|
291 |
* @return Count of controls contained in a compound control
|
|
292 |
*/
|
|
293 |
TInt CountComponentControls() const;
|
|
294 |
|
|
295 |
/**
|
|
296 |
* From CCoeControl : Get the components of a compound control
|
|
297 |
* @param aIndex : index of control
|
|
298 |
* @return Control of argument aIndex
|
|
299 |
*/
|
|
300 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
301 |
|
|
302 |
/**
|
|
303 |
* From CCoeControl : Handling key event
|
|
304 |
* @param aKeyEvent : The key event
|
|
305 |
* @param aType : The type of the event
|
|
306 |
* @return EKeyWasConsumed : Key event is used.
|
|
307 |
* EKeyWasNotConsumed : Key event is not used.
|
|
308 |
*/
|
|
309 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
|
|
310 |
TEventCode aType);
|
|
311 |
|
|
312 |
/**
|
|
313 |
* From CCoeControl : Notifier for changing language
|
|
314 |
* @param aType : Type of resource change
|
|
315 |
*/
|
|
316 |
void HandleResourceChange(TInt aType);
|
|
317 |
|
|
318 |
/**
|
|
319 |
* @param aType : Type of resource change
|
|
320 |
*/
|
|
321 |
void HandleResourceChangeCalSoftL(TInt aType);
|
|
322 |
|
|
323 |
/**
|
|
324 |
* From CCoeControl : Control size is set.
|
|
325 |
*/
|
|
326 |
void SizeChanged();
|
|
327 |
|
|
328 |
/**
|
|
329 |
* From CCoeControl : Clear whole rectangle.
|
|
330 |
* @param aRect : rectangle of control
|
|
331 |
*/
|
|
332 |
void Draw(const TRect& aRect) const;
|
|
333 |
|
|
334 |
/**
|
|
335 |
* From CCoeControl.
|
|
336 |
* Pass skin information if need.
|
|
337 |
* @param aId : Type of supplied object.
|
|
338 |
*/
|
|
339 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
340 |
/**
|
|
341 |
* From CCoeControl : Handling pointer event
|
|
342 |
* @param aKeyEvent : The key event
|
|
343 |
*
|
|
344 |
*/
|
|
345 |
void HandlePointerEventL
|
|
346 |
( const TPointerEvent& aKeyEvent );
|
|
347 |
|
|
348 |
private: // Data
|
|
349 |
CCalcEditorSubPane* iEditorPane; // Editor subpane
|
|
350 |
CCalcFuncmapSubPane* iFuncmapPane; // FunctionMap subpane
|
|
351 |
CCalcOutputSheet* iSheetPane; // OutputSheet
|
|
352 |
CCalcView* iView; // Calculator view
|
|
353 |
CCalcDocument* iCalcDocument;
|
|
354 |
CPeriodic* iTimeout; // For handling *-key
|
|
355 |
|
|
356 |
CPeriodic* iTimeoutChr; // For handling */key
|
|
357 |
CPeriodic* iTimeoutShift; // For handling +#key
|
|
358 |
|
|
359 |
TUint iPrevInput; // Key code of previous input
|
|
360 |
CAknsBasicBackgroundControlContext* iSkinContext; // skin data
|
|
361 |
TInt iValue ;
|
|
362 |
};
|
|
363 |
|
|
364 |
#include "CalcCont.inl"
|
|
365 |
|
|
366 |
#endif // CALCCONT_H
|
|
367 |
|
|
368 |
// End of File
|