summaryrefslogtreecommitdiff
path: root/calculator.h
diff options
context:
space:
mode:
Diffstat (limited to 'calculator.h')
-rwxr-xr-xcalculator.h41
1 files changed, 25 insertions, 16 deletions
diff --git a/calculator.h b/calculator.h
index 2332669..e043274 100755
--- a/calculator.h
+++ b/calculator.h
@@ -1,27 +1,28 @@
#include <gui/ApplicationWindow.h>
#include <gui/Application.h>
#include <gui/TextView.h>
+#include <cstdlib>
using namespace SkyGI;
#define BUTTON_ZERO 0
#define BUTTON_ONE 1
#define BUTTON_TWO 2
-#define BUTTON_THREE 3
+#define BUTTON_THREE 3
#define BUTTON_FOUR 4
#define BUTTON_FIVE 5
-#define BUTTON_SIX 6
-#define BUTTON_SEVEN 7
-#define BUTTON_EIGHT 8
+#define BUTTON_SIX 6
+#define BUTTON_SEVEN 7
+#define BUTTON_EIGHT 8
#define BUTTON_NINE 9
#define BUTTON_PLUS 10
-#define BUTTON_MINUS 11
-#define BUTTON_TIMES 12
-#define BUTTON_DIVIDE 13
+#define BUTTON_MINUS 11
+#define BUTTON_TIMES 12
+#define BUTTON_DIVIDE 13
#define BUTTON_EQUALS 14
-#define BUTTON_POINT 15
+#define BUTTON_POINT 15
#define BUTTON_SIGN 16
-#define BUTTON_CLEAR 17
+#define BUTTON_CLEAR 17
class Calculator : public Application {
public:
@@ -30,11 +31,19 @@ class Calculator : public Application {
class CalculatorWindow : public ApplicationWindow {
public:
- CalculatorWindow( const Rect &rFrame,
- const String& szTitle,
- unsigned int nWindowLayoutFlags,
- unsigned int uiFlags = 0);
- void OnCommand( const MessageCommand *pMessage);
-
- TextView * pText;
+ CalculatorWindow( const Rect &rFrame,
+ const String& szTitle,
+ unsigned int nWindowLayoutFlags,
+ unsigned int uiFlags = 0);
+ void OnCommand( const MessageCommand *pMessage);
+ private:
+ void Clear();
+ void doOperation( int next_operation);
+
+ TextView * pText;
+ String * line;
+ double total;
+ double operand;
+ int operation;
+ bool new_operand;
};