ReactOS  0.4.12-dev-57-g7050ac4
winmain.c
Go to the documentation of this file.
1 #include "calc.h"
2 
3 #include <winbase.h>
4 #include <wingdi.h>
5 #include <winreg.h>
6 #include <shellapi.h>
7 #include <commctrl.h>
8 
9 #define HTMLHELP_PATH(_pt) TEXT("%systemroot%\\Help\\calc.chm::") TEXT(_pt)
10 
11 #define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2) \
12  (((_show_b2) << 0) | \
13  ((_show_b8) << 1) | \
14  ((_show_b10) << 2) | \
15  ((_show_b16) << 3))
16 
17 #define MAKE_BITMASK5(_transl, _is_stats, _is_ctrl, _show_b16, _show_b10, _show_b8, _show_b2) \
18  (((_show_b2) << 0) | \
19  ((_show_b8) << 1) | \
20  ((_show_b10) << 2) | \
21  ((_show_b16) << 3) | \
22  ((_is_ctrl) << 5) | \
23  ((_is_stats) << 6) | \
24  ((_transl) << 7))
25 
26 #define KEY_IS_UP 0x80000000
27 #define KEY_WAS_DOWN 0x40000000
28 
29 #define BITMASK_IS_ASCII 0x80
30 #define BITMASK_IS_STATS 0x40
31 #define BITMASK_IS_CTRL 0x20
32 #define BITMASK_HEX_MASK 0x08
33 #define BITMASK_DEC_MASK 0x04
34 #define BITMASK_OCT_MASK 0x02
35 #define BITMASK_BIN_MASK 0x01
36 
37 #define CALC_CLR_RED 0x000000FF
38 #define CALC_CLR_BLUE 0x00FF0000
39 #define CALC_CLR_PURP 0x00FF00FF
40 
41 typedef struct {
42  CHAR key; // Virtual key identifier
43  WORD idc; // IDC for posting message
44 } key2code_t;
45 
46 typedef struct {
47  WORD idc; // IDC for posting message
48  CHAR key; // Virtual key identifier
49  BYTE mask; // enable/disable into the various modes.
50  COLORREF col; // color used for drawing the text
51 } key3code_t;
52 
53 #define CTRL_FLAG 0x100
54 #define ALT_FLAG 0x200
55 
56 #define CTRL_A (0x0001+'A'-'A')
57 #define CTRL_C (0x0001+'C'-'A')
58 #define CTRL_D (0x0001+'D'-'A')
59 #define CTRL_L (0x0001+'L'-'A')
60 #define CTRL_M (0x0001+'M'-'A')
61 #define CTRL_P (0x0001+'P'-'A')
62 #define CTRL_R (0x0001+'R'-'A')
63 #define CTRL_S (0x0001+'S'-'A')
64 #define CTRL_T (0x0001+'T'-'A')
65 #define CTRL_V (0x0001+'V'-'A')
66 #define CTRL_Z (0x0001+'Z'-'A')
67 
68 static const key3code_t key2code[] = {
69  /* CONTROL-ID Key asc sta ctl hex dec oct bin */
70  { IDC_BUTTON_STA, CTRL_S, MAKE_BITMASK5( 1, 0, 1, 1, 1, 1, 1), CALC_CLR_BLUE, },
71  { IDC_BUTTON_AVE, CTRL_A, MAKE_BITMASK5( 1, 1, 1, 1, 1, 1, 1), CALC_CLR_BLUE, },
72  { IDC_BUTTON_SUM, CTRL_T, MAKE_BITMASK5( 1, 1, 1, 1, 1, 1, 1), CALC_CLR_BLUE, },
73  { IDC_BUTTON_S, CTRL_D, MAKE_BITMASK5( 1, 1, 1, 1, 1, 1, 1), CALC_CLR_BLUE, },
74  { IDC_BUTTON_MS, CTRL_M, MAKE_BITMASK5( 1, 0, 1, 1, 1, 1, 1), CALC_CLR_RED, },
75  { IDC_BUTTON_MR, CTRL_R, MAKE_BITMASK5( 1, 0, 1, 1, 1, 1, 1), CALC_CLR_RED, },
76  { IDC_BUTTON_MP, CTRL_P, MAKE_BITMASK5( 1, 0, 1, 1, 1, 1, 1), CALC_CLR_RED, },
77  { IDC_BUTTON_MC, CTRL_L, MAKE_BITMASK5( 1, 0, 1, 1, 1, 1, 1), CALC_CLR_RED, },
78  { IDC_BUTTON_0, '0', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_BLUE, },
79  { IDC_BUTTON_1, '1', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_BLUE, },
80  { IDC_BUTTON_2, '2', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
81  { IDC_BUTTON_3, '3', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
82  { IDC_BUTTON_4, '4', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
83  { IDC_BUTTON_5, '5', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
84  { IDC_BUTTON_6, '6', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
85  { IDC_BUTTON_7, '7', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 0), CALC_CLR_BLUE, },
86  { IDC_BUTTON_8, '8', MAKE_BITMASK5( 1, 0, 0, 1, 1, 0, 0), CALC_CLR_BLUE, },
87  { IDC_BUTTON_9, '9', MAKE_BITMASK5( 1, 0, 0, 1, 1, 0, 0), CALC_CLR_BLUE, },
88  { IDC_BUTTON_DOT, '.', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_BLUE, },
89  { IDC_BUTTON_DOT, ',', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), -1, },
90  { IDC_BUTTON_ADD, '+', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
91  { IDC_BUTTON_SUB, '-', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
92  { IDC_BUTTON_MULT, '*', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
93  { IDC_BUTTON_DIV, '/', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
94  { IDC_BUTTON_AND, '&', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
95  { IDC_BUTTON_OR, '|', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
96  { IDC_BUTTON_XOR, '^', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
97  { IDC_BUTTON_LSH, '<', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
98  { IDC_BUTTON_NOT, '~', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
99  { IDC_BUTTON_INT, ';', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_RED, },
100  { IDC_BUTTON_EQU, '=', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
101  { IDC_BUTTON_A, 'A', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
102  { IDC_BUTTON_B, 'B', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
103  { IDC_BUTTON_C, 'C', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
104  { IDC_BUTTON_D, 'D', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
105  { IDC_BUTTON_E, 'E', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
106  { IDC_BUTTON_F, 'F', MAKE_BITMASK5( 1, 0, 0, 1, 0, 0, 0), CALC_CLR_BLUE, },
107  { IDC_CHECK_HYP, 'H', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), -1, },
108  { IDC_CHECK_INV, 'I', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), -1, },
109  { IDC_BUTTON_LOG, 'L', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
110  { IDC_BUTTON_DMS, 'M', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
111  { IDC_BUTTON_LN, 'N', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
112  { IDC_BUTTON_PI, 'P', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_BLUE, },
113  { IDC_BUTTON_RX, 'R', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
114  { IDC_BUTTON_SIN, 'S', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
115  { IDC_BUTTON_COS, 'O', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
116  { IDC_BUTTON_TAN, 'T', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
117  { IDC_BUTTON_FE, 'V', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
118  { IDC_BUTTON_EXP, 'X', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_PURP, },
119  { IDC_BUTTON_XeY, 'Y', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
120  { IDC_BUTTON_SQRT, '@', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_BLUE, },
121  { IDC_BUTTON_Xe2, '@', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
122  { IDC_BUTTON_Xe3, '#', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
123  { IDC_BUTTON_NF, '!', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
124  { IDC_BUTTON_LEFTPAR, '(', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
125  { IDC_BUTTON_RIGHTPAR, ')', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_PURP, },
126  { IDC_BUTTON_MOD, '%', MAKE_BITMASK5( 1, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
127  { IDC_BUTTON_PERCENT, '%', MAKE_BITMASK5( 1, 0, 0, 0, 1, 0, 0), CALC_CLR_BLUE, },
128  /*----------------------------------------------------------------------*/
129  { IDC_BUTTON_DAT, VK_INSERT, MAKE_BITMASK5( 0, 1, 0, 1, 1, 1, 1), CALC_CLR_BLUE, },
130  { IDC_BUTTON_EQU, VK_RETURN, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
131  { IDC_BUTTON_CANC, VK_ESCAPE, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
132  { IDC_BUTTON_CE, VK_DELETE, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
133  { IDC_BUTTON_BACK, VK_BACK, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), CALC_CLR_RED, },
134  { IDC_RADIO_HEX, VK_F5, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), -1, },
135  { IDC_RADIO_DEC, VK_F6, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), -1, },
136  { IDC_RADIO_OCT, VK_F7, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), -1, },
137  { IDC_RADIO_BIN, VK_F8, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), -1, },
138  { IDC_BUTTON_SIGN, VK_F9, MAKE_BITMASK5( 0, 0, 0, 1, 1, 1, 1), CALC_CLR_BLUE, },
139 };
140 
141 static const key2code_t key2code_base16[] = {
142  { VK_F2, IDC_RADIO_DWORD, },
143  { VK_F3, IDC_RADIO_WORD, },
144  { VK_F4, IDC_RADIO_BYTE, },
145  { VK_F12, IDC_RADIO_QWORD, },
146 };
147 
148 static const key2code_t key2code_base10[] = {
149  { VK_F2, IDC_RADIO_DEG, },
150  { VK_F3, IDC_RADIO_RAD, },
151  { VK_F4, IDC_RADIO_GRAD, },
152 };
153 
154 static const WORD operator_codes[] = {
155  /* CONTROL-ID operator */
156  (WORD)IDC_STATIC, // RPN_OPERATOR_PARENT
157  IDC_BUTTON_PERCENT, // RPN_OPERATOR_PERCENT
158  IDC_BUTTON_EQU, // RPN_OPERATOR_EQUAL
159  IDC_BUTTON_OR, // RPN_OPERATOR_OR
160  IDC_BUTTON_XOR, // RPN_OPERATOR_XOR
161  IDC_BUTTON_AND, // RPN_OPERATOR_AND
162  IDC_BUTTON_LSH, // RPN_OPERATOR_LSH
163  IDC_BUTTON_RSH, // RPN_OPERATOR_RSH
164  IDC_BUTTON_ADD, // RPN_OPERATOR_ADD
165  IDC_BUTTON_SUB, // RPN_OPERATOR_SUB
166  IDC_BUTTON_MULT, // RPN_OPERATOR_MULT
167  IDC_BUTTON_DIV, // RPN_OPERATOR_DIV
168  IDC_BUTTON_MOD, // RPN_OPERATOR_MOD
169 };
170 
172 
173 typedef struct {
182 
183 static void run_pow(calc_number_t *number);
184 static void run_sqr(calc_number_t *number);
185 static void run_fe(calc_number_t *number);
186 static void run_dat_sta(calc_number_t *number);
187 static void run_mp(calc_number_t *c);
188 static void run_mm(calc_number_t *c);
189 static void run_ms(calc_number_t *c);
190 static void run_mw(calc_number_t *c);
191 static void run_canc(calc_number_t *c);
192 static void run_rpar(calc_number_t *c);
193 static void run_lpar(calc_number_t *c);
194 
200  { IDC_BUTTON_RX, 0, 1, rpn_reci, NULL, NULL, NULL },
201  { IDC_BUTTON_NOT, 0, 1, rpn_not, NULL, NULL, NULL },
202  { IDC_BUTTON_PI, MODIFIER_INV, 0, rpn_pi, rpn_2pi, NULL, NULL },
205  { IDC_BUTTON_LN, MODIFIER_INV, 1, rpn_ln, rpn_exp, NULL, NULL },
207  { IDC_BUTTON_NF, 0, 1, rpn_fact, NULL, NULL, NULL },
208  { IDC_BUTTON_AVE, 0, 0, rpn_ave, NULL, NULL, NULL },
209  { IDC_BUTTON_SUM, 0, 0, rpn_sum, NULL, NULL, NULL },
210  { IDC_BUTTON_S, MODIFIER_INV, 0, rpn_s_m1, rpn_s, NULL, NULL },
212  { IDC_BUTTON_SQRT, MODIFIER_INV, 1, rpn_sqrt, NULL, NULL, NULL },
214  { IDC_BUTTON_FE, 0, 1, run_fe, NULL, NULL, NULL },
215  { IDC_BUTTON_DAT, 0, 1, run_dat_sta, NULL, NULL, NULL, },
221 };
222 
223 /*
224 */
225 
227 
228 static void load_config(void)
229 {
230  DWORD tmp;
231  HKEY hKey;
232 
233  /* If no settings are found in the registry, then use the default options */
235  calc.usesep = FALSE;
236 
237  /* Get the configuration based on what version of Windows that's being used */
238  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Calc"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
239  {
240  /* Try to load last selected layout */
241  tmp = sizeof(calc.layout);
242  if (RegQueryValueEx(hKey, TEXT("layout"), NULL, NULL, (LPBYTE)&calc.layout, &tmp) != ERROR_SUCCESS)
244 
245  /* Try to load last selected formatting option */
246  tmp = sizeof(calc.usesep);
247  if (RegQueryValueEx(hKey, TEXT("UseSep"), NULL, NULL, (LPBYTE)&calc.usesep, &tmp) != ERROR_SUCCESS)
248  calc.usesep = FALSE;
249 
250  /* close the key */
251  RegCloseKey(hKey);
252  }
253 
254  /* memory is empty at startup */
255  calc.is_memory = FALSE;
256 
257  /* empty these values */
258  calc.sDecimal[0] = TEXT('\0');
259  calc.sThousand[0] = TEXT('\0');
260 
261  /* try to open the registry */
262  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\International"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
263  {
264  /* get these values (ignore errors) */
265  tmp = sizeof(calc.sDecimal);
266  RegQueryValueEx(hKey, TEXT("sDecimal"), NULL, NULL, (LPBYTE)calc.sDecimal, &tmp);
267 
268  tmp = sizeof(calc.sThousand);
269  RegQueryValueEx(hKey, TEXT("sThousand"), NULL, NULL, (LPBYTE)calc.sThousand, &tmp);
270 
271  /* close the key */
272  RegCloseKey(hKey);
273  }
274  /* if something goes wrong, let's apply the defaults */
275  if (calc.sDecimal[0] == TEXT('\0'))
276  _tcscpy(calc.sDecimal, TEXT("."));
277 
278  if (calc.sThousand[0] == TEXT('\0'))
279  _tcscpy(calc.sThousand, TEXT(","));
280 
281  /* get the string lengths */
282  calc.sDecimal_len = _tcslen(calc.sDecimal);
283  calc.sThousand_len = _tcslen(calc.sThousand);
284 }
285 
286 static void save_config(void)
287 {
288  HKEY hKey;
289  DWORD sepValue;
290 
291  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Calc"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL) != ERROR_SUCCESS)
292  {
293  return;
294  }
295 
296  sepValue = (calc.usesep) ? 1 : 0;
297 
298  RegSetValueEx(hKey, TEXT("layout"), 0, REG_DWORD, (const BYTE*)&calc.layout, sizeof(calc.layout));
299  RegSetValueEx(hKey, TEXT("UseSep"), 0, REG_DWORD, (const BYTE*)&sepValue, sizeof(sepValue));
300 
301  RegCloseKey(hKey);
302 }
303 
305 {
306  HWND hCtlWnd = GetDlgItem(calc.hWnd,idc);
307  TCHAR ClassName[64];
308 
309  /* check if the key is enabled! */
310  if (!IsWindowEnabled(hCtlWnd))
311  return 1;
312 
313  if (!GetClassName(hCtlWnd, ClassName, SIZEOF(ClassName)))
314  return 1;
315 
316  if (!_tcscmp(ClassName, TEXT("Button"))) {
317  DWORD dwStyle = GetWindowLongPtr(hCtlWnd, GWL_STYLE) & 0xF;
318 
319  /* Set states for press/release, but only for push buttons */
320  if (dwStyle == BS_PUSHBUTTON || dwStyle == BS_DEFPUSHBUTTON || dwStyle == BS_OWNERDRAW) {
321  if (!(lParam & KEY_WAS_DOWN)) {
322  PostMessage(hCtlWnd, BM_SETSTATE, 1, 0);
323  } else
324  if ((lParam & KEY_IS_UP)) {
325  PostMessage(hCtlWnd, BM_SETSTATE, 0, 0);
326  PostMessage(hCtlWnd, BM_CLICK, 0, 0);
327  }
328  return 1;
329  }
330  }
331  /* default action: simple click event at key release */
332  if ((lParam & KEY_IS_UP)) {
333  PostMessage(hCtlWnd, BM_CLICK, 0, 0);
334  }
335  return 1;
336 }
337 
338 static int vk2ascii(unsigned int vk)
339 {
340  unsigned short int s;
341  int scan;
342  BYTE state[256];
344 
345  if(!GetKeyboardState(state))
346  return 0;
347 
348  scan=MapVirtualKeyEx(vk, 0, layout);
349  s = 0;
350  if (ToAsciiEx(vk, scan, state, &s, 0, layout)>0) {
351  /* convert to upper case */
352  if (s >= 'a' && s <= 'z')
353  s = s - 'a' + 'A';
354  /* add check to CTRL key */
355  if (vk >= 'A' && vk <= 'Z' &&
356  s >= CTRL_A && s <= CTRL_Z)
357  s |= CTRL_FLAG;
358  else
359  if (GetAsyncKeyState(VK_MENU) < 0)
360  s |= ALT_FLAG;
361  return s;
362  }
363  return 0;
364 }
365 
367 {
368  const key2code_t *k;
369  unsigned int x;
370  unsigned short int ch;
371 
372  ch = vk2ascii(LOWORD(wParam));
373  if ((lParam & KEY_IS_UP)) {
374  /* Test for "copy" to clipboard */
375  if (ch == (CTRL_C|CTRL_FLAG)) {
377  return 1;
378  }
379  /* Test for "paste" from clipboard */
380  if (ch == (CTRL_V|CTRL_FLAG)) {
382  return 1;
383  }
384  /* Test of help menu */
385  if (LOWORD(wParam) == VK_F1) {
387  return 1;
388  }
389  }
390 
391  for (x=0; x<SIZEOF(key2code); x++) {
392  int key = key2code[x].key;
393  if (key2code[x].mask & BITMASK_IS_CTRL)
394  key |= CTRL_FLAG;
395  if ((key == ch && (key2code[x].mask & BITMASK_IS_ASCII)) ||
396  (key == LOWORD(wParam) && !(key2code[x].mask & BITMASK_IS_ASCII))
397  ) {
398  if (GetDlgItem(calc.hWnd, key2code[x].idc) == NULL)
399  continue;
400  return post_key_press(lParam, key2code[x].idc);
401  }
402  }
403  if (calc.layout == CALC_LAYOUT_SCIENTIFIC) {
404  if (calc.base == IDC_RADIO_DEC) {
405  k = key2code_base10;
406  x = SIZEOF(key2code_base10);
407  } else {
408  k = key2code_base16;
409  x = SIZEOF(key2code_base16);
410  }
411  do {
412  if (k->key == LOWORD(wParam)) {
413  return post_key_press(lParam, k->idc);
414  }
415  k++;
416  } while (--x);
417  }
418  return 0;
419 }
420 
421 #ifdef USE_KEYBOARD_HOOK
422 static LRESULT CALLBACK
424 {
425  if(nCode<0 || calc.is_menu_on)
426  return CallNextHookEx(calc.hKeyboardHook,nCode,wParam,lParam);
427 
428  if(nCode==HC_ACTION)
429  if (process_vk_key(wParam, lParam))
430  return;
431 
432  return CallNextHookEx(calc.hKeyboardHook,nCode,wParam,lParam);
433 }
434 #endif
435 
437 {
438  /*
439  * multiply size of calc.buffer by 2 because it may
440  * happen that separator is used between each digit.
441  * Also added little additional space for dot and '\0'.
442  */
443  TCHAR *tmp = (TCHAR *)alloca(sizeof(calc.buffer)*2+2*sizeof(TCHAR));
444 
445  if (calc.buffer[0] == TEXT('\0'))
446  _tcscpy(tmp, TEXT("0"));
447  else
448  _tcscpy(tmp, calc.buffer);
449  /* add final '.' in decimal mode (if it's missing) */
450  if (calc.base == IDC_RADIO_DEC) {
451  if (_tcschr(tmp, TEXT('.')) == NULL)
452  _tcscat(tmp, TEXT("."));
453  }
454  /* if separator mode is on, let's add an additional space */
455  if (calc.usesep && !calc.sci_in && !calc.sci_out && !calc.is_nan) {
456  /* go to the integer part of the string */
457  TCHAR *p = _tcschr(tmp, TEXT('.'));
458  TCHAR *e = _tcschr(tmp, TEXT('\0'));
459  int n=0, t;
460 
461  if (p == NULL) p = e;
462  switch (calc.base) {
463  case IDC_RADIO_HEX:
464  case IDC_RADIO_BIN:
465  t = 4;
466  break;
467  default:
468  /* fall here for:
469  IDC_RADIO_DEC:
470  IDC_RADIO_OCT: */
471  t = 3;
472  break;
473  }
474  while (--p > tmp) {
475  if (++n == t && *(p-1) != TEXT('-')) {
476  memmove(p+1, p, (e-p+1)*sizeof(TCHAR));
477  e++;
478  *p = TEXT(' ');
479  n = 0;
480  }
481  }
482  /* if decimal mode, apply regional settings */
483  if (calc.base == IDC_RADIO_DEC) {
484  TCHAR *p = tmp;
485  TCHAR *e = _tcschr(tmp, TEXT('.'));
486 
487  /* searching for thousands default separator */
488  while (p < e) {
489  if (*p == TEXT(' ')) {
490  memmove(p+calc.sThousand_len, p+1, _tcslen(p)*sizeof(TCHAR));
491  memcpy(p, calc.sThousand, calc.sThousand_len*sizeof(TCHAR));
492  p += calc.sThousand_len;
493  } else
494  p++;
495  }
496  /* update decimal point too. */
497  memmove(p+calc.sDecimal_len, p+1, _tcslen(p)*sizeof(TCHAR));
498  memcpy(p, calc.sDecimal, calc.sDecimal_len*sizeof(TCHAR));
499  }
500  } else {
501  TCHAR *p = _tcschr(tmp, TEXT('.'));
502 
503  /* update decimal point when usesep is false */
504  if (p != NULL) {
505  memmove(p+calc.sDecimal_len, p+1, _tcslen(p)*sizeof(TCHAR));
506  memcpy(p, calc.sDecimal, calc.sDecimal_len*sizeof(TCHAR));
507  }
508  }
510 }
511 
513 {
514  TCHAR str[8];
515  int n = eval_parent_count();
516 
517  if (!n)
518  str[0] = TEXT('\0');
519  else
520  _stprintf(str,TEXT("(=%d"), n);
522 }
523 
524 static void build_operand(HWND hwnd, DWORD idc)
525 {
526  unsigned int i = 0, n;
527 
528  if (idc == IDC_BUTTON_DOT) {
529  /* if dot is the first char, it's added automatically */
530  if (calc.buffer == calc.ptr) {
531  *calc.ptr++ = TEXT('0');
532  *calc.ptr++ = TEXT('.');
533  *calc.ptr = TEXT('\0');
534  update_lcd_display(hwnd);
535  return;
536  }
537  /* if pressed dot and it's already in the string, then return */
538  if (_tcschr(calc.buffer, TEXT('.')) != NULL)
539  return;
540  }
541  if (idc != IDC_STATIC) {
542  while (idc != key2code[i].idc) i++;
543  }
544  n = calc.ptr - calc.buffer;
545  if (idc == IDC_BUTTON_0 && n == 0) {
546  /* no need to put the dot because it's handled by update_lcd_display() */
547  calc.buffer[0] = TEXT('0');
548  calc.buffer[1] = TEXT('\0');
549  update_lcd_display(hwnd);
550  return;
551  }
552  switch (calc.base) {
553  case IDC_RADIO_HEX:
554  if (n >= 16)
555  return;
556  break;
557  case IDC_RADIO_DEC:
558  if (n >= SIZEOF(calc.buffer)-1)
559  return;
560  if (calc.sci_in) {
561  if (idc != IDC_STATIC)
562  calc.esp = (calc.esp * 10 + (key2code[i].key-'0')) % LOCAL_EXP_SIZE;
563  if (calc.ptr == calc.buffer)
564  _stprintf(calc.ptr, TEXT("0.e%+d"), calc.esp);
565  else {
566  /* adds the dot at the end if the number has no decimal part */
567  if (!_tcschr(calc.buffer, TEXT('.')))
568  *calc.ptr++ = TEXT('.');
569  _stprintf(calc.ptr, TEXT("e%+d"), calc.esp);
570  }
571  update_lcd_display(hwnd);
572  return;
573  }
574  break;
575  case IDC_RADIO_OCT:
576  if (n >= 22)
577  return;
578  break;
579  case IDC_RADIO_BIN:
580  if (n >= 64)
581  return;
582  break;
583  }
584  calc.ptr += _stprintf(calc.ptr, TEXT("%C"), key2code[i].key);
585  update_lcd_display(hwnd);
586 }
587 
588 static void prepare_rpn_result(calc_number_t *rpn, TCHAR *buffer, int size, int base)
589 {
590  if (calc.is_nan) {
591  rpn_zero(&calc.code);
592  LoadString(calc.hInstance, IDS_MATH_ERROR, buffer, size);
593  return;
594  }
595  prepare_rpn_result_2(rpn, buffer, size, base);
596 }
597 
599 {
600  calc.sci_in = FALSE;
601  prepare_rpn_result(rpn, calc.buffer, SIZEOF(calc.buffer), calc.base);
602  calc.ptr = calc.buffer + _tcslen(calc.buffer);
603  update_lcd_display(hwnd);
604  calc.ptr = calc.buffer;
605  update_parent_display(hwnd);
606 }
607 
609 {
610  int modifiers = 0;
611 
612  if (SendDlgItemMessage(hwnd, IDC_CHECK_INV, BM_GETCHECK, 0, 0))
613  modifiers |= MODIFIER_INV;
614  if (SendDlgItemMessage(hwnd, IDC_CHECK_HYP, BM_GETCHECK, 0, 0))
615  modifiers |= MODIFIER_HYP;
616 
617  return modifiers;
618 }
619 
621 {
622  /* if the screen output buffer is empty, then */
623  /* the operand is taken from the last input */
624  if (calc.buffer == calc.ptr) {
625  /* if pushed valued is ZERO then we should grab it */
626  if (!_tcscmp(calc.buffer, TEXT("0.")) ||
627  !_tcscmp(calc.buffer, TEXT("0")))
628  /* this zero is good for both integer and decimal */
629  rpn_zero(a);
630  else
631  rpn_copy(a, &calc.code);
632  return;
633  }
634  /* ZERO is the default value for all numeric bases */
635  rpn_zero(a);
637 }
638 
639 static const struct _update_check_menus {
643 } upd[] = {
647  /*-----------------------------------------*/
648  { &calc.base, IDM_VIEW_HEX, IDC_RADIO_HEX, },
649  { &calc.base, IDM_VIEW_DEC, IDC_RADIO_DEC, },
650  { &calc.base, IDM_VIEW_OCT, IDC_RADIO_OCT, },
651  { &calc.base, IDM_VIEW_BIN, IDC_RADIO_BIN, },
652  /*-----------------------------------------*/
653  { &calc.degr, IDM_VIEW_DEG, IDC_RADIO_DEG, },
654  { &calc.degr, IDM_VIEW_RAD, IDC_RADIO_RAD, },
655  { &calc.degr, IDM_VIEW_GRAD, IDC_RADIO_GRAD, },
656  /*-----------------------------------------*/
657  { &calc.size, IDM_VIEW_QWORD, IDC_RADIO_QWORD, },
658  { &calc.size, IDM_VIEW_DWORD, IDC_RADIO_DWORD, },
659  { &calc.size, IDM_VIEW_WORD, IDC_RADIO_WORD, },
660  { &calc.size, IDM_VIEW_BYTE, IDC_RADIO_BYTE, },
661 };
662 
663 static void update_menu(HWND hwnd)
664 {
665  HMENU hMenu = GetSubMenu(GetMenu(hwnd), 1);
666  unsigned int x;
667 
668  /* Sets the state of the layout in the menu based on the configuration file */
669  if (calc.layout == CALC_LAYOUT_SCIENTIFIC)
670  {
675  MF_BYCOMMAND);
676  }
677  else if (calc.layout == CALC_LAYOUT_CONVERSION)
678  {
683  MF_BYCOMMAND);
684  }
685  else
686  {
691  MF_BYCOMMAND);
692  }
693 
694  for (x=3; x<SIZEOF(upd); x++) {
695  if (*(upd[x].sel) != upd[x].idc) {
698  } else {
701  }
702  }
704 }
705 
706 typedef struct {
710 
711 static const radio_config_t radio_setup[] = {
712  /* CONTROL-ID hex dec oct bin */
713  { IDC_RADIO_QWORD, MAKE_BITMASK4( 1, 0, 1, 1) },
714  { IDC_RADIO_DWORD, MAKE_BITMASK4( 1, 0, 1, 1) },
715  { IDC_RADIO_WORD, MAKE_BITMASK4( 1, 0, 1, 1) },
716  { IDC_RADIO_BYTE, MAKE_BITMASK4( 1, 0, 1, 1) },
717  { IDC_RADIO_DEG, MAKE_BITMASK4( 0, 1, 0, 0) },
718  { IDC_RADIO_RAD, MAKE_BITMASK4( 0, 1, 0, 0) },
719  { IDC_RADIO_GRAD, MAKE_BITMASK4( 0, 1, 0, 0) },
720 };
721 
723 {
724  BYTE mask;
725  int n;
726 
727  switch (base) {
728  case IDC_RADIO_DEC:
729  mask = BITMASK_DEC_MASK;
730  break;
731  case IDC_RADIO_HEX:
732  mask = BITMASK_HEX_MASK;
733  break;
734  case IDC_RADIO_OCT:
735  mask = BITMASK_OCT_MASK;
736  break;
737  case IDC_RADIO_BIN:
738  mask = BITMASK_BIN_MASK;
739  break;
740  default:
741  return;
742  }
743  for (n=0; n<SIZEOF(key2code); n++) {
744  if (key2code[n].mask != 0) {
745  HWND hCtlWnd = GetDlgItem(hwnd, key2code[n].idc);
746  BOOL current;
747 
748  if ((key2code[n].mask & BITMASK_IS_STATS))
749  current = IsWindow(calc.hStatWnd) ? TRUE : FALSE;
750  else
751  current = (key2code[n].mask & mask) ? TRUE : FALSE;
752  if (IsWindowEnabled(hCtlWnd) != current)
753  EnableWindow(hCtlWnd, current);
754  }
755  }
756 }
757 
758 static void update_radio(HWND hwnd, unsigned int base)
759 {
760  HMENU hMenu;
761  LPCTSTR lpMenuId;
762  WORD mask;
763  int n;
764 
765  switch (base) {
766  case IDC_RADIO_DEC:
768  mask = BITMASK_DEC_MASK;
769  break;
770  case IDC_RADIO_HEX:
772  mask = BITMASK_HEX_MASK;
773  break;
774  case IDC_RADIO_OCT:
776  mask = BITMASK_OCT_MASK;
777  break;
778  case IDC_RADIO_BIN:
780  mask = BITMASK_BIN_MASK;
781  break;
782  default:
783  return;
784  }
785 
786  if (calc.base != base) {
787  convert_text2number(&calc.code);
788  convert_real_integer(base);
789  calc.base = base;
790  display_rpn_result(hwnd, &calc.code);
791 
792  hMenu = GetMenu(hwnd);
793  DestroyMenu(hMenu);
794  hMenu = LoadMenu(calc.hInstance, lpMenuId);
795  SetMenu(hwnd, hMenu);
796  update_menu(hwnd);
797 
798  for (n=0; n<SIZEOF(radio_setup); n++)
799  ShowWindow(GetDlgItem(hwnd, radio_setup[n].idc), (radio_setup[n].mask & mask) ? SW_SHOW : SW_HIDE);
800 
801  enable_allowed_controls(hwnd, base);
802  }
803 
805  if (base == IDC_RADIO_DEC)
807  else
809 }
810 
811 static void update_memory_flag(HWND hWnd, BOOL mem_flag)
812 {
813  calc.is_memory = mem_flag;
814  SendDlgItemMessage(hWnd, IDC_TEXT_MEMORY, WM_SETTEXT, 0, (LPARAM)(mem_flag ? TEXT("M") : TEXT("")));
815 }
816 
818 {
819  unsigned int n = SendDlgItemMessage(hWnd, IDC_LIST_STAT, LB_GETCOUNT, 0, 0);
820 
821  _stprintf(buffer, TEXT("n=%d"), n);
823 }
824 
825 static void clean_stat_list(void)
826 {
827  statistic_t *p = calc.stat;
828 
829  while (p != NULL) {
830  statistic_t *s = p;
831  p = (statistic_t *)(p->next);
832  rpn_free(&s->num);
833  free(s);
834  }
835  calc.stat = p;
836 }
837 
838 static void delete_stat_item(int n)
839 {
840  statistic_t *p = calc.stat;
841  statistic_t *s;
842 
843  if (n == 0) {
844  calc.stat = (statistic_t *)p->next;
845  rpn_free(&p->num);
846  free(p);
847  } else {
848  s = (statistic_t *)p->next;
849  while (--n) {
850  p = s;
851  s = (statistic_t *)p->next;
852  }
853  p->next = s->next;
854  rpn_free(&s->num);
855  free(s);
856  }
857 }
858 
859 static char *ReadConversion(const char *formula)
860 {
861  int len = strlen(formula);
862  char *str = (char *)malloc(len+3);
863 
864  if (str == NULL)
865  return NULL;
866 
867  str[0] = '(';
868  memcpy(str+1, formula, len);
869  str[len+1] = ')';
870  str[len+2] = '\0';
871 
872  _tcscpy(calc.source, (*calc.buffer == _T('\0')) ? _T("0") : calc.buffer);
873 
874  /* clear display content before proceeding */
875  calc.ptr = calc.buffer;
876  calc.buffer[0] = TEXT('\0');
877 
878  return str;
879 }
880 
882 {
883  TCHAR buffer[SIZEOF(calc.buffer)];
884  DWORD n;
885 
886  switch (msg) {
887  case WM_INITDIALOG:
888  return TRUE;
889  case WM_COMMAND:
890  switch (LOWORD(wp)) {
891  case IDC_LIST_STAT:
892  if (HIWORD(wp) == CBN_DBLCLK)
894  return TRUE;
895  case IDC_BUTTON_RET:
897  return TRUE;
898  case IDC_BUTTON_LOAD:
900  if (n == (DWORD)-1)
901  return TRUE;
902  PostMessage(GetParent(hWnd), WM_LOAD_STAT, (WPARAM)n, 0);
903  return TRUE;
904  case IDC_BUTTON_CD:
906  if (n == (DWORD)-1)
907  return TRUE;
909  update_n_stats_items(hWnd, buffer);
910  delete_stat_item(n);
911  return TRUE;
912  case IDC_BUTTON_CAD:
914  clean_stat_list();
915  update_n_stats_items(hWnd, buffer);
916  return TRUE;
917  }
918  break;
919  case WM_CLOSE:
920  clean_stat_list();
921  DestroyWindow(hWnd);
922  return TRUE;
923  case WM_DESTROY:
924  PostMessage(GetParent(hWnd), WM_CLOSE_STATS, 0, 0);
925  return TRUE;
926  case WM_INSERT_STAT:
927  prepare_rpn_result(&(((statistic_t *)lp)->num),
928  buffer, SIZEOF(buffer),
929  ((statistic_t *)lp)->base);
931  update_n_stats_items(hWnd, buffer);
932  return TRUE;
933  }
934  return FALSE;
935 }
936 
937 static BOOL idm_2_idc(int idm, WPARAM *pIdc)
938 {
939  int x;
940 
941  for (x=0; x<SIZEOF(upd); x++) {
942  if (upd[x].idm == idm)
943  {
944  *pIdc = (WPARAM)(upd[x].idc);
945  return TRUE;
946  }
947  }
948  return FALSE;
949 }
950 
951 static void CopyMemToClipboard(void *ptr)
952 {
953  if(OpenClipboard(NULL)) {
954  HGLOBAL clipbuffer;
955  TCHAR *buffer;
956 
957  EmptyClipboard();
958  clipbuffer = GlobalAlloc(GMEM_DDESHARE, (_tcslen(ptr)+1)*sizeof(TCHAR));
959  buffer = (TCHAR *)GlobalLock(clipbuffer);
960  _tcscpy(buffer, ptr);
961  GlobalUnlock(clipbuffer);
962 #ifdef UNICODE
963  SetClipboardData(CF_UNICODETEXT,clipbuffer);
964 #else
965  SetClipboardData(CF_TEXT,clipbuffer);
966 #endif
967  CloseClipboard();
968  }
969 }
970 
972 {
973  TCHAR display[sizeof(calc.buffer)];
974 
976  if (calc.base == IDC_RADIO_DEC && _tcschr(calc.buffer, _T('.')) == NULL)
977  display[_tcslen(display)-calc.sDecimal_len] = TEXT('\0');
978  CopyMemToClipboard(display);
979 }
980 
981 static char *ReadClipboard(void)
982 {
983  char *buffer = NULL;
984 
985  if (OpenClipboard(NULL)) {
987  char *fromClipboard;
988 
989  if (hData != NULL) {
990  fromClipboard = (char *)GlobalLock(hData);
991  if (strlen(fromClipboard))
992  buffer = _strupr(_strdup(fromClipboard));
993  GlobalUnlock( hData );
994  }
995  CloseClipboard();
996  }
997  return buffer;
998 }
999 
1001 {
1002  char *ptr = seq->ptr;
1003  int ch, x;
1004 
1005  ch = *ptr++;
1006  if (ch == '\\')
1008  else
1009  if (ch == ':') {
1010  ch = *ptr;
1011  if (ch != '\0')
1012  ptr++;
1013  switch (ch) {
1014  case 'C': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MC, 0); break;
1015  case 'E': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_EXP,0); break;
1016  case 'M': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MS, 0); break;
1017  case 'P': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MP, 0); break;
1018  case 'Q': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_CANC, 0); break;
1019  case 'R': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MR, 0); break;
1020  }
1021  } else
1022  if (ch == '$') {
1023  calc.ptr =
1024  _tcscpy(calc.buffer, calc.source) +
1025  _tcslen(calc.source);
1026  } else {
1027  for (x=0; x<SIZEOF(key2code); x++) {
1028  if (!(key2code[x].mask & BITMASK_IS_ASCII) ||
1029  (key2code[x].mask & BITMASK_IS_CTRL))
1030  continue;
1031  if (key2code[x].key == ch) {
1032  PostMessage(hwnd, WM_COMMAND, (WPARAM)key2code[x].idc, 0);
1033  break;
1034  }
1035  }
1036  }
1037  seq->ptr = ptr;
1038  if (*ptr != '\0')
1039  PostMessage(hwnd, seq->wm_msg, 0, 0);
1040  else {
1041  free(seq->data);
1042  seq->data = seq->ptr = ptr = NULL;
1043  }
1044  return ptr;
1045 }
1046 
1048 {
1049  statistic_t *s = (statistic_t *)malloc(sizeof(statistic_t));
1050  statistic_t *p = calc.stat;
1051 
1052  rpn_alloc(&s->num);
1053  rpn_copy(&s->num, a);
1054  s->base = calc.base;
1055  s->next = NULL;
1056  if (p == NULL)
1057  calc.stat = s;
1058  else {
1059  while (p->next != NULL)
1060  p = (statistic_t *)(p->next);
1061  p->next = s;
1062  }
1063  PostMessage(calc.hStatWnd, WM_INSERT_STAT, 0, (LPARAM)s);
1064 }
1065 
1066 static void run_mp(calc_number_t *c)
1067 {
1068  calc_node_t cn;
1069 
1070  cn.number = *c;
1071  cn.base = calc.base;
1072  run_operator(&calc.memory, &calc.memory, &cn, RPN_OPERATOR_ADD);
1073  update_memory_flag(calc.hWnd, TRUE);
1074 }
1075 
1076 static void run_mm(calc_number_t *c)
1077 {
1078  calc_node_t cn;
1079 
1080  cn.number = *c;
1081  cn.base = calc.base;
1082  run_operator(&calc.memory, &calc.memory, &cn, RPN_OPERATOR_SUB);
1083  update_memory_flag(calc.hWnd, TRUE);
1084 }
1085 
1086 static void run_ms(calc_number_t *c)
1087 {
1088  rpn_copy(&calc.memory.number, c);
1089  calc.memory.base = calc.base;
1091 }
1092 
1093 static void run_mw(calc_number_t *c)
1094 {
1095  calc_number_t tmp;
1096 
1097  rpn_copy(&tmp, &calc.memory.number);
1098  rpn_copy(&calc.memory.number, c);
1099  calc.memory.base = calc.base;
1100  if (calc.is_memory)
1101  rpn_copy(c, &tmp);
1103 }
1104 
1106 {
1107  statistic_t *p = calc.stat;
1108 
1109  if (p == NULL)
1110  return p;
1111 
1112  while (n--) {
1113  p = (statistic_t *)(p->next);
1114  if (p == NULL)
1115  return p;
1116  }
1117 
1118 #ifndef ENABLE_MULTI_PRECISION
1119  if (calc.base != p->base) {
1120  if (calc.base == IDC_RADIO_DEC)
1121  calc.code.f = (double)p->num.i;
1122  else {
1123  calc.code.i = (__int64)p->num.f;
1124  apply_int_mask(&calc.code);
1125  }
1126  } else
1127 #endif
1128  rpn_copy(&calc.code, &p->num);
1129 
1130  calc.is_nan = FALSE;
1131 
1132  return p;
1133 }
1134 
1136 {
1138 }
1139 
1141 {
1143 }
1144 
1146 {
1147  calc.sci_out = ((calc.sci_out != FALSE) ? FALSE : TRUE);
1148 }
1149 
1151 {
1152  TCHAR text[64];
1153  HMENU hMenu = CreatePopupMenu();
1154  BOOL idm;
1155 
1156  LoadString(calc.hInstance, IDS_QUICKHELP, text, SIZEOF(text));
1157  AppendMenu(hMenu, MF_STRING | MF_ENABLED, IDM_HELP_HELP, text);
1158  idm = TrackPopupMenu( hMenu,
1160  LOWORD(lp),
1161  HIWORD(lp),
1162  0,
1163  hWnd,
1164  NULL);
1165  DestroyMenu(hMenu);
1166 #ifndef DISABLE_HTMLHELP_SUPPORT
1167  if (idm) {
1168  HH_POPUP popup;
1169 
1170  memset(&popup, 0, sizeof(popup));
1171  popup.cbStruct = sizeof(HH_POPUP);
1172  popup.clrForeground = 1;
1173  popup.clrBackground = -1;
1174  popup.pt.x = LOWORD(lp);
1175  popup.pt.y = HIWORD(lp);
1176  popup.rcMargins.top = -1;
1177  popup.rcMargins.bottom = -1;
1178  popup.rcMargins.left = -1;
1179  popup.rcMargins.right = -1;
1180  popup.idString = GetWindowLongPtr((HWND)wp, GWL_ID);
1181  HtmlHelp((HWND)wp, HTMLHELP_PATH("/popups.txt"), HH_DISPLAY_TEXT_POPUP, (DWORD_PTR)&popup);
1182  }
1183 #else
1184  (void)idm;
1185 #endif
1186 }
1187 
1188 static void run_canc(calc_number_t *c)
1189 {
1190  flush_postfix();
1191  rpn_zero(c);
1192  /* clear also scientific display modes */
1193  calc.sci_out = FALSE;
1194  calc.sci_in = FALSE;
1195  /* clear state of inv and hyp flags */
1198 }
1199 
1200 static void run_rpar(calc_number_t *c)
1201 {
1202  exec_closeparent(c);
1203 }
1204 
1205 static void run_lpar(calc_number_t *c)
1206 {
1208 }
1209 
1211 {
1213  DWORD dwStyle;
1214  UINT dwText;
1215  TCHAR text[64];
1216  int dx, dy, len;
1217  SIZE size;
1218  POINT pt;
1219 
1220  if(dis->CtlType == ODT_BUTTON) {
1221  /*
1222  * little exception: 1/x has different color
1223  * in standard and scientific modes
1224  */
1225  if ((calc.layout == CALC_LAYOUT_STANDARD ||
1226  calc.layout == CALC_LAYOUT_CONVERSION) &&
1227  IDC_BUTTON_RX == dis->CtlID) {
1229  } else
1230  for (dx=0; dx<SIZEOF(key2code); dx++) {
1231  if (key2code[dx].idc == dis->CtlID) {
1232  SetTextColor(dis->hDC, key2code[dx].col);
1233  break;
1234  }
1235  }
1236  /* button text to write */
1237  len = GetWindowText(dis->hwndItem, text, SIZEOF(text));
1238  /* default state: unpushed & enabled */
1239  dwStyle = 0;
1240  dwText = 0;
1241  if ((dis->itemState & ODS_DISABLED))
1242  dwText = DSS_DISABLED;
1243  if ((dis->itemState & ODS_SELECTED))
1244  dwStyle = DFCS_PUSHED;
1245 
1246  DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH | dwStyle);
1247  GetTextExtentPoint32(dis->hDC, text, len, &size);
1248  dx = ((dis->rcItem.right-dis->rcItem.left) - size.cx) >> 1;
1249  dy = ((dis->rcItem.bottom-dis->rcItem.top) - size.cy) >> 1;
1250  if ((dwStyle & DFCS_PUSHED)) {
1251  dx++;
1252  dy++;
1253  }
1254  pt.x = dis->rcItem.left + dx;
1255  pt.y = dis->rcItem.top + dy;
1256  DrawState(dis->hDC, NULL, NULL, (LPARAM)text, 0, pt.x, pt.y, size.cx, size.cy, DST_TEXT | dwText);
1257  }
1258  return 1L;
1259 }
1260 
1262 {
1263  unsigned int x;
1264  RECT rc;
1265  HMENU hMenu;
1266 
1267  switch (msg) {
1268  case WM_DRAWITEM:
1269  return SubclassButtonProc(hWnd, wp, lp);
1270 
1271  case WM_INITDIALOG:
1272  // For now, the Help dialog is disabled because of lacking of HTML Help support
1274  calc.hWnd=hWnd;
1275 
1276 #ifdef USE_KEYBOARD_HOOK
1277  calc.hKeyboardHook=SetWindowsHookEx(
1278  WH_KEYBOARD,
1280  NULL,
1282  );
1283 #endif
1284  rpn_zero(&calc.code);
1285  calc.sci_out = FALSE;
1286  calc.base = IDC_RADIO_DEC;
1287  calc.size = IDC_RADIO_QWORD;
1288  calc.degr = IDC_RADIO_DEG;
1289  calc.ptr = calc.buffer;
1290  calc.is_nan = FALSE;
1292  update_radio(hWnd, IDC_RADIO_DEC);
1293  update_menu(hWnd);
1294  display_rpn_result(hWnd, &calc.code);
1295  update_memory_flag(hWnd, calc.is_memory);
1296  /* remove keyboard focus */
1298  /* set our calc icon */
1301 
1302  /* Sets the state of the option to group digits */
1303  hMenu = GetSubMenu(GetMenu(hWnd), 1);
1305 
1306  /* update text for decimal button */
1308  /* Fill combo box for conversion */
1309  if (calc.layout == CALC_LAYOUT_CONVERSION)
1310  ConvInit(hWnd);
1311  /* Restore the window at the same position it was */
1312  if (calc.x_coord >= 0 && calc.y_coord >= 0) {
1313  int w, h, sw, sh;
1314 
1315  GetWindowRect(hWnd, &rc);
1316  w = rc.right-rc.left;
1317  h = rc.bottom-rc.top;
1320  if (calc.x_coord+w > sw) calc.x_coord = sw - w;
1321  if (calc.y_coord+h > sh) calc.y_coord = sh - h;
1322  MoveWindow(hWnd, calc.x_coord, calc.y_coord, w, h, FALSE);
1323  }
1324  break;
1325  case WM_CTLCOLORSTATIC:
1326  if ((HWND)lp == GetDlgItem(hWnd, IDC_TEXT_OUTPUT))
1328  break;
1329  case WM_HANDLE_CLIPBOARD:
1330  handle_sequence_input(hWnd, &calc.Clipboard);
1331  return TRUE;
1332  case WM_COMMAND:
1333  /*
1334  * if selection of category is changed, we must
1335  * updatethe content of the "from/to" combo boxes.
1336  */
1339  return TRUE;
1340  }
1341  if (HIWORD(wp) != BN_CLICKED && HIWORD(wp) != BN_DBLCLK)
1342  break;
1343  /* avoid flicker if the user selects from keyboard */
1344  if (GetFocus() != GetDlgItem(hWnd, IDC_BUTTON_FOCUS))
1346  switch (LOWORD(wp)) {
1347  case IDM_HELP_ABOUT:
1348  {
1349  TCHAR infotitle[100];
1350  TCHAR infotext[200];
1351  LoadString(calc.hInstance, IDS_CALC_NAME, infotitle, SIZEOF(infotitle));
1352  LoadString(calc.hInstance, IDS_AUTHOR, infotext, SIZEOF(infotext));
1353  ShellAbout(hWnd, infotitle, infotext, (HICON)LoadIcon(calc.hInstance, MAKEINTRESOURCE(IDI_CALC_BIG)));
1354  return TRUE;
1355  }
1356  case IDM_HELP_HELP:
1357 #ifndef DISABLE_HTMLHELP_SUPPORT
1358  HtmlHelp(hWnd, HTMLHELP_PATH("/general_information.htm"), HH_DISPLAY_TOPIC, (DWORD_PTR)NULL);
1359 #endif
1360  return TRUE;
1361  case IDM_VIEW_STANDARD:
1362  if (calc.layout != CALC_LAYOUT_STANDARD)
1363  {
1365  calc.action = IDM_VIEW_STANDARD;
1366  DestroyWindow(hWnd);
1367  save_config();
1368 
1373  MF_BYCOMMAND);
1374  }
1375  return TRUE;
1376  case IDM_VIEW_SCIENTIFIC:
1377  if (calc.layout != CALC_LAYOUT_SCIENTIFIC)
1378  {
1380  calc.action = IDM_VIEW_SCIENTIFIC;
1381  DestroyWindow(hWnd);
1382  save_config();
1383 
1388  MF_BYCOMMAND);
1389  }
1390  return TRUE;
1391  case IDM_VIEW_CONVERSION:
1392  if (calc.layout != CALC_LAYOUT_CONVERSION)
1393  {
1395  calc.action = IDM_VIEW_CONVERSION;
1396  DestroyWindow(hWnd);
1397  save_config();
1398 
1403  MF_BYCOMMAND);
1404  }
1405  return TRUE;
1406  case IDM_VIEW_HEX:
1407  case IDM_VIEW_DEC:
1408  case IDM_VIEW_OCT:
1409  case IDM_VIEW_BIN:
1410  case IDM_VIEW_DEG:
1411  case IDM_VIEW_RAD:
1412  case IDM_VIEW_GRAD:
1413  case IDM_VIEW_QWORD:
1414  case IDM_VIEW_DWORD:
1415  case IDM_VIEW_WORD:
1416  case IDM_VIEW_BYTE:
1417  {
1418  WPARAM idc;
1419  if(idm_2_idc(LOWORD(wp), &idc))
1420  {
1421  SendMessage(hWnd, WM_COMMAND, idc, 0);
1422  return TRUE;
1423  }
1424  return FALSE;
1425  }
1426  case IDM_EDIT_COPY:
1427  handle_copy_command(hWnd);
1428  return TRUE;
1429  case IDM_EDIT_PASTE:
1430  if (calc.Clipboard.data != NULL)
1431  break;
1432  calc.Clipboard.data = ReadClipboard();
1433  if (calc.Clipboard.data != NULL) {
1434  /* clear the content of the display before pasting */
1436  calc.Clipboard.ptr = calc.Clipboard.data;
1438  handle_sequence_input(hWnd, &calc.Clipboard);
1439  }
1440  return TRUE;
1441  case IDM_VIEW_GROUP:
1442  calc.usesep = (calc.usesep ? FALSE : TRUE);
1443  update_menu(hWnd);
1444  update_lcd_display(hWnd);
1445  save_config();
1446  return TRUE;
1447  case IDC_BUTTON_CONVERT:
1448  ConvExecute(hWnd);
1449  return TRUE;
1450  case IDC_BUTTON_CE: {
1451  calc_number_t tmp;
1452  rpn_zero(&tmp);
1453  display_rpn_result(hWnd, &tmp);
1454  }
1455  return TRUE;
1456  case IDC_RADIO_DEC:
1457  case IDC_RADIO_HEX:
1458  case IDC_RADIO_OCT:
1459  case IDC_RADIO_BIN:
1460 /* GNU WINDRES is bugged so I must always force radio update */
1461 /* (Fix for Win95/98) */
1462 #ifdef _MSC_VER
1463  if (calc.base == LOWORD(wp))
1464  break;
1465 #endif
1466  calc.is_nan = FALSE;
1467  update_radio(hWnd, LOWORD(wp));
1468  return TRUE;
1469  case IDC_RADIO_DEG:
1470  case IDC_RADIO_RAD:
1471  case IDC_RADIO_GRAD:
1472 /* GNU WINDRES is bugged so I must always force radio update */
1473 /* (Fix for Win95/98) */
1474 #ifdef _MSC_VER
1475  if (calc.degr == LOWORD(wp))
1476  break;
1477 #endif
1478  calc.degr = LOWORD(wp);
1479  calc.is_nan = FALSE;
1480  update_menu(hWnd);
1481  return TRUE;
1482  case IDC_RADIO_QWORD:
1483  case IDC_RADIO_DWORD:
1484  case IDC_RADIO_WORD:
1485  case IDC_RADIO_BYTE:
1486 /* GNU WINDRES is bugged so I must always force radio update */
1487 /* (Fix for Win95/98) */
1488 #ifdef _MSC_VER
1489  if (calc.size == LOWORD(wp))
1490  break;
1491 #endif
1492  calc.size = LOWORD(wp);
1493  calc.is_nan = FALSE;
1494  update_menu(hWnd);
1495  /*
1496  * update the content of the display
1497  */
1498  convert_text2number(&calc.code);
1499  apply_int_mask(&calc.code);
1500  display_rpn_result(hWnd, &calc.code);
1501  return TRUE;
1502  case IDC_BUTTON_1:
1503  case IDC_BUTTON_2:
1504  case IDC_BUTTON_3:
1505  case IDC_BUTTON_4:
1506  case IDC_BUTTON_5:
1507  case IDC_BUTTON_6:
1508  case IDC_BUTTON_7:
1509  case IDC_BUTTON_8:
1510  case IDC_BUTTON_9:
1511  case IDC_BUTTON_0:
1512  case IDC_BUTTON_DOT:
1513  case IDC_BUTTON_A:
1514  case IDC_BUTTON_B:
1515  case IDC_BUTTON_C:
1516  case IDC_BUTTON_D:
1517  case IDC_BUTTON_E:
1518  case IDC_BUTTON_F:
1519  calc.is_nan = FALSE;
1520  build_operand(hWnd, LOWORD(wp));
1521  return TRUE;
1522  case IDC_BUTTON_PERCENT:
1523  case IDC_BUTTON_ADD:
1524  case IDC_BUTTON_SUB:
1525  case IDC_BUTTON_MULT:
1526  case IDC_BUTTON_DIV:
1527  case IDC_BUTTON_MOD:
1528  case IDC_BUTTON_AND:
1529  case IDC_BUTTON_OR:
1530  case IDC_BUTTON_XOR:
1531  case IDC_BUTTON_LSH:
1532  case IDC_BUTTON_RSH:
1533  case IDC_BUTTON_EQU:
1534  if (calc.is_nan) break;
1535  /*
1536  * LSH button holds the RSH function too with INV modifier,
1537  * but since it's a two operand operator, it must be handled here.
1538  */
1539  if (LOWORD(wp) == IDC_BUTTON_LSH &&
1540  (get_modifiers(hWnd) & MODIFIER_INV)) {
1543  break;
1544  }
1545  for (x=0; x<SIZEOF(operator_codes); x++) {
1546  if (LOWORD(wp) == operator_codes[x]) {
1547  convert_text2number(&calc.code);
1548 
1549  if (calc.ptr == calc.buffer) {
1550  if (calc.last_operator != x) {
1551  if (x != RPN_OPERATOR_EQUAL)
1553  } else
1554  if (x == RPN_OPERATOR_EQUAL) {
1555  exec_infix2postfix(&calc.code, calc.prev_operator);
1556  rpn_copy(&calc.code, &calc.prev);
1557  } else
1558  break;
1559  }
1560 
1561  /* if no change then quit silently, */
1562  /* without display updates */
1563  if (!exec_infix2postfix(&calc.code, x))
1564  break;
1565 
1566  display_rpn_result(hWnd, &calc.code);
1567  break;
1568  }
1569  }
1570  return TRUE;
1571  case IDC_BUTTON_BACK:
1572  if (calc.sci_in) {
1573  if (calc.esp == 0) {
1574  TCHAR *ptr;
1575 
1576  calc.sci_in = FALSE;
1577  ptr = _tcschr(calc.ptr, TEXT('e'));
1578  if (ptr)
1579  *ptr = TEXT('\0');
1580  update_lcd_display(hWnd);
1581  } else {
1582  calc.esp /= 10;
1583  build_operand(hWnd, IDC_STATIC);
1584  }
1585  } else
1586  if (calc.ptr != calc.buffer) {
1587  *--calc.ptr = TEXT('\0');
1588  if (!_tcscmp(calc.buffer, TEXT("-")) ||
1589  !_tcscmp(calc.buffer, TEXT("-0")) ||
1590  !_tcscmp(calc.buffer, TEXT("0"))) {
1591  calc.ptr = calc.buffer;
1592  calc.buffer[0] = TEXT('\0');
1593  }
1594  update_lcd_display(hWnd);
1595  }
1596  return TRUE;
1597  case IDC_BUTTON_MC:
1598  rpn_zero(&calc.memory.number);
1599  update_memory_flag(hWnd, FALSE);
1600  return TRUE;
1601  case IDC_BUTTON_MR:
1602  if (calc.is_memory) {
1603  calc.is_nan = FALSE;
1604  rpn_copy(&calc.code, &calc.memory.number);
1605  display_rpn_result(hWnd, &calc.code);
1606  }
1607  return TRUE;
1608  case IDC_BUTTON_EXP:
1609  if (calc.sci_in || calc.is_nan || calc.buffer == calc.ptr)
1610  break;
1611  calc.sci_in = TRUE;
1612  calc.esp = 0;
1613  build_operand(hWnd, IDC_STATIC);
1614  return TRUE;
1615  case IDC_BUTTON_SIGN:
1616  if (calc.sci_in) {
1617  calc.esp = 0-calc.esp;
1618  build_operand(hWnd, IDC_STATIC);
1619  } else {
1620  if (calc.is_nan || calc.buffer[0] == TEXT('\0'))
1621  break;
1622 
1623  if (calc.buffer[0] == TEXT('-')) {
1624  /* make the number positive */
1625  memmove(calc.buffer, calc.buffer+1, sizeof(calc.buffer)-1);
1626  if (calc.buffer != calc.ptr)
1627  calc.ptr--;
1628  } else {
1629  /* if first char is '0' and no dot, it isn't valid */
1630  if (calc.buffer[0] == TEXT('0') &&
1631  calc.buffer[1] != TEXT('.'))
1632  break;
1633  /* make the number negative */
1634  memmove(calc.buffer+1, calc.buffer, sizeof(calc.buffer)-1);
1635  calc.buffer[0] = TEXT('-');
1636  if (calc.buffer != calc.ptr)
1637  calc.ptr++;
1638  }
1639  /* If the input buffer is empty, then
1640  we change also the sign of calc.code
1641  because it could be the result of a
1642  previous calculation. */
1643  if (calc.buffer == calc.ptr)
1644  rpn_sign(&calc.code);
1645  update_lcd_display(hWnd);
1646  }
1647  return TRUE;
1648  case IDC_BUTTON_RIGHTPAR:
1649  case IDC_BUTTON_LEFTPAR:
1650  case IDC_BUTTON_CANC:
1651  case IDC_BUTTON_MP:
1652  case IDC_BUTTON_DAT:
1653  case IDC_BUTTON_FE:
1654  case IDC_BUTTON_DMS:
1655  case IDC_BUTTON_SQRT:
1656  case IDC_BUTTON_S:
1657  case IDC_BUTTON_SUM:
1658  case IDC_BUTTON_AVE:
1659  case IDC_BUTTON_NF:
1660  case IDC_BUTTON_LN:
1661  case IDC_BUTTON_LOG:
1662  case IDC_BUTTON_Xe2:
1663  case IDC_BUTTON_Xe3:
1664  case IDC_BUTTON_PI:
1665  case IDC_BUTTON_NOT:
1666  case IDC_BUTTON_RX:
1667  case IDC_BUTTON_INT:
1668  case IDC_BUTTON_SIN:
1669  case IDC_BUTTON_COS:
1670  case IDC_BUTTON_TAN:
1671  case IDC_BUTTON_XeY:
1672  case IDC_BUTTON_MS:
1673  for (x=0; x<SIZEOF(function_table); x++) {
1674  if (LOWORD(wp) == function_table[x].idc) {
1675  rpn_callback1 cb = NULL;
1676 
1677  /* test if NaN state is important or not */
1678  if (calc.is_nan && function_table[x].check_nan) break;
1679  /* otherwise, it's cleared */
1680  calc.is_nan = FALSE;
1681 
1682  switch (get_modifiers(hWnd) & function_table[x].range) {
1683  case 0:
1684  cb = function_table[x].direct;
1685  break;
1686  case MODIFIER_INV:
1687  cb = function_table[x].inverse;
1688  break;
1689  case MODIFIER_HYP:
1690  cb = function_table[x].hyperb;
1691  break;
1692  case MODIFIER_INV|MODIFIER_HYP:
1693  cb = function_table[x].inv_hyp;
1694  break;
1695  }
1696  if (cb != NULL) {
1697  convert_text2number(&calc.code);
1698  cb(&calc.code);
1699  display_rpn_result(hWnd, &calc.code);
1700  if (!(function_table[x].range & NO_CHAIN))
1702  if (function_table[x].range & MODIFIER_INV)
1704  if (function_table[x].range & MODIFIER_HYP)
1706  }
1707  }
1708  }
1709  return TRUE;
1710  case IDC_BUTTON_STA:
1711  if (IsWindow(calc.hStatWnd))
1712  break;
1713  calc.hStatWnd = CreateDialog(calc.hInstance,
1715  if (calc.hStatWnd != NULL) {
1716  enable_allowed_controls(hWnd, calc.base);
1717  SendMessage(calc.hStatWnd, WM_SETFOCUS, 0, 0);
1718  }
1719  return TRUE;
1720  }
1721  break;
1722  case WM_CLOSE_STATS:
1723  enable_allowed_controls(hWnd, calc.base);
1724  return TRUE;
1725  case WM_LOAD_STAT:
1726  if (upload_stat_number((int)LOWORD(wp)) != NULL)
1727  display_rpn_result(hWnd, &calc.code);
1728  return TRUE;
1729  case WM_START_CONV:
1730  x = LOWORD(lp);
1731  calc.Convert[x].data = ReadConversion(calc.Convert[x].data);
1732  if (calc.Convert[x].data != NULL) {
1733  calc.Convert[x].ptr = calc.Convert[x].data;
1734  PostMessage(hWnd, HIWORD(lp), 0, 0);
1735  }
1736  return TRUE;
1737  case WM_HANDLE_FROM:
1738  if (calc.is_nan)
1739  break;
1740  if (handle_sequence_input(hWnd, &calc.Convert[0]) == NULL)
1741  PostMessage(hWnd, WM_START_CONV, 0,
1742  MAKELPARAM(0x0001, WM_HANDLE_TO));
1743  return TRUE;
1744  case WM_HANDLE_TO:
1745  if (!calc.is_nan)
1746  handle_sequence_input(hWnd, &calc.Convert[1]);
1747  return TRUE;
1748  case WM_CLOSE:
1749  calc.action = IDC_STATIC;
1750  DestroyWindow(hWnd);
1751  return TRUE;
1752  case WM_DESTROY:
1753  /* Get (x,y) position of the calculator */
1754  GetWindowRect(hWnd, &rc);
1755  calc.x_coord = rc.left;
1756  calc.y_coord = rc.top;
1757 #ifdef USE_KEYBOARD_HOOK
1758  UnhookWindowsHookEx(calc.hKeyboardHook);
1759 #endif
1760  PostQuitMessage(0);
1761  return TRUE;
1762  case WM_CONTEXTMENU:
1763  if ((HWND)wp != hWnd)
1764  handle_context_menu(hWnd, wp, lp);
1765  return TRUE;
1766  case WM_ENTERMENULOOP:
1767  calc.is_menu_on = TRUE;
1768  /* Check if a valid format is available in the clipboard */
1769  EnableMenuItem(GetSubMenu(GetMenu(hWnd), 0),
1771  MF_BYCOMMAND|
1773  MF_ENABLED : MF_GRAYED));
1774  break;
1775  case WM_EXITMENULOOP:
1776  calc.is_menu_on = FALSE;
1777  break;
1778  }
1779  return FALSE;
1780 }
1781 
1782 #if defined(__GNUC__) && !defined(__REACTOS__)
1783 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
1784 #else
1785 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
1786 #endif
1787 {
1788  MSG msg;
1789  DWORD dwLayout;
1790 
1792 
1793  calc.hInstance = hInstance;
1794 
1795  calc.x_coord = -1;
1796  calc.y_coord = -1;
1797 
1798  load_config();
1799  start_rpn_engine();
1800 
1801  do {
1802  /* ignore hwnd: dialogs are already visible! */
1803  if (calc.layout == CALC_LAYOUT_SCIENTIFIC)
1804  dwLayout = IDD_DIALOG_SCIENTIFIC;
1805  else if (calc.layout == CALC_LAYOUT_CONVERSION)
1806  dwLayout = IDD_DIALOG_CONVERSION;
1807  else
1808  dwLayout = IDD_DIALOG_STANDARD;
1809 
1810  /* This call will always fail if UNICODE for Win9x */
1811  if (NULL == CreateDialog(hInstance, MAKEINTRESOURCE(dwLayout), NULL, DlgMainProc))
1812  break;
1813 
1814  while (GetMessage(&msg, NULL, 0, 0)) {
1815 #ifndef USE_KEYBOARD_HOOK
1816  if ((msg.message == WM_KEYUP ||
1817  msg.message == WM_KEYDOWN) &&
1818  !calc.is_menu_on)
1819  process_vk_key(msg.wParam, msg.lParam);
1820 #endif
1821  TranslateMessage(&msg);
1822  DispatchMessage(&msg);
1823  }
1824  } while (calc.action != IDC_STATIC);
1825 
1826  stop_rpn_engine();
1827 
1828  return 0;
1829 }
#define IDC_BUTTON_1
Definition: resource.h:49
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define IDC_BUTTON_MC
Definition: resource.h:42
#define RegQueryValueEx
Definition: winreg.h:524
static INT_PTR CALLBACK DlgStatProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:881
void rpn_s(calc_number_t *c)
Definition: fun_mpfr.c:403
#define IDC_BUTTON_CANC
Definition: resource.h:84
statistic_t * stat
Definition: calc.h:130
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD base
Definition: calc.h:138
static void convert_text2number(calc_number_t *a)
Definition: winmain.c:620
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define BM_SETSTATE
Definition: winuser.h:1884
#define IDC_BUTTON_CAD
Definition: resource.h:94
void rpn_pi(calc_number_t *c)
Definition: fun_mpfr.c:269
#define DispatchMessage
Definition: winuser.h:5631
#define CTRL_R
Definition: winmain.c:62
#define IDC_RADIO_DEG
Definition: resource.h:81
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define IDI_CALC_SMALL
Definition: resource.h:15
#define BS_OWNERDRAW
Definition: pedump.c:661
sequence_t Convert[2]
Definition: calc.h:145
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static void update_n_stats_items(HWND hWnd, TCHAR *buffer)
Definition: winmain.c:817
static HICON
Definition: imagelist.c:84
#define IDC_BUTTON_0
Definition: resource.h:50
static void update_menu(HWND hwnd)
Definition: winmain.c:663
#define IDC_BUTTON_INT
Definition: resource.h:75
#define TRUE
Definition: types.h:120
#define BITMASK_DEC_MASK
Definition: winmain.c:33
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
COLORREF col
Definition: winmain.c:50
#define IDC_BUTTON_CE
Definition: resource.h:85
#define DFC_BUTTON
Definition: winuser.h:476
void rpn_acosh(calc_number_t *c)
Definition: fun_mpfr.c:213
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
#define IDC_BUTTON_BACK
Definition: resource.h:86
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
UINT wm_msg
Definition: calc.h:102
#define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2)
Definition: winmain.c:11
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define VK_F5
Definition: winuser.h:2213
#define IDM_VIEW_OCT
Definition: resource.h:368
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_VIEW_BIN
Definition: resource.h:369
static void delete_stat_item(int n)
Definition: winmain.c:838
BOOL sci_out
Definition: calc.h:133
long y
Definition: polytest.cpp:48
#define IDC_BUTTON_B
Definition: resource.h:56
calc_number_t code
Definition: calc.h:127
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define IDC_RADIO_GRAD
Definition: resource.h:83
rpn_callback1 inverse
Definition: winmain.c:178
void rpn_cbrt(calc_number_t *c)
Definition: fun_mpfr.c:303
#define IDC_BUTTON_MP
Definition: resource.h:45
Definition: calc.h:117
#define VK_F6
Definition: winuser.h:2214
BOOL is_menu_on
Definition: calc.h:136
DWORD layout
Definition: calc.h:123
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define IDM_VIEW_QWORD
Definition: resource.h:376
#define IDC_RADIO_DEC
Definition: resource.h:17
#define LB_ADDSTRING
Definition: winuser.h:1992
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define IDC_BUTTON_2
Definition: resource.h:54
void rpn_atanh(calc_number_t *c)
Definition: fun_mpfr.c:218
#define IDM_VIEW_DEC
Definition: resource.h:367
long x
Definition: polytest.cpp:48
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void rpn_sqrt(calc_number_t *c)
Definition: fun_mpfr.c:297
#define IDC_BUTTON_RX
Definition: resource.h:41
static void run_fe(calc_number_t *number)
Definition: winmain.c:1145
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define IDD_DIALOG_SCIENTIFIC
Definition: resource.h:7
#define IDC_BUTTON_EQU
Definition: resource.h:70
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2331
TCHAR * ptr
Definition: calc.h:126
#define SW_HIDE
Definition: winuser.h:762
calc_t calc
Definition: winmain.c:226
double f
Definition: calc.h:77
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:436
#define IDI_CALC_BIG
Definition: resource.h:14
static const key2code_t key2code_base16[]
Definition: winmain.c:141
const WCHAR * text
Definition: package.c:1827
#define IDC_CHECK_INV
Definition: resource.h:20
#define IDC_RADIO_WORD
Definition: resource.h:79
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define TPM_RETURNCMD
Definition: winuser.h:2341
rpn_callback1 direct
Definition: winmain.c:177
unsigned int sThousand_len
Definition: calc.h:151
#define GWL_ID
Definition: winuser.h:853
#define IDC_STATIC
Definition: calc.h:41
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
void rpn_free(calc_number_t *c)
Definition: fun_mpfr.c:487
#define WM_GETTEXT
Definition: winuser.h:1600
#define IDR_MENU_SCIENTIFIC_2
Definition: resource.h:12
#define IDM_VIEW_GROUP
Definition: resource.h:373
#define IDC_BUTTON_SQRT
Definition: resource.h:96
static void update_parent_display(HWND hWnd)
Definition: winmain.c:512
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define CALLBACK
Definition: compat.h:27
static void run_mw(calc_number_t *c)
Definition: winmain.c:1093
#define VK_F9
Definition: winuser.h:2217
static void run_pow(calc_number_t *number)
Definition: winmain.c:1135
#define MF_STRING
Definition: winuser.h:138
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn.c:288
#define IDS_MATH_ERROR
Definition: resource.h:4
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
HWND hWnd
Definition: settings.c:17
#define WM_HANDLE_FROM
Definition: calc.h:21
LONG top
Definition: windef.h:297
#define IDC_BUTTON_SUM
Definition: resource.h:24
GLdouble GLdouble t
Definition: gl.h:2047
#define WM_INSERT_STAT
Definition: calc.h:18
static int vk2ascii(unsigned int vk)
Definition: winmain.c:338
static void enable_allowed_controls(HWND hwnd, DWORD base)
Definition: winmain.c:722
#define IDC_BUTTON_Xe3
Definition: resource.h:36
void rpn_exp(calc_number_t *c)
Definition: fun_mpfr.c:309
#define IDC_BUTTON_6
Definition: resource.h:58
#define IDC_BUTTON_3
Definition: resource.h:59
#define IDC_BUTTON_PI
Definition: resource.h:46
static BYTE cn[]
Definition: cert.c:2938
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define IDC_BUTTON_S
Definition: resource.h:25
void convert_real_integer(unsigned int base)
Definition: utl.c:92
GLuint buffer
Definition: glext.h:5915
static void update_radio(HWND hwnd, unsigned int base)
Definition: winmain.c:758
#define WHITE_BRUSH
Definition: wingdi.h:900
#define IDM_HELP_ABOUT
Definition: resource.h:375
#define HTMLHELP_PATH(_pt)
Definition: winmain.c:9
HWND WINAPI SetFocus(_In_opt_ HWND)
DWORD degr
Definition: calc.h:140
#define IDM_VIEW_BYTE
Definition: resource.h:378
#define IDM_VIEW_RAD
Definition: resource.h:371
static void run_dat_sta(calc_number_t *number)
Definition: winmain.c:1047
#define IDC_BUTTON_LOAD
Definition: resource.h:92
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define CALC_CLR_RED
Definition: winmain.c:37
#define BN_DBLCLK
Definition: winuser.h:1887
#define IDM_VIEW_GRAD
Definition: resource.h:372
#define VK_INSERT
Definition: winuser.h:2186
#define SendDlgItemMessage
Definition: winuser.h:5708
static LRESULT CALLBACK SubclassButtonProc(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1210
#define VK_MENU
Definition: winuser.h:2158
LONG left
Definition: windef.h:296
#define DST_TEXT
Definition: winuser.h:513
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
void ConvInit(HWND hWnd)
Definition: convert.c:615
#define MapVirtualKeyEx
Definition: winuser.h:5687
int32_t INT_PTR
Definition: typedefs.h:62
#define IDD_DIALOG_STANDARD
Definition: resource.h:8
char * LPSTR
Definition: xmlstorage.h:182
#define VK_ESCAPE
Definition: winuser.h:2168
#define _strdup
Definition: debug_ros.c:7
LONG right
Definition: windef.h:298
BOOL is_nan
Definition: calc.h:132
rpn_callback1 hyperb
Definition: winmain.c:179
static const WORD operator_codes[]
Definition: winmain.c:154
signed int esp
Definition: calc.h:137
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDC_BUTTON_NOT
Definition: resource.h:74
#define IDC_TEXT_MEMORY
Definition: resource.h:89
void rpn_asin(calc_number_t *c)
Definition: fun_mpfr.c:176
void rpn_dms2dec(calc_number_t *c)
Definition: fun_mpfr.c:413
GLuint const GLubyte mask[]
Definition: s_context.h:57
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define VK_RETURN
Definition: winuser.h:2155
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDM_VIEW_STANDARD
Definition: resource.h:364
WPARAM wParam
Definition: combotst.c:138
#define IDC_BUTTON_MOD
Definition: resource.h:67
#define IDC_BUTTON_FOCUS
Definition: resource.h:99
#define IDC_BUTTON_DOT
Definition: resource.h:60
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define alloca
Definition: malloc.h:361
void rpn_frac(calc_number_t *c)
Definition: fun_mpfr.c:229
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
CHAR key
Definition: winmain.c:42
#define GetWindowText
Definition: winuser.h:5664
#define CTRL_M
Definition: winmain.c:60
UINT_PTR WPARAM
Definition: windef.h:207
void rpn_exp2(calc_number_t *c)
Definition: fun_mpfr.c:285
int * display
Definition: x11stubs.c:12
#define ICON_SMALL
Definition: tnclass.cpp:48
void rpn_not(calc_number_t *c)
Definition: fun_mpfr.c:258
static void run_rpar(calc_number_t *c)
Definition: winmain.c:1200
#define IDC_RADIO_BIN
Definition: resource.h:19
static void load_config(void)
Definition: winmain.c:228
#define MODIFIER_INV
Definition: calc.h:165
#define DrawState
Definition: winuser.h:5636
GLuint n
Definition: s_context.h:57
#define IDM_EDIT_PASTE
Definition: resource.h:363
#define DFCS_PUSHED
Definition: winuser.h:503
while(1)
Definition: macro.lex.yy.c:743
DWORD action
Definition: calc.h:141
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
#define SM_CXSCREEN
Definition: winuser.h:949
void convert_text2number_2(calc_number_t *a)
Definition: utl.c:66
GLenum GLclampf GLint i
Definition: glfuncs.h:14
HINSTANCE hInstance
Definition: charmap.c:20
#define IDC_BUTTON_FE
Definition: resource.h:27
#define LB_RESETCONTENT
Definition: winuser.h:2016
#define IDC_BUTTON_EXP
Definition: resource.h:33
void exec_change_infix(void)
Definition: rpn.c:397
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SIZEOF(_ar)
Definition: calc.h:48
GLenum GLint GLuint mask
Definition: glext.h:6028
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define IDM_VIEW_SCIENTIFIC
Definition: resource.h:365
#define IDM_VIEW_DWORD
Definition: resource.h:379
#define IDC_RADIO_QWORD
Definition: resource.h:77
#define CTRL_T
Definition: winmain.c:64
#define IDM_EDIT_COPY
Definition: resource.h:362
GLuint base
Definition: 3dtext.c:35
#define e
Definition: ke_i.h:82
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_BUTTON_LN
Definition: resource.h:38
static BOOL idm_2_idc(int idm, WPARAM *pIdc)
Definition: winmain.c:937
static size_t double number
Definition: printf.c:64
#define WM_ENTERMENULOOP
Definition: winuser.h:1780
#define IDC_RADIO_HEX
Definition: resource.h:16
static LRESULT post_key_press(LPARAM lParam, WORD idc)
Definition: winmain.c:304
void ConvExecute(HWND hWnd)
Definition: convert.c:533
#define TPM_TOPALIGN
Definition: winuser.h:2337
static PVOID ptr
Definition: dispmode.c:27
DWORD size
Definition: calc.h:139
#define VK_F4
Definition: winuser.h:2212
#define VK_F2
Definition: winuser.h:2210
signed int y_coord
Definition: calc.h:153
void rpn_log(calc_number_t *c)
Definition: fun_mpfr.c:327
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define IDC_TEXT_NITEMS
Definition: resource.h:95
#define CF_UNICODETEXT
Definition: constants.h:408
const WCHAR * str
#define IDC_TEXT_PARENT
Definition: resource.h:88
#define IDC_BUTTON_9
Definition: resource.h:57
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define CBN_DBLCLK
Definition: winuser.h:1934
static statistic_t * upload_stat_number(int n)
Definition: winmain.c:1105
#define WM_EXITMENULOOP
Definition: winuser.h:1781
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
#define NO_CHAIN
Definition: calc.h:167
unsigned int prev_operator
Definition: calc.h:147
LONG cx
Definition: windef.h:324
#define WM_KEYDOWN
Definition: winuser.h:1691
HINSTANCE hInstance
Definition: calc.h:118
#define IDC_COMBO_CATEGORY
Definition: resource.h:100
signed int x_coord
Definition: calc.h:152
#define IDC_BUTTON_MULT
Definition: resource.h:63
#define BM_GETCHECK
Definition: winuser.h:1879
BOOL WINAPI IsWindowEnabled(_In_ HWND)
TCHAR sThousand[8]
Definition: calc.h:149
#define IDC_BUTTON_OR
Definition: resource.h:68
WORD idc
Definition: winmain.c:47
#define SW_SHOW
Definition: winuser.h:769
void rpn_acos(calc_number_t *c)
Definition: fun_mpfr.c:181
#define LB_GETCOUNT
Definition: winuser.h:1999
#define WM_SETTEXT
Definition: winuser.h:1599
#define MODIFIER_HYP
Definition: calc.h:166
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
void rpn_ave(calc_number_t *c)
Definition: fun_mpfr.c:344
#define VK_DELETE
Definition: winuser.h:2187
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
void start_rpn_engine(void)
Definition: rpn.c:454
#define CF_TEXT
Definition: constants.h:396
#define WM_DESTROY
Definition: winuser.h:1591
#define CALC_CLR_BLUE
Definition: winmain.c:38
#define PostMessage
Definition: winuser.h:5698
#define KEY_WAS_DOWN
Definition: winmain.c:27
static void run_sqr(calc_number_t *number)
Definition: winmain.c:1140
#define CTRL_V
Definition: winmain.c:65
static const struct _update_check_menus upd[]
#define IDC_BUTTON_AND
Definition: resource.h:72
CHAR key
Definition: winmain.c:48
static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: msg.c:16281
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define MF_CHECKED
Definition: winuser.h:132
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn.c:365
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1878
#define HH_DISPLAY_TOPIC
Definition: htmlhelp.h:22
#define SM_CYSCREEN
Definition: winuser.h:950
HWND hWnd
Definition: calc.h:122
#define IDC_BUTTON_PERCENT
Definition: resource.h:97
void * next
Definition: calc.h:108
TCHAR sDecimal[8]
Definition: calc.h:148
#define BM_SETCHECK
Definition: winuser.h:1882
static void run_ms(calc_number_t *c)
Definition: winmain.c:1086
#define IDC_BUTTON_SIN
Definition: resource.h:29
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
#define IDC_BUTTON_Xe2
Definition: resource.h:35
#define _T(x)
Definition: vfdio.h:22
void rpn_cosh(calc_number_t *c)
Definition: fun_mpfr.c:197
static const radio_config_t radio_setup[]
Definition: winmain.c:711
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define IDC_BUTTON_7
Definition: resource.h:47
int rpn_is_zero(calc_number_t *c)
Definition: fun_mpfr.c:477
#define AppendMenu
Definition: winuser.h:5597
#define VK_F7
Definition: winuser.h:2215
unsigned int sDecimal_len
Definition: calc.h:150
void rpn_int(calc_number_t *c)
Definition: fun_mpfr.c:224
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL usesep
Definition: calc.h:135
#define WM_LOAD_STAT
Definition: calc.h:19
#define ODS_DISABLED
Definition: winuser.h:2501
char * ptr
Definition: calc.h:101
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
INT64 i
Definition: calc.h:78
#define IDC_BUTTON_NF
Definition: resource.h:40
#define WM_CLOSE_STATS
Definition: calc.h:16
static int process_vk_key(WPARAM wParam, LPARAM lParam)
Definition: winmain.c:366
void rpn_ln(calc_number_t *c)
Definition: fun_mpfr.c:321
#define DSS_DISABLED
Definition: winuser.h:519
#define IDR_MENU_SCIENTIFIC_1
Definition: resource.h:11
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
void rpn_tan(calc_number_t *c)
Definition: fun_mpfr.c:154
#define VK_F12
Definition: winuser.h:2220
void rpn_dec2dms(calc_number_t *c)
Definition: fun_mpfr.c:440
const GLubyte * c
Definition: glext.h:8905
#define WM_KEYUP
Definition: winuser.h:1692
unsigned int UINT
Definition: ndis.h:50
#define SetWindowsHookEx
Definition: winuser.h:5722
#define IDS_AUTHOR
Definition: resource.h:6
#define IDM_VIEW_CONVERSION
Definition: resource.h:380
unsigned short WORD
Definition: ntddk_ex.h:93
int WINAPI GetSystemMetrics(_In_ int)
void rpn_s_m1(calc_number_t *c)
Definition: fun_mpfr.c:408
#define BN_CLICKED
Definition: winuser.h:1886
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
#define KEY_IS_UP
Definition: winmain.c:26
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
void rpn_sign(calc_number_t *c)
Definition: fun_mpfr.c:280
#define ShellAbout
Definition: shellapi.h:678
BOOL sci_in
Definition: calc.h:134
int eval_parent_count(void)
Definition: rpn.c:432
void rpn_2pi(calc_number_t *c)
Definition: fun_mpfr.c:274
unsigned int last_operator
Definition: calc.h:146
static DWORD cb
Definition: integrity.c:41
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
void rpn_sinh(calc_number_t *c)
Definition: fun_mpfr.c:192
#define IDC_BUTTON_XeY
Definition: resource.h:34
DWORD base
Definition: calc.h:107
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl.c:3
#define VK_F3
Definition: winuser.h:2211
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
calc_number_t number
Definition: calc.h:84
#define IDC_BUTTON_SUB
Definition: resource.h:64
#define IDC_BUTTON_STA
Definition: resource.h:22
#define IDC_BUTTON_A
Definition: resource.h:51
#define IDC_BUTTON_LSH
Definition: resource.h:69
static int get_modifiers(HWND hwnd)
Definition: winmain.c:608
#define VK_F8
Definition: winuser.h:2216
static void run_mp(calc_number_t *c)
Definition: winmain.c:1066
WORD idc
Definition: winmain.c:43
#define WPARAM
Definition: msvc.h:37
static const WCHAR L[]
Definition: oid.c:1087
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define ALT_FLAG
Definition: winmain.c:54
static void run_canc(calc_number_t *c)
Definition: winmain.c:1188
#define CTRL_P
Definition: winmain.c:61
#define IDC_BUTTON_CONVERT
Definition: resource.h:98
#define IDC_BUTTON_F
Definition: resource.h:76
static int state
Definition: maze.c:121
static DWORD layout
Definition: bitmap.c:46
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define IDC_BUTTON_4
Definition: resource.h:48
GLenum GLsizei len
Definition: glext.h:6722
void exec_closeparent(calc_number_t *)
Definition: rpn.c:411
GLdouble s
Definition: gl.h:2039
#define IDC_BUTTON_RET
Definition: resource.h:91
static void handle_context_menu(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1150
void rpn_cos(calc_number_t *c)
Definition: fun_mpfr.c:130
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
static void CopyMemToClipboard(void *ptr)
Definition: winmain.c:951
#define WM_COMMAND
Definition: winuser.h:1716
#define BITMASK_OCT_MASK
Definition: winmain.c:34
UINT_PTR HKL
Definition: msctf.idl:101
void rpn_atan(calc_number_t *c)
Definition: fun_mpfr.c:186
static void handle_copy_command(HWND hWnd)
Definition: winmain.c:971
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define VK_BACK
Definition: winuser.h:2152
#define MF_UNCHECKED
Definition: winuser.h:204
#define IDC_BUTTON_8
Definition: resource.h:52
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define IDD_DIALOG_CONVERSION
Definition: resource.h:10
#define IDC_BUTTON_XOR
Definition: resource.h:73
#define IDM_VIEW_HEX
Definition: resource.h:366
#define WINAPI
Definition: msvc.h:20
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)
#define MAKE_BITMASK5(_transl, _is_stats, _is_ctrl, _show_b16, _show_b10, _show_b8, _show_b2)
Definition: winmain.c:17
#define BS_PUSHBUTTON
Definition: pedump.c:651
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define IDC_BUTTON_RIGHTPAR
Definition: resource.h:37
#define WM_START_CONV
Definition: calc.h:20
#define IDC_BUTTON_RSH
Definition: resource.h:103
unsigned char BYTE
Definition: ntddk_ex.h:96
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDC_BUTTON_MR
Definition: resource.h:43
GLenum GLint * range
Definition: glext.h:7539
#define IDC_BUTTON_E
Definition: resource.h:71
char * data
Definition: calc.h:100
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
short sh
Definition: format.c:272
#define GWL_STYLE
Definition: winuser.h:846
#define _stprintf
Definition: utility.h:124
#define GetClassName
Definition: winuser.h:5649
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:784
static void prepare_rpn_result(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: winmain.c:588
void rpn_exp10(calc_number_t *c)
Definition: fun_mpfr.c:315
HWND WINAPI GetParent(_In_ HWND)
void flush_postfix(void)
Definition: rpn.c:445
#define IDC_BUTTON_LOG
Definition: resource.h:39
#define RegOpenKeyEx
Definition: winreg.h:520
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define TEXT(s)
Definition: k32.h:26
#define CTRL_D
Definition: winmain.c:58
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define LoadMenu
Definition: winuser.h:5683
INT INT dy
Definition: msvc.h:65
INT x
Definition: msvc.h:62
calc_number_t num
Definition: calc.h:106
#define HC_ACTION
Definition: winuser.h:48
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:586
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
HWND hStatWnd
Definition: calc.h:142
static void display_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:598
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
DWORD base
Definition: calc.h:86
#define BITMASK_IS_CTRL
Definition: winmain.c:31
#define WM_HANDLE_CLIPBOARD
Definition: calc.h:17
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define IDC_BUTTON_DMS
Definition: resource.h:28
static const key3code_t key2code[]
Definition: winmain.c:68
static const function_table_t function_table[]
Definition: winmain.c:195
rpn_callback1 inv_hyp
Definition: winmain.c:180
static void save_config(void)
Definition: winmain.c:286
#define IDC_RADIO_DWORD
Definition: resource.h:78
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
Definition: winmain.c:1785
#define IDC_LIST_STAT
Definition: resource.h:90
BOOL is_memory
Definition: calc.h:131
#define LB_GETCURSEL
Definition: winuser.h:2000
#define IDM_VIEW_DEG
Definition: resource.h:370
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static char * handle_sequence_input(HWND hwnd, sequence_t *seq)
Definition: winmain.c:1000
#define GetMessage
Definition: winuser.h:5656
#define CBN_SELCHANGE
Definition: winuser.h:1940
static void build_operand(HWND hwnd, DWORD idc)
Definition: winmain.c:524
void rpn_fact(calc_number_t *c)
Definition: fun_mpfr.c:242
HANDLE WINAPI GetClipboardData(_In_ UINT)
#define VK_F1
Definition: winuser.h:2209
#define BST_CHECKED
Definition: winuser.h:197
static void run_lpar(calc_number_t *c)
Definition: winmain.c:1205
#define GMEM_DDESHARE
Definition: winbase.h:295
TCHAR source[MAX_CALC_SIZE]
Definition: calc.h:125
#define IDC_CHECK_HYP
Definition: resource.h:21
#define WM_DRAWITEM
Definition: winuser.h:1627
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI GetFocus(void)
Definition: window.c:1860
#define CTRL_C
Definition: winmain.c:57
#define IDC_BUTTON_TAN
Definition: resource.h:31
BYTE mask
Definition: winmain.c:49
#define IDC_BUTTON_D
Definition: resource.h:66
#define IDD_DIALOG_STAT
Definition: resource.h:9
#define CTRL_A
Definition: winmain.c:56
#define IDC_RADIO_RAD
Definition: resource.h:82
#define IDC_BUTTON_MS
Definition: resource.h:44
#define IDC_BUTTON_ADD
Definition: resource.h:65
#define ODS_SELECTED
Definition: winuser.h:2499
#define GetTextExtentPoint32
Definition: wingdi.h:4449
#define SendMessage
Definition: winuser.h:5709
#define WH_KEYBOARD
Definition: winuser.h:32
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
void rpn_sin(calc_number_t *c)
Definition: fun_mpfr.c:106
#define ODT_BUTTON
Definition: winuser.h:2494
#define IDC_BUTTON_5
Definition: resource.h:53
static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:1261
#define CALC_CLR_PURP
Definition: winmain.c:39
#define c
Definition: ke_i.h:80
#define HIWORD(l)
Definition: typedefs.h:246
static void run_mm(calc_number_t *c)
Definition: winmain.c:1076
LONG bottom
Definition: windef.h:299
#define CTRL_Z
Definition: winmain.c:66
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
Definition: main.c:8
#define IDC_BUTTON_AVE
Definition: resource.h:23
#define malloc
Definition: debug_ros.c:4
void rpn_sum(calc_number_t *c)
Definition: fun_mpfr.c:358
#define LOCAL_EXP_SIZE
Definition: calc.h:34
#define IDC_BUTTON_LEFTPAR
Definition: resource.h:32
calc_node_t memory
Definition: calc.h:129
#define WM_HANDLE_TO
Definition: calc.h:22
#define IDC_TEXT_OUTPUT
Definition: resource.h:87
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
void(* rpn_callback1)(calc_number_t *)
Definition: winmain.c:171
#define CTRL_S
Definition: winmain.c:63
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define BITMASK_HEX_MASK
Definition: winmain.c:32
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define IDM_HELP_HELP
Definition: resource.h:374
#define IDM_VIEW_WORD
Definition: resource.h:377
#define LoadIcon
Definition: winuser.h:5679
#define HH_DISPLAY_TEXT_POPUP
Definition: htmlhelp.h:37
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
#define BITMASK_IS_STATS
Definition: winmain.c:30
#define IDC_BUTTON_SIGN
Definition: resource.h:55
LONG_PTR LRESULT
Definition: windef.h:209
#define IDC_RADIO_OCT
Definition: resource.h:18
#define IDC_BUTTON_COS
Definition: resource.h:30
static void clean_stat_list(void)
Definition: winmain.c:825
#define LB_DELETESTRING
Definition: winuser.h:1993
DWORD COLORREF
Definition: windef.h:290
static char * ReadConversion(const char *formula)
Definition: winmain.c:859
void stop_rpn_engine(void)
Definition: rpn.c:459
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811
#define BITMASK_IS_ASCII
Definition: winmain.c:29
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:539
HMENU WINAPI GetMenu(_In_ HWND)
#define HtmlHelp
Definition: htmlhelp.h:425
#define IDC_BUTTON_DAT
Definition: resource.h:26
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LONG cy
Definition: windef.h:325
static const key2code_t key2code_base10[]
Definition: winmain.c:148
#define IDC_BUTTON_C
Definition: resource.h:61
void rpn_exp3(calc_number_t *c)
Definition: fun_mpfr.c:291
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define CTRL_FLAG
Definition: winmain.c:53
int k
Definition: mpi.c:3369
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define RegSetValueEx
Definition: winreg.h:533
#define LoadString
Definition: winuser.h:5685
#define RegCreateKeyEx
Definition: winreg.h:501
#define IDS_CALC_NAME
Definition: resource.h:3
#define IDC_BUTTON_CD
Definition: resource.h:93
void rpn_reci(calc_number_t *c)
Definition: fun_mpfr.c:234
#define CTRL_L
Definition: winmain.c:59
static char * ReadClipboard(void)
Definition: winmain.c:981
#define CreateDialog
Definition: winuser.h:5615
#define __int64
Definition: basetyps.h:16
sequence_t Clipboard
Definition: calc.h:144
#define IDC_RADIO_BYTE
Definition: resource.h:80
#define ICON_BIG
Definition: tnclass.cpp:51
struct task_struct * current
Definition: linux.c:32
void rpn_asinh(calc_number_t *c)
Definition: fun_mpfr.c:208
calc_number_t prev
Definition: calc.h:128
void apply_int_mask(calc_number_t *a)
Definition: fun_mpfr.c:3
#define IDC_BUTTON_DIV
Definition: resource.h:62
Definition: path.c:42
#define BITMASK_BIN_MASK
Definition: winmain.c:35
void rpn_tanh(calc_number_t *c)
Definition: fun_mpfr.c:202
#define IDS_QUICKHELP
Definition: resource.h:5
void rpn_alloc(calc_number_t *c)
Definition: fun_mpfr.c:482
INT dx
Definition: msvc.h:65