ReactOS  0.4.11-dev-946-g431643b
winmain.c File Reference
#include "calc.h"
#include <winbase.h>
#include <wingdi.h>
#include <winreg.h>
#include <shellapi.h>
#include <commctrl.h>
Include dependency graph for winmain.c:

Go to the source code of this file.

Classes

struct  key2code_t
 
struct  key3code_t
 
struct  function_table_t
 
struct  _update_check_menus
 
struct  radio_config_t
 

Macros

#define HTMLHELP_PATH(_pt)   TEXT("%systemroot%\\Help\\calc.chm::") TEXT(_pt)
 
#define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2)
 
#define MAKE_BITMASK5(_transl, _is_stats, _is_ctrl, _show_b16, _show_b10, _show_b8, _show_b2)
 
#define KEY_IS_UP   0x80000000
 
#define KEY_WAS_DOWN   0x40000000
 
#define BITMASK_IS_ASCII   0x80
 
#define BITMASK_IS_STATS   0x40
 
#define BITMASK_IS_CTRL   0x20
 
#define BITMASK_HEX_MASK   0x08
 
#define BITMASK_DEC_MASK   0x04
 
#define BITMASK_OCT_MASK   0x02
 
#define BITMASK_BIN_MASK   0x01
 
#define CALC_CLR_RED   0x000000FF
 
#define CALC_CLR_BLUE   0x00FF0000
 
#define CALC_CLR_PURP   0x00FF00FF
 
#define CTRL_FLAG   0x100
 
#define ALT_FLAG   0x200
 
#define CTRL_A   (0x0001+'A'-'A')
 
#define CTRL_C   (0x0001+'C'-'A')
 
#define CTRL_D   (0x0001+'D'-'A')
 
#define CTRL_L   (0x0001+'L'-'A')
 
#define CTRL_M   (0x0001+'M'-'A')
 
#define CTRL_P   (0x0001+'P'-'A')
 
#define CTRL_R   (0x0001+'R'-'A')
 
#define CTRL_S   (0x0001+'S'-'A')
 
#define CTRL_T   (0x0001+'T'-'A')
 
#define CTRL_V   (0x0001+'V'-'A')
 
#define CTRL_Z   (0x0001+'Z'-'A')
 

Typedefs

typedef void(* rpn_callback1) (calc_number_t *)
 

Functions

static void run_pow (calc_number_t *number)
 
static void run_sqr (calc_number_t *number)
 
static void run_fe (calc_number_t *number)
 
static void run_dat_sta (calc_number_t *number)
 
static void run_mp (calc_number_t *c)
 
static void run_mm (calc_number_t *c)
 
static void run_ms (calc_number_t *c)
 
static void run_mw (calc_number_t *c)
 
static void run_canc (calc_number_t *c)
 
static void run_rpar (calc_number_t *c)
 
static void run_lpar (calc_number_t *c)
 
static void load_config (void)
 
static void save_config (void)
 
static LRESULT post_key_press (LPARAM lParam, WORD idc)
 
static int vk2ascii (unsigned int vk)
 
static int process_vk_key (WPARAM wParam, LPARAM lParam)
 
static void update_lcd_display (HWND hwnd)
 
static void update_parent_display (HWND hWnd)
 
static void build_operand (HWND hwnd, DWORD idc)
 
static void prepare_rpn_result (calc_number_t *rpn, TCHAR *buffer, int size, int base)
 
static void display_rpn_result (HWND hwnd, calc_number_t *rpn)
 
static int get_modifiers (HWND hwnd)
 
static void convert_text2number (calc_number_t *a)
 
static void update_menu (HWND hwnd)
 
static void enable_allowed_controls (HWND hwnd, DWORD base)
 
static void update_radio (HWND hwnd, unsigned int base)
 
static void update_memory_flag (HWND hWnd, BOOL mem_flag)
 
static void update_n_stats_items (HWND hWnd, TCHAR *buffer)
 
static void clean_stat_list (void)
 
static void delete_stat_item (int n)
 
static charReadConversion (const char *formula)
 
static INT_PTR CALLBACK DlgStatProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 
static BOOL idm_2_idc (int idm, WPARAM *pIdc)
 
static void CopyMemToClipboard (void *ptr)
 
static void handle_copy_command (HWND hWnd)
 
static charReadClipboard (void)
 
static charhandle_sequence_input (HWND hwnd, sequence_t *seq)
 
static statistic_tupload_stat_number (int n)
 
static void handle_context_menu (HWND hWnd, WPARAM wp, LPARAM lp)
 
static LRESULT CALLBACK SubclassButtonProc (HWND hWnd, WPARAM wp, LPARAM lp)
 
static INT_PTR CALLBACK DlgMainProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 
int WINAPI _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
 

Variables

static const key3code_t key2code []
 
static const key2code_t key2code_base16 []
 
static const key2code_t key2code_base10 []
 
static const WORD operator_codes []
 
static const function_table_t function_table []
 
calc_t calc
 
static const struct _update_check_menus upd []
 
static const radio_config_t radio_setup []
 

Macro Definition Documentation

◆ ALT_FLAG

#define ALT_FLAG   0x200

Definition at line 54 of file winmain.c.

Referenced by vk2ascii().

◆ BITMASK_BIN_MASK

#define BITMASK_BIN_MASK   0x01

Definition at line 35 of file winmain.c.

Referenced by enable_allowed_controls(), and update_radio().

◆ BITMASK_DEC_MASK

#define BITMASK_DEC_MASK   0x04

Definition at line 33 of file winmain.c.

Referenced by enable_allowed_controls(), and update_radio().

◆ BITMASK_HEX_MASK

#define BITMASK_HEX_MASK   0x08

Definition at line 32 of file winmain.c.

Referenced by enable_allowed_controls(), and update_radio().

◆ BITMASK_IS_ASCII

#define BITMASK_IS_ASCII   0x80

Definition at line 29 of file winmain.c.

Referenced by handle_sequence_input(), and process_vk_key().

◆ BITMASK_IS_CTRL

#define BITMASK_IS_CTRL   0x20

Definition at line 31 of file winmain.c.

Referenced by handle_sequence_input(), and process_vk_key().

◆ BITMASK_IS_STATS

#define BITMASK_IS_STATS   0x40

Definition at line 30 of file winmain.c.

Referenced by enable_allowed_controls().

◆ BITMASK_OCT_MASK

#define BITMASK_OCT_MASK   0x02

Definition at line 34 of file winmain.c.

Referenced by enable_allowed_controls(), and update_radio().

◆ CALC_CLR_BLUE

#define CALC_CLR_BLUE   0x00FF0000

Definition at line 38 of file winmain.c.

Referenced by SubclassButtonProc().

◆ CALC_CLR_PURP

#define CALC_CLR_PURP   0x00FF00FF

Definition at line 39 of file winmain.c.

◆ CALC_CLR_RED

#define CALC_CLR_RED   0x000000FF

Definition at line 37 of file winmain.c.

◆ CTRL_A

#define CTRL_A   (0x0001+'A'-'A')

Definition at line 56 of file winmain.c.

Referenced by vk2ascii().

◆ CTRL_C

#define CTRL_C   (0x0001+'C'-'A')

Definition at line 57 of file winmain.c.

Referenced by process_vk_key().

◆ CTRL_D

#define CTRL_D   (0x0001+'D'-'A')

Definition at line 58 of file winmain.c.

◆ CTRL_FLAG

#define CTRL_FLAG   0x100

Definition at line 53 of file winmain.c.

Referenced by process_vk_key(), and vk2ascii().

◆ CTRL_L

#define CTRL_L   (0x0001+'L'-'A')

Definition at line 59 of file winmain.c.

◆ CTRL_M

#define CTRL_M   (0x0001+'M'-'A')

Definition at line 60 of file winmain.c.

◆ CTRL_P

#define CTRL_P   (0x0001+'P'-'A')

Definition at line 61 of file winmain.c.

◆ CTRL_R

#define CTRL_R   (0x0001+'R'-'A')

Definition at line 62 of file winmain.c.

◆ CTRL_S

#define CTRL_S   (0x0001+'S'-'A')

Definition at line 63 of file winmain.c.

◆ CTRL_T

#define CTRL_T   (0x0001+'T'-'A')

Definition at line 64 of file winmain.c.

◆ CTRL_V

#define CTRL_V   (0x0001+'V'-'A')

Definition at line 65 of file winmain.c.

