ReactOS  0.4.14-dev-52-g6116262
calc.h
Go to the documentation of this file.
1 #ifndef __CALC_H__
2 #define __CALC_H__
3 
4 #define WIN32_LEAN_AND_MEAN
5 #include <windows.h>
6 #include <tchar.h>
7 #include <commctrl.h>
8 #include <shellapi.h>
9 
10 #include <stdio.h>
11 #include <string.h>
12 #include <math.h>
13 #include <float.h>
14 #include <malloc.h>
15 #ifndef DISABLE_HTMLHELP_SUPPORT
16 #include <htmlhelp.h>
17 #endif
18 #include <limits.h>
19 
20 /* RESOURCES */
21 #include "resource.h"
22 
23 /* Messages reserved for the main dialog */
24 #define WM_CLOSE_STATS (WM_APP+1)
25 #define WM_HANDLE_CLIPBOARD (WM_APP+2)
26 #define WM_INSERT_STAT (WM_APP+3)
27 #define WM_LOAD_STAT (WM_APP+4)
28 #define WM_START_CONV (WM_APP+5)
29 #define WM_HANDLE_FROM (WM_APP+6)
30 #define WM_HANDLE_TO (WM_APP+7)
31 
32 /* GNU MULTI-PRECISION LIBRARY support */
33 #ifdef ENABLE_MULTI_PRECISION
34 #include "mpfr.h"
35 
36 #ifndef MPFR_DEFAULT_RND
37 #define MPFR_DEFAULT_RND mpfr_get_default_rounding_mode ()
38 #endif
39 
40 #define LOCAL_EXP_SIZE 100000000L
41 #else
42 
43 #define LOCAL_EXP_SIZE 10000L
44 
45 #endif
46 
47 #define CALC_VERSION _T("1.12")
48 
49 #define MAX_CALC_SIZE 256
50 
51 /* HTMLHELP SUPPORT */
54 
57 
58 #ifndef UNICODE
59 #define calc_HtmlHelp calc_HtmlHelpA
60 #else
61 #define calc_HtmlHelp calc_HtmlHelpW
62 #endif
63 
65 void HtmlHelp_Stop(void);
66 
67 /* THEMING SUPPORT */
68 #if (_WIN32_WINNT >= 0x0600)
69 #include <vssym32.h>
70 #include <vsstyle.h>
71 #else
72 #include <tmschema.h>
73 #endif
74 #include <uxtheme.h>
75 
77 void Theme_Stop(void);
78 
86 
94 
95 /*#define USE_KEYBOARD_HOOK*/
96 
97 #define SIZEOF(_ar) (sizeof(_ar)/sizeof(_ar[1]))
98 
99 // RPN.C
100 
101 enum {
105 
118 
120 };
121 
122 typedef union {
123 #ifdef ENABLE_MULTI_PRECISION
124  mpfr_t mf;
125 #else
126  double f;
129 #endif
130 } calc_number_t;
131 
132 typedef struct {
134  unsigned int operation;
136 } calc_node_t;
137 
139  calc_node_t *b, unsigned int operation);
140 int exec_infix2postfix(calc_number_t *, unsigned int);
142 int eval_parent_count(void);
143 void flush_postfix(void);
144 void exec_change_infix(void);
145 void start_rpn_engine(void);
146 void stop_rpn_engine(void);
147 
148 typedef struct {
149  char *data;
150  char *ptr;
152 } sequence_t;
153 
154 typedef struct {
157  void *next;
158 } statistic_t;
159 
160 enum {
164 };
165 
166 typedef struct {
168 #ifdef USE_KEYBOARD_HOOK
169  HHOOK hKeyboardHook;
170 #endif
188  signed int esp;
196  sequence_t Convert[2];
197  unsigned int last_operator;
198  unsigned int prev_operator;
199  TCHAR sDecimal[8];
200  TCHAR sThousand[8];
201  unsigned int sDecimal_len;
202  unsigned int sThousand_len;
203  signed int x_coord;
204  signed int y_coord;
205 } calc_t;
206 
207 extern calc_t calc;
208 
209 /* IEEE constants */
210 #define CALC_E 2.718281828459045235360
211 #define CALC_PI_2 1.570796326794896619231
212 #define CALC_PI 3.141592653589793238462
213 #define CALC_3_PI_2 4.712388980384689857694
214 #define CALC_2_PI 6.283185307179586476925
215 
216 #define MODIFIER_INV 0x01
217 #define MODIFIER_HYP 0x02
218 #define NO_CHAIN 0x04
219 
221 #ifndef ENABLE_MULTI_PRECISION
223 double logic_int2dbl(calc_number_t *a);
224 #endif
225 void rpn_sin(calc_number_t *c);
226 void rpn_cos(calc_number_t *c);
227 void rpn_tan(calc_number_t *c);
228 void rpn_asin(calc_number_t *c);
229 void rpn_acos(calc_number_t *c);
230 void rpn_atan(calc_number_t *c);
231 void rpn_sinh(calc_number_t *c);
232 void rpn_cosh(calc_number_t *c);
233 void rpn_tanh(calc_number_t *c);
234 void rpn_asinh(calc_number_t *c);
235 void rpn_acosh(calc_number_t *c);
236 void rpn_atanh(calc_number_t *c);
238 void rpn_int(calc_number_t *c);
239 void rpn_frac(calc_number_t *c);
240 void rpn_reci(calc_number_t *c);
241 void rpn_fact(calc_number_t *c);
242 void rpn_not(calc_number_t *c);
243 void rpn_pi(calc_number_t *c);
244 void rpn_2pi(calc_number_t *c);
245 void rpn_sign(calc_number_t *c);
246 void rpn_exp2(calc_number_t *c);
247 void rpn_exp3(calc_number_t *c);
248 void rpn_sqrt(calc_number_t *c);
249 void rpn_cbrt(calc_number_t *c);
250 void rpn_exp(calc_number_t *c);
251 void rpn_exp10(calc_number_t *c);
252 void rpn_ln(calc_number_t *c);
253 void rpn_log(calc_number_t *c);
254 void rpn_ave(calc_number_t *c);
255 void rpn_ave2(calc_number_t *c);
256 void rpn_sum(calc_number_t *c);
257 void rpn_sum2(calc_number_t *c);
258 void rpn_s(calc_number_t *c);
259 void rpn_s_m1(calc_number_t *c);
262 void rpn_zero(calc_number_t *c);
265 void rpn_alloc(calc_number_t *c);
266 void rpn_free(calc_number_t *c);
267 
268 //
269 
270 void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base);
272 void convert_real_integer(unsigned int base);
273 
274 //
275 
277 
278 //
279 
280 void ConvExecute(HWND hWnd);
281 void ConvAdjust(HWND hWnd, int n_cat);
282 void ConvInit(HWND hWnd);
283 
284 #endif /* __CALC_H__ */
void rpn_ave2(calc_number_t *c)
Definition: fun_ieee.c:483
void rpn_s(calc_number_t *c)
Definition: fun_ieee.c:553
statistic_t * stat
Definition: calc.h:181
#define HRESULT
Definition: msvc.h:9
DWORD base
Definition: calc.h:189
void rpn_pi(calc_number_t *c)
Definition: fun_ieee.c:290
UINT64 u
Definition: calc.h:128
static HICON
Definition: imagelist.c:84
void rpn_sum2(calc_number_t *c)
Definition: fun_ieee.c:509
void Theme_Start(HINSTANCE hInstance)
Definition: theme.c:105
void rpn_acosh(calc_number_t *c)
Definition: fun_ieee.c:188
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
UINT wm_msg
Definition: calc.h:151
HRESULT(WINAPI * type_CloseThemeData)(HTHEME)
Definition: calc.h:80
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
BOOL sci_out
Definition: calc.h:184
type_IsAppThemed calc_IsAppThemed
Definition: theme.c:53
calc_number_t code
Definition: calc.h:178
void rpn_cbrt(calc_number_t *c)
Definition: fun_ieee.c:387
Definition: calc.h:166
BOOL is_menu_on
Definition: calc.h:187
DWORD layout
Definition: calc.h:174
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
void rpn_atanh(calc_number_t *c)
Definition: fun_ieee.c:194
void HtmlHelp_Start(HINSTANCE hInstance)
Definition: htmlhelp.c:50
void rpn_sqrt(calc_number_t *c)
Definition: fun_ieee.c:358
TCHAR * ptr
Definition: calc.h:177
void HtmlHelp_Stop(void)
Definition: htmlhelp.c:60
double f
Definition: calc.h:126
type_IsThemeBackgroundPartiallyTransparent calc_IsThemeBackgroundPartiallyTransparent
Definition: theme.c:55
unsigned int sThousand_len
Definition: calc.h:202
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
void rpn_free(calc_number_t *c)
Definition: fun_ieee.c:605
type_DrawThemeBackground calc_DrawThemeBackground
Definition: theme.c:52
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:13
void rpn_exp(calc_number_t *c)
Definition: fun_ieee.c:400
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
void convert_real_integer(unsigned int base)
Definition: utl_ieee.c:112
GLuint buffer
Definition: glext.h:5915
HICON hBgIcon
Definition: calc.h:172
DWORD degr
Definition: calc.h:191
type_HtmlHelpA calc_HtmlHelpA
Definition: htmlhelp.c:33
UINT_PTR WPARAM
Definition: windef.h:207
void ConvInit(HWND hWnd)
Definition: convert.c:650
double logic_int2dbl(calc_number_t *a)
Definition: fun_ieee.c:275
int32_t INT_PTR
Definition: typedefs.h:62
BOOL is_nan
Definition: calc.h:183
#define BOOL
Definition: nt_native.h:43
signed int esp
Definition: calc.h:188
void rpn_asin(calc_number_t *c)
Definition: fun_ieee.c:144
void rpn_dms2dec(calc_number_t *c)
Definition: fun_ieee.c:563
#define DWORD
Definition: nt_native.h:44
void rpn_frac(calc_number_t *c)
Definition: fun_ieee.c:209
void rpn_exp2(calc_number_t *c)
Definition: fun_ieee.c:308
void rpn_not(calc_number_t *c)
Definition: fun_ieee.c:280
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
DWORD action
Definition: calc.h:192
void convert_text2number_2(calc_number_t *a)
Definition: utl_ieee.c:86
HINSTANCE hInstance
Definition: charmap.c:20
void exec_change_infix(void)
Definition: rpn_ieee.c:422
type_IsThemeActive calc_IsThemeActive
Definition: theme.c:54
type_DrawThemeParentBackground calc_DrawThemeParentBackground
Definition: theme.c:57
unsigned int BOOL
Definition: ntddk_ex.h:94
void ConvExecute(HWND hWnd)
Definition: convert.c:568
DWORD size
Definition: calc.h:190
signed int y_coord
Definition: calc.h:204
void rpn_log(calc_number_t *c)
Definition: fun_ieee.c:429
BOOL(WINAPI * type_IsAppThemed)(void)
Definition: calc.h:82
HRESULT(WINAPI * type_DrawThemeParentBackground)(HWND, HDC, RECT *)
Definition: calc.h:85
unsigned int prev_operator
Definition: calc.h:198
LONG_PTR LPARAM
Definition: windef.h:208
HINSTANCE hInstance
Definition: calc.h:167
signed int x_coord
Definition: calc.h:203
HTHEME(WINAPI * type_OpenThemeData)(HWND, const WCHAR *)
Definition: calc.h:79
const char * LPCSTR
Definition: xmlstorage.h:183
void rpn_acos(calc_number_t *c)
Definition: fun_ieee.c:150
void rpn_ave(calc_number_t *c)
Definition: fun_ieee.c:467
void start_rpn_engine(void)
Definition: rpn_ieee.c:479
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: sndrec32.cpp:83
void Theme_Stop(void)
Definition: theme.c:120
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn_ieee.c:391
char TCHAR
Definition: xmlstorage.h:189
HWND hWnd
Definition: calc.h:171
void * next
Definition: calc.h:157
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
void rpn_cosh(calc_number_t *c)
Definition: fun_ieee.c:169
GLsizeiptr size
Definition: glext.h:5919
int rpn_is_zero(calc_number_t *c)
Definition: fun_ieee.c:596
unsigned int sDecimal_len
Definition: calc.h:201
void rpn_int(calc_number_t *c)
Definition: fun_ieee.c:201
BOOL usesep
Definition: calc.h:186
__wchar_t WCHAR
Definition: xmlstorage.h:180
char * ptr
Definition: calc.h:150
INT64 i
Definition: calc.h:127
void rpn_ln(calc_number_t *c)
Definition: fun_ieee.c:421
void rpn_tan(calc_number_t *c)
Definition: fun_ieee.c:131
void rpn_dec2dms(calc_number_t *c)
Definition: fun_ieee.c:577
#define WINAPI
Definition: msvc.h:8
const GLubyte * c
Definition: glext.h:8905
void rpn_s_m1(calc_number_t *c)
Definition: fun_ieee.c:558
unsigned long DWORD
Definition: ntddk_ex.h:95
void rpn_sign(calc_number_t *c)
Definition: fun_ieee.c:300
BOOL sci_in
Definition: calc.h:185
int eval_parent_count(void)
Definition: rpn_ieee.c:457
void rpn_2pi(calc_number_t *c)
Definition: fun_ieee.c:295
unsigned int last_operator
Definition: calc.h:197
#define MAX_CALC_SIZE
Definition: calc.h:49
void rpn_sinh(calc_number_t *c)
Definition: fun_ieee.c:163
DWORD base
Definition: calc.h:156
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl_ieee.c:23
type_OpenThemeData calc_OpenThemeData
Definition: theme.c:50
calc_number_t number
Definition: calc.h:133
HICON hSmIcon
Definition: calc.h:173
signed long long INT64
HWND hConvWnd
Definition: calc.h:194
void exec_closeparent(calc_number_t *)
Definition: rpn_ieee.c:436
void rpn_cos(calc_number_t *c)
Definition: fun_ieee.c:116
GLenum src
Definition: glext.h:6340
void rpn_atan(calc_number_t *c)
Definition: fun_ieee.c:156
BOOL(WINAPI * type_IsThemeBackgroundPartiallyTransparent)(HTHEME, int, int)
Definition: calc.h:84
char * data
Definition: calc.h:149
void rpn_exp10(calc_number_t *c)
Definition: fun_ieee.c:407
void flush_postfix(void)
Definition: rpn_ieee.c:470
BOOL rpn_validate_result(calc_number_t *c)
calc_number_t num
Definition: calc.h:155
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:621
type_HtmlHelpW calc_HtmlHelpW
Definition: htmlhelp.c:34
HWND hStatWnd
Definition: calc.h:193
DWORD base
Definition: calc.h:135
GLenum GLenum dst
Definition: glext.h:6340
BOOL is_memory
Definition: calc.h:182
unsigned int UINT
Definition: ndis.h:50
unsigned int operation
Definition: calc.h:134
void rpn_fact(calc_number_t *c)
Definition: fun_ieee.c:224
#define msg(x)
Definition: auth_time.c:54
void rpn_sin(calc_number_t *c)
Definition: fun_ieee.c:101
BOOL(WINAPI * type_IsThemeActive)(void)
Definition: calc.h:83
void rpn_sum(calc_number_t *c)
Definition: fun_ieee.c:499
calc_node_t memory
Definition: calc.h:180
HWND(WINAPI * type_HtmlHelpA)(HWND, LPCSTR, UINT, DWORD)
Definition: calc.h:52
HRESULT(WINAPI * type_DrawThemeBackground)(HTHEME, HDC, int, int, const RECT *, const RECT *)
Definition: calc.h:81
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
unsigned long long UINT64
void stop_rpn_engine(void)
Definition: rpn_ieee.c:484
calc_t calc
Definition: winmain.c:247
GLuint64EXT * result
Definition: glext.h:11304
void rpn_exp3(calc_number_t *c)
Definition: fun_ieee.c:318
void rpn_reci(calc_number_t *c)
Definition: fun_ieee.c:216
HWND(WINAPI * type_HtmlHelpW)(HWND, LPCWSTR, UINT, DWORD)
Definition: calc.h:53
type_CloseThemeData calc_CloseThemeData
Definition: theme.c:51
#define __int64
Definition: basetyps.h:16
sequence_t Clipboard
Definition: calc.h:195
void rpn_asinh(calc_number_t *c)
Definition: fun_ieee.c:182
calc_number_t prev
Definition: calc.h:179
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
void rpn_tanh(calc_number_t *c)
Definition: fun_ieee.c:175
void rpn_alloc(calc_number_t *c)
Definition: fun_ieee.c:601