ReactOS 0.4.16-dev-297-gc569aee
calc.h
Go to the documentation of this file.
1#pragma once
2
3#define WIN32_LEAN_AND_MEAN
4#include <windows.h>
5#include <tchar.h>
6#include <commctrl.h>
7#include <shellapi.h>
8
9#include <stdio.h>
10#include <string.h>
11#include <math.h>
12#include <float.h>
13#include <malloc.h>
14#ifndef DISABLE_HTMLHELP_SUPPORT
15#include <htmlhelp.h>
16#endif
17#include <limits.h>
18#include <strsafe.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
65void 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
77void 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
101enum {
105
118
121
122typedef union {
123#ifdef ENABLE_MULTI_PRECISION
124 mpfr_t mf;
125#else
126 double f;
129#endif
131
132typedef struct {
134 unsigned int operation;
137
139 calc_node_t *b, unsigned int operation);
140int exec_infix2postfix(calc_number_t *, unsigned int);
142int eval_parent_count(void);
143void flush_postfix(void);
144void exec_change_infix(void);
145void start_rpn_engine(void);
146void stop_rpn_engine(void);
147
148typedef struct {
149 char *data;
150 char *ptr;
152} sequence_t;
153
154typedef struct {
157 void *next;
159
160enum {
164};
165
166typedef 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
207extern 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
224#endif
225void rpn_sin(calc_number_t *c);
226void rpn_cos(calc_number_t *c);
227void rpn_tan(calc_number_t *c);
238void rpn_int(calc_number_t *c);
242void rpn_not(calc_number_t *c);
243void rpn_pi(calc_number_t *c);
244void rpn_2pi(calc_number_t *c);
250void rpn_exp(calc_number_t *c);
252void rpn_ln(calc_number_t *c);
253void rpn_log(calc_number_t *c);
254void rpn_ave(calc_number_t *c);
256void rpn_sum(calc_number_t *c);
258void rpn_s(calc_number_t *c);
267
268//
269
272void convert_real_integer(unsigned int base);
273
274//
275
277
278//
279
280void ConvExecute(HWND hWnd);
281void ConvAdjust(HWND hWnd, int n_cat);
282void ConvInit(HWND hWnd);
unsigned long long UINT64
signed long long INT64
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
operation
Definition: copy.c:29
#define __int64
Definition: basetyps.h:16
void rpn_2pi(calc_number_t *c)
Definition: fun_ieee.c:295
BOOL(WINAPI * type_IsThemeBackgroundPartiallyTransparent)(HTHEME, int, int)
Definition: calc.h:84
@ RPN_OPERATOR_NONE
Definition: calc.h:119
@ RPN_OPERATOR_POW
Definition: calc.h:116
@ RPN_OPERATOR_AND
Definition: calc.h:108
@ RPN_OPERATOR_OR
Definition: calc.h:106
@ RPN_OPERATOR_SQR
Definition: calc.h:117
@ RPN_OPERATOR_XOR
Definition: calc.h:107
@ RPN_OPERATOR_SUB
Definition: calc.h:112
@ RPN_OPERATOR_LSH
Definition: calc.h:109
@ RPN_OPERATOR_MULT
Definition: calc.h:113
@ RPN_OPERATOR_EQUAL
Definition: calc.h:104
@ RPN_OPERATOR_PERCENT
Definition: calc.h:103
@ RPN_OPERATOR_DIV
Definition: calc.h:114
@ RPN_OPERATOR_PARENT
Definition: calc.h:102
@ RPN_OPERATOR_RSH
Definition: calc.h:110
@ RPN_OPERATOR_ADD
Definition: calc.h:111
@ RPN_OPERATOR_MOD
Definition: calc.h:115
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
#define MAX_CALC_SIZE
Definition: calc.h:49
void rpn_ln(calc_number_t *c)
Definition: fun_ieee.c:421
void start_rpn_engine(void)
Definition: rpn_ieee.c:479
void rpn_pi(calc_number_t *c)
Definition: fun_ieee.c:290
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl_ieee.c:23
void rpn_free(calc_number_t *c)
Definition: fun_ieee.c:605
HRESULT(WINAPI * type_DrawThemeBackground)(HTHEME, HDC, int, int, const RECT *, const RECT *)
Definition: calc.h:81
void rpn_sinh(calc_number_t *c)
Definition: fun_ieee.c:163
HTHEME(WINAPI * type_OpenThemeData)(HWND, const WCHAR *)
Definition: calc.h:79
HWND(WINAPI * type_HtmlHelpA)(HWND, LPCSTR, UINT, DWORD)
Definition: calc.h:52
type_DrawThemeParentBackground calc_DrawThemeParentBackground
Definition: theme.c:57
void HtmlHelp_Stop(void)
Definition: htmlhelp.c:60
void rpn_frac(calc_number_t *c)
Definition: fun_ieee.c:209
BOOL(WINAPI * type_IsAppThemed)(void)
Definition: calc.h:82
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26
void convert_text2number_2(calc_number_t *a)
Definition: utl_ieee.c:86
void rpn_tan(calc_number_t *c)
Definition: fun_ieee.c:131
type_OpenThemeData calc_OpenThemeData
Definition: theme.c:50
void rpn_dec2dms(calc_number_t *c)
Definition: fun_ieee.c:577
void ConvExecute(HWND hWnd)
Definition: convert.c:568
void rpn_sqrt(calc_number_t *c)
Definition: fun_ieee.c:358
HRESULT(WINAPI * type_DrawThemeParentBackground)(HWND, HDC, RECT *)
Definition: calc.h:85
void rpn_exp3(calc_number_t *c)
Definition: fun_ieee.c:318
void rpn_exp2(calc_number_t *c)
Definition: fun_ieee.c:308
void HtmlHelp_Start(HINSTANCE hInstance)
Definition: htmlhelp.c:50
void ConvInit(HWND hWnd)
Definition: convert.c:650
void Theme_Start(HINSTANCE hInstance)
Definition: theme.c:105
void rpn_int(calc_number_t *c)
Definition: fun_ieee.c:201
void rpn_cbrt(calc_number_t *c)
Definition: fun_ieee.c:387
double logic_int2dbl(calc_number_t *a)
Definition: fun_ieee.c:275
void rpn_alloc(calc_number_t *c)
Definition: fun_ieee.c:601
void rpn_asin(calc_number_t *c)
Definition: fun_ieee.c:144
void rpn_sin(calc_number_t *c)
Definition: fun_ieee.c:101
void rpn_reci(calc_number_t *c)
Definition: fun_ieee.c:216
void exec_change_infix(void)
Definition: rpn_ieee.c:422
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: aboutdlg.c:11
HRESULT(WINAPI * type_CloseThemeData)(HTHEME)
Definition: calc.h:80
void rpn_exp(calc_number_t *c)
Definition: fun_ieee.c:400
void rpn_sign(calc_number_t *c)
Definition: fun_ieee.c:300
BOOL(WINAPI * type_IsThemeActive)(void)
Definition: calc.h:83
void rpn_atan(calc_number_t *c)
Definition: fun_ieee.c:156
void rpn_asinh(calc_number_t *c)
Definition: fun_ieee.c:182
void rpn_cosh(calc_number_t *c)
Definition: fun_ieee.c:169
void rpn_ave2(calc_number_t *c)
Definition: fun_ieee.c:483
void rpn_fact(calc_number_t *c)
Definition: fun_ieee.c:224
void rpn_log(calc_number_t *c)
Definition: fun_ieee.c:429
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
void exec_closeparent(calc_number_t *)
Definition: rpn_ieee.c:436
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:621
void rpn_acos(calc_number_t *c)
Definition: fun_ieee.c:150
type_HtmlHelpA calc_HtmlHelpA
Definition: htmlhelp.c:33
type_DrawThemeBackground calc_DrawThemeBackground
Definition: theme.c:52
HWND(WINAPI * type_HtmlHelpW)(HWND, LPCWSTR, UINT, DWORD)
Definition: calc.h:53
void rpn_s(calc_number_t *c)
Definition: fun_ieee.c:553
void rpn_tanh(calc_number_t *c)
Definition: fun_ieee.c:175
calc_t calc
Definition: winmain.c:247
int eval_parent_count(void)
Definition: rpn_ieee.c:457
void rpn_sum(calc_number_t *c)
Definition: fun_ieee.c:499
void Theme_Stop(void)
Definition: theme.c:120
int rpn_is_zero(calc_number_t *c)
Definition: fun_ieee.c:596
void rpn_dms2dec(calc_number_t *c)
Definition: fun_ieee.c:563
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn_ieee.c:391
void rpn_ave(calc_number_t *c)
Definition: fun_ieee.c:467
type_IsThemeBackgroundPartiallyTransparent calc_IsThemeBackgroundPartiallyTransparent
Definition: theme.c:55
void rpn_s_m1(calc_number_t *c)
Definition: fun_ieee.c:558
void convert_real_integer(unsigned int base)
Definition: utl_ieee.c:112
type_HtmlHelpW calc_HtmlHelpW
Definition: htmlhelp.c:34
void rpn_cos(calc_number_t *c)
Definition: fun_ieee.c:116
void rpn_sum2(calc_number_t *c)
Definition: fun_ieee.c:509
BOOL rpn_validate_result(calc_number_t *c)
@ CALC_LAYOUT_SCIENTIFIC
Definition: calc.h:161
@ CALC_LAYOUT_STANDARD
Definition: calc.h:162
@ CALC_LAYOUT_CONVERSION
Definition: calc.h:163
void stop_rpn_engine(void)
Definition: rpn_ieee.c:484
type_CloseThemeData calc_CloseThemeData
Definition: theme.c:51
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
void rpn_exp10(calc_number_t *c)
Definition: fun_ieee.c:407
void rpn_acosh(calc_number_t *c)
Definition: fun_ieee.c:188
void rpn_atanh(calc_number_t *c)
Definition: fun_ieee.c:194
type_IsThemeActive calc_IsThemeActive
Definition: theme.c:54
type_IsAppThemed calc_IsAppThemed
Definition: theme.c:53
void flush_postfix(void)
Definition: rpn_ieee.c:470
void rpn_not(calc_number_t *c)
Definition: fun_ieee.c:280
HINSTANCE hInstance
Definition: charmap.c:19
HANDLE HWND
Definition: compat.h:19
#define CALLBACK
Definition: compat.h:35
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLenum dst
Definition: glext.h:6340
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLuint64EXT * result
Definition: glext.h:11304
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
unsigned int operation
Definition: calc.h:134
calc_number_t number
Definition: calc.h:133
DWORD base
Definition: calc.h:135
Definition: calc.h:166
HWND hWnd
Definition: calc.h:171
DWORD degr
Definition: calc.h:191
HINSTANCE hInstance
Definition: calc.h:167
signed int y_coord
Definition: calc.h:204
DWORD layout
Definition: calc.h:174
BOOL sci_in
Definition: calc.h:185
calc_node_t memory
Definition: calc.h:180
unsigned int prev_operator
Definition: calc.h:198
unsigned int sThousand_len
Definition: calc.h:202
unsigned int last_operator
Definition: calc.h:197
DWORD action
Definition: calc.h:192
BOOL is_nan
Definition: calc.h:183
calc_number_t code
Definition: calc.h:178
HICON hSmIcon
Definition: calc.h:173
BOOL usesep
Definition: calc.h:186
signed int esp
Definition: calc.h:188
signed int x_coord
Definition: calc.h:203
calc_number_t prev
Definition: calc.h:179
statistic_t * stat
Definition: calc.h:181
sequence_t Clipboard
Definition: calc.h:195
HICON hBgIcon
Definition: calc.h:172
HWND hStatWnd
Definition: calc.h:193
BOOL sci_out
Definition: calc.h:184
DWORD size
Definition: calc.h:190
TCHAR * ptr
Definition: calc.h:177
BOOL is_memory
Definition: calc.h:182
unsigned int sDecimal_len
Definition: calc.h:201
HWND hConvWnd
Definition: calc.h:194
DWORD base
Definition: calc.h:189
BOOL is_menu_on
Definition: calc.h:187
char * data
Definition: calc.h:149
char * ptr
Definition: calc.h:150
UINT wm_msg
Definition: calc.h:151
calc_number_t num
Definition: calc.h:155
void * next
Definition: calc.h:157
DWORD base
Definition: calc.h:156
int32_t INT_PTR
Definition: typedefs.h:64
UINT64 u
Definition: calc.h:128
INT64 i
Definition: calc.h:127
double f
Definition: calc.h:126
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
char TCHAR
Definition: xmlstorage.h:189
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185