2 // Open Service Platform (or Tizen C++ SDK)
\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
\r
5 // Licensed under the Flora License, Version 1.0 (the License);
\r
6 // you may not use this file except in compliance with the License.
\r
7 // You may obtain a copy of the License at
\r
9 // http://www.tizenopensource.org/license
\r
11 // Unless required by applicable law or agreed to in writing, software
\r
12 // distributed under the License is distributed on an AS IS BASIS,
\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 // See the License for the specific language governing permissions and
\r
15 // limitations under the License.
\r
18 #include "Calculator.h"
\r
20 #include "FUiRelativeLayout.h"
\r
21 #include "FUiGridLayout.h"
\r
24 class CalculatorForm :
\r
25 public Osp::Ui::Controls::Form,
\r
26 public Osp::Ui::IActionEventListener
\r
29 Osp::Ui::Controls::Panel* __pGridPanel;
\r
32 static const int ID_BTN_DOT = 104;
\r
33 static const int ID_BTN_BACK = 105;
\r
34 static const int ID_BTN_EQUAL = 106;
\r
36 static const int ID_BTN_CLEAR = 107;
\r
38 static const int ID_BTN_PLUS = 109;
\r
39 static const int ID_BTN_MINUS = 110;
\r
41 static const int ID_BTN_MULTIPLY = 111;
\r
42 static const int ID_BTN_DIVIDE = 112;
\r
43 static const int ID_BTN_SIGN = 113;
\r
44 static const int ID_BTN_UNKNOWNOP = 114;
\r
45 static const int ID_BUTTON_OK_POPUP = 115;
\r
48 CalculatorForm(void);
\r
49 ~CalculatorForm(void);
\r
54 virtual result OnInitializing(void);
\r
55 virtual result OnTerminating(void);
\r
56 virtual result OnDraw(void);
\r
57 virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
\r
60 void CreateButtons(void);
\r
64 Osp::Ui::Controls::Label* __pLabelPrint;
\r
65 Osp::Ui::RelativeLayout* __pRelLayout;
\r
66 Osp::Ui::GridLayout* __pGridLayout;
\r
67 Osp::Ui::Controls::Popup* __pPopup;
\r
70 class CalculatorModel
\r
73 CalculatorModel(void);
\r
74 bool HandleNumKeys(int numKey);
\r
75 void HandleOperatorKeys(int key);
\r
76 void HandleEqualKey(void);
\r
77 void HandleBackKey(void);
\r
78 void HandleClearKey(void);
\r
80 const Osp::Base::String& GetResult() const;
\r
81 bool UpdateOperand(int key);
\r
82 void Calculate(void);
\r
85 enum CALCULATE_MODE {
\r
93 CALCULATE_MODE __calcMode; // Calculator mode
\r
94 int __operator; // operator
\r
95 Osp::Base::String __operand1; // result
\r
96 Osp::Base::String __operand2; // operand
\r
97 Osp::Base::String __errString;
\r
99 static const int MAX_PRINTABLE_CHARS = 8;
\r
100 static const int MAX_PRINTABLE_VALUE = 99999999;
\r