Referenced by process_vk_key().

◆ CTRL_Z

#define CTRL_Z   (0x0001+'Z'-'A')

Definition at line 66 of file winmain.c.

Referenced by vk2ascii().

◆ HTMLHELP_PATH

#define HTMLHELP_PATH (   _pt)    TEXT("%systemroot%\\Help\\calc.chm::") TEXT(_pt)

Definition at line 9 of file winmain.c.

Referenced by DlgMainProc(), and handle_context_menu().

◆ KEY_IS_UP

#define KEY_IS_UP   0x80000000

Definition at line 26 of file winmain.c.

Referenced by post_key_press(), and process_vk_key().

◆ KEY_WAS_DOWN

#define KEY_WAS_DOWN   0x40000000

Definition at line 27 of file winmain.c.

Referenced by post_key_press().

◆ MAKE_BITMASK4

#define MAKE_BITMASK4 (   _show_b16,
  _show_b10,
  _show_b8,
  _show_b2 
)
Value:
(((_show_b2) << 0) | \
((_show_b8) << 1) | \
((_show_b10) << 2) | \
((_show_b16) << 3))

Definition at line 11 of file winmain.c.

◆ MAKE_BITMASK5

#define MAKE_BITMASK5 (   _transl,
  _is_stats,
  _is_ctrl,
  _show_b16,
  _show_b10,
  _show_b8,
  _show_b2 
)
Value:
(((_show_b2) << 0) | \
((_show_b8) << 1) | \
((_show_b10) << 2) | \
((_show_b16) << 3) | \
((_is_ctrl) << 5) | \
((_is_stats) << 6) | \
((_transl) << 7))

Definition at line 17 of file winmain.c.

Typedef Documentation

◆ rpn_callback1

typedef void(* rpn_callback1) (calc_number_t *)

Definition at line 171 of file winmain.c.

Function Documentation

◆ _tWinMain()

int WINAPI _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPTSTR  lpCmdLine,
int  nShowCmd 
)

Definition at line 1785 of file winmain.c.

1787 {
1788  MSG msg;
1789  DWORD dwLayout;
1790 
1792 
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! */
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 MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL is_menu_on
Definition: calc.h:136
DWORD layout
Definition: calc.h:123
#define IDD_DIALOG_SCIENTIFIC
Definition: resource.h:7
calc_t calc
Definition: winmain.c:226
#define IDC_STATIC
Definition: calc.h:41
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define IDD_DIALOG_STANDARD
Definition: resource.h:8
static void load_config(void)
Definition: winmain.c:228
DWORD action
Definition: calc.h:141
HINSTANCE hInstance
Definition: charmap.c:20
signed int y_coord
Definition: calc.h:153
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
HINSTANCE hInstance
Definition: calc.h:118
signed int x_coord
Definition: calc.h:152
void start_rpn_engine(void)
Definition: rpn.c:454
static int process_vk_key(WPARAM wParam, LPARAM lParam)
Definition: winmain.c:366
#define WM_KEYUP
Definition: winuser.h:1692
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDD_DIALOG_CONVERSION
Definition: resource.h:10
#define GetMessage
Definition: winuser.h:5656
#define msg(x)
Definition: auth_time.c:54
static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:1261
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
void stop_rpn_engine(void)
Definition: rpn.c:459
#define CreateDialog
Definition: winuser.h:5615

◆ build_operand()

static void build_operand ( HWND  hwnd,
DWORD  idc 
)
static

Definition at line 524 of file winmain.c.

Referenced by DlgMainProc().

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 }
DWORD base
Definition: calc.h:138
#define IDC_BUTTON_0
Definition: resource.h:50
#define IDC_RADIO_DEC
Definition: resource.h:17
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:436
#define IDC_STATIC
Definition: calc.h:41
signed int esp
Definition: calc.h:137
#define IDC_BUTTON_DOT
Definition: resource.h:60
#define IDC_RADIO_BIN
Definition: resource.h:19
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define SIZEOF(_ar)
Definition: calc.h:48
#define IDC_RADIO_HEX
Definition: resource.h:16
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
CHAR key
Definition: winmain.c:48
BOOL sci_in
Definition: calc.h:134
#define _stprintf
Definition: utility.h:124
#define TEXT(s)
Definition: k32.h:26
static const key3code_t key2code[]
Definition: winmain.c:68
#define LOCAL_EXP_SIZE
Definition: calc.h:34
#define IDC_RADIO_OCT
Definition: resource.h:18
Definition: path.c:42

◆ clean_stat_list()

static void clean_stat_list ( void  )
static

Definition at line 825 of file winmain.c.

Referenced by DlgStatProc().

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 }
statistic_t * stat
Definition: calc.h:130
calc_t calc
Definition: winmain.c:226
#define free
Definition: debug_ros.c:5
void rpn_free(calc_number_t *c)
Definition: fun_mpfr.c:487
smooth NULL
Definition: ftsmooth.c:416
void * next
Definition: calc.h:108
GLdouble s
Definition: gl.h:2039
calc_number_t num
Definition: calc.h:106
GLfloat GLfloat p
Definition: glext.h:8902

◆ convert_text2number()

static void convert_text2number ( calc_number_t a)
static

Definition at line 620 of file winmain.c.

Referenced by DlgMainProc(), and update_radio().

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 }
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
calc_number_t code
Definition: calc.h:127
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
void convert_text2number_2(calc_number_t *a)
Definition: utl.c:66
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
#define TEXT(s)
Definition: k32.h:26

◆ CopyMemToClipboard()

static void CopyMemToClipboard ( void ptr)
static

Definition at line 951 of file winmain.c.

Referenced by handle_copy_command().

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 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLuint buffer
Definition: glext.h:5915
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define CF_UNICODETEXT
Definition: constants.h:408
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
char TCHAR
Definition: xmlstorage.h:189
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_DDESHARE
Definition: winbase.h:295
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

◆ delete_stat_item()

static void delete_stat_item ( int  n)
static

Definition at line 838 of file winmain.c.

Referenced by DlgStatProc().

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 }
statistic_t * stat
Definition: calc.h:130
calc_t calc
Definition: winmain.c:226
#define free
Definition: debug_ros.c:5
void rpn_free(calc_number_t *c)
Definition: fun_mpfr.c:487
GLuint n
Definition: s_context.h:57
while(1)
Definition: macro.lex.yy.c:743
void * next
Definition: calc.h:108
GLdouble s
Definition: gl.h:2039
calc_number_t num
Definition: calc.h:106
GLfloat GLfloat p
Definition: glext.h:8902

◆ display_rpn_result()

static void display_rpn_result ( HWND  hwnd,
calc_number_t rpn 
)
static

Definition at line 598 of file winmain.c.

Referenced by DlgMainProc(), and update_radio().

