Change the translation of the "Help" menu item to "?", so that the menu can be displa...
[reactos.git] / rosapps / winecalc / winecalc.h
1 /*
2 * WineCalc (winecalc.h)
3 *
4 * Copyright 2003 James Briggs
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 //////////////////////////////////////////////////////////////////
22
23 #ifdef UNICODE
24 #define CF_TTEXT CF_UNICODETEXT
25 #else
26 #define CF_TTEXT CF_TEXT
27 #endif
28
29 // numerics are defined here for easier porting
30
31 typedef double calcfloat;
32 #define FMT_DESC_FLOAT TEXT("%g")
33 #define FMT_DESC_EXP TEXT("%e")
34
35 #define CALC_ATOF(x) atof(x)
36
37 #define CONST_PI 3.1415926535897932384626433832795
38
39 /////////////////////////////////////////////////////////////////
40
41 #define CALC_BUF_SIZE 128
42
43 // statistics dialog dimensions
44
45 #define CALC_STA_X 235
46 #define CALC_STA_Y 180
47
48 // sentinel for differentiating Return from Ctrl+M events
49
50 #define NUMBER_OF_THE_BEAST 666
51
52 #define CALC_COLOR_BLUE 0
53 #define CALC_COLOR_RED 1
54 #define CALC_COLOR_GRAY 2
55 #define CALC_COLOR_MAGENTA 3
56
57 // gray hilite on rectangle owner-drawn controls RGB(CALC_GRAY, CALC_GRAY, CALC_GRAY)
58
59 #define CALC_GRAY 132
60
61 // count of buttons needing special toggle states depending on number base
62
63 #define TOGGLE_COUNT 23
64
65 // there are 3 window menus, standard, decimal measurement system and word size menus
66
67 #define COUNT_MENUS 3
68 #define MENU_STD 0
69 #define MENU_SCIMS 1
70 #define MENU_SCIWS 2
71
72 // count of buttons
73
74 #define CALC_BUTTONS_STANDARD 28
75 #define CALC_BUTTONS_SCIENTIFIC 73
76
77 // winecalc window outer dimensions
78
79 #define CALC_STANDARD_WIDTH 260
80 #define CALC_STANDARD_HEIGHT 252
81 #define CALC_SCIENTIFIC_WIDTH 480
82 #define CALC_SCIENTIFIC_HEIGHT 310
83
84 // winecalc private ids for events
85
86 #define ID_CALC_ZERO 0
87 #define ID_CALC_ONE 1
88 #define ID_CALC_TWO 2
89 #define ID_CALC_THREE 3
90 #define ID_CALC_FOUR 4
91 #define ID_CALC_FIVE 5
92 #define ID_CALC_SIX 6
93 #define ID_CALC_SEVEN 7
94 #define ID_CALC_EIGHT 8
95 #define ID_CALC_NINE 9
96 #define ID_CALC_BACKSPACE 20
97 #define ID_CALC_CLEAR_ENTRY 21
98 #define ID_CALC_CLEAR_ALL 22
99 #define ID_CALC_MEM_CLEAR 23
100 #define ID_CALC_DIVIDE 24
101 #define ID_CALC_SQRT 25
102 #define ID_CALC_MEM_RECALL 26
103 #define ID_CALC_MULTIPLY 27
104 #define ID_CALC_PERCENT 28
105 #define ID_CALC_MEM_STORE 29
106 #define ID_CALC_MINUS 30
107 #define ID_CALC_RECIPROCAL 31
108 #define ID_CALC_MEM_PLUS 32
109 #define ID_CALC_SIGN 33
110 #define ID_CALC_DECIMAL 34
111 #define ID_CALC_PLUS 35
112 #define ID_CALC_EQUALS 36
113 #define ID_CALC_STA 37
114 #define ID_CALC_FE 38
115 #define ID_CALC_LEFTPAREN 39
116 #define ID_CALC_RIGHTPAREN 40
117 #define ID_CALC_MOD 41
118 #define ID_CALC_AND 42
119 #define ID_CALC_OR 43
120 #define ID_CALC_XOR 44
121 #define ID_CALC_SUM 45
122 #define ID_CALC_SIN 46
123 #define ID_CALC_LOG10 47
124 #define ID_CALC_LSH 48
125 #define ID_CALC_NOT 49
126 #define ID_CALC_S 50
127 #define ID_CALC_COS 52
128 #define ID_CALC_FACTORIAL 53
129 #define ID_CALC_INT 54
130 #define ID_CALC_DAT 55
131 #define ID_CALC_TAN 56
132 #define ID_CALC_SQUARE 57
133 #define ID_CALC_A 58
134 #define ID_CALC_B 59
135 #define ID_CALC_C 60
136 #define ID_CALC_D 61
137 #define ID_CALC_E 62
138 #define ID_CALC_F 63
139 #define ID_CALC_AVE 64
140 #define ID_CALC_DMS 65
141 #define ID_CALC_EXP 66
142 #define ID_CALC_LN 67
143 #define ID_CALC_PI 68
144 #define ID_CALC_CUBE 69
145 #define ID_CALC_POWER 51
146
147 // Number System Radio Buttons
148
149 #define CALC_NS_COUNT 4
150 #define ID_CALC_NS_HEX 2000
151 #define ID_CALC_NS_DEC 2001
152 #define ID_CALC_NS_OCT 2002
153 #define ID_CALC_NS_BIN 2003
154
155 #define NBASE_DECIMAL 0
156 #define NBASE_BINARY 1
157 #define NBASE_OCTAL 2
158 #define NBASE_HEX 3
159
160 #define CALC_NS_OFFSET_X 15
161 #define CALC_NS_OFFSET_Y 37
162
163 #define SZ_RADIO_NS_X 50
164 #define SZ_RADIO_NS_Y 15
165
166 #define CALC_NS_HEX_LEFT 0
167 #define CALC_NS_HEX_TOP 0
168
169 #define CALC_NS_DEC_LEFT 50
170 #define CALC_NS_DEC_TOP 0
171
172 #define CALC_NS_OCT_LEFT 98
173 #define CALC_NS_OCT_TOP 0
174
175 #define CALC_NS_BIN_LEFT 148
176 #define CALC_NS_BIN_TOP 0
177
178 // Measurement System Radio Buttons
179
180 #define CALC_MS_COUNT 3
181 #define ID_CALC_MS_DEGREES 2010
182 #define ID_CALC_MS_RADIANS 2011
183 #define ID_CALC_MS_GRADS 2012
184
185 #define TRIGMODE_DEGREES 0
186 #define TRIGMODE_RADIANS 1
187 #define TRIGMODE_GRADS 2
188
189 #define CALC_MS_OFFSET_X 225
190 #define CALC_MS_OFFSET_Y 37
191
192 #define SZ_RADIO_MS_X 75
193 #define SZ_RADIO_MS_Y 15
194
195 #define CALC_MS_DEGREES_LEFT 0
196 #define CALC_MS_DEGREES_TOP 0
197
198 #define CALC_MS_RADIANS_LEFT 82
199 #define CALC_MS_RADIANS_TOP 0
200
201 #define CALC_MS_GRADS_LEFT 162
202 #define CALC_MS_GRADS_TOP 0
203
204 // Inv and Hyp Checkboxes
205
206 #define CALC_CB_COUNT 2
207 #define ID_CALC_CB_INV 2020
208 #define ID_CALC_CB_HYP 2021
209
210 #define WORDSIZE_BYTE 1
211 #define WORDSIZE_WORD 2
212 #define WORDSIZE_DWORD 4
213 #define WORDSIZE_QWORD 8
214
215 #define CALC_CB_OFFSET_X 15
216 #define CALC_CB_OFFSET_Y 58
217
218 #define CALC_CB_INV_LEFT 0
219 #define CALC_CB_INV_TOP 10
220
221 #define SZ_RADIO_CB_X 50
222 #define SZ_RADIO_CB_Y 14
223
224 #define CALC_CB_HYP_LEFT 58
225 #define CALC_CB_HYP_TOP 10
226
227 // Word Size Radio Buttons
228
229 #define CALC_WS_COUNT 4
230 #define ID_CALC_WS_QWORD 2030
231 #define ID_CALC_WS_DWORD 2031
232 #define ID_CALC_WS_WORD 2032
233 #define ID_CALC_WS_BYTE 2033
234
235 #define CALC_WS_OFFSET_X CALC_MS_OFFSET_X
236 #define CALC_WS_OFFSET_Y CALC_MS_OFFSET_Y
237
238 #define CALC_WS_QWORD_LEFT 0
239 #define CALC_WS_QWORD_TOP 0
240
241 #define CALC_WS_DWORD_LEFT 57
242 #define CALC_WS_DWORD_TOP 0
243
244 #define CALC_WS_WORD_LEFT 120
245 #define CALC_WS_WORD_TOP 0
246
247 #define CALC_WS_BYTE_LEFT 175
248 #define CALC_WS_BYTE_TOP 0
249
250 #define SZ_RADIO_WS_X 50
251 #define SZ_RADIO_WS_Y 15
252
253 // drawing offsets
254
255 #define CALC_EDIT_HEIGHT 20
256
257 #define SZ_FILLER_X 32
258 #define SZ_FILLER_Y 30
259
260 #define SZ_BIGBTN_X 62
261 #define SZ_BIGBTN_Y 30
262
263 #define SZ_MEDBTN_X 36
264 #define SZ_MEDBTN_Y 30
265
266 #define MARGIN_LEFT 7
267 #define MARGIN_SMALL_X 3
268 #define MARGIN_SMALL_Y 3
269 #define MARGIN_BIG_X 274
270 #define MARGIN_STANDARD_BIG_X 11
271 #define MARGIN_BIG_Y 6
272
273 #define SZ_SPACER_X 11
274
275 // winecalc results display area
276
277 #define WDISPLAY_STANDARD_LEFT MARGIN_LEFT + 4
278 #define WDISPLAY_STANDARD_TOP 5
279 #define WDISPLAY_STANDARD_RIGHT 244
280 #define WDISPLAY_STANDARD_BOTTOM 24
281 #define CALC_STANDARD_MARGIN_TOP 16
282
283 #define WDISPLAY_SCIENTIFIC_LEFT MARGIN_LEFT + 4
284 #define WDISPLAY_SCIENTIFIC_TOP 5
285 #define WDISPLAY_SCIENTIFIC_RIGHT 465
286 #define WDISPLAY_SCIENTIFIC_BOTTOM 24
287 #define CALC_SCIENTIFIC_MARGIN_TOP 44
288
289 typedef struct tagCalcBtn {
290 int id; // private id
291 HWND hBtn; // button child window handle
292 TCHAR label[80]; // text on buttonface
293 int color; // text color
294 RECT r; // location
295 int enable; // 1 = control enbabled, 0 = disabled
296 }
297 CALCBTN;
298
299 typedef struct tagPos {
300 int x;
301 int y;
302 }
303 POS;
304
305 typedef struct tagCalc {
306 HINSTANCE hInst; // this HINSTANCE
307 HWND hWnd; // main window's HWND
308
309 POS pos;
310 int numButtons; // standard = 28, scientific = more
311
312 TCHAR buffer [CALC_BUF_SIZE]; // current keyboard buffer
313 TCHAR display[CALC_BUF_SIZE]; // display buffer before output
314
315 calcfloat value; // most recent computer value
316 calcfloat memory; // most recent stored memory value from display buffer
317 int paren; // current parentheses level
318
319 int sciMode; // standard = 1, scientific = 0
320 int displayMode; // 0 = float, 1 = scientific exponential notation like 1.0e+10
321
322 TCHAR oper; // most recent operator pushed
323 calcfloat operand; // most recent operand pushed
324 int newenter; // track multiple =
325 int next; // binary operation flag
326 int err; // errror status for divide by zero, infinity, etc.
327 int init; // starting buffer
328
329 int digitGrouping; // no separators = 0, separators = 1
330
331 int trigMode; // degrees = 0, radians = 1, grads = 2
332 int numBase; // 10 = decimal, 2 = binary, 8 = octal, 16 = hex
333 int wordSize; // 1 = byte, 2 = word, 4 = dword, 8 = qword
334 int invMode; // INV mode 0 = off, 1 = on
335 int hypMode; // HYP mode 0 = off, 1 = on
336
337 int new; // first time 0 = false, 1 = true
338 CALCBTN cb[80]; // enough buttons for standard or scientific mode
339 }
340 CALC;
341
342 BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
343 LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
344
345 void InitLuts(void);
346 void InitMenus(HINSTANCE hInst);
347 void DestroyMenus();
348
349 void InitCalc (CALC *calc);
350 void DestroyCalc (CALC *calc);
351
352 void calc_buffer_format(CALC *calc);
353 void calc_buffer_display(CALC *calc);
354 TCHAR *calc_sep(TCHAR *s);
355
356 void DrawCalcText (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, int object, TCHAR *s);
357 void CalcRect (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, int object);
358 void DrawCalcRectSci(HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, RECT *r);
359 void DrawCalc (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc);
360
361 void calc_setmenuitem_radio(HMENU hMenu, UINT id);
362
363 void show_debug(CALC *calc, TCHAR *title, long wParam, long lParam);
364
365 calcfloat calc_atof(const TCHAR *s, int base);
366 void calc_ftoa(CALC *calc, calcfloat r, TCHAR *buf);
367 long factorial(long n);
368
369 calcfloat calc_convert_to_radians(CALC *calc);
370 calcfloat calc_convert_from_radians(CALC *calc);
371