|
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 CCalcView class |
|
15 * which derived from CAknView class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CALCVIEW_H |
|
21 #define CALCVIEW_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <aknview.h> |
|
26 |
|
27 #include "CalcEditline.h" |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 const TInt KCalcViewId(1); // view ID of CCalcView |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CCalcContainer; |
|
35 class CEikMenuPane; |
|
36 class CCalcDocument; |
|
37 class CCalcEditorSubPane; |
|
38 class CCalcOutputSheet; |
|
39 class CAiwServiceHandler; |
|
40 |
|
41 // CLASS DEFINITIONS |
|
42 |
|
43 /** |
|
44 View class for Calculator application |
|
45 */ |
|
46 class CCalcView |
|
47 : public CAknView |
|
48 { |
|
49 public: |
|
50 enum TStateNo // State number |
|
51 { |
|
52 EInitialMode, // State 1 : initial mode |
|
53 EOperandOnly, // State 2 : operand only |
|
54 EOperandAndOperator, // State 3 : operand and operator |
|
55 EOperandAndOperatorAndOperand, // State 4 : operand,operator and operand |
|
56 ESelectResult, // State 5 : User has selected result |
|
57 EOperatorOnlyResult // State 6 : sqrt and percent display result right away |
|
58 }; |
|
59 |
|
60 enum TKindOfInput // kind of operand or operator |
|
61 { |
|
62 EOperand, |
|
63 EOperator, |
|
64 EEqual, |
|
65 EMemorySave, |
|
66 EMemoryRecall, // Latest input is MR, LR, or +/- on State3. |
|
67 EAllClear, |
|
68 EOperatorResult // For sqrt and percent, because they displayes the result right away |
|
69 }; |
|
70 |
|
71 |
|
72 public: // Constructors and destructor |
|
73 /** |
|
74 * Two-phased constructor. |
|
75 */ |
|
76 static CCalcView* NewLC(); |
|
77 |
|
78 /** |
|
79 * Destructor. |
|
80 */ |
|
81 virtual ~CCalcView(); |
|
82 |
|
83 public: // New functions |
|
84 /** |
|
85 * Return current state |
|
86 * @return Current state |
|
87 */ |
|
88 TStateNo State() const; |
|
89 |
|
90 /** |
|
91 * Return type of latest input |
|
92 */ |
|
93 TKindOfInput LatestInput() const; |
|
94 |
|
95 /** |
|
96 * Update state by using kind of input |
|
97 * @param aKind : Kind of input |
|
98 */ |
|
99 void UpdateState(const TKindOfInput& aKind); |
|
100 |
|
101 /** |
|
102 * Display error message |
|
103 * @param aErrorCode : error code, e.g KErrOverflow. |
|
104 */ |
|
105 void ErrorMsgL(TInt aErrorCode); |
|
106 |
|
107 /** |
|
108 * Delete meaningless items from main menu. |
|
109 * @param aMenuPane : Pointer of menu pane |
|
110 */ |
|
111 void DynInitMainMenuPane(CEikMenuPane* aMenuPane); |
|
112 |
|
113 /** |
|
114 * Delete meaningless items from menu of memory |
|
115 * @param aMenuPane : Pointer of menu pane |
|
116 */ |
|
117 void DynInitMemoryMenuPane(CEikMenuPane* aMenuPane); |
|
118 |
|
119 /** |
|
120 * Notify changing decimal separator. |
|
121 * @param aOld : Old decimal separator |
|
122 * @param aNew : New decimal separator |
|
123 */ |
|
124 void NotifyChangeDecimal(TChar aOld, TChar aNew); |
|
125 |
|
126 /** |
|
127 * Handle Memory-Recall command |
|
128 */ |
|
129 void HandleMemoryRecallL(); |
|
130 |
|
131 public: // Functions from base classes |
|
132 /** |
|
133 * From MEikMenuObserver : Handle a command |
|
134 * @param aCommand : command ID |
|
135 */ |
|
136 void HandleCommandL(TInt aCommand); |
|
137 |
|
138 |
|
139 private: // New functions |
|
140 /** |
|
141 * By default constructor is private. |
|
142 */ |
|
143 CCalcView(); |
|
144 |
|
145 /** |
|
146 * Second-phase constructor |
|
147 */ |
|
148 void ConstructL(); |
|
149 |
|
150 /** |
|
151 * Create CCalcContainer class |
|
152 */ |
|
153 void CreateContainerL(); |
|
154 |
|
155 /** |
|
156 * Handle Result command |
|
157 */ |
|
158 void HandleResultL(); |
|
159 |
|
160 /** |
|
161 * Handle Change-Sign command |
|
162 */ |
|
163 void HandleChangeSignL(); |
|
164 |
|
165 /** |
|
166 * Handle Last-Result command |
|
167 */ |
|
168 void HandleLastResultL(); |
|
169 |
|
170 /** |
|
171 * Handle Memory-Save command |
|
172 */ |
|
173 void HandleMemorySaveL(); |
|
174 |
|
175 /** |
|
176 * Handle Memory-Clear command |
|
177 */ |
|
178 void HandleMemoryClearL(); |
|
179 |
|
180 /** |
|
181 * Handle Scroll-up command |
|
182 */ |
|
183 void HandleScrollUp(); |
|
184 |
|
185 /** |
|
186 * Handle Scroll-Down command |
|
187 */ |
|
188 void HandleScrollDown(); |
|
189 |
|
190 /** |
|
191 * Handle Clear OutputSheet command |
|
192 */ |
|
193 void DoClearCalcAndHistoryL(); |
|
194 |
|
195 /** |
|
196 * Handle Add, Subtract, Multiply, Divide command |
|
197 * @param TCalcEditLine::TCalcOperatorType : Type of operator |
|
198 */ |
|
199 void HandleOperatorL(TCalcEditLine::TCalcOperatorType aOperator); |
|
200 |
|
201 /** |
|
202 * Common routine for handling result and handling memory save |
|
203 * on State4 and two operands and operator. |
|
204 * Role of this function is calculating result. |
|
205 * But State is not updated. |
|
206 * @return KErrNone : Calculation error does not occur |
|
207 * KErrOverflow, KErrDivideByZero : Calculation error occurs |
|
208 */ |
|
209 TInt HandleEqualSubRoutineL(); |
|
210 |
|
211 private: // From CAknView |
|
212 /** |
|
213 * When CCalcView becomes active, this is called. |
|
214 * @param aPrevViewId : |
|
215 * @param aCustomMessageId : |
|
216 * @param aCustomMessage : |
|
217 */ |
|
218 void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, |
|
219 const TDesC8& aCustomMessage); |
|
220 |
|
221 /** |
|
222 * When CCalcView becomes deactive, this is called. |
|
223 */ |
|
224 void DoDeactivate(); |
|
225 |
|
226 /** |
|
227 * Return UID of CCalcView |
|
228 * @return UID of CCalcView, KCalcViewId |
|
229 */ |
|
230 TUid Id() const; |
|
231 |
|
232 /** |
|
233 * From MEikMenuObserver, Delete meaningless menu item. |
|
234 * @param aResourceId : resource ID of menu pane |
|
235 * @param aMenuPane : Pointer of menu pane object |
|
236 */ |
|
237 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
238 |
|
239 /** |
|
240 *To handle when this application comes to foreground. |
|
241 */ |
|
242 void HandleForegroundEventL(TBool aForeground); |
|
243 |
|
244 private: // Data |
|
245 CCalcDocument* iCalcDocument; // Not own |
|
246 CCalcContainer* iContainer; // own |
|
247 CCalcEditorSubPane* iEditorSubPane; // Not own |
|
248 CCalcOutputSheet* iOutputSheet; // Not own |
|
249 TStateNo iState; // Current State |
|
250 TKindOfInput iLatestInput; // Kind of latest input |
|
251 public: |
|
252 CAiwServiceHandler* iServiceHandler; |
|
253 TBool iLastResultSetected; |
|
254 }; |
|
255 |
|
256 #endif // CALCVIEW_H |
|
257 |
|
258 // End of File |