599 {
600  calc.sci_in = FALSE;
603  update_lcd_display(hwnd);
604  calc.ptr = calc.buffer;
605  update_parent_display(hwnd);
606 }
DWORD base
Definition: calc.h:138
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:436
static void update_parent_display(HWND hWnd)
Definition: winmain.c:512
#define SIZEOF(_ar)
Definition: calc.h:48
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
BOOL sci_in
Definition: calc.h:134
static void prepare_rpn_result(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: winmain.c:588

◆ DlgMainProc()

static INT_PTR CALLBACK DlgMainProc ( HWND  hWnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 1261 of file winmain.c.

Referenced by _tWinMain().

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;
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);
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 */
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:
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:
1363  {
1366  DestroyWindow(hWnd);
1367  save_config();
1368 
1373  MF_BYCOMMAND);
1374  }
1375  return TRUE;
1376  case IDM_VIEW_SCIENTIFIC:
1378  {
1381  DestroyWindow(hWnd);
1382  save_config();
1383 
1388  MF_BYCOMMAND);
1389  }
1390  return TRUE;
1391  case IDM_VIEW_CONVERSION:
1393  {
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;
1433  if (calc.Clipboard.data != NULL) {
1434  /* clear the content of the display before pasting */
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  */
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]) {
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) {
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:
1599  update_memory_flag(hWnd, FALSE);
1600  return TRUE;
1601  case IDC_BUTTON_MR:
1602  if (calc.is_memory) {
1603  calc.is_nan = FALSE;
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) {
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)
1706  }
1707  }
1708  }
1709  return TRUE;
1710  case IDC_BUTTON_STA:
1711  if (IsWindow(calc.hStatWnd))
1712  break;
1715  if (calc.hStatWnd != NULL) {
1718  }
1719  return TRUE;
1720  }
1721  break;
1722  case WM_CLOSE_STATS:
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);
1732  if (calc.Convert[x].data != NULL) {
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:
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 }
#define IDC_BUTTON_1
Definition: resource.h:49
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define IDC_BUTTON_MC
Definition: resource.h:42
static INT_PTR CALLBACK DlgStatProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:881
#define IDC_BUTTON_CANC
Definition: resource.h:84
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 IDC_RADIO_DEG
Definition: resource.h:81
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define IDI_CALC_SMALL
Definition: resource.h:15
sequence_t Convert[2]
Definition: calc.h:145
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 MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define IDC_BUTTON_CE
Definition: resource.h:85
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 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
BOOL sci_out
Definition: calc.h:133
#define IDC_BUTTON_B
Definition: resource.h:56
calc_number_t code
Definition: calc.h:127
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define IDC_RADIO_GRAD
Definition: resource.h:83
rpn_callback1 inverse
Definition: winmain.c:178
#define IDC_BUTTON_MP
Definition: resource.h:45
BOOL is_menu_on
Definition: calc.h:136
DWORD layout
Definition: calc.h:123
#define IDM_VIEW_QWORD
Definition: resource.h:376
#define IDC_RADIO_DEC
Definition: resource.h:17
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define IDC_BUTTON_2
Definition: resource.h:54
#define IDM_VIEW_DEC
Definition: resource.h:367
#define IDC_BUTTON_RX
Definition: resource.h:41
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define IDC_BUTTON_EQU
Definition: resource.h:70
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:436
#define IDI_CALC_BIG
Definition: resource.h:14
#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)
rpn_callback1 direct
Definition: winmain.c:177
#define IDC_STATIC
Definition: calc.h:41
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
#define IDM_VIEW_GROUP
Definition: resource.h:373
#define IDC_BUTTON_SQRT
Definition: resource.h:96
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
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
static void enable_allowed_controls(HWND hwnd, DWORD base)
Definition: winmain.c:722
#define IDC_BUTTON_Xe3
Definition: resource.h:36
#define IDC_BUTTON_6
Definition: resource.h:58
#define IDC_BUTTON_3
Definition: resource.h:59
#define IDC_BUTTON_PI
Definition: resource.h:46
#define IDC_BUTTON_S
Definition: resource.h:25
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
#define BN_DBLCLK
Definition: winuser.h:1887
#define IDM_VIEW_GRAD
Definition: resource.h:372
#define SendDlgItemMessage
Definition: winuser.h:5708
static LRESULT CALLBACK SubclassButtonProc(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1210
LONG left
Definition: windef.h:296
void ConvInit(HWND hWnd)
Definition: convert.c:615
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 CB_GETCURSEL
Definition: winuser.h:1904
#define IDM_VIEW_STANDARD
Definition: resource.h:364
#define IDC_BUTTON_MOD
Definition: resource.h:67
#define IDC_BUTTON_FOCUS
Definition: resource.h:99
#define IDC_BUTTON_DOT
Definition: resource.h:60
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
UINT_PTR WPARAM
Definition: windef.h:207
#define ICON_SMALL
Definition: tnclass.cpp:48
#define IDC_RADIO_BIN
Definition: resource.h:19
#define MODIFIER_INV
Definition: calc.h:165
#define IDM_EDIT_PASTE
Definition: resource.h:363
DWORD action
Definition: calc.h:141
#define SM_CXSCREEN
Definition: winuser.h:949
#define IDC_BUTTON_FE
Definition: resource.h:27
#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
#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 IDM_EDIT_COPY
Definition: resource.h:362
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
#define WM_ENTERMENULOOP
Definition: winuser.h:1780
#define IDC_RADIO_HEX
Definition: resource.h:16
void ConvExecute(HWND hWnd)
Definition: convert.c:533
static PVOID ptr
Definition: dispmode.c:27
DWORD size
Definition: calc.h:139
signed int y_coord
Definition: calc.h:153
#define IDC_BUTTON_9
Definition: resource.h:57
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
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 IDC_BUTTON_OR
Definition: resource.h:68
#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
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define CF_TEXT
Definition: constants.h:396
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5698
#define IDC_BUTTON_AND
Definition: resource.h:72
static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: msg.c:16281
#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 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
TCHAR sDecimal[8]
Definition: calc.h:148
#define BM_SETCHECK
Definition: winuser.h:1882
#define IDC_BUTTON_SIN
Definition: resource.h:29
#define IDC_BUTTON_Xe2
Definition: resource.h:35
#define IDC_BUTTON_7
Definition: resource.h:47
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL usesep
Definition: calc.h:135
#define WM_LOAD_STAT
Definition: calc.h:19
char * ptr
Definition: calc.h:101
#define IDC_BUTTON_NF
Definition: resource.h:40
#define WM_CLOSE_STATS
Definition: calc.h:16
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
#define SetWindowsHookEx
Definition: winuser.h:5722
#define IDS_AUTHOR
Definition: resource.h:6
#define IDM_VIEW_CONVERSION
Definition: resource.h:380
int WINAPI GetSystemMetrics(_In_ int)
#define BN_CLICKED
Definition: winuser.h:1886
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
unsigned int last_operator
Definition: calc.h:146
static DWORD cb
Definition: integrity.c:41
#define IDC_BUTTON_XeY
Definition: resource.h:34
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 IDC_BUTTON_CONVERT
Definition: resource.h:98
#define IDC_BUTTON_F
Definition: resource.h:76
#define IDC_BUTTON_4
Definition: resource.h:48
static void handle_context_menu(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1150
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
static void handle_copy_command(HWND hWnd)
Definition: winmain.c:971
uint32_t DWORD_PTR
Definition: typedefs.h:63
#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 IDC_BUTTON_XOR
Definition: resource.h:73
#define IDM_VIEW_HEX
Definition: resource.h:366
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
#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
short sh
Definition: format.c:272
#define IDC_BUTTON_LOG
Definition: resource.h:39
#define TEXT(s)
Definition: k32.h:26
INT x
Definition: msvc.h:62
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:586
HWND hStatWnd
Definition: calc.h:142
static void display_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:598
#define WM_HANDLE_CLIPBOARD
Definition: calc.h:17
#define IDC_BUTTON_DMS
Definition: resource.h:28
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
BOOL is_memory
Definition: calc.h:131
#define IDM_VIEW_DEG
Definition: resource.h:370
static char * handle_sequence_input(HWND hwnd, sequence_t *seq)
Definition: winmain.c:1000
#define CBN_SELCHANGE
Definition: winuser.h:1940
static void build_operand(HWND hwnd, DWORD idc)
Definition: winmain.c:524
#define IDC_CHECK_HYP
Definition: resource.h:21
#define WM_DRAWITEM
Definition: winuser.h:1627
HWND WINAPI GetFocus(void)
Definition: window.c:1860
#define IDC_BUTTON_TAN
Definition: resource.h:31
#define IDC_BUTTON_D
Definition: resource.h:66
#define IDD_DIALOG_STAT
Definition: resource.h:9
#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 SendMessage
Definition: winuser.h:5709
#define WH_KEYBOARD
Definition: winuser.h:32
#define IDC_BUTTON_5
Definition: resource.h:53
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:299
#define IDC_BUTTON_AVE
Definition: resource.h:23
#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 IDM_HELP_HELP
Definition: resource.h:374
#define IDM_VIEW_WORD
Definition: resource.h:377
#define LoadIcon
Definition: winuser.h:5679
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
#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 char * ReadConversion(const char *formula)
Definition: winmain.c:859
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811
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
#define IDC_BUTTON_C
Definition: resource.h:61
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define LoadString
Definition: winuser.h:5685
#define IDS_CALC_NAME
Definition: resource.h:3
static char * ReadClipboard(void)
Definition: winmain.c:981
#define CreateDialog
Definition: winuser.h:5615
sequence_t Clipboard
Definition: calc.h:144
#define IDC_RADIO_BYTE
Definition: resource.h:80
#define ICON_BIG
Definition: tnclass.cpp:51
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

◆ DlgStatProc()

static INT_PTR CALLBACK DlgStatProc ( HWND  hWnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 881 of file winmain.c.

Referenced by DlgMainProc().

882 {
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 }
#define IDC_BUTTON_CAD
Definition: resource.h:94
static void update_n_stats_items(HWND hWnd, TCHAR *buffer)
Definition: winmain.c:817
#define TRUE
Definition: types.h:120
static void delete_stat_item(int n)
Definition: winmain.c:838
#define LB_ADDSTRING
Definition: winuser.h:1992
calc_t calc
Definition: winmain.c:226
#define WM_INSERT_STAT
Definition: calc.h:18
GLuint buffer
Definition: glext.h:5915
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDC_BUTTON_LOAD
Definition: resource.h:92
#define SendDlgItemMessage
Definition: winuser.h:5708
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDC_BUTTON_FOCUS
Definition: resource.h:99
UINT_PTR WPARAM
Definition: windef.h:207
GLuint n
Definition: s_context.h:57
#define LB_RESETCONTENT
Definition: winuser.h:2016
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
#define CBN_DBLCLK
Definition: winuser.h:1934
UINT msg
Definition: msvc.h:92
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5698
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_LOAD_STAT
Definition: calc.h:19
#define WM_CLOSE_STATS
Definition: calc.h:16
#define WM_CLOSE
Definition: winuser.h:1603
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
#define IDC_BUTTON_RET
Definition: resource.h:91
#define WM_COMMAND
Definition: winuser.h:1716
static void prepare_rpn_result(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: winmain.c:588
HWND WINAPI GetParent(_In_ HWND)
#define IDC_LIST_STAT
Definition: resource.h:90
#define LB_GETCURSEL
Definition: winuser.h:2000
#define SendMessage
Definition: winuser.h:5709
#define HIWORD(l)
Definition: typedefs.h:246
static void clean_stat_list(void)
Definition: winmain.c:825
#define LB_DELETESTRING
Definition: winuser.h:1993
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_BUTTON_CD
Definition: resource.h:93

◆ enable_allowed_controls()

static void enable_allowed_controls ( HWND  hwnd,
DWORD  base 
)
static

Definition at line 722 of file winmain.c.

Referenced by DlgMainProc(), and update_radio().

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 }
#define TRUE
Definition: types.h:120
#define BITMASK_DEC_MASK
Definition: winmain.c:33
#define IDC_RADIO_DEC
Definition: resource.h:17
BOOL WINAPI IsWindow(_In_opt_ HWND)
calc_t calc
Definition: winmain.c:226
GLuint const GLubyte mask[]
Definition: s_context.h:57
#define IDC_RADIO_BIN
Definition: resource.h:19
GLuint n
Definition: s_context.h:57
#define SIZEOF(_ar)
Definition: calc.h:48
#define IDC_RADIO_HEX
Definition: resource.h:16
BOOL WINAPI IsWindowEnabled(_In_ HWND)
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BITMASK_OCT_MASK
Definition: winmain.c:34
unsigned char BYTE
Definition: ntddk_ex.h:96
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND hStatWnd
Definition: calc.h:142
static const key3code_t key2code[]
Definition: winmain.c:68
BYTE mask
Definition: winmain.c:49
#define BITMASK_HEX_MASK
Definition: winmain.c:32
#define BITMASK_IS_STATS
Definition: winmain.c:30
#define IDC_RADIO_OCT
Definition: resource.h:18
struct task_struct * current
Definition: linux.c:32
#define BITMASK_BIN_MASK
Definition: winmain.c:35

◆ get_modifiers()

static int get_modifiers ( HWND  hwnd)
static

Definition at line 608 of file winmain.c.

Referenced by DlgMainProc().

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 }
#define IDC_CHECK_INV
Definition: resource.h:20
#define SendDlgItemMessage
Definition: winuser.h:5708
#define MODIFIER_INV
Definition: calc.h:165
#define BM_GETCHECK
Definition: winuser.h:1879
#define MODIFIER_HYP
Definition: calc.h:166
#define IDC_CHECK_HYP
Definition: resource.h:21

◆ handle_context_menu()

static void handle_context_menu ( HWND  hWnd,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 1150 of file winmain.c.

Referenced by DlgMainProc().

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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define TPM_LEFTALIGN
Definition: winuser.h:2331
calc_t calc
Definition: winmain.c:226
const WCHAR * text
Definition: package.c:1827
#define TPM_RETURNCMD
Definition: winuser.h:2341
#define GWL_ID
Definition: winuser.h:853
#define MF_STRING
Definition: winuser.h:138
#define HTMLHELP_PATH(_pt)
Definition: winmain.c:9
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
#define SIZEOF(_ar)
Definition: calc.h:48
#define TPM_TOPALIGN
Definition: winuser.h:2337
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE hInstance
Definition: calc.h:118
char TCHAR
Definition: xmlstorage.h:189
unsigned int BOOL
Definition: ntddk_ex.h:94
#define AppendMenu
Definition: winuser.h:5597
#define MF_ENABLED
Definition: winuser.h:128
uint32_t DWORD_PTR
Definition: typedefs.h:63
BOOL WINAPI DestroyMenu(_In_ HMENU)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
#define HIWORD(l)
Definition: typedefs.h:246
#define IDM_HELP_HELP
Definition: resource.h:374
#define HH_DISPLAY_TEXT_POPUP
Definition: htmlhelp.h:37
#define GetWindowLongPtr
Definition: treelist.c:73
#define memset(x, y, z)
Definition: compat.h:39
#define HtmlHelp
Definition: htmlhelp.h:425
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
#define LoadString
Definition: winuser.h:5685
#define IDS_QUICKHELP
Definition: resource.h:5

◆ handle_copy_command()

static void handle_copy_command ( HWND  hWnd)
static

Definition at line 971 of file winmain.c.

Referenced by DlgMainProc().

972 {
973  TCHAR display[sizeof(calc.buffer)];
974 
976  if (calc.base == IDC_RADIO_DEC && _tcschr(calc.buffer, _T('.')) == NULL)
979 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
calc_t calc
Definition: winmain.c:226
#define WM_GETTEXT
Definition: winuser.h:1600
#define SendDlgItemMessage
Definition: winuser.h:5708
UINT_PTR WPARAM
Definition: windef.h:207
int * display
Definition: x11stubs.c:12
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned int sDecimal_len
Definition: calc.h:150
static void CopyMemToClipboard(void *ptr)
Definition: winmain.c:951
#define TEXT(s)
Definition: k32.h:26
#define IDC_TEXT_OUTPUT
Definition: resource.h:87

◆ handle_sequence_input()

static char* handle_sequence_input ( HWND  hwnd,
sequence_t seq 
)
static

Definition at line 1000 of file winmain.c.

Referenced by DlgMainProc().

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 =
1025  _tcslen(calc.source);
1026  } else {
1027  for (x=0; x<SIZEOF(key2code); x++) {
1028  if (!(key2code[x].mask & BITMASK_IS_ASCII) ||
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 }
#define IDC_BUTTON_MC
Definition: resource.h:42
#define IDC_BUTTON_CANC
Definition: resource.h:84
UINT wm_msg
Definition: calc.h:102
#define IDC_BUTTON_MP
Definition: resource.h:45
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
#define free
Definition: debug_ros.c:5
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
UINT_PTR WPARAM
Definition: windef.h:207
#define IDC_BUTTON_EXP
Definition: resource.h:33
#define SIZEOF(_ar)
Definition: calc.h:48
GLenum GLint GLuint mask
Definition: glext.h:6028
static PVOID ptr
Definition: dispmode.c:27
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
#define PostMessage
Definition: winuser.h:5698
char * ptr
Definition: calc.h:101
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_BUTTON_MR
Definition: resource.h:43
char * data
Definition: calc.h:100
INT x
Definition: msvc.h:62
#define BITMASK_IS_CTRL
Definition: winmain.c:31
static const key3code_t key2code[]
Definition: winmain.c:68
TCHAR source[MAX_CALC_SIZE]
Definition: calc.h:125
BYTE mask
Definition: winmain.c:49
#define IDC_BUTTON_MS
Definition: resource.h:44
#define BITMASK_IS_ASCII
Definition: winmain.c:29
#define IDC_BUTTON_DAT
Definition: resource.h:26
Definition: path.c:42

◆ idm_2_idc()

static BOOL idm_2_idc ( int  idm,
WPARAM pIdc 
)
static

Definition at line 937 of file winmain.c.

Referenced by DlgMainProc().

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 }
#define TRUE
Definition: types.h:120
#define SIZEOF(_ar)
Definition: calc.h:48
static const struct _update_check_menus upd[]
#define WPARAM
Definition: msvc.h:37
INT x
Definition: msvc.h:62

◆ load_config()

static void load_config ( void  )
static

Definition at line 228 of file winmain.c.

Referenced by _tWinMain().

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 */
284 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD layout
Definition: calc.h:123
calc_t calc
Definition: winmain.c:226
unsigned int sThousand_len
Definition: calc.h:151
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR sThousand[8]
Definition: calc.h:149
TCHAR sDecimal[8]
Definition: calc.h:148
unsigned int sDecimal_len
Definition: calc.h:150
BOOL usesep
Definition: calc.h:135
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
BOOL is_memory
Definition: calc.h:131

◆ post_key_press()

static LRESULT post_key_press ( LPARAM  lParam,
WORD  idc 
)
static

Definition at line 304 of file winmain.c.

Referenced by process_vk_key().

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 }
#define BM_SETSTATE
Definition: winuser.h:1884
#define BS_OWNERDRAW
Definition: pedump.c:661
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
calc_t calc
Definition: winmain.c:226
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define SIZEOF(_ar)
Definition: calc.h:48
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define PostMessage
Definition: winuser.h:5698
#define KEY_WAS_DOWN
Definition: winmain.c:27
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1878
HWND hWnd
Definition: calc.h:122
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_IS_UP
Definition: winmain.c:26
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define GWL_STYLE
Definition: winuser.h:846
#define GetClassName
Definition: winuser.h:5649
#define TEXT(s)
Definition: k32.h:26
#define GetWindowLongPtr
Definition: treelist.c:73
LPARAM lParam
Definition: combotst.c:139

◆ prepare_rpn_result()

static void prepare_rpn_result ( calc_number_t rpn,
TCHAR buffer,
int  size,
int  base 
)
static

Definition at line 588 of file winmain.c.

Referenced by display_rpn_result(), and DlgStatProc().

589 {
590  if (calc.is_nan) {
591  rpn_zero(&calc.code);
593  return;
594  }
596 }
calc_number_t code
Definition: calc.h:127
calc_t calc
Definition: winmain.c:226
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
#define IDS_MATH_ERROR
Definition: resource.h:4
GLuint buffer
Definition: glext.h:5915
BOOL is_nan
Definition: calc.h:132
HINSTANCE hInstance
Definition: calc.h:118
GLsizeiptr size
Definition: glext.h:5919
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl.c:3
#define LoadString
Definition: winuser.h:5685

◆ process_vk_key()

static int process_vk_key ( WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 366 of file winmain.c.

Referenced by _tWinMain().

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  }
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 }
DWORD base
Definition: calc.h:138
DWORD layout
Definition: calc.h:123
#define IDC_RADIO_DEC
Definition: resource.h:17
calc_t calc
Definition: winmain.c:226
static const key2code_t key2code_base16[]
Definition: winmain.c:141
static int vk2ascii(unsigned int vk)
Definition: winmain.c:338
WPARAM wParam
Definition: combotst.c:138
CHAR key
Definition: winmain.c:42
#define IDM_EDIT_PASTE
Definition: resource.h:363
#define SIZEOF(_ar)
Definition: calc.h:48
GLenum GLint GLuint mask
Definition: glext.h:6028
#define IDM_EDIT_COPY
Definition: resource.h:362
static LRESULT post_key_press(LPARAM lParam, WORD idc)
Definition: winmain.c:304
smooth NULL
Definition: ftsmooth.c:416
WORD idc
Definition: winmain.c:47
#define CTRL_V
Definition: winmain.c:65
CHAR key
Definition: winmain.c:48
HWND hWnd
Definition: calc.h:122
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define KEY_IS_UP
Definition: winmain.c:26
WORD idc
Definition: winmain.c:43
#define WM_COMMAND
Definition: winuser.h:1716
INT x
Definition: msvc.h:62
#define BITMASK_IS_CTRL
Definition: winmain.c:31
static const key3code_t key2code[]
Definition: winmain.c:68
#define VK_F1
Definition: winuser.h:2209
#define CTRL_C
Definition: winmain.c:57
BYTE mask
Definition: winmain.c:49
#define SendMessage
Definition: winuser.h:5709
#define IDM_HELP_HELP
Definition: resource.h:374
#define BITMASK_IS_ASCII
Definition: winmain.c:29
static const key2code_t key2code_base10[]
Definition: winmain.c:148
LPARAM lParam
Definition: combotst.c:139
#define CTRL_FLAG
Definition: winmain.c:53
int k
Definition: mpi.c:3369
#define LOWORD(l)
Definition: pedump.c:82
Definition: path.c:42

◆ ReadClipboard()

static char* ReadClipboard ( void  )
static

Definition at line 981 of file winmain.c.

Referenced by DlgMainProc().

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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint buffer
Definition: glext.h:5915
#define _strdup
Definition: debug_ros.c:7
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HANDLE WINAPI GetClipboardData(_In_ UINT)
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

◆ ReadConversion()

static char* ReadConversion ( const char formula)
static

Definition at line 859 of file winmain.c.

Referenced by DlgMainProc().

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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
TCHAR * ptr
Definition: calc.h:126
calc_t calc
Definition: winmain.c:226
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
#define _T(x)
Definition: vfdio.h:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define TEXT(s)
Definition: k32.h:26
TCHAR source[MAX_CALC_SIZE]
Definition: calc.h:125
#define malloc
Definition: debug_ros.c:4

◆ run_canc()

static void run_canc ( calc_number_t c)
static

Definition at line 1188 of file winmain.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 }
BOOL sci_out
Definition: calc.h:133
calc_t calc
Definition: winmain.c:226
#define IDC_CHECK_INV
Definition: resource.h:20
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
#define SendDlgItemMessage
Definition: winuser.h:5708
HWND hWnd
Definition: calc.h:122
#define BM_SETCHECK
Definition: winuser.h:1882
BOOL sci_in
Definition: calc.h:134
void flush_postfix(void)
Definition: rpn.c:445
#define IDC_CHECK_HYP
Definition: resource.h:21

◆ run_dat_sta()

static void run_dat_sta ( calc_number_t number)
static

Definition at line 1047 of file winmain.c.

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  }
1064 }
statistic_t * stat
Definition: calc.h:130
DWORD base
Definition: calc.h:138
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
calc_t calc
Definition: winmain.c:226
#define WM_INSERT_STAT
Definition: calc.h:18
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
#define PostMessage
Definition: winuser.h:5698
void * next
Definition: calc.h:108
DWORD base
Definition: calc.h:107
GLdouble s
Definition: gl.h:2039
calc_number_t num
Definition: calc.h:106
HWND hStatWnd
Definition: calc.h:142
#define malloc
Definition: debug_ros.c:4
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
void rpn_alloc(calc_number_t *c)
Definition: fun_mpfr.c:482

◆ run_fe()

static void run_fe ( calc_number_t number)
static

Definition at line 1145 of file winmain.c.

1146 {
1147  calc.sci_out = ((calc.sci_out != FALSE) ? FALSE : TRUE);
1148 }
#define TRUE
Definition: types.h:120
BOOL sci_out
Definition: calc.h:133
calc_t calc
Definition: winmain.c:226

◆ run_lpar()

static void run_lpar ( calc_number_t c)
static

Definition at line 1205 of file winmain.c.

1206 {
1208 }
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn.c:365

◆ run_mm()

static void run_mm ( calc_number_t c)
static

Definition at line 1076 of file winmain.c.

1077 {
1078  calc_node_t cn;
1079 
1080  cn.number = *c;
1081  cn.base = calc.base;
1084 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
calc_t calc
Definition: winmain.c:226
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn.c:288
static BYTE cn[]
Definition: cert.c:2938
HWND hWnd
Definition: calc.h:122
calc_number_t number
Definition: calc.h:84
DWORD base
Definition: calc.h:86
#define c
Definition: ke_i.h:80
calc_node_t memory
Definition: calc.h:129
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811

◆ run_mp()

static void run_mp ( calc_number_t c)
static

Definition at line 1066 of file winmain.c.

1067 {
1068  calc_node_t cn;
1069 
1070  cn.number = *c;
1071  cn.base = calc.base;
1074 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
calc_t calc
Definition: winmain.c:226
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn.c:288
static BYTE cn[]
Definition: cert.c:2938
HWND hWnd
Definition: calc.h:122
calc_number_t number
Definition: calc.h:84
DWORD base
Definition: calc.h:86
#define c
Definition: ke_i.h:80
calc_node_t memory
Definition: calc.h:129
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811

◆ run_ms()

static void run_ms ( calc_number_t c)
static

Definition at line 1086 of file winmain.c.

1087 {
1088  rpn_copy(&calc.memory.number, c);
1089  calc.memory.base = calc.base;
1091 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
calc_t calc
Definition: winmain.c:226
HWND hWnd
Definition: calc.h:122
int rpn_is_zero(calc_number_t *c)
Definition: fun_mpfr.c:477
calc_number_t number
Definition: calc.h:84
DWORD base
Definition: calc.h:86
calc_node_t memory
Definition: calc.h:129
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811

◆ run_mw()

static void run_mw ( calc_number_t c)
static

Definition at line 1093 of file winmain.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 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
calc_t calc
Definition: winmain.c:226
HWND hWnd
Definition: calc.h:122
int rpn_is_zero(calc_number_t *c)
Definition: fun_mpfr.c:477
calc_number_t number
Definition: calc.h:84
DWORD base
Definition: calc.h:86
BOOL is_memory
Definition: calc.h:131
calc_node_t memory
Definition: calc.h:129
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:811

◆ run_pow()

static void run_pow ( calc_number_t number)
static

Definition at line 1135 of file winmain.c.

1136 {
1138 }
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn.c:365

◆ run_rpar()

static void run_rpar ( calc_number_t c)
static

Definition at line 1200 of file winmain.c.

1201 {
1202  exec_closeparent(c);
1203 }
void exec_closeparent(calc_number_t *)
Definition: rpn.c:411

◆ run_sqr()

static void run_sqr ( calc_number_t number)
static

Definition at line 1140 of file winmain.c.

1141 {
1143 }
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn.c:365

◆ save_config()

static void save_config ( void  )
static

Definition at line 286 of file winmain.c.

Referenced by DlgMainProc().

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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD layout
Definition: calc.h:123
#define KEY_SET_VALUE
Definition: nt_native.h:1017
calc_t calc
Definition: winmain.c:226
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
BOOL usesep
Definition: calc.h:135
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: ntddk_ex.h:96
#define TEXT(s)
Definition: k32.h:26
#define REG_DWORD
Definition: sdbapi.c:539
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501

◆ SubclassButtonProc()

static LRESULT CALLBACK SubclassButtonProc ( HWND  hWnd,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 1210 of file winmain.c.

Referenced by DlgMainProc().

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 ||
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 }
COLORREF col
Definition: winmain.c:50
#define DFC_BUTTON
Definition: winuser.h:476
long y
Definition: polytest.cpp:48
DWORD layout
Definition: calc.h:123
long x
Definition: polytest.cpp:48
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define IDC_BUTTON_RX
Definition: resource.h:41
#define pt(x, y)
Definition: drawing.c:79
calc_t calc
Definition: winmain.c:226
const WCHAR * text
Definition: package.c:1827
LONG top
Definition: windef.h:297
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
LONG left
Definition: windef.h:296
#define DST_TEXT
Definition: winuser.h:513
LONG right
Definition: windef.h:298
#define GetWindowText
Definition: winuser.h:5664
#define DrawState
Definition: winuser.h:5636
#define DFCS_PUSHED
Definition: winuser.h:503
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:324
#define CALC_CLR_BLUE
Definition: winmain.c:38
char TCHAR
Definition: xmlstorage.h:189
GLsizeiptr size
Definition: glext.h:5919
#define ODS_DISABLED
Definition: winuser.h:2501
#define DSS_DISABLED
Definition: winuser.h:519
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
GLenum GLsizei len
Definition: glext.h:6722
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:784
INT INT dy
Definition: msvc.h:65
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
static const key3code_t key2code[]
Definition: winmain.c:68
#define ODS_SELECTED
Definition: winuser.h:2499
#define GetTextExtentPoint32
Definition: wingdi.h:4449
#define ODT_BUTTON
Definition: winuser.h:2494
LONG bottom
Definition: windef.h:299
LONG cy
Definition: windef.h:325
INT dx
Definition: msvc.h:65

◆ update_lcd_display()

static void update_lcd_display ( HWND  hwnd)
static

Definition at line 436 of file winmain.c.

Referenced by build_operand(), display_rpn_result(), and DlgMainProc().

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));
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 }
DWORD base
Definition: calc.h:138
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
BOOL sci_out
Definition: calc.h:133
#define IDC_RADIO_DEC
Definition: resource.h:17
calc_t calc
Definition: winmain.c:226
unsigned int sThousand_len
Definition: calc.h:151
GLdouble GLdouble t
Definition: gl.h:2047
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define SendDlgItemMessage
Definition: winuser.h:5708
BOOL is_nan
Definition: calc.h:132
#define alloca
Definition: malloc.h:361
UINT_PTR WPARAM
Definition: windef.h:207
#define IDC_RADIO_BIN
Definition: resource.h:19
GLuint n
Definition: s_context.h:57
#define e
Definition: ke_i.h:82
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_RADIO_HEX
Definition: resource.h:16
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
TCHAR sThousand[8]
Definition: calc.h:149
#define WM_SETTEXT
Definition: winuser.h:1599
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
TCHAR sDecimal[8]
Definition: calc.h:148
unsigned int sDecimal_len
Definition: calc.h:150
BOOL usesep
Definition: calc.h:135
BOOL sci_in
Definition: calc.h:134
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TEXT(s)
Definition: k32.h:26
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define IDC_TEXT_OUTPUT
Definition: resource.h:87
GLfloat GLfloat p
Definition: glext.h:8902

◆ update_memory_flag()

static void update_memory_flag ( HWND  hWnd,
BOOL  mem_flag 
)
static

Definition at line 811 of file winmain.c.

Referenced by DlgMainProc(), run_mm(), run_mp(), run_ms(), and run_mw().

812 {
813  calc.is_memory = mem_flag;
814  SendDlgItemMessage(hWnd, IDC_TEXT_MEMORY, WM_SETTEXT, 0, (LPARAM)(mem_flag ? TEXT("M") : TEXT("")));
815 }
calc_t calc
Definition: winmain.c:226
#define SendDlgItemMessage
Definition: winuser.h:5708
#define IDC_TEXT_MEMORY
Definition: resource.h:89
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
#define TEXT(s)
Definition: k32.h:26
BOOL is_memory
Definition: calc.h:131

◆ update_menu()

static void update_menu ( HWND  hwnd)
static

Definition at line 663 of file winmain.c.

Referenced by DlgMainProc(), and update_radio().

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 */
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) {
696  CheckMenuItem(hMenu, upd[x].idm, MF_BYCOMMAND|MF_UNCHECKED);
697  SendMessage((HWND)GetDlgItem(hwnd,upd[x].idc),BM_SETCHECK,FALSE,0L);
698  } else {
699  CheckMenuItem(hMenu, upd[x].idm, MF_BYCOMMAND|MF_CHECKED);
700  SendMessage((HWND)GetDlgItem(hwnd,upd[x].idc),BM_SETCHECK,TRUE,0L);
701  }
702  }
704 }
#define TRUE
Definition: types.h:120
#define MF_BYCOMMAND
Definition: winuser.h:202
DWORD layout
Definition: calc.h:123
calc_t calc
Definition: winmain.c:226
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define IDM_VIEW_GROUP
Definition: resource.h:373
#define IDM_VIEW_STANDARD
Definition: resource.h:364
#define SIZEOF(_ar)
Definition: calc.h:48
#define IDM_VIEW_SCIENTIFIC
Definition: resource.h:365
static const struct _update_check_menus upd[]
#define MF_CHECKED
Definition: winuser.h:132
#define BM_SETCHECK
Definition: winuser.h:1882
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL usesep
Definition: calc.h:135
#define IDM_VIEW_CONVERSION
Definition: resource.h:380
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1087
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MF_UNCHECKED
Definition: winuser.h:204
INT x
Definition: msvc.h:62
#define SendMessage
Definition: winuser.h:5709
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ update_n_stats_items()

static void update_n_stats_items ( HWND  hWnd,
TCHAR buffer 
)
static

Definition at line 817 of file winmain.c.

Referenced by DlgStatProc().

818 {
819  unsigned int n = SendDlgItemMessage(hWnd, IDC_LIST_STAT, LB_GETCOUNT, 0, 0);
820 
821  _stprintf(buffer, TEXT("n=%d"), n);
823 }
GLuint buffer
Definition: glext.h:5915
#define SendDlgItemMessage
Definition: winuser.h:5708
GLuint n
Definition: s_context.h:57
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_TEXT_NITEMS
Definition: resource.h:95
#define LB_GETCOUNT
Definition: winuser.h:1999
#define WM_SETTEXT
Definition: winuser.h:1599
#define _stprintf
Definition: utility.h:124
#define TEXT(s)
Definition: k32.h:26
#define IDC_LIST_STAT
Definition: resource.h:90

◆ update_parent_display()

static void update_parent_display ( HWND  hWnd)
static

Definition at line 512 of file winmain.c.

Referenced by display_rpn_result().

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 }
#define SendDlgItemMessage
Definition: winuser.h:5708
GLuint n
Definition: s_context.h:57
LONG_PTR LPARAM
Definition: windef.h:208
const WCHAR * str
#define IDC_TEXT_PARENT
Definition: resource.h:88
#define WM_SETTEXT
Definition: winuser.h:1599
char TCHAR
Definition: xmlstorage.h:189
int eval_parent_count(void)
Definition: rpn.c:432
#define _stprintf
Definition: utility.h:124
#define TEXT(s)
Definition: k32.h:26

◆ update_radio()

static void update_radio ( HWND  hwnd,
unsigned int  base 
)
static

Definition at line 758 of file winmain.c.

Referenced by DlgMainProc().

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) {
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++)
800 
802  }
803 
805  if (base == IDC_RADIO_DEC)
807  else
809 }
DWORD base
Definition: calc.h:138
static void convert_text2number(calc_number_t *a)
Definition: winmain.c:620
#define MAKEINTRESOURCE
Definition: winuser.h:591
static void update_menu(HWND hwnd)
Definition: winmain.c:663
#define BITMASK_DEC_MASK
Definition: winmain.c:33
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
calc_number_t code
Definition: calc.h:127
#define IDC_RADIO_DEC
Definition: resource.h:17
#define SW_HIDE
Definition: winuser.h:762
calc_t calc
Definition: winmain.c:226
#define IDR_MENU_SCIENTIFIC_2
Definition: resource.h:12
static void enable_allowed_controls(HWND hwnd, DWORD base)
Definition: winmain.c:722
void convert_real_integer(unsigned int base)
Definition: utl.c:92
DWORD degr
Definition: calc.h:140
#define SendDlgItemMessage
Definition: winuser.h:5708
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
GLuint const GLubyte mask[]
Definition: s_context.h:57
#define IDC_RADIO_BIN
Definition: resource.h:19
GLuint n
Definition: s_context.h:57
#define SIZEOF(_ar)
Definition: calc.h:48
GLuint base
Definition: 3dtext.c:35
#define IDC_RADIO_HEX
Definition: resource.h:16
DWORD size
Definition: calc.h:139
HINSTANCE hInstance
Definition: calc.h:118
#define SW_SHOW
Definition: winuser.h:769
#define BM_SETCHECK
Definition: winuser.h:1882
static const radio_config_t radio_setup[]
Definition: winmain.c:711
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define IDR_MENU_SCIENTIFIC_1
Definition: resource.h:11
unsigned short WORD
Definition: ntddk_ex.h:93
#define BITMASK_OCT_MASK
Definition: winmain.c:34
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define LoadMenu
Definition: winuser.h:5683
static void display_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:598
#define BST_CHECKED
Definition: winuser.h:197
#define BITMASK_HEX_MASK
Definition: winmain.c:32
#define IDC_RADIO_OCT
Definition: resource.h:18
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define BITMASK_BIN_MASK
Definition: winmain.c:35

◆ upload_stat_number()

static statistic_t* upload_stat_number ( int  n)
static

Definition at line 1105 of file winmain.c.

Referenced by DlgMainProc().

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;
1125  }
1126  } else
1127 #endif
1128  rpn_copy(&calc.code, &p->num);
1129 
1130  calc.is_nan = FALSE;
1131 
1132  return p;
1133 }
statistic_t * stat
Definition: calc.h:130
DWORD base
Definition: calc.h:138
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_mpfr.c:472
calc_number_t code
Definition: calc.h:127
#define IDC_RADIO_DEC
Definition: resource.h:17
calc_t calc
Definition: winmain.c:226
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
GLuint n
Definition: s_context.h:57
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
void * next
Definition: calc.h:108
INT64 i
Definition: calc.h:78
DWORD base
Definition: calc.h:107
calc_number_t num
Definition: calc.h:106
GLfloat GLfloat p
Definition: glext.h:8902
#define __int64
Definition: basetyps.h:16
void apply_int_mask(calc_number_t *a)
Definition: fun_mpfr.c:3

◆ vk2ascii()

static int vk2ascii ( unsigned int  vk)
static

Definition at line 338 of file winmain.c.

Referenced by process_vk_key().

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 }
#define VK_MENU
Definition: winuser.h:2158
#define MapVirtualKeyEx
Definition: winuser.h:5687
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define ALT_FLAG
Definition: winmain.c:54
static int state
Definition: maze.c:121
static DWORD layout
Definition: bitmap.c:46
SHORT WINAPI GetAsyncKeyState(_In_ int)
GLdouble s
Definition: gl.h:2039
UINT_PTR HKL
Definition: msctf.idl:101
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)
unsigned char BYTE
Definition: ntddk_ex.h:96
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define CTRL_A
Definition: winmain.c:56
#define CTRL_Z
Definition: winmain.c:66
#define CTRL_FLAG
Definition: winmain.c:53

Variable Documentation

◆ calc

◆ function_table

const function_table_t function_table[]
static
Initial value:
= {
{ IDC_BUTTON_RX, 0, 1, rpn_reci, NULL, NULL, NULL },
{ IDC_BUTTON_NOT, 0, 1, rpn_not, NULL, NULL, NULL },
{ IDC_BUTTON_NF, 0, 1, rpn_fact, NULL, NULL, NULL },
{ IDC_BUTTON_AVE, 0, 0, rpn_ave, NULL, NULL, NULL },
{ IDC_BUTTON_SUM, 0, 0, rpn_sum, NULL, NULL, NULL },
{ IDC_BUTTON_FE, 0, 1, run_fe, NULL, NULL, NULL },
}
void rpn_s(calc_number_t *c)
Definition: fun_mpfr.c:403
#define IDC_BUTTON_CANC
Definition: resource.h:84
void rpn_pi(calc_number_t *c)
Definition: fun_mpfr.c:269
#define IDC_BUTTON_INT
Definition: resource.h:75
void rpn_acosh(calc_number_t *c)
Definition: fun_mpfr.c:213
void rpn_cbrt(calc_number_t *c)
Definition: fun_mpfr.c:303
#define IDC_BUTTON_MP
Definition: resource.h:45
void rpn_atanh(calc_number_t *c)
Definition: fun_mpfr.c:218
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
#define IDC_BUTTON_SQRT
Definition: resource.h:96
static void run_mw(calc_number_t *c)
Definition: winmain.c:1093
static void run_pow(calc_number_t *number)
Definition: winmain.c:1135
#define IDC_BUTTON_SUM
Definition: resource.h:24
#define IDC_BUTTON_Xe3
Definition: resource.h:36
void rpn_exp(calc_number_t *c)
Definition: fun_mpfr.c:309
#define IDC_BUTTON_PI
Definition: resource.h:46
#define IDC_BUTTON_S
Definition: resource.h:25
static void run_dat_sta(calc_number_t *number)
Definition: winmain.c:1047
#define IDC_BUTTON_NOT
Definition: resource.h:74
void rpn_asin(calc_number_t *c)
Definition: fun_mpfr.c:176
void rpn_dms2dec(calc_number_t *c)
Definition: fun_mpfr.c:413
void rpn_frac(calc_number_t *c)
Definition: fun_mpfr.c:229
void rpn_exp2(calc_number_t *c)
Definition: fun_mpfr.c:285
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 MODIFIER_INV
Definition: calc.h:165
#define IDC_BUTTON_FE
Definition: resource.h:27
#define IDC_BUTTON_LN
Definition: resource.h:38
void rpn_log(calc_number_t *c)
Definition: fun_mpfr.c:327
smooth NULL
Definition: ftsmooth.c:416
#define NO_CHAIN
Definition: calc.h:167
void rpn_acos(calc_number_t *c)
Definition: fun_mpfr.c:181
#define MODIFIER_HYP
Definition: calc.h:166
void rpn_ave(calc_number_t *c)
Definition: fun_mpfr.c:344
static void run_sqr(calc_number_t *number)
Definition: winmain.c:1140
static void run_ms(calc_number_t *c)
Definition: winmain.c:1086
#define IDC_BUTTON_SIN
Definition: resource.h:29
#define IDC_BUTTON_Xe2
Definition: resource.h:35
void rpn_cosh(calc_number_t *c)
Definition: fun_mpfr.c:197
void rpn_int(calc_number_t *c)
Definition: fun_mpfr.c:224
#define IDC_BUTTON_NF
Definition: resource.h:40
void rpn_ln(calc_number_t *c)
Definition: fun_mpfr.c:321
void rpn_tan(calc_number_t *c)
Definition: fun_mpfr.c:154
void rpn_dec2dms(calc_number_t *c)
Definition: fun_mpfr.c:440
void rpn_s_m1(calc_number_t *c)
Definition: fun_mpfr.c:408
void rpn_2pi(calc_number_t *c)
Definition: fun_mpfr.c:274
void rpn_sinh(calc_number_t *c)
Definition: fun_mpfr.c:192
#define IDC_BUTTON_XeY
Definition: resource.h:34
static void run_mp(calc_number_t *c)
Definition: winmain.c:1066
static void run_canc(calc_number_t *c)
Definition: winmain.c:1188
void rpn_cos(calc_number_t *c)
Definition: fun_mpfr.c:130
void rpn_atan(calc_number_t *c)
Definition: fun_mpfr.c:186
#define IDC_BUTTON_RIGHTPAR
Definition: resource.h:37
void rpn_exp10(calc_number_t *c)
Definition: fun_mpfr.c:315
#define IDC_BUTTON_LOG
Definition: resource.h:39
#define IDC_BUTTON_DMS
Definition: resource.h:28
void rpn_fact(calc_number_t *c)
Definition: fun_mpfr.c:242
static void run_lpar(calc_number_t *c)
Definition: winmain.c:1205
#define IDC_BUTTON_TAN
Definition: resource.h:31
#define IDC_BUTTON_MS
Definition: resource.h:44
void rpn_sin(calc_number_t *c)
Definition: fun_mpfr.c:106
static void run_mm(calc_number_t *c)
Definition: winmain.c:1076
#define IDC_BUTTON_AVE
Definition: resource.h:23
void rpn_sum(calc_number_t *c)
Definition: fun_mpfr.c:358
#define IDC_BUTTON_LEFTPAR
Definition: resource.h:32
#define IDC_BUTTON_COS
Definition: resource.h:30
#define IDC_BUTTON_DAT
Definition: resource.h:26
void rpn_exp3(calc_number_t *c)
Definition: fun_mpfr.c:291
void rpn_reci(calc_number_t *c)
Definition: fun_mpfr.c:234
void rpn_asinh(calc_number_t *c)
Definition: fun_mpfr.c:208
void rpn_tanh(calc_number_t *c)
Definition: fun_mpfr.c:202

Definition at line 195 of file winmain.c.

◆ key2code

const key3code_t key2code[]
static

Definition at line 68 of file winmain.c.

◆ key2code_base10

const key2code_t key2code_base10[]
static
Initial value:
= {
}
#define IDC_RADIO_DEG
Definition: resource.h:81
#define IDC_RADIO_GRAD
Definition: resource.h:83
#define VK_F4
Definition: winuser.h:2212
#define VK_F2
Definition: winuser.h:2210
#define VK_F3
Definition: winuser.h:2211
#define IDC_RADIO_RAD
Definition: resource.h:82

Definition at line 148 of file winmain.c.

Referenced by process_vk_key().

◆ key2code_base16

const key2code_t key2code_base16[]
static
Initial value:
= {
}
#define IDC_RADIO_WORD
Definition: resource.h:79
#define IDC_RADIO_QWORD
Definition: resource.h:77
#define VK_F4
Definition: winuser.h:2212
#define VK_F2
Definition: winuser.h:2210
#define VK_F12
Definition: winuser.h:2220
#define VK_F3
Definition: winuser.h:2211
#define IDC_RADIO_DWORD
Definition: resource.h:78
#define IDC_RADIO_BYTE
Definition: resource.h:80

Definition at line 141 of file winmain.c.

Referenced by process_vk_key().

◆ operator_codes

const WORD operator_codes[]
static
Initial value:
= {
}
#define IDC_BUTTON_EQU
Definition: resource.h:70
#define IDC_STATIC
Definition: calc.h:41
#define IDC_BUTTON_MOD
Definition: resource.h:67
#define IDC_BUTTON_MULT
Definition: resource.h:63
#define IDC_BUTTON_OR
Definition: resource.h:68
#define IDC_BUTTON_AND
Definition: resource.h:72
#define IDC_BUTTON_PERCENT
Definition: resource.h:97
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_BUTTON_SUB
Definition: resource.h:64
#define IDC_BUTTON_LSH
Definition: resource.h:69
#define IDC_BUTTON_XOR
Definition: resource.h:73
#define IDC_BUTTON_RSH
Definition: resource.h:103
#define IDC_BUTTON_ADD
Definition: resource.h:65
#define IDC_BUTTON_DIV
Definition: resource.h:62

Definition at line 154 of file winmain.c.

Referenced by DlgMainProc().

◆ radio_setup

const radio_config_t radio_setup[]
static
Initial value:
= {
{ IDC_RADIO_QWORD, MAKE_BITMASK4( 1, 0, 1, 1) },
{ IDC_RADIO_DWORD, MAKE_BITMASK4( 1, 0, 1, 1) },
{ IDC_RADIO_WORD, MAKE_BITMASK4( 1, 0, 1, 1) },
{ IDC_RADIO_BYTE, MAKE_BITMASK4( 1, 0, 1, 1) },
{ IDC_RADIO_DEG, MAKE_BITMASK4( 0, 1, 0, 0) },
{ IDC_RADIO_RAD, MAKE_BITMASK4( 0, 1, 0, 0) },
{ IDC_RADIO_GRAD, MAKE_BITMASK4( 0, 1, 0, 0) },
}
#define IDC_RADIO_DEG
Definition: resource.h:81
#define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2)
Definition: winmain.c:11
#define IDC_RADIO_GRAD
Definition: resource.h:83
#define IDC_RADIO_WORD
Definition: resource.h:79
#define IDC_RADIO_QWORD
Definition: resource.h:77
#define IDC_RADIO_DWORD
Definition: resource.h:78
#define IDC_RADIO_RAD
Definition: resource.h:82
#define IDC_RADIO_BYTE
Definition: resource.h:80

Definition at line 711 of file winmain.c.

◆ upd

Initial value:
= {
}
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEG
Definition: resource.h:81
#define IDM_VIEW_OCT
Definition: resource.h:368
#define IDM_VIEW_BIN
Definition: resource.h:369
#define IDC_RADIO_GRAD
Definition: resource.h:83
DWORD layout
Definition: calc.h:123
#define IDM_VIEW_QWORD
Definition: resource.h:376
#define IDC_RADIO_DEC
Definition: resource.h:17
#define IDM_VIEW_DEC
Definition: resource.h:367
calc_t calc
Definition: winmain.c:226
#define IDC_RADIO_WORD
Definition: resource.h:79
DWORD degr
Definition: calc.h:140
#define IDM_VIEW_BYTE
Definition: resource.h:378
#define IDM_VIEW_RAD
Definition: resource.h:371
#define IDM_VIEW_GRAD
Definition: resource.h:372
#define IDM_VIEW_STANDARD
Definition: resource.h:364
#define IDC_RADIO_BIN
Definition: resource.h:19
#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 IDC_RADIO_HEX
Definition: resource.h:16
DWORD size
Definition: calc.h:139
#define IDM_VIEW_CONVERSION
Definition: resource.h:380
#define IDM_VIEW_HEX
Definition: resource.h:366
#define IDC_RADIO_DWORD
Definition: resource.h:78
#define IDM_VIEW_DEG
Definition: resource.h:370
#define IDC_RADIO_RAD
Definition: resource.h:82
#define IDM_VIEW_WORD
Definition: resource.h:377
#define IDC_RADIO_OCT
Definition: resource.h:18
#define IDC_RADIO_BYTE
Definition: resource.h:80

Referenced by idm_2_idc(), and update_menu().