2 * Copyright 2006-2013, Haiku, Inc. All rights reserved.
3 * Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
4 * Distributed under the terms of the MIT License.
7 * Stephan Aßmus, superstippi@gmx.de
8 * Philippe Saint-Pierre, stpere@gmail.com
9 * John Scipione, jscipione@gmail.com
10 * Timothy Wayper, timmy@wunderbear.com
20 MSG_OPTIONS_AUTO_NUM_LOCK
= 'oanl',
21 MSG_OPTIONS_AUDIO_FEEDBACK
= 'oafb',
22 MSG_OPTIONS_ANGLE_MODE_RADIAN
= 'oamr',
23 MSG_OPTIONS_ANGLE_MODE_DEGREE
= 'oamd',
24 MSG_OPTIONS_KEYPAD_MODE_COMPACT
= 'okmc',
25 MSG_OPTIONS_KEYPAD_MODE_BASIC
= 'okmb',
26 MSG_OPTIONS_KEYPAD_MODE_SCIENTIFIC
= 'okms',
27 MSG_UNFLASH_KEY
= 'uflk'
30 static const float kMinimumWidthBasic
= 130.0f
;
31 static const float kMaximumWidthBasic
= 400.0f
;
32 static const float kMinimumHeightBasic
= 130.0f
;
33 static const float kMaximumHeightBasic
= 400.0f
;
41 class CalcOptionsWindow
;
42 class ExpressionTextView
;
45 class CalcView
: public BView
{
48 static CalcView
* Instantiate(BMessage
* archive
);
52 rgb_color rgbBaseColor
,
54 CalcView(BMessage
* archive
);
57 virtual void AttachedToWindow();
58 virtual void MessageReceived(BMessage
* message
);
59 virtual void Draw(BRect updateRect
);
60 virtual void MouseDown(BPoint point
);
61 virtual void MouseUp(BPoint point
);
62 virtual void KeyDown(const char* bytes
, int32 numBytes
);
63 virtual void MakeFocus(bool focused
= true);
64 virtual void FrameResized(float width
, float height
);
67 virtual status_t
Archive(BMessage
* archive
, bool deep
) const;
69 // Cut contents of view to system clipboard.
72 // Copy contents of view to system clipboard.
75 // Paste contents of system clipboard to view.
76 void Paste(BMessage
* message
);
78 // Save current settings
79 status_t
SaveSettings(BMessage
* archive
) const;
81 // Evaluate the expression
84 // Flash the key on the keypad
85 void FlashKey(const char* bytes
, int32 numBytes
);
87 // Toggle whether or not the Num Lock key starts on
88 void ToggleAutoNumlock(void);
90 // Toggle whether or not to provide audio feedback
91 // (option currently disabled)
92 void ToggleAudioFeedback(void);
94 // Set the angle mode to degrees or radians
95 void SetDegreeMode(bool degrees
);
97 // Set the keypad mode
98 void SetKeypadMode(uint8 mode
);
101 static status_t
_EvaluateThread(void* data
);
102 void _Init(BMessage
* settings
);
103 status_t
_LoadSettings(BMessage
* archive
);
104 void _ParseCalcDesc(const char* keypadDescription
);
106 void _PressKey(int key
);
107 void _PressKey(const char* label
);
108 int32
_KeyForLabel(const char* label
) const;
109 void _FlashKey(int32 key
, uint32 flashFlags
);
110 void _AudioFeedback(bool inBackGround
);
114 void _CreatePopUpMenu(bool addKeypadModeMenuItems
);
116 BRect
_ExpressionRect() const;
117 BRect
_KeypadRect() const;
119 void _MarkKeypadItems(uint8 mode
);
121 void _FetchAppIcon(BBitmap
* into
);
124 void _SetEnabled(bool enable
);
131 rgb_color fBaseColor
;
132 rgb_color fLightColor
;
133 rgb_color fDarkColor
;
134 rgb_color fButtonTextColor
;
135 rgb_color fExpressionBGColor
;
136 rgb_color fExpressionTextColor
;
138 bool fHasCustomBaseColor
;
147 char* fKeypadDescription
;
154 ExpressionTextView
* fExpressionTextView
;
156 // pop-up context menu.
157 BPopUpMenu
* fPopUpMenu
;
158 BMenuItem
* fAutoNumlockItem
;
159 BMenuItem
* fAudioFeedbackItem
;
161 BMenuItem
* fAngleModeRadianItem
;
162 BMenuItem
* fAngleModeDegreeItem
;
164 BMenuItem
* fKeypadModeCompactItem
;
165 BMenuItem
* fKeypadModeBasicItem
;
166 BMenuItem
* fKeypadModeScientificItem
;
168 // calculator options.
169 CalcOptions
* fOptions
;
171 thread_id fEvaluateThread
;
172 BMessageRunner
* fEvaluateMessageRunner
;
173 sem_id fEvaluateSemaphore
;
177 #endif // _CALC_VIEW_H