ReactOS  0.4.13-dev-257-gfabbd7c
winmain.c File Reference
#include "calc.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  BTNINFO
 
struct  _update_check_menus
 
struct  radio_config_t
 

Macros

#define HTMLHELP_PATH(_pt)   _T("%systemroot%\\Help\\calc.chm::") _T(_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   RGB(0xFF, 0x00, 0x00)
 
#define CALC_CLR_BLUE   RGB(0x00, 0x00, 0xFF)
 
#define CALC_CLR_PURP   RGB(0xFF, 0x00, 0xFF)
 
#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 *)
 
typedef struct BTNINFOLPBTNINFO
 

Functions

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 UpdateNumberIntl (void)
 
static int LoadRegInt (LPCTSTR lpszApp, LPCTSTR lpszKey, int iDefault)
 
static void SaveRegInt (LPCTSTR lpszApp, LPCTSTR lpszKey, int iValue)
 
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 set_rpn_result (HWND hwnd, calc_number_t *rpn)
 
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 WPARAM idm_2_idc (int idm)
 
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 HotButtonProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 
static BOOL CALLBACK EnumChildProc (HWND hWnd, LPARAM lParam)
 
static INT_PTR CALLBACK OnSettingChange (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
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
 
BTNINFO BtnInfo [255]
 
UINT BtnCount
 
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 68 of file winmain.c.

◆ BITMASK_BIN_MASK

#define BITMASK_BIN_MASK   0x01

Definition at line 49 of file winmain.c.

◆ BITMASK_DEC_MASK

#define BITMASK_DEC_MASK   0x04

Definition at line 47 of file winmain.c.

◆ BITMASK_HEX_MASK

#define BITMASK_HEX_MASK   0x08

Definition at line 46 of file winmain.c.

◆ BITMASK_IS_ASCII

#define BITMASK_IS_ASCII   0x80

Definition at line 43 of file winmain.c.

◆ BITMASK_IS_CTRL

#define BITMASK_IS_CTRL   0x20

Definition at line 45 of file winmain.c.

◆ BITMASK_IS_STATS

#define BITMASK_IS_STATS   0x40

Definition at line 44 of file winmain.c.

◆ BITMASK_OCT_MASK

#define BITMASK_OCT_MASK   0x02

Definition at line 48 of file winmain.c.

◆ CALC_CLR_BLUE

#define CALC_CLR_BLUE   RGB(0x00, 0x00, 0xFF)

Definition at line 52 of file winmain.c.

◆ CALC_CLR_PURP

#define CALC_CLR_PURP   RGB(0xFF, 0x00, 0xFF)

Definition at line 53 of file winmain.c.

◆ CALC_CLR_RED

#define CALC_CLR_RED   RGB(0xFF, 0x00, 0x00)

Definition at line 51 of file winmain.c.

◆ CTRL_A

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

Definition at line 70 of file winmain.c.

◆ CTRL_C

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

Definition at line 71 of file winmain.c.

◆ CTRL_D

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

Definition at line 72 of file winmain.c.

◆ CTRL_FLAG

#define CTRL_FLAG   0x100

Definition at line 67 of file winmain.c.

◆ CTRL_L

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

Definition at line 73 of file winmain.c.

◆ CTRL_M

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

Definition at line 74 of file winmain.c.

◆ CTRL_P

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

Definition at line 75 of file winmain.c.

◆ CTRL_R

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

Definition at line 76 of file winmain.c.

◆ CTRL_S

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

Definition at line 77 of file winmain.c.

◆ CTRL_T

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

Definition at line 78 of file winmain.c.

◆ CTRL_V

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

Definition at line 79 of file winmain.c.

◆ CTRL_Z

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

Definition at line 80 of file winmain.c.

◆ HTMLHELP_PATH

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

Definition at line 23 of file winmain.c.

◆ KEY_IS_UP

#define KEY_IS_UP   0x80000000

Definition at line 40 of file winmain.c.

◆ KEY_WAS_DOWN

#define KEY_WAS_DOWN   0x40000000

Definition at line 41 of file winmain.c.

◆ 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 25 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 31 of file winmain.c.

Typedef Documentation

◆ LPBTNINFO

◆ rpn_callback1

typedef void(* rpn_callback1) (calc_number_t *)

Definition at line 187 of file winmain.c.

Function Documentation

◆ _tWinMain()

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

Definition at line 1923 of file winmain.c.

1925 {
1926  MSG msg;
1927  DWORD dwLayout;
1928 
1929  /* Initialize controls for theming & manifest support */
1931 
1933 
1934  calc.x_coord = -1;
1935  calc.y_coord = -1;
1936 
1937  load_config();
1938  start_rpn_engine();
1939 
1941 
1943 
1945  hInstance,
1947  IMAGE_ICON,
1950  0);
1951 
1953  hInstance,
1955  IMAGE_ICON,
1958  0);
1959 
1960  do {
1961  /* ignore hwnd: dialogs are already visible! */
1963  dwLayout = IDD_DIALOG_SCIENTIFIC;
1964  else
1966  dwLayout = IDD_DIALOG_CONVERSION;
1967  else
1968  dwLayout = IDD_DIALOG_STANDARD;
1969 
1970  /* This call will always fail if UNICODE for Win9x */
1972  break;
1973 
1974  while (GetMessage(&msg, NULL, 0, 0)) {
1975 #ifndef USE_KEYBOARD_HOOK
1976  if ((msg.message == WM_KEYUP ||
1977  msg.message == WM_KEYDOWN) &&
1978  !calc.is_menu_on)
1979  process_vk_key(msg.wParam, msg.lParam);
1980 #endif
1982  DispatchMessage(&msg);
1983  }
1984 
1985  save_config();
1986  } while (calc.action != IDC_STATIC);
1987 
1988  if (calc.hBgIcon != NULL)
1990 
1991  if (calc.hSmIcon != NULL)
1993 
1994  stop_rpn_engine();
1995 
1996  Theme_Stop();
1997  HtmlHelp_Stop();
1998 
1999  return 0;
2000 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void Theme_Start(HINSTANCE hInstance)
Definition: theme.c:105
#define IMAGE_ICON
Definition: winuser.h:212
BOOL is_menu_on
Definition: calc.h:187
DWORD layout
Definition: calc.h:174
void HtmlHelp_Start(HINSTANCE hInstance)
Definition: htmlhelp.c:50
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDD_DIALOG_SCIENTIFIC
Definition: resource.h:11
void HtmlHelp_Stop(void)
Definition: htmlhelp.c:60
calc_t calc
Definition: winmain.c:247
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hBgIcon
Definition: calc.h:172
#define IDD_DIALOG_STANDARD
Definition: resource.h:12
static void load_config(void)
Definition: winmain.c:301
DWORD action
Definition: calc.h:192
HINSTANCE hInstance
Definition: charmap.c:20
#define SM_CXICON
Definition: winuser.h:962
signed int y_coord
Definition: calc.h:204
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
HINSTANCE hInstance
Definition: calc.h:167
signed int x_coord
Definition: calc.h:203
void start_rpn_engine(void)
Definition: rpn_ieee.c:479
void Theme_Stop(void)
Definition: theme.c:120
static int process_vk_key(WPARAM wParam, LPARAM lParam)
Definition: winmain.c:419
#define WM_KEYUP
Definition: winuser.h:1692
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_STATIC
Definition: resource.h:4
#define SM_CXSMICON
Definition: winuser.h:1002
#define SM_CYICON
Definition: winuser.h:963
HICON hSmIcon
Definition: calc.h:173
#define IDD_DIALOG_CONVERSION
Definition: resource.h:15
#define IDI_CALC
Definition: resource.h:20
static void save_config(void)
Definition: winmain.c:334
#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:1412
#define LoadImage
Definition: winuser.h:5681
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
void stop_rpn_engine(void)
Definition: rpn_ieee.c:484
#define CreateDialog
Definition: winuser.h:5615

◆ build_operand()

static void build_operand ( HWND  hwnd,
DWORD  idc 
)
static

Definition at line 580 of file winmain.c.

581 {
582  unsigned int i = 0, n;
583 
584  if (idc == IDC_BUTTON_DOT) {
585  /* if dot is the first char, it's added automatically */
586  if (calc.buffer == calc.ptr) {
587  *calc.ptr++ = _T('0');
588  *calc.ptr++ = _T('.');
589  *calc.ptr = _T('\0');
591  return;
592  }
593  /* if pressed dot and it's already in the string, then return */
594  if (_tcschr(calc.buffer, _T('.')) != NULL)
595  return;
596  }
597  if (idc != IDC_STATIC) {
598  while (idc != key2code[i].idc) i++;
599  }
600  n = calc.ptr - calc.buffer;
601  if (idc == IDC_BUTTON_0 && n == 0) {
602  /* no need to put the dot because it's handled by update_lcd_display() */
603  calc.buffer[0] = _T('0');
604  calc.buffer[1] = _T('\0');
606  return;
607  }
608  switch (calc.base) {
609  case IDC_RADIO_HEX:
610  if (n >= 16)
611  return;
612  break;
613  case IDC_RADIO_DEC:
614  if (n >= SIZEOF(calc.buffer)-1)
615  return;
616  if (calc.sci_in) {
617  if (idc != IDC_STATIC)
618  calc.esp = (calc.esp * 10 + (key2code[i].key-'0')) % LOCAL_EXP_SIZE;
619  if (calc.ptr == calc.buffer)
620  _stprintf(calc.ptr, _T("0.e%+d"), calc.esp);
621  else {
622  /* adds the dot at the end if the number has no decimal part */
623  if (!_tcschr(calc.buffer, _T('.')))
624  *calc.ptr++ = _T('.');
625  _stprintf(calc.ptr, _T("e%+d"), calc.esp);
626  }
628  return;
629  }
630  break;
631  case IDC_RADIO_OCT:
632  if (n >= 22)
633  return;
634  break;
635  case IDC_RADIO_BIN:
636  if (n >= 64)
637  return;
638  break;
639  }
640  calc.ptr += _stprintf(calc.ptr, _T("%C"), key2code[i].key);
642 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD base
Definition: calc.h:189
#define IDC_BUTTON_0
Definition: resource.h:55
#define IDC_RADIO_DEC
Definition: resource.h:22
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:489
GLdouble n
Definition: glext.h:7729
signed int esp
Definition: calc.h:188
#define IDC_BUTTON_DOT
Definition: resource.h:65
#define IDC_RADIO_BIN
Definition: resource.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SIZEOF(_ar)
Definition: calc.h:97
#define IDC_RADIO_HEX
Definition: resource.h:21
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
CHAR key
Definition: winmain.c:62
#define _T(x)
Definition: vfdio.h:22
#define IDC_STATIC
Definition: resource.h:4
BOOL sci_in
Definition: calc.h:185
#define _stprintf
Definition: utility.h:124
static const key3code_t key2code[]
Definition: winmain.c:82
#define LOCAL_EXP_SIZE
Definition: calc.h:43
#define IDC_RADIO_OCT
Definition: resource.h:23
Definition: path.c:42

Referenced by DlgMainProc().

◆ clean_stat_list()

static void clean_stat_list ( void  )
static

Definition at line 861 of file winmain.c.

862 {
863  statistic_t *p = calc.stat;
864 
865  while (p != NULL) {
866  statistic_t *s = p;
867  p = (statistic_t *)(p->next);
868  rpn_free(&s->num);
869  free(s);
870  }
871  calc.stat = p;
872 }
statistic_t * stat
Definition: calc.h:181
calc_t calc
Definition: winmain.c:247
#define free
Definition: debug_ros.c:5
void rpn_free(calc_number_t *c)
Definition: fun_ieee.c:605
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by DlgStatProc().

◆ convert_text2number()

static void convert_text2number ( calc_number_t a)
static

Definition at line 681 of file winmain.c.

682 {
683  /* if the screen output buffer is empty, then */
684  /* the operand is taken from the last input */
685  if (calc.buffer == calc.ptr) {
686  /* if pushed valued is ZERO then we should grab it */
687  if (!_tcscmp(calc.buffer, _T("0.")) ||
688  !_tcscmp(calc.buffer, _T("0")))
689  /* this zero is good for both integer and decimal */
690  rpn_zero(a);
691  else
692  rpn_copy(a, &calc.code);
693  return;
694  }
695  /* ZERO is the default value for all numeric bases */
696  rpn_zero(a);
698 }
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
calc_number_t code
Definition: calc.h:178
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
void convert_text2number_2(calc_number_t *a)
Definition: utl_ieee.c:86
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
#define _T(x)
Definition: vfdio.h:22
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by DlgMainProc(), and update_radio().

◆ CopyMemToClipboard()

static void CopyMemToClipboard ( void ptr)
static

Definition at line 984 of file winmain.c.

985 {
986  if(OpenClipboard(NULL)) {
987  HGLOBAL clipbuffer;
988  TCHAR *buffer;
989 
990  EmptyClipboard();
991  clipbuffer = GlobalAlloc(GMEM_DDESHARE, (_tcslen(ptr)+1)*sizeof(TCHAR));
992  buffer = (TCHAR *)GlobalLock(clipbuffer);
993  _tcscpy(buffer, ptr);
994  GlobalUnlock(clipbuffer);
995 #ifdef UNICODE
996  SetClipboardData(CF_UNICODETEXT,clipbuffer);
997 #else
998  SetClipboardData(CF_TEXT,clipbuffer);
999 #endif
1000  CloseClipboard();
1001  }
1002 }
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)
static PVOID ptr
Definition: dispmode.c:27
#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)

Referenced by handle_copy_command().

◆ delete_stat_item()

static void delete_stat_item ( int  n)
static

Definition at line 874 of file winmain.c.

875 {
876  statistic_t *p = calc.stat;
877  statistic_t *s;
878 
879  if (n == 0) {
880  calc.stat = (statistic_t *)p->next;
881  rpn_free(&p->num);
882  free(p);
883  } else {
884  s = (statistic_t *)p->next;
885  while (--n) {
886  p = s;
887  s = (statistic_t *)p->next;
888  }
889  p->next = s->next;
890  rpn_free(&s->num);
891  free(s);
892  }
893 }
statistic_t * stat
Definition: calc.h:181
calc_t calc
Definition: winmain.c:247
#define free
Definition: debug_ros.c:5
void rpn_free(calc_number_t *c)
Definition: fun_ieee.c:605
GLdouble n
Definition: glext.h:7729
while(1)
Definition: macro.lex.yy.c:740
void * next
Definition: calc.h:157
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by DlgStatProc().

◆ display_rpn_result()

static void display_rpn_result ( HWND  hwnd,
calc_number_t rpn 
)
static

Definition at line 663 of file winmain.c.

664 {
665  set_rpn_result(hwnd, rpn);
666  calc.ptr = calc.buffer;
667 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
static void set_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:654

Referenced by DlgMainProc(), and update_radio().

◆ DlgMainProc()

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

Definition at line 1412 of file winmain.c.

1413 {
1414  unsigned int x;
1415  RECT rc;
1416 
1417  switch (msg) {
1418  case WM_DRAWITEM:
1419  return SubclassButtonProc(hWnd, wp, lp);
1420 
1421  case WM_INITDIALOG:
1422 #ifdef DISABLE_HTMLHELP_SUPPORT
1424 #endif
1425  calc.hWnd=hWnd;
1426  /* Enumerate children and apply hover function */
1427  BtnCount = 0;
1429 
1430 #ifdef USE_KEYBOARD_HOOK
1431  calc.hKeyboardHook=SetWindowsHookEx(
1432  WH_KEYBOARD,
1434  NULL,
1436  );
1437 #endif
1438  rpn_zero(&calc.code);
1439  calc.sci_out = FALSE;
1443  calc.ptr = calc.buffer;
1444  calc.is_nan = FALSE;
1447  update_menu(hWnd);
1450  /* remove keyboard focus */
1452  /* set our calc icon */
1453  SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)calc.hBgIcon);
1454  SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)calc.hSmIcon);
1455  /* update text for decimal button */
1457  /* Fill combo box for conversion */
1459  ConvInit(hWnd);
1460  /* Restore the window at the same position it was */
1461  if (calc.x_coord >= 0 && calc.y_coord >= 0) {
1462  int w, h, sw, sh;
1463 
1464  GetWindowRect(hWnd, &rc);
1465  w = rc.right-rc.left;
1466  h = rc.bottom-rc.top;
1469  if (calc.x_coord+w > sw) calc.x_coord = sw - w;
1470  if (calc.y_coord+h > sh) calc.y_coord = sh - h;
1472  }
1473  break;
1474  case WM_CTLCOLORSTATIC:
1475  if ((HWND)lp == GetDlgItem(hWnd, IDC_TEXT_OUTPUT))
1477  break;
1478  case WM_HANDLE_CLIPBOARD:
1480  return TRUE;
1481  case WM_COMMAND:
1482  /*
1483  * if selection of category is changed, we must
1484  * update the content of the "from/to" combo boxes.
1485  */
1488  return TRUE;
1489  }
1490  if (HIWORD(wp) != BN_CLICKED && HIWORD(wp) != BN_DBLCLK)
1491  break;
1492  /* avoid flicker if the user selects from keyboard */
1495  switch (LOWORD(wp)) {
1496  case IDM_HELP_ABOUT:
1497  {
1498  TCHAR infotitle[100];
1499  TCHAR infotext[200];
1500  LoadString(calc.hInstance, IDS_CALC_NAME, infotitle, SIZEOF(infotitle));
1501  LoadString(calc.hInstance, IDS_AUTHOR, infotext, SIZEOF(infotext));
1502  ShellAbout(hWnd, infotitle, infotext, calc.hBgIcon);
1503  return TRUE;
1504  }
1505  case IDM_HELP_HELP:
1506 #ifndef DISABLE_HTMLHELP_SUPPORT
1507  calc_HtmlHelp(hWnd, HTMLHELP_PATH("/general_information.htm"), HH_DISPLAY_TOPIC, (DWORD_PTR)NULL);
1508 #endif
1509  return TRUE;
1510  case IDM_VIEW_STANDARD:
1514  return TRUE;
1515  case IDM_VIEW_SCIENTIFIC:
1519  return TRUE;
1520  case IDM_VIEW_CONVERSION:
1524  return TRUE;
1525  case IDM_VIEW_HEX:
1526  case IDM_VIEW_DEC:
1527  case IDM_VIEW_OCT:
1528  case IDM_VIEW_BIN:
1529  case IDM_VIEW_DEG:
1530  case IDM_VIEW_RAD:
1531  case IDM_VIEW_GRAD:
1532  case IDM_VIEW_QWORD:
1533  case IDM_VIEW_DWORD:
1534  case IDM_VIEW_WORD:
1535  case IDM_VIEW_BYTE:
1537  return TRUE;
1538  case IDM_EDIT_COPY:
1540  return TRUE;
1541  case IDM_EDIT_PASTE:
1542  if (calc.Clipboard.data != NULL)
1543  break;
1545  if (calc.Clipboard.data != NULL) {
1546  /* clear the content of the display before pasting */
1551  }
1552  return TRUE;
1553  case IDM_VIEW_GROUP:
1554  calc.usesep = (calc.usesep ? FALSE : TRUE);
1555  update_menu(hWnd);
1557  return TRUE;
1558  case IDC_BUTTON_CONVERT:
1559  ConvExecute(hWnd);
1560  return TRUE;
1561  case IDC_BUTTON_CE: {
1562  calc_number_t tmp;
1563  rpn_zero(&tmp);
1564  display_rpn_result(hWnd, &tmp);
1565  }
1566  return TRUE;
1567  case IDC_RADIO_DEC:
1568  case IDC_RADIO_HEX:
1569  case IDC_RADIO_OCT:
1570  case IDC_RADIO_BIN:
1571 /* GNU WINDRES is bugged so I must always force radio update */
1572 /* (Fix for Win95/98) */
1573 #ifdef _MSC_VER
1574  if (calc.base == LOWORD(wp))
1575  break;
1576 #endif
1577  calc.is_nan = FALSE;
1578  update_radio(hWnd, LOWORD(wp));
1579  return TRUE;
1580  case IDC_RADIO_DEG:
1581  case IDC_RADIO_RAD:
1582  case IDC_RADIO_GRAD:
1583 /* GNU WINDRES is bugged so I must always force radio update */
1584 /* (Fix for Win95/98) */
1585 #ifdef _MSC_VER
1586  if (calc.degr == LOWORD(wp))
1587  break;
1588 #endif
1589  calc.degr = LOWORD(wp);
1590  calc.is_nan = FALSE;
1591  update_menu(hWnd);
1592  return TRUE;
1593  case IDC_RADIO_QWORD:
1594  case IDC_RADIO_DWORD:
1595  case IDC_RADIO_WORD:
1596  case IDC_RADIO_BYTE:
1597 /* GNU WINDRES is bugged so I must always force radio update */
1598 /* (Fix for Win95/98) */
1599 #ifdef _MSC_VER
1600  if (calc.size == LOWORD(wp))
1601  break;
1602 #endif
1603  calc.size = LOWORD(wp);
1604  calc.is_nan = FALSE;
1605  update_menu(hWnd);
1606  /*
1607  * update the content of the display
1608  */
1612  return TRUE;
1613  case IDC_BUTTON_1:
1614  case IDC_BUTTON_2:
1615  case IDC_BUTTON_3:
1616  case IDC_BUTTON_4:
1617  case IDC_BUTTON_5:
1618  case IDC_BUTTON_6:
1619  case IDC_BUTTON_7:
1620  case IDC_BUTTON_8:
1621  case IDC_BUTTON_9:
1622  case IDC_BUTTON_0:
1623  case IDC_BUTTON_DOT:
1624  case IDC_BUTTON_A:
1625  case IDC_BUTTON_B:
1626  case IDC_BUTTON_C:
1627  case IDC_BUTTON_D:
1628  case IDC_BUTTON_E:
1629  case IDC_BUTTON_F:
1630  calc.is_nan = FALSE;
1631  build_operand(hWnd, LOWORD(wp));
1632  return TRUE;
1633  case IDC_BUTTON_PERCENT:
1634  case IDC_BUTTON_ADD:
1635  case IDC_BUTTON_SUB:
1636  case IDC_BUTTON_MULT:
1637  case IDC_BUTTON_DIV:
1638  case IDC_BUTTON_MOD:
1639  case IDC_BUTTON_AND:
1640  case IDC_BUTTON_OR:
1641  case IDC_BUTTON_XOR:
1642  case IDC_BUTTON_LSH:
1643  case IDC_BUTTON_RSH:
1644  case IDC_BUTTON_EQU:
1645  case IDC_BUTTON_XeY:
1646  case IDC_BUTTON_XrY:
1647  if (calc.is_nan) break;
1648  /*
1649  * LSH and XeY buttons hold also the RSH and XrY functions with INV modifier,
1650  * but since they are two operand operators, they must be handled here.
1651  */
1652  if ((get_modifiers(hWnd) & MODIFIER_INV))
1653  {
1654  WPARAM IdcSim = IDC_STATIC;
1655 
1656  switch (LOWORD(wp)) {
1657  case IDC_BUTTON_LSH: IdcSim = MAKEWPARAM(IDC_BUTTON_RSH, BN_CLICKED); break;
1658  case IDC_BUTTON_XeY: IdcSim = MAKEWPARAM(IDC_BUTTON_XrY, BN_CLICKED); break;
1659  }
1660 
1661  if (IdcSim != IDC_STATIC)
1662  {
1663  PostMessage(hWnd, WM_COMMAND, IdcSim, 0);
1665  break;
1666  }
1667  }
1668 
1669  for (x=0; x<SIZEOF(operator_codes); x++) {
1670  if (LOWORD(wp) == operator_codes[x]) {
1672 
1673  if (calc.ptr == calc.buffer) {
1674  if (calc.last_operator != x) {
1675  if (x != RPN_OPERATOR_EQUAL)
1677  } else
1678  if (x == RPN_OPERATOR_EQUAL) {
1680  rpn_copy(&calc.code, &calc.prev);
1681  } else
1682  break;
1683  }
1684 
1685  /* if no change then quit silently, */
1686  /* without display updates */
1687  if (!exec_infix2postfix(&calc.code, x))
1688  break;
1689 
1691  break;
1692  }
1693  }
1694  return TRUE;
1695  case IDC_BUTTON_BACK:
1696  if (calc.sci_in) {
1697  if (calc.esp == 0) {
1698  TCHAR *ptr;
1699 
1700  calc.sci_in = FALSE;
1701  ptr = _tcschr(calc.ptr, _T('e'));
1702  if (ptr)
1703  *ptr = _T('\0');
1705  } else {
1706  calc.esp /= 10;
1708  }
1709  } else
1710  if (calc.ptr != calc.buffer) {
1711  *--calc.ptr = _T('\0');
1712  if (!_tcscmp(calc.buffer, _T("-")) ||
1713  !_tcscmp(calc.buffer, _T("-0")) ||
1714  !_tcscmp(calc.buffer, _T("0"))) {
1715  calc.ptr = calc.buffer;
1716  calc.buffer[0] = _T('\0');
1717  }
1719  }
1720  return TRUE;
1721  case IDC_BUTTON_MC:
1724  return TRUE;
1725  case IDC_BUTTON_MR:
1726  if (calc.is_memory) {
1727  calc.is_nan = FALSE;
1730  }
1731  return TRUE;
1732  case IDC_BUTTON_EXP:
1733  if (calc.sci_in || calc.is_nan || calc.buffer == calc.ptr)
1734  break;
1735  calc.sci_in = TRUE;
1736  calc.esp = 0;
1738  return TRUE;
1739  case IDC_BUTTON_SIGN:
1740  if (calc.sci_in) {
1741  calc.esp = 0-calc.esp;
1743  } else {
1744  if (calc.is_nan || calc.buffer[0] == _T('\0'))
1745  break;
1746 
1747  if (calc.buffer[0] == _T('-')) {
1748  /* make the number positive */
1749  memmove(calc.buffer, calc.buffer+1, sizeof(calc.buffer)-1);
1750  if (calc.buffer != calc.ptr)
1751  calc.ptr--;
1752  } else {
1753  /* if first char is '0' and no dot, it isn't valid */
1754  if (calc.buffer[0] == _T('0') &&
1755  calc.buffer[1] != _T('.'))
1756  break;
1757  /* make the number negative */
1758  memmove(calc.buffer+1, calc.buffer, sizeof(calc.buffer)-1);
1759  calc.buffer[0] = _T('-');
1760  if (calc.buffer != calc.ptr)
1761  calc.ptr++;
1762  }
1763  /* If the input buffer is empty, then
1764  we change also the sign of calc.code
1765  because it could be the result of a
1766  previous calculation. */
1767  if (calc.buffer == calc.ptr)
1768  rpn_sign(&calc.code);
1770  }
1771  return TRUE;
1772  case IDC_BUTTON_RIGHTPAR:
1773  case IDC_BUTTON_LEFTPAR:
1774  case IDC_BUTTON_CANC:
1775  case IDC_BUTTON_MP:
1776  case IDC_BUTTON_DAT:
1777  case IDC_BUTTON_FE:
1778  case IDC_BUTTON_DMS:
1779  case IDC_BUTTON_SQRT:
1780  case IDC_BUTTON_S:
1781  case IDC_BUTTON_SUM:
1782  case IDC_BUTTON_AVE:
1783  case IDC_BUTTON_NF:
1784  case IDC_BUTTON_LN:
1785  case IDC_BUTTON_LOG:
1786  case IDC_BUTTON_Xe2:
1787  case IDC_BUTTON_Xe3:
1788  case IDC_BUTTON_PI:
1789  case IDC_BUTTON_NOT:
1790  case IDC_BUTTON_RX:
1791  case IDC_BUTTON_INT:
1792  case IDC_BUTTON_SIN:
1793  case IDC_BUTTON_COS:
1794  case IDC_BUTTON_TAN:
1795  case IDC_BUTTON_MS:
1796  for (x=0; x<SIZEOF(function_table); x++) {
1797  if (LOWORD(wp) == function_table[x].idc) {
1798  rpn_callback1 cb = NULL;
1799 
1800  /* test if NaN state is important or not */
1801  if (calc.is_nan && function_table[x].check_nan) break;
1802  /* otherwise, it's cleared */
1803  calc.is_nan = FALSE;
1804 
1805  switch (get_modifiers(hWnd) & function_table[x].range) {
1806  case 0:
1808  break;
1809  case MODIFIER_INV:
1811  break;
1812  case MODIFIER_HYP:
1814  break;
1817  break;
1818  }
1819  if (cb != NULL) {
1821  cb(&calc.code);
1822 // display_rpn_result(hWnd, &calc.code);
1824 
1825  if ((function_table[x].range & NO_CHAIN))
1826  calc.ptr = calc.buffer;
1827 
1828 // if (!(function_table[x].range & NO_CHAIN))
1829 // exec_infix2postfix(&calc.code, RPN_OPERATOR_NONE);
1834  }
1835  break;
1836  }
1837  }
1838  return TRUE;
1839  case IDC_BUTTON_STA:
1840  if (IsWindow(calc.hStatWnd))
1841  break;
1844  if (calc.hStatWnd != NULL) {
1847  }
1848  return TRUE;
1849  }
1850  break;
1851  case WM_CLOSE_STATS:
1852  calc.hStatWnd = NULL;
1854  return TRUE;
1855  case WM_LOAD_STAT:
1856  if (upload_stat_number((int)LOWORD(wp)) != NULL)
1858  return TRUE;
1859  case WM_START_CONV:
1860  x = LOWORD(lp);
1862  if (calc.Convert[x].data != NULL) {
1864  PostMessage(hWnd, HIWORD(lp), 0, 0);
1865  }
1866  return TRUE;
1867  case WM_HANDLE_FROM:
1868  if (calc.is_nan)
1869  break;
1872  MAKELPARAM(0x0001, WM_HANDLE_TO));
1873  return TRUE;
1874  case WM_HANDLE_TO:
1875  if (!calc.is_nan)
1877  return TRUE;
1878  case WM_CLOSE:
1881  return TRUE;
1882 
1883  case WM_DESTROY:
1884  /* Get (x,y) position of the calculator */
1885  GetWindowRect(hWnd, &rc);
1886  calc.x_coord = rc.left;
1887  calc.y_coord = rc.top;
1888 #ifdef USE_KEYBOARD_HOOK
1889  UnhookWindowsHookEx(calc.hKeyboardHook);
1890 #endif
1891  PostQuitMessage(0);
1892  return TRUE;
1893  case WM_CONTEXTMENU:
1894  if ((HWND)wp != hWnd)
1895  handle_context_menu(hWnd, wp, lp);
1896  return TRUE;
1897  case WM_ENTERMENULOOP:
1898  calc.is_menu_on = TRUE;
1899  /* Check if a valid format is available in the clipboard */
1902  MF_BYCOMMAND|
1904  MF_ENABLED : MF_GRAYED));
1905  break;
1906  case WM_EXITMENULOOP:
1907  calc.is_menu_on = FALSE;
1908  break;
1909 
1910  case WM_SETTINGCHANGE:
1911  return OnSettingChange(hWnd, wp, lp);
1912 
1913  case WM_THEMECHANGED:
1915  break;
1916  }
1917  return FALSE;
1918 }
#define IDC_BUTTON_1
Definition: resource.h:54
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define IDC_BUTTON_MC
Definition: resource.h:47
static INT_PTR CALLBACK DlgStatProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:917
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define IDC_BUTTON_CANC
Definition: resource.h:89
DWORD base
Definition: calc.h:189
static void convert_text2number(calc_number_t *a)
Definition: winmain.c:681
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDC_RADIO_DEG
Definition: resource.h:86
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
sequence_t Convert[2]
Definition: calc.h:196
#define IDC_BUTTON_0
Definition: resource.h:55
#define IDC_BUTTON_INT
Definition: resource.h:80
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define IDC_BUTTON_CE
Definition: resource.h:90
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
#define IDC_BUTTON_BACK
Definition: resource.h:91
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
UINT wm_msg
Definition: calc.h:151
#define IDM_VIEW_OCT
Definition: resource.h:378
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_VIEW_BIN
Definition: resource.h:379
BOOL sci_out
Definition: calc.h:184
#define IDC_BUTTON_B
Definition: resource.h:61
calc_number_t code
Definition: calc.h:178
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define IDC_RADIO_GRAD
Definition: resource.h:88
rpn_callback1 inverse
Definition: winmain.c:194
#define IDC_BUTTON_MP
Definition: resource.h:50
BOOL is_menu_on
Definition: calc.h:187
DWORD layout
Definition: calc.h:174
#define IDM_VIEW_QWORD
Definition: resource.h:386
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define IDC_BUTTON_2
Definition: resource.h:59
#define IDM_VIEW_DEC
Definition: resource.h:377
static WPARAM idm_2_idc(int idm)
Definition: winmain.c:973
#define IDC_BUTTON_RX
Definition: resource.h:46
#define IDC_BUTTON_XrY
Definition: resource.h:111
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define IDC_BUTTON_EQU
Definition: resource.h:75
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:489
#define IDC_CHECK_INV
Definition: resource.h:25
#define IDC_RADIO_WORD
Definition: resource.h:84
rpn_callback1 direct
Definition: winmain.c:193
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
#define IDM_VIEW_GROUP
Definition: resource.h:383
#define IDC_BUTTON_SQRT
Definition: resource.h:102
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
static void update_menu(HWND hWnd)
Definition: winmain.c:724
HWND hWnd
Definition: settings.c:17
#define WM_HANDLE_FROM
Definition: calc.h:29
LONG top
Definition: windef.h:292
#define IDC_BUTTON_SUM
Definition: resource.h:29
static void enable_allowed_controls(HWND hwnd, DWORD base)
Definition: winmain.c:757
#define IDC_BUTTON_Xe3
Definition: resource.h:41
#define IDC_BUTTON_6
Definition: resource.h:63
#define IDC_BUTTON_3
Definition: resource.h:64
#define IDC_BUTTON_PI
Definition: resource.h:51
#define IDC_BUTTON_S
Definition: resource.h:30
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static void update_radio(HWND hwnd, unsigned int base)
Definition: winmain.c:793
#define WHITE_BRUSH
Definition: wingdi.h:901
#define IDM_HELP_ABOUT
Definition: resource.h:385
HICON hBgIcon
Definition: calc.h:172
#define HTMLHELP_PATH(_pt)
Definition: winmain.c:23
HWND WINAPI SetFocus(_In_opt_ HWND)
DWORD degr
Definition: calc.h:191
#define IDM_VIEW_BYTE
Definition: resource.h:388
#define IDM_VIEW_RAD
Definition: resource.h:381
UINT_PTR WPARAM
Definition: windef.h:207
#define BN_DBLCLK
Definition: winuser.h:1887
#define IDM_VIEW_GRAD
Definition: resource.h:382
#define SendDlgItemMessage
Definition: winuser.h:5708
static LRESULT CALLBACK SubclassButtonProc(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1240
LONG left
Definition: windef.h:291
void ConvInit(HWND hWnd)
Definition: convert.c:650
LONG right
Definition: windef.h:293
BOOL is_nan
Definition: calc.h:183
rpn_callback1 hyperb
Definition: winmain.c:195
static const WORD operator_codes[]
Definition: winmain.c:168
signed int esp
Definition: calc.h:188
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDC_BUTTON_NOT
Definition: resource.h:79
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDM_VIEW_STANDARD
Definition: resource.h:374
#define IDC_BUTTON_MOD
Definition: resource.h:72
#define IDC_BUTTON_FOCUS
Definition: resource.h:106
#define IDC_BUTTON_DOT
Definition: resource.h:65
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define ICON_SMALL
Definition: tnclass.cpp:48
#define IDC_RADIO_BIN
Definition: resource.h:24
#define MODIFIER_INV
Definition: calc.h:216
#define calc_HtmlHelp
Definition: calc.h:59
#define IDM_EDIT_PASTE
Definition: resource.h:373
DWORD action
Definition: calc.h:192
#define SM_CXSCREEN
Definition: winuser.h:949
#define IDC_BUTTON_FE
Definition: resource.h:32
#define IDC_BUTTON_EXP
Definition: resource.h:38
void exec_change_infix(void)
Definition: rpn_ieee.c:422
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SIZEOF(_ar)
Definition: calc.h:97
#define IDM_VIEW_SCIENTIFIC
Definition: resource.h:375
#define IDM_VIEW_DWORD
Definition: resource.h:389
#define IDC_RADIO_QWORD
Definition: resource.h:82
#define IDM_EDIT_COPY
Definition: resource.h:372
#define IDC_BUTTON_LN
Definition: resource.h:43
#define WM_ENTERMENULOOP
Definition: winuser.h:1780
#define IDC_RADIO_HEX
Definition: resource.h:21
void ConvExecute(HWND hWnd)
Definition: convert.c:568
static PVOID ptr
Definition: dispmode.c:27
DWORD size
Definition: calc.h:190
signed int y_coord
Definition: calc.h:204
#define IDC_BUTTON_9
Definition: resource.h:62
static statistic_t * upload_stat_number(int n)
Definition: winmain.c:1143
#define WM_EXITMENULOOP
Definition: winuser.h:1781
static BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
Definition: winmain.c:1366
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
#define NO_CHAIN
Definition: calc.h:218
unsigned int prev_operator
Definition: calc.h:198
LONG_PTR LPARAM
Definition: windef.h:208
HINSTANCE hInstance
Definition: calc.h:167
#define IDC_COMBO_CATEGORY
Definition: resource.h:107
signed int x_coord
Definition: calc.h:203
#define IDC_BUTTON_MULT
Definition: resource.h:68
#define IDC_BUTTON_OR
Definition: resource.h:73
#define MODIFIER_HYP
Definition: calc.h:217
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
static int get_modifiers(HWND hWnd)
Definition: winmain.c:669
#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:77
static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: msg.c:16281
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn_ieee.c:391
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:171
#define IDC_BUTTON_PERCENT
Definition: resource.h:103
TCHAR sDecimal[8]
Definition: calc.h:199
#define IDC_BUTTON_SIN
Definition: resource.h:34
#define IDC_BUTTON_Xe2
Definition: resource.h:40
#define _T(x)
Definition: vfdio.h:22
#define IDC_BUTTON_7
Definition: resource.h:52
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL usesep
Definition: calc.h:186
#define WM_LOAD_STAT
Definition: calc.h:27
char * ptr
Definition: calc.h:150
#define IDC_BUTTON_NF
Definition: resource.h:45
#define WM_CLOSE_STATS
Definition: calc.h:24
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
#define SetWindowsHookEx
Definition: winuser.h:5722
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define IDS_AUTHOR
Definition: resource.h:10
#define IDM_VIEW_CONVERSION
Definition: resource.h:390
int WINAPI GetSystemMetrics(_In_ int)
#define BN_CLICKED
Definition: winuser.h:1886
#define IDC_STATIC
Definition: resource.h:4
void rpn_sign(calc_number_t *c)
Definition: fun_ieee.c:300
#define ShellAbout
Definition: shellapi.h:688
BOOL sci_in
Definition: calc.h:185
unsigned int last_operator
Definition: calc.h:197
static DWORD cb
Definition: integrity.c:41
#define IDC_BUTTON_XeY
Definition: resource.h:39
#define SetDlgItemText
Definition: winuser.h:5715
UINT BtnCount
Definition: winmain.c:251
calc_number_t number
Definition: calc.h:133
#define IDC_BUTTON_SUB
Definition: resource.h:69
#define IDC_BUTTON_STA
Definition: resource.h:27
#define IDC_BUTTON_A
Definition: resource.h:56
#define IDC_BUTTON_LSH
Definition: resource.h:74
static void set_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:654
HICON hSmIcon
Definition: calc.h:173
#define IDC_BUTTON_CONVERT
Definition: resource.h:104
#define IDC_BUTTON_F
Definition: resource.h:81
#define IDC_BUTTON_4
Definition: resource.h:53
static void handle_context_menu(HWND hWnd, WPARAM wp, LPARAM lp)
Definition: winmain.c:1178
static INT_PTR CALLBACK OnSettingChange(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: winmain.c:1389
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
static void handle_copy_command(HWND hWnd)
Definition: winmain.c:1004
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define IDC_BUTTON_8
Definition: resource.h:57
#define BST_UNCHECKED
Definition: winuser.h:199
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define IDC_BUTTON_XOR
Definition: resource.h:78
#define IDM_VIEW_HEX
Definition: resource.h:376
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define IDC_BUTTON_RIGHTPAR
Definition: resource.h:42
#define WM_START_CONV
Definition: calc.h:28
#define IDC_BUTTON_RSH
Definition: resource.h:110
#define IDC_BUTTON_MR
Definition: resource.h:48
GLenum GLint * range
Definition: glext.h:7539
#define IDC_BUTTON_E
Definition: resource.h:76
char * data
Definition: calc.h:149
short sh
Definition: format.c:272
#define IDC_BUTTON_LOG
Definition: resource.h:44
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:621
HWND hStatWnd
Definition: calc.h:193
static void display_rpn_result(HWND hwnd, calc_number_t *rpn)
Definition: winmain.c:663
#define WM_HANDLE_CLIPBOARD
Definition: calc.h:25
#define IDC_BUTTON_DMS
Definition: resource.h:33
static const function_table_t function_table[]
Definition: winmain.c:209
rpn_callback1 inv_hyp
Definition: winmain.c:196
#define IDC_RADIO_DWORD
Definition: resource.h:83
BOOL is_memory
Definition: calc.h:182
#define IDM_VIEW_DEG
Definition: resource.h:380
static char * handle_sequence_input(HWND hwnd, sequence_t *seq)
Definition: winmain.c:1036
#define CBN_SELCHANGE
Definition: winuser.h:1940
static void build_operand(HWND hwnd, DWORD idc)
Definition: winmain.c:580
#define IDC_CHECK_HYP
Definition: resource.h:26
#define WM_DRAWITEM
Definition: winuser.h:1627
HWND WINAPI GetFocus(void)
Definition: window.c:1875
#define msg(x)
Definition: auth_time.c:54
#define IDC_BUTTON_TAN
Definition: resource.h:36
#define IDC_BUTTON_D
Definition: resource.h:71
#define IDD_DIALOG_STAT
Definition: resource.h:14
#define IDC_RADIO_RAD
Definition: resource.h:87
#define IDC_BUTTON_MS
Definition: resource.h:49
#define IDC_BUTTON_ADD
Definition: resource.h:70
#define SendMessage
Definition: winuser.h:5709
#define WH_KEYBOARD
Definition: winuser.h:32
#define IDC_BUTTON_5
Definition: resource.h:58
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:294
#define IDC_BUTTON_AVE
Definition: resource.h:28
#define IDC_BUTTON_LEFTPAR
Definition: resource.h:37
calc_node_t memory
Definition: calc.h:180
#define WM_HANDLE_TO
Definition: calc.h:30
#define IDC_TEXT_OUTPUT
Definition: resource.h:92
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
void(* rpn_callback1)(calc_number_t *)
Definition: winmain.c:187
#define IDM_HELP_HELP
Definition: resource.h:384
#define IDM_VIEW_WORD
Definition: resource.h:387
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
#define IDC_BUTTON_SIGN
Definition: resource.h:60
LONG_PTR LRESULT
Definition: windef.h:209
#define IDC_RADIO_OCT
Definition: resource.h:23
#define IDC_BUTTON_COS
Definition: resource.h:35
static char * ReadConversion(const char *formula)
Definition: winmain.c:895
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:847
HMENU WINAPI GetMenu(_In_ HWND)
#define IDC_BUTTON_DAT
Definition: resource.h:31
#define IDC_BUTTON_C
Definition: resource.h:66
#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:7
static char * ReadClipboard(void)
Definition: winmain.c:1017
#define CreateDialog
Definition: winuser.h:5615
sequence_t Clipboard
Definition: calc.h:195
#define IDC_RADIO_BYTE
Definition: resource.h:85
#define ICON_BIG
Definition: tnclass.cpp:51
calc_number_t prev
Definition: calc.h:179
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26
#define IDC_BUTTON_DIV
Definition: resource.h:67

Referenced by _tWinMain().

◆ DlgStatProc()

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

Definition at line 917 of file winmain.c.

918 {
920  DWORD n;
921 
922  switch (msg) {
923  case WM_INITDIALOG:
924  return TRUE;
925  case WM_COMMAND:
926  switch (LOWORD(wp)) {
927  case IDC_LIST_STAT:
928  if (HIWORD(wp) == CBN_DBLCLK)
930  return TRUE;
931  case IDC_BUTTON_RET:
933  return TRUE;
934  case IDC_BUTTON_LOAD:
936  if (n == LB_ERR)
937  return TRUE;
939  return TRUE;
940  case IDC_BUTTON_CD:
942  if (n == LB_ERR)
943  return TRUE;
947  return TRUE;
948  case IDC_BUTTON_CAD:
950  clean_stat_list();
952  return TRUE;
953  }
954  break;
955  case WM_CLOSE:
957  return TRUE;
958  case WM_DESTROY:
959  clean_stat_list();
961  return TRUE;
962  case WM_INSERT_STAT:
963  prepare_rpn_result(&(((statistic_t *)lp)->num),
964  buffer, SIZEOF(buffer),
965  ((statistic_t *)lp)->base);
968  return TRUE;
969  }
970  return FALSE;
971 }
#define IDC_BUTTON_CAD
Definition: resource.h:100
static void update_n_stats_items(HWND hWnd, TCHAR *buffer)
Definition: winmain.c:853
#define TRUE
Definition: types.h:120
static void delete_stat_item(int n)
Definition: winmain.c:874
#define LB_ADDSTRING
Definition: winuser.h:1992
calc_t calc
Definition: winmain.c:247
HWND hWnd
Definition: settings.c:17
GLdouble n
Definition: glext.h:7729
#define WM_INSERT_STAT
Definition: calc.h:26
GLuint buffer
Definition: glext.h:5915
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDC_BUTTON_LOAD
Definition: resource.h:98
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDC_BUTTON_FOCUS
Definition: resource.h:106
#define LB_RESETCONTENT
Definition: winuser.h:2016
#define SIZEOF(_ar)
Definition: calc.h:97
#define LB_ERR
Definition: winuser.h:2386
#define CBN_DBLCLK
Definition: winuser.h:1934
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
LONG_PTR LPARAM
Definition: windef.h:208
#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:27
#define WM_CLOSE_STATS
Definition: calc.h:24
#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:97
#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:644
HWND WINAPI GetParent(_In_ HWND)
#define IDC_LIST_STAT
Definition: resource.h:96
#define LB_GETCURSEL
Definition: winuser.h:2000
#define msg(x)
Definition: auth_time.c:54
#define SendMessage
Definition: winuser.h:5709
#define HIWORD(l)
Definition: typedefs.h:246
static void clean_stat_list(void)
Definition: winmain.c:861
#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:99

Referenced by DlgMainProc().

◆ enable_allowed_controls()

static void enable_allowed_controls ( HWND  hwnd,
DWORD  base 
)
static

Definition at line 757 of file winmain.c.

758 {
759  BYTE mask;
760  int n;
761 
762  switch (base) {
763  case IDC_RADIO_DEC:
765  break;
766  case IDC_RADIO_HEX:
768  break;
769  case IDC_RADIO_OCT:
771  break;
772  case IDC_RADIO_BIN:
774  break;
775  default:
776  return;
777  }
778  for (n=0; n<SIZEOF(key2code); n++) {
779  if (key2code[n].mask != 0) {
780  HWND hCtlWnd = GetDlgItem(hwnd, key2code[n].idc);
781  BOOL current;
782 
783  if ((key2code[n].mask & BITMASK_IS_STATS))
785  else
786  current = (key2code[n].mask & mask) ? TRUE : FALSE;
787  if (IsWindowEnabled(hCtlWnd) != current)
788  EnableWindow(hCtlWnd, current);
789  }
790  }
791 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define BITMASK_DEC_MASK
Definition: winmain.c:47
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL WINAPI IsWindow(_In_opt_ HWND)
calc_t calc
Definition: winmain.c:247
GLdouble n
Definition: glext.h:7729
#define IDC_RADIO_BIN
Definition: resource.h:24
#define SIZEOF(_ar)
Definition: calc.h:97
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_RADIO_HEX
Definition: resource.h:21
BOOL WINAPI IsWindowEnabled(_In_ HWND)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned char BYTE
Definition: mem.h:68
#define BITMASK_OCT_MASK
Definition: winmain.c:48
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND hStatWnd
Definition: calc.h:193
static const key3code_t key2code[]
Definition: winmain.c:82
BYTE mask
Definition: winmain.c:63
#define BITMASK_HEX_MASK
Definition: winmain.c:46
#define BITMASK_IS_STATS
Definition: winmain.c:44
#define IDC_RADIO_OCT
Definition: resource.h:23
struct task_struct * current
Definition: linux.c:32
#define BITMASK_BIN_MASK
Definition: winmain.c:49

Referenced by DlgMainProc(), and update_radio().

◆ EnumChildProc()

static BOOL CALLBACK EnumChildProc ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 1366 of file winmain.c.

1367 {
1368  TCHAR szClass[64];
1369 
1370  if (!GetClassName(hWnd, szClass, SIZEOF(szClass)))
1371  return TRUE;
1372 
1373  if (!_tcscmp(szClass, WC_BUTTON))
1374  {
1375  int *pnCtrls = (int *)lParam;
1376  int nCtrls = *pnCtrls;
1377 
1379  BtnInfo[nCtrls].bHover = FALSE;
1380 
1383 
1384  *pnCtrls = ++nCtrls;
1385  }
1386  return TRUE;
1387 }
BOOL bHover
Definition: winmain.c:238
#define TRUE
Definition: types.h:120
#define WC_BUTTON
Definition: commctrl.h:4597
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
BTNINFO BtnInfo[255]
Definition: winmain.c:250
HWND hWnd
Definition: settings.c:17
#define SetWindowLongPtr
Definition: treelist.c:70
#define SIZEOF(_ar)
Definition: calc.h:97
#define GWLP_USERDATA
Definition: treelist.c:63
char TCHAR
Definition: xmlstorage.h:189
static INT_PTR CALLBACK HotButtonProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: winmain.c:1334
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define GetClassName
Definition: winuser.h:5649
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WNDPROC oldProc
Definition: winmain.c:239
#define GetWindowLongPtr
Definition: treelist.c:73
LPARAM lParam
Definition: combotst.c:139

Referenced by DlgMainProc().

◆ get_modifiers()

static int get_modifiers ( HWND  hWnd)
static

Definition at line 669 of file winmain.c.

670 {
671  int modifiers = 0;
672 
674  modifiers |= MODIFIER_INV;
676  modifiers |= MODIFIER_HYP;
677 
678  return modifiers;
679 }
#define IDC_CHECK_INV
Definition: resource.h:25
HWND hWnd
Definition: settings.c:17
#define MODIFIER_INV
Definition: calc.h:216
#define MODIFIER_HYP
Definition: calc.h:217
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define BST_CHECKED
Definition: winuser.h:197
#define IDC_CHECK_HYP
Definition: resource.h:26

Referenced by DlgMainProc().

◆ handle_context_menu()

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

Definition at line 1178 of file winmain.c.

1179 {
1180  TCHAR text[64];
1181  HMENU hMenu = CreatePopupMenu();
1182  BOOL idm;
1183 
1186  idm = TrackPopupMenu( hMenu,
1188  LOWORD(lp),
1189  HIWORD(lp),
1190  0,
1191  hWnd,
1192  NULL);
1193  DestroyMenu(hMenu);
1194 #ifndef DISABLE_HTMLHELP_SUPPORT
1195  if (idm) {
1196  HH_POPUP popup;
1197 
1198  memset(&popup, 0, sizeof(popup));
1199  popup.cbStruct = sizeof(HH_POPUP);
1200  popup.clrForeground = 1;
1201  popup.clrBackground = -1;
1202  popup.pt.x = LOWORD(lp);
1203  popup.pt.y = HIWORD(lp);
1204  popup.rcMargins.top = -1;
1205  popup.rcMargins.bottom = -1;
1206  popup.rcMargins.left = -1;
1207  popup.rcMargins.right = -1;
1208  popup.idString = GetWindowLongPtr((HWND)wp, GWL_ID);
1209  calc_HtmlHelp((HWND)wp, HTMLHELP_PATH("/popups.txt"), HH_DISPLAY_TEXT_POPUP, (DWORD_PTR)&popup);
1210  }
1211 #else
1212  (void)idm;
1213 #endif
1214 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define TPM_LEFTALIGN
Definition: winuser.h:2331
calc_t calc
Definition: winmain.c:247
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
HWND hWnd
Definition: settings.c:17
#define HTMLHELP_PATH(_pt)
Definition: winmain.c:23
#define calc_HtmlHelp
Definition: calc.h:59
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
#define SIZEOF(_ar)
Definition: calc.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TPM_TOPALIGN
Definition: winuser.h:2337
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE hInstance
Definition: calc.h:167
char TCHAR
Definition: xmlstorage.h:189
#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:384
#define HH_DISPLAY_TEXT_POPUP
Definition: htmlhelp.h:37
#define GetWindowLongPtr
Definition: treelist.c:73
#define memset(x, y, z)
Definition: compat.h:39
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:9

Referenced by DlgMainProc().

◆ handle_copy_command()

static void handle_copy_command ( HWND  hWnd)
static

Definition at line 1004 of file winmain.c.

1005 {
1007  UINT n;
1008 
1010 
1011  if (calc.base == IDC_RADIO_DEC && _tcschr(calc.buffer, _T('.')) == NULL)
1012  display[n - calc.sDecimal_len] = _T('\0');
1013 
1015 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
calc_t calc
Definition: winmain.c:247
HWND hWnd
Definition: settings.c:17
GLdouble n
Definition: glext.h:7729
int * display
Definition: x11stubs.c:12
#define SIZEOF(_ar)
Definition: calc.h:97
smooth NULL
Definition: ftsmooth.c:416
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define GetDlgItemText
Definition: winuser.h:5651
unsigned int sDecimal_len
Definition: calc.h:201
#define MAX_CALC_SIZE
Definition: calc.h:49
static void CopyMemToClipboard(void *ptr)
Definition: winmain.c:984
unsigned int UINT
Definition: ndis.h:50
#define IDC_TEXT_OUTPUT
Definition: resource.h:92

Referenced by DlgMainProc().

◆ handle_sequence_input()

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

Definition at line 1036 of file winmain.c.

1037 {
1038  char *ptr = seq->ptr;
1039  int ch, x;
1040 
1041  ch = *ptr++;
1042  if (ch == '\\')
1044  else
1045  if (ch == ':') {
1046  ch = *ptr;
1047  if (ch != '\0')
1048  ptr++;
1049  switch (ch) {
1050  case 'C': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MC, 0); break;
1051  case 'E': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_EXP,0); break;
1052  case 'M': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MS, 0); break;
1053  case 'P': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MP, 0); break;
1054  case 'Q': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_CANC, 0); break;
1055  case 'R': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MR, 0); break;
1056  }
1057  } else
1058  if (ch == '$') {
1059  calc.ptr =
1061  _tcslen(calc.source);
1062  } else {
1063  for (x=0; x<SIZEOF(key2code); x++) {
1064  if (!(key2code[x].mask & BITMASK_IS_ASCII) ||
1066  continue;
1067  if (key2code[x].key == ch) {
1069  break;
1070  }
1071  }
1072  }
1073 
1074  if (*ptr != '\0')
1075  {
1076  seq->ptr = ptr;
1077  PostMessage(hwnd, seq->wm_msg, 0, 0);
1078  } else {
1079  free(seq->data);
1080  seq->data = seq->ptr = ptr = NULL;
1081  }
1082  return ptr;
1083 }
#define IDC_BUTTON_MC
Definition: resource.h:47
#define IDC_BUTTON_CANC
Definition: resource.h:89
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT wm_msg
Definition: calc.h:151
#define IDC_BUTTON_MP
Definition: resource.h:50
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
#define free
Definition: debug_ros.c:5
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT_PTR WPARAM
Definition: windef.h:207
#define IDC_BUTTON_EXP
Definition: resource.h:38
#define SIZEOF(_ar)
Definition: calc.h:97
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:175
#define PostMessage
Definition: winuser.h:5698
char * ptr
Definition: calc.h:150
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_BUTTON_MR
Definition: resource.h:48
char * data
Definition: calc.h:149
#define BITMASK_IS_CTRL
Definition: winmain.c:45
static const key3code_t key2code[]
Definition: winmain.c:82
TCHAR source[MAX_CALC_SIZE]
Definition: calc.h:176
BYTE mask
Definition: winmain.c:63
#define IDC_BUTTON_MS
Definition: resource.h:49
#define BITMASK_IS_ASCII
Definition: winmain.c:43
#define IDC_BUTTON_DAT
Definition: resource.h:31
Definition: path.c:42

Referenced by DlgMainProc().

◆ HotButtonProc()

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

Definition at line 1334 of file winmain.c.

1335 {
1338 
1339  switch (msg) {
1340  case WM_MOUSEMOVE:
1341  mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
1342  mouse_event.dwFlags = TME_QUERY;
1343  if (!TrackMouseEvent(&mouse_event) || !(mouse_event.dwFlags & (TME_HOVER|TME_LEAVE)))
1344  {
1345  mouse_event.dwFlags = TME_HOVER|TME_LEAVE;
1346  mouse_event.hwndTrack = hWnd;
1347  mouse_event.dwHoverTime = 1;
1349  }
1350  break;
1351 
1352  case WM_MOUSEHOVER:
1353  lpBtnInfo->bHover = TRUE;
1355  break;
1356 
1357  case WM_MOUSELEAVE:
1358  lpBtnInfo->bHover = FALSE;
1360  break;
1361  }
1362 
1363  return CallWindowProc(lpBtnInfo->oldProc, hWnd, msg, wp, lp);
1364 }
#define CallWindowProc
Definition: winuser.h:5601
struct BTNINFO * LPBTNINFO
BOOL bHover
Definition: winmain.c:238
#define TRUE
Definition: types.h:120
#define WM_MOUSEHOVER
Definition: commctrl.h:4945
HWND hWnd
Definition: settings.c:17
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
#define GWLP_USERDATA
Definition: treelist.c:63
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define TME_QUERY
Definition: commctrl.h:4954
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define TME_HOVER
Definition: commctrl.h:4951
#define TME_LEAVE
Definition: commctrl.h:4952
#define WM_MOUSEMOVE
Definition: winuser.h:1751
WNDPROC oldProc
Definition: winmain.c:239
#define msg(x)
Definition: auth_time.c:54
#define GetWindowLongPtr
Definition: treelist.c:73

Referenced by EnumChildProc().

◆ idm_2_idc()

static WPARAM idm_2_idc ( int  idm)
static

Definition at line 973 of file winmain.c.

974 {
975  int x;
976 
977  for (x=0; x<SIZEOF(upd); x++) {
978  if (upd[x].idm == idm)
979  break;
980  }
981  return (WPARAM)(upd[x].idc);
982 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
UINT_PTR WPARAM
Definition: windef.h:207
#define SIZEOF(_ar)
Definition: calc.h:97
static const struct _update_check_menus upd[]

Referenced by DlgMainProc().

◆ load_config()

static void load_config ( void  )
static

Definition at line 301 of file winmain.c.

302 {
304 
305  osvi.dwOSVersionInfoSize = sizeof(osvi);
306  GetVersionEx(&osvi);
307 
308  switch (osvi.dwPlatformId) {
309  case VER_PLATFORM_WIN32s:
311  /* Try to load last selected layout */
312  calc.layout = GetProfileInt(_T("SciCalc"), _T("layout"), CALC_LAYOUT_STANDARD);
313 
314  /* Try to load last selected formatting option */
315  calc.usesep = (GetProfileInt(_T("SciCalc"), _T("UseSep"), FALSE)) ? TRUE : FALSE;
316  break;
317 
318  default: /* VER_PLATFORM_WIN32_NT */
319  /* Try to load last selected layout */
320  calc.layout = LoadRegInt(_T("SOFTWARE\\Microsoft\\Calc"), _T("layout"), CALC_LAYOUT_STANDARD);
321 
322  /* Try to load last selected formatting option */
323  calc.usesep = (LoadRegInt(_T("SOFTWARE\\Microsoft\\Calc"), _T("UseSep"), FALSE)) ? TRUE : FALSE;
324  break;
325  }
326 
327  /* memory is empty at startup */
328  calc.is_memory = FALSE;
329 
330  /* Get locale info for numbers */
332 }
#define TRUE
Definition: types.h:120
DWORD layout
Definition: calc.h:174
OSVERSIONINFO osvi
Definition: ver.c:28
calc_t calc
Definition: winmain.c:247
#define VER_PLATFORM_WIN32s
Definition: rtltypes.h:234
static int LoadRegInt(LPCTSTR lpszApp, LPCTSTR lpszKey, int iDefault)
Definition: winmain.c:267
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
#define _T(x)
Definition: vfdio.h:22
BOOL usesep
Definition: calc.h:186
#define GetProfileInt
Definition: winbase.h:3651
ULONG dwPlatformId
Definition: rtltypes.h:237
#define GetVersionEx
Definition: winbase.h:3666
BOOL is_memory
Definition: calc.h:182
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235
static void UpdateNumberIntl(void)
Definition: winmain.c:253

Referenced by _tWinMain().

◆ LoadRegInt()

static int LoadRegInt ( LPCTSTR  lpszApp,
LPCTSTR  lpszKey,
int  iDefault 
)
static

Definition at line 267 of file winmain.c.

268 {
269  HKEY hKey;
270  int iValue;
271  DWORD tmp;
272 
273  if (RegOpenKeyEx(HKEY_CURRENT_USER, lpszApp, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
274  {
275  /* Try to load integer value */
276  tmp = sizeof(int);
277 
278  if (RegQueryValueEx(hKey, lpszKey, NULL, NULL, (LPBYTE)&iValue, &tmp) == ERROR_SUCCESS)
279  iDefault = iValue;
280 
281  /* close the key */
282  RegCloseKey(hKey);
283  }
284 
285  return iDefault;
286 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by load_config().

◆ OnSettingChange()

static INT_PTR CALLBACK OnSettingChange ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1389 of file winmain.c.

1390 {
1391  /* Check for user policy and area string valid */
1392  if (wParam == 0 && lParam != 0)
1393  {
1394  LPTSTR lpArea = (LPTSTR)lParam;
1395 
1396  /* Check if a parameter has been changed into the locale settings */
1397  if (!_tcsicmp(lpArea, _T("intl")))
1398  {
1399  /* Re-load locale parameters */
1400  UpdateNumberIntl();
1401 
1402  /* Update text for decimal button */
1404 
1405  /* Update text into the output display */
1407  }
1408  }
1409  return 0;
1410 }
#define _tcsicmp
Definition: xmlstorage.h:205
calc_t calc
Definition: winmain.c:247
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:489
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
#define IDC_BUTTON_DOT
Definition: resource.h:65
CHAR * LPTSTR
Definition: xmlstorage.h:192
TCHAR sDecimal[8]
Definition: calc.h:199
#define _T(x)
Definition: vfdio.h:22
#define SetDlgItemText
Definition: winuser.h:5715
static void UpdateNumberIntl(void)
Definition: winmain.c:253
LPARAM lParam
Definition: combotst.c:139

Referenced by DlgMainProc().

◆ post_key_press()

static LRESULT post_key_press ( LPARAM  lParam,
WORD  idc 
)
static

Definition at line 357 of file winmain.c.

358 {
359  HWND hCtlWnd = GetDlgItem(calc.hWnd,idc);
360  TCHAR ClassName[64];
361 
362  /* check if the key is enabled! */
363  if (!IsWindowEnabled(hCtlWnd))
364  return 1;
365 
366  if (!GetClassName(hCtlWnd, ClassName, SIZEOF(ClassName)))
367  return 1;
368 
369  if (!_tcscmp(ClassName, WC_BUTTON)) {
370  DWORD dwStyle = GetWindowLongPtr(hCtlWnd, GWL_STYLE) & 0xF;
371 
372  /* Set states for press/release, but only for push buttons */
373  if (dwStyle == BS_PUSHBUTTON || dwStyle == BS_DEFPUSHBUTTON || dwStyle == BS_OWNERDRAW) {
374  if (!(lParam & KEY_WAS_DOWN)) {
375  PostMessage(hCtlWnd, BM_SETSTATE, 1, 0);
376  } else
377  if ((lParam & KEY_IS_UP)) {
378  PostMessage(hCtlWnd, BM_SETSTATE, 0, 0);
379  PostMessage(hCtlWnd, BM_CLICK, 0, 0);
380  }
381  return 1;
382  }
383  }
384  /* default action: simple click event at key release */
385  if ((lParam & KEY_IS_UP)) {
386  PostMessage(hCtlWnd, BM_CLICK, 0, 0);
387  }
388  return 1;
389 }
#define BM_SETSTATE
Definition: winuser.h:1884
#define BS_OWNERDRAW
Definition: pedump.c:661
#define WC_BUTTON
Definition: commctrl.h:4597
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
calc_t calc
Definition: winmain.c:247
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define SIZEOF(_ar)
Definition: calc.h:97
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define PostMessage
Definition: winuser.h:5698
#define KEY_WAS_DOWN
Definition: winmain.c:41
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1878
HWND hWnd
Definition: calc.h:171
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_IS_UP
Definition: winmain.c:40
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define GWL_STYLE
Definition: winuser.h:846
#define GetClassName
Definition: winuser.h:5649
#define GetWindowLongPtr
Definition: treelist.c:73
LPARAM lParam
Definition: combotst.c:139

Referenced by process_vk_key().

◆ prepare_rpn_result()

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

Definition at line 644 of file winmain.c.

645 {
646  if (calc.is_nan) {
647  rpn_zero(&calc.code);
649  return;
650  }
652 }
calc_number_t code
Definition: calc.h:178
calc_t calc
Definition: winmain.c:247
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
#define IDS_MATH_ERROR
Definition: resource.h:8
GLuint buffer
Definition: glext.h:5915
BOOL is_nan
Definition: calc.h:183
HINSTANCE hInstance
Definition: calc.h:167
GLsizeiptr size
Definition: glext.h:5919
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: utl_ieee.c:23
#define LoadString
Definition: winuser.h:5685

Referenced by DlgStatProc(), and set_rpn_result().

◆ process_vk_key()

static int process_vk_key ( WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 419 of file winmain.c.

420 {
421  const key2code_t *k;
422  unsigned int x;
423  unsigned short int ch;
424 
425  ch = vk2ascii(LOWORD(wParam));
426  if ((lParam & KEY_IS_UP)) {
427  /* Test for "copy" to clipboard */
428  if (ch == (CTRL_C|CTRL_FLAG)) {
430  return 1;
431  }
432  /* Test for "paste" from clipboard */
433  if (ch == (CTRL_V|CTRL_FLAG)) {
435  return 1;
436  }
437  /* Test of help menu */
438  if (LOWORD(wParam) == VK_F1) {
440  return 1;
441  }
442  }
443 
444  for (x=0; x<SIZEOF(key2code); x++) {
445  int key = key2code[x].key;
447  key |= CTRL_FLAG;
448  if ((key == ch && (key2code[x].mask & BITMASK_IS_ASCII)) ||
450  ) {
451  if (GetDlgItem(calc.hWnd, key2code[x].idc) == NULL)
452  continue;
453  return post_key_press(lParam, key2code[x].idc);
454  }
455  }
457  if (calc.base == IDC_RADIO_DEC) {
458  k = key2code_base10;
460  } else {
461  k = key2code_base16;
463  }
464  do {
465  if (k->key == LOWORD(wParam)) {
466  return post_key_press(lParam, k->idc);
467  }
468  k++;
469  } while (--x);
470  }
471  return 0;
472 }
DWORD base
Definition: calc.h:189
DWORD layout
Definition: calc.h:174
#define IDC_RADIO_DEC
Definition: resource.h:22
calc_t calc
Definition: winmain.c:247
static const key2code_t key2code_base16[]
Definition: winmain.c:155
static int vk2ascii(unsigned int vk)
Definition: winmain.c:391
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
WPARAM wParam
Definition: combotst.c:138
#define IDM_EDIT_PASTE
Definition: resource.h:373
#define SIZEOF(_ar)
Definition: calc.h:97
GLenum GLint GLuint mask
Definition: glext.h:6028
#define IDM_EDIT_COPY
Definition: resource.h:372
static LRESULT post_key_press(LPARAM lParam, WORD idc)
Definition: winmain.c:357
smooth NULL
Definition: ftsmooth.c:416
WORD idc
Definition: winmain.c:61
#define CTRL_V
Definition: winmain.c:79
CHAR key
Definition: winmain.c:62
HWND hWnd
Definition: calc.h:171
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define KEY_IS_UP
Definition: winmain.c:40
#define WM_COMMAND
Definition: winuser.h:1716
#define BITMASK_IS_CTRL
Definition: winmain.c:45
static const key3code_t key2code[]
Definition: winmain.c:82
#define VK_F1
Definition: winuser.h:2209
#define CTRL_C
Definition: winmain.c:71
BYTE mask
Definition: winmain.c:63
#define SendMessage
Definition: winuser.h:5709
#define IDM_HELP_HELP
Definition: resource.h:384
#define BITMASK_IS_ASCII
Definition: winmain.c:43
static const key2code_t key2code_base10[]
Definition: winmain.c:162
LPARAM lParam
Definition: combotst.c:139
#define CTRL_FLAG
Definition: winmain.c:67
int k
Definition: mpi.c:3369
#define LOWORD(l)
Definition: pedump.c:82
Definition: path.c:42

Referenced by _tWinMain().

◆ ReadClipboard()

static char* ReadClipboard ( void  )
static

Definition at line 1017 of file winmain.c.

1018 {
1019  char *buffer = NULL;
1020 
1021  if (OpenClipboard(NULL)) {
1022  HANDLE hData = GetClipboardData(CF_TEXT);
1023  char *fromClipboard;
1024 
1025  if (hData != NULL) {
1026  fromClipboard = (char *)GlobalLock(hData);
1027  if (fromClipboard[0])
1028  buffer = _strupr(_strdup(fromClipboard));
1029  GlobalUnlock( hData );
1030  }
1031  CloseClipboard();
1032  }
1033  return buffer;
1034 }
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)

Referenced by DlgMainProc().

◆ ReadConversion()

static char* ReadConversion ( const char formula)
static

Definition at line 895 of file winmain.c.

896 {
897  int len = strlen(formula);
898  char *str = (char *)malloc(len+3);
899 
900  if (str == NULL)
901  return NULL;
902 
903  str[0] = '(';
904  memcpy(str+1, formula, len);
905  str[len+1] = ')';
906  str[len+2] = '\0';
907 
908  _tcscpy(calc.source, (*calc.buffer == _T('\0')) ? _T("0") : calc.buffer);
909 
910  /* clear display content before proceeding */
911  calc.ptr = calc.buffer;
912  calc.buffer[0] = _T('\0');
913 
914  return str;
915 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
_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:175
#define _T(x)
Definition: vfdio.h:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
TCHAR source[MAX_CALC_SIZE]
Definition: calc.h:176
#define malloc
Definition: debug_ros.c:4

Referenced by DlgMainProc().

◆ run_canc()

static void run_canc ( calc_number_t c)
static

Definition at line 1216 of file winmain.c.

1217 {
1218  flush_postfix();
1219  rpn_zero(c);
1220 
1221  /* clear also scientific display modes */
1222  calc.sci_out = FALSE;
1223  calc.sci_in = FALSE;
1224 
1225  /* clear state of inv and hyp flags */
1228 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
BOOL sci_out
Definition: calc.h:184
calc_t calc
Definition: winmain.c:247
#define IDC_CHECK_INV
Definition: resource.h:25
void rpn_zero(calc_number_t *c)
Definition: fun_ieee.c:586
HWND hWnd
Definition: calc.h:171
const GLubyte * c
Definition: glext.h:8905
BOOL sci_in
Definition: calc.h:185
#define BST_UNCHECKED
Definition: winuser.h:199
void flush_postfix(void)
Definition: rpn_ieee.c:470
#define IDC_CHECK_HYP
Definition: resource.h:26

◆ run_dat_sta()

static void run_dat_sta ( calc_number_t number)
static

Definition at line 1085 of file winmain.c.

1086 {
1087  statistic_t *s = (statistic_t *)malloc(sizeof(statistic_t));
1088  statistic_t *p = calc.stat;
1089 
1090  rpn_alloc(&s->num);
1091  rpn_copy(&s->num, a);
1092  s->base = calc.base;
1093  s->next = NULL;
1094  if (p == NULL)
1095  calc.stat = s;
1096  else {
1097  while (p->next != NULL)
1098  p = (statistic_t *)(p->next);
1099  p->next = s;
1100  }
1102 }
statistic_t * stat
Definition: calc.h:181
DWORD base
Definition: calc.h:189
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
calc_t calc
Definition: winmain.c:247
#define WM_INSERT_STAT
Definition: calc.h:26
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define PostMessage
Definition: winuser.h:5698
GLdouble s
Definition: gl.h:2039
HWND hStatWnd
Definition: calc.h:193
#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_ieee.c:601

◆ run_fe()

static void run_fe ( calc_number_t number)
static

Definition at line 1173 of file winmain.c.

1174 {
1175  calc.sci_out = ((calc.sci_out != FALSE) ? FALSE : TRUE);
1176 }
#define TRUE
Definition: types.h:120
BOOL sci_out
Definition: calc.h:184
calc_t calc
Definition: winmain.c:247

◆ run_lpar()

static void run_lpar ( calc_number_t c)
static

Definition at line 1235 of file winmain.c.

1236 {
1238 }
int exec_infix2postfix(calc_number_t *, unsigned int)
Definition: rpn_ieee.c:391
const GLubyte * c
Definition: glext.h:8905

◆ run_mm()

static void run_mm ( calc_number_t c)
static

Definition at line 1114 of file winmain.c.

1115 {
1116  calc_node_t cn;
1117 
1118  cn.number = *c;
1119  cn.base = calc.base;
1122 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
calc_t calc
Definition: winmain.c:247
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
static BYTE cn[]
Definition: cert.c:2938
HWND hWnd
Definition: calc.h:171
#define c
Definition: ke_i.h:80
calc_node_t memory
Definition: calc.h:180
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:847

◆ run_mp()

static void run_mp ( calc_number_t c)
static

Definition at line 1104 of file winmain.c.

1105 {
1106  calc_node_t cn;
1107 
1108  cn.number = *c;
1109  cn.base = calc.base;
1112 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
calc_t calc
Definition: winmain.c:247
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
static BYTE cn[]
Definition: cert.c:2938
HWND hWnd
Definition: calc.h:171
#define c
Definition: ke_i.h:80
calc_node_t memory
Definition: calc.h:180
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:847

◆ run_ms()

static void run_ms ( calc_number_t c)
static

Definition at line 1124 of file winmain.c.

1125 {
1127  calc.memory.base = calc.base;
1129 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
calc_t calc
Definition: winmain.c:247
HWND hWnd
Definition: calc.h:171
int rpn_is_zero(calc_number_t *c)
Definition: fun_ieee.c:596
const GLubyte * c
Definition: glext.h:8905
calc_number_t number
Definition: calc.h:133
DWORD base
Definition: calc.h:135
calc_node_t memory
Definition: calc.h:180
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:847

◆ run_mw()

static void run_mw ( calc_number_t c)
static

Definition at line 1131 of file winmain.c.

1132 {
1133  calc_number_t tmp;
1134 
1135  rpn_copy(&tmp, &calc.memory.number);
1137  calc.memory.base = calc.base;
1138  if (calc.is_memory)
1139  rpn_copy(c, &tmp);
1141 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
calc_t calc
Definition: winmain.c:247
HWND hWnd
Definition: calc.h:171
int rpn_is_zero(calc_number_t *c)
Definition: fun_ieee.c:596
const GLubyte * c
Definition: glext.h:8905
calc_number_t number
Definition: calc.h:133
DWORD base
Definition: calc.h:135
BOOL is_memory
Definition: calc.h:182
calc_node_t memory
Definition: calc.h:180
static void update_memory_flag(HWND hWnd, BOOL mem_flag)
Definition: winmain.c:847

◆ run_rpar()

static void run_rpar ( calc_number_t c)
static

Definition at line 1230 of file winmain.c.

1231 {
1233 }
const GLubyte * c
Definition: glext.h:8905
void exec_closeparent(calc_number_t *)
Definition: rpn_ieee.c:436

◆ save_config()

static void save_config ( void  )
static

Definition at line 334 of file winmain.c.

335 {
336  TCHAR buf[32];
338 
339  osvi.dwOSVersionInfoSize = sizeof(osvi);
340  GetVersionEx(&osvi);
341 
342  switch (osvi.dwPlatformId) {
343  case VER_PLATFORM_WIN32s:
345  _stprintf(buf, _T("%lu"), calc.layout);
346  WriteProfileString(_T("SciCalc"), _T("layout"), buf);
347  WriteProfileString(_T("SciCalc"), _T("UseSep"), (calc.usesep==TRUE) ? _T("1") : _T("0"));
348  break;
349 
350  default: /* VER_PLATFORM_WIN32_NT */
351  SaveRegInt(_T("SOFTWARE\\Microsoft\\Calc"), _T("layout"), calc.layout);
352  SaveRegInt(_T("SOFTWARE\\Microsoft\\Calc"), _T("UseSep"), calc.usesep);
353  break;
354  }
355 }
#define TRUE
Definition: types.h:120
DWORD layout
Definition: calc.h:174
OSVERSIONINFO osvi
Definition: ver.c:28
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
calc_t calc
Definition: winmain.c:247
#define VER_PLATFORM_WIN32s
Definition: rtltypes.h:234
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
BOOL usesep
Definition: calc.h:186
#define WriteProfileString
Definition: winbase.h:3740
static void SaveRegInt(LPCTSTR lpszApp, LPCTSTR lpszKey, int iValue)
Definition: winmain.c:288
#define _stprintf
Definition: utility.h:124
ULONG dwPlatformId
Definition: rtltypes.h:237
#define GetVersionEx
Definition: winbase.h:3666
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235

Referenced by _tWinMain().

◆ SaveRegInt()

static void SaveRegInt ( LPCTSTR  lpszApp,
LPCTSTR  lpszKey,
int  iValue 
)
static

Definition at line 288 of file winmain.c.

289 {
290  HKEY hKey;
291 
293  {
294  RegSetValueEx(hKey, lpszKey, 0, REG_DWORD, (const BYTE*)&iValue, sizeof(int));
295 
296  /* close the key */
297  RegCloseKey(hKey);
298  }
299 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#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
unsigned char BYTE
Definition: mem.h:68
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by save_config().

◆ set_rpn_result()

static void set_rpn_result ( HWND  hwnd,
calc_number_t rpn 
)
static

Definition at line 654 of file winmain.c.

655 {
656  calc.sci_in = FALSE;
661 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD base
Definition: calc.h:189
TCHAR * ptr
Definition: calc.h:177
calc_t calc
Definition: winmain.c:247
static void update_lcd_display(HWND hwnd)
Definition: winmain.c:489
static void update_parent_display(HWND hWnd)
Definition: winmain.c:568
#define SIZEOF(_ar)
Definition: calc.h:97
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
BOOL sci_in
Definition: calc.h:185
static void prepare_rpn_result(calc_number_t *rpn, TCHAR *buffer, int size, int base)
Definition: winmain.c:644

Referenced by display_rpn_result(), and DlgMainProc().

◆ SubclassButtonProc()

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

Definition at line 1240 of file winmain.c.

1241 {
1243  UINT dwText;
1244  TCHAR text[64];
1245  int dx, dy, len;
1246  SIZE size;
1247  POINT pt;
1248 
1249  if(dis->CtlType == ODT_BUTTON)
1250  {
1251  HTHEME hTheme = NULL;
1252  LPBTNINFO lpBtnInfo;
1253 
1255  hTheme = calc_OpenThemeData(hWnd, L"Button");
1256 
1257  if (hTheme)
1258  {
1259  int iState = 0;
1260 
1261  if ((dis->itemState & ODS_DISABLED))
1262  iState |= PBS_DISABLED;
1263  if ((dis->itemState & ODS_SELECTED))
1264  iState |= PBS_PRESSED;
1265 
1266  lpBtnInfo = (LPBTNINFO)GetWindowLongPtr(dis->hwndItem, GWLP_USERDATA);
1267  if (lpBtnInfo != NULL)
1268  {
1269  if (lpBtnInfo->bHover)
1270  iState |= PBS_HOT;
1271  }
1272 
1274  {
1276  }
1277 
1278  // Draw the frame around the control
1279  calc_DrawThemeBackground(hTheme, dis->hDC, BP_PUSHBUTTON, iState, &dis->rcItem, NULL);
1280 
1281  calc_CloseThemeData(hTheme);
1282  } else {
1283  /* default state: unpushed */
1284  DWORD dwStyle = 0;
1285 
1286  if ((dis->itemState & ODS_SELECTED))
1287  dwStyle = DFCS_PUSHED;
1288 
1289  DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH | dwStyle);
1290  }
1291 
1292  /* button text to write */
1294 
1295  /*
1296  * little exception: 1/x has different color
1297  * in standard and scientific modes
1298  */
1299  if ((calc.layout == CALC_LAYOUT_STANDARD ||
1301  IDC_BUTTON_RX == dis->CtlID) {
1303  } else
1304  for (dx=0; dx<SIZEOF(key2code); dx++) {
1305  if (key2code[dx].idc == dis->CtlID) {
1306  SetTextColor(dis->hDC, key2code[dx].col);
1307  break;
1308  }
1309  }
1310 
1311  /* No background, to avoid corruption of the texture */
1312  SetBkMode(dis->hDC, TRANSPARENT);
1313 
1314  /* Default state: enabled */
1315  dwText = 0;
1316  if ((dis->itemState & ODS_DISABLED))
1317  dwText = DSS_DISABLED;
1318 
1319  /* Draw the text in the button */
1320  GetTextExtentPoint32(dis->hDC, text, len, &size);
1321  dx = ((dis->rcItem.right-dis->rcItem.left) - size.cx) >> 1;
1322  dy = ((dis->rcItem.bottom-dis->rcItem.top) - size.cy) >> 1;
1323  if ((dis->itemState & ODS_SELECTED)) {
1324  dx++;
1325  dy++;
1326  }
1327  pt.x = dis->rcItem.left + dx;
1328  pt.y = dis->rcItem.top + dy;
1329  DrawState(dis->hDC, NULL, NULL, (LPARAM)text, 0, pt.x, pt.y, size.cx, size.cy, DST_TEXT | dwText);
1330  }
1331  return 1L;
1332 }
struct BTNINFO * LPBTNINFO
BOOL bHover
Definition: winmain.c:238
COLORREF col
Definition: winmain.c:64
#define DFC_BUTTON
Definition: winuser.h:476
type_IsAppThemed calc_IsAppThemed
Definition: theme.c:53
DWORD layout
Definition: calc.h:174
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define IDC_BUTTON_RX
Definition: resource.h:46
#define pt(x, y)
Definition: drawing.c:79
calc_t calc
Definition: winmain.c:247
type_IsThemeBackgroundPartiallyTransparent calc_IsThemeBackgroundPartiallyTransparent
Definition: theme.c:55
const WCHAR * text
Definition: package.c:1827
GLint dy
Definition: linetemp.h:97
type_DrawThemeBackground calc_DrawThemeBackground
Definition: theme.c:52
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:292
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
LONG left
Definition: windef.h:291
#define DST_TEXT
Definition: winuser.h:513
LONG right
Definition: windef.h:293
#define GetWindowText
Definition: winuser.h:5664
#define DrawState
Definition: winuser.h:5636
#define DFCS_PUSHED
Definition: winuser.h:503
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define SIZEOF(_ar)
Definition: calc.h:97
type_IsThemeActive calc_IsThemeActive
Definition: theme.c:54
type_DrawThemeParentBackground calc_DrawThemeParentBackground
Definition: theme.c:57
#define TRANSPARENT
Definition: wingdi.h:949
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define CALC_CLR_BLUE
Definition: winmain.c:52
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 long DWORD
Definition: ntddk_ex.h:95
type_OpenThemeData calc_OpenThemeData
Definition: theme.c:50
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
static const key3code_t key2code[]
Definition: winmain.c:82
unsigned int UINT
Definition: ndis.h:50
GLint dx
Definition: linetemp.h:97
#define ODS_SELECTED
Definition: winuser.h:2499
#define GetTextExtentPoint32
Definition: wingdi.h:4450
#define ODT_BUTTON
Definition: winuser.h:2494
LONG bottom
Definition: windef.h:294
#define GetWindowLongPtr
Definition: treelist.c:73
type_CloseThemeData calc_CloseThemeData
Definition: theme.c:51

Referenced by DlgMainProc().

◆ update_lcd_display()

static void update_lcd_display ( HWND  hwnd)
static

Definition at line 489 of file winmain.c.

490 {
491  /*
492  * multiply size of calc.buffer by 2 because it may
493  * happen that separator is used between each digit.
494  * Also added little additional space for dot and '\0'.
495  */
496  TCHAR tmp[MAX_CALC_SIZE * 2 + 2];
497 
498  if (calc.buffer[0] == _T('\0'))
499  _tcscpy(tmp, _T("0"));
500  else
501  _tcscpy(tmp, calc.buffer);
502 
503  /* Add final '.' in decimal mode (if it's missing), but
504  * only if it's a result: no append if it prints "ERROR".
505  */
506  if (calc.base == IDC_RADIO_DEC && !calc.is_nan) {
507  if (_tcschr(tmp, _T('.')) == NULL)
508  _tcscat(tmp, _T("."));
509  }
510  /* if separator mode is on, let's add an additional space */
511  if (calc.usesep && !calc.sci_in && !calc.sci_out && !calc.is_nan) {
512  /* go to the integer part of the string */
513  TCHAR *p = _tcschr(tmp, _T('.'));
514  TCHAR *e = _tcschr(tmp, _T('\0'));
515  int n=0, t;
516 
517  if (p == NULL) p = e;
518  switch (calc.base) {
519  case IDC_RADIO_HEX:
520  case IDC_RADIO_BIN:
521  t = 4;
522  break;
523  default:
524  /* fall here for:
525  IDC_RADIO_DEC:
526  IDC_RADIO_OCT: */
527  t = 3;
528  break;
529  }
530  while (--p > tmp) {
531  if (++n == t && *(p-1) != _T('-')) {
532  memmove(p+1, p, (e-p+1)*sizeof(TCHAR));
533  e++;
534  *p = _T(' ');
535  n = 0;
536  }
537  }
538  /* if decimal mode, apply regional settings */
539  if (calc.base == IDC_RADIO_DEC) {
540  TCHAR *p = tmp;
541  TCHAR *e = _tcschr(tmp, _T('.'));
542 
543  /* searching for thousands default separator */
544  while (p < e) {
545  if (*p == _T(' ')) {
546  memmove(p+calc.sThousand_len, p+1, _tcslen(p)*sizeof(TCHAR));
548  p += calc.sThousand_len;
549  } else
550  p++;
551  }
552  /* update decimal point too. */
553  memmove(p+calc.sDecimal_len, p+1, _tcslen(p)*sizeof(TCHAR));
555  }
556  } else {
557  TCHAR *p = _tcschr(tmp, _T('.'));
558 
559  /* update decimal point when usesep is false */
560  if (p != NULL) {
561  memmove(p+calc.sDecimal_len, p+1, _tcslen(p)*sizeof(TCHAR));
563  }
564  }
566 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD base
Definition: calc.h:189
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
BOOL sci_out
Definition: calc.h:184
#define IDC_RADIO_DEC
Definition: resource.h:22
calc_t calc
Definition: winmain.c:247
unsigned int sThousand_len
Definition: calc.h:202
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
BOOL is_nan
Definition: calc.h:183
#define IDC_RADIO_BIN
Definition: resource.h:24
#define e
Definition: ke_i.h:82
#define IDC_RADIO_HEX
Definition: resource.h:21
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:175
TCHAR sThousand[8]
Definition: calc.h:200
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
TCHAR sDecimal[8]
Definition: calc.h:199
#define _T(x)
Definition: vfdio.h:22
unsigned int sDecimal_len
Definition: calc.h:201
BOOL usesep
Definition: calc.h:186
BOOL sci_in
Definition: calc.h:185
#define MAX_CALC_SIZE
Definition: calc.h:49
#define SetDlgItemText
Definition: winuser.h:5715
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define IDC_TEXT_OUTPUT
Definition: resource.h:92
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by build_operand(), DlgMainProc(), OnSettingChange(), and set_rpn_result().

◆ update_memory_flag()

static void update_memory_flag ( HWND  hWnd,
BOOL  mem_flag 
)
static

Definition at line 847 of file winmain.c.

848 {
849  calc.is_memory = mem_flag;
850  SetDlgItemText(hWnd, IDC_TEXT_MEMORY, mem_flag ? _T("M") : _T(""));
851 }
calc_t calc
Definition: winmain.c:247
HWND hWnd
Definition: settings.c:17
#define IDC_TEXT_MEMORY
Definition: resource.h:94
#define _T(x)
Definition: vfdio.h:22
#define SetDlgItemText
Definition: winuser.h:5715
BOOL is_memory
Definition: calc.h:182

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

◆ update_menu()

static void update_menu ( HWND  hWnd)
static

Definition at line 724 of file winmain.c.

725 {
726  HMENU hMenu = GetSubMenu(GetMenu(hWnd), 1);
727  unsigned int x;
728 
729  for (x=0; x<SIZEOF(upd); x++) {
730  if (*(upd[x].sel) != upd[x].idc) {
733  } else {
734  CheckMenuItem(hMenu, upd[x].idm, MF_BYCOMMAND|MF_CHECKED);
736  }
737  }
739 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
calc_t calc
Definition: winmain.c:247
#define IDM_VIEW_GROUP
Definition: resource.h:383
HWND hWnd
Definition: settings.c:17
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define SIZEOF(_ar)
Definition: calc.h:97
static const struct _update_check_menus upd[]
#define MF_CHECKED
Definition: winuser.h:132
BOOL usesep
Definition: calc.h:186
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MF_UNCHECKED
Definition: winuser.h:204
#define BST_UNCHECKED
Definition: winuser.h:199
#define BST_CHECKED
Definition: winuser.h:197
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by DlgMainProc(), and update_radio().

◆ update_n_stats_items()

static void update_n_stats_items ( HWND  hWnd,
TCHAR buffer 
)
static

Definition at line 853 of file winmain.c.

854 {
855  unsigned int n = SendDlgItemMessage(hWnd, IDC_LIST_STAT, LB_GETCOUNT, 0, 0);
856 
857  _stprintf(buffer, _T("n=%u"), n);
859 }
HWND hWnd
Definition: settings.c:17
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
#define SendDlgItemMessage
Definition: winuser.h:5708
#define IDC_TEXT_NITEMS
Definition: resource.h:101
#define LB_GETCOUNT
Definition: winuser.h:1999
#define _T(x)
Definition: vfdio.h:22
#define SetDlgItemText
Definition: winuser.h:5715
#define _stprintf
Definition: utility.h:124
#define IDC_LIST_STAT
Definition: resource.h:96

Referenced by DlgStatProc().

◆ update_parent_display()

static void update_parent_display ( HWND  hWnd)
static

Definition at line 568 of file winmain.c.

569 {
570  TCHAR str[8];
571  int n = eval_parent_count();
572 
573  if (!n)
574  str[0] = _T('\0');
575  else
576  _stprintf(str,_T("(=%d"), n);
578 }
HWND hWnd
Definition: settings.c:17
GLdouble n
Definition: glext.h:7729
const WCHAR * str
#define IDC_TEXT_PARENT
Definition: resource.h:93
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
int eval_parent_count(void)
Definition: rpn_ieee.c:457
#define SetDlgItemText
Definition: winuser.h:5715
#define _stprintf
Definition: utility.h:124

Referenced by set_rpn_result().

◆ update_radio()

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

Definition at line 793 of file winmain.c.

794 {
795  HMENU hMenu;
796  LPCTSTR lpMenuId;
797  WORD mask;
798  int n;
799 
800  switch (base) {
801  case IDC_RADIO_DEC:
804  break;
805  case IDC_RADIO_HEX:
808  break;
809  case IDC_RADIO_OCT:
812  break;
813  case IDC_RADIO_BIN:
816  break;
817  default:
818  return;
819  }
820 
821  if (calc.base != base) {
824  calc.base = base;
826 
827  hMenu = GetMenu(hwnd);
828  DestroyMenu(hMenu);
829  hMenu = LoadMenu(calc.hInstance, lpMenuId);
830  SetMenu(hwnd, hMenu);
831  update_menu(hwnd);
832 
833  for (n=0; n<SIZEOF(radio_setup); n++)
835 
837  }
838 
840 
841  if (base == IDC_RADIO_DEC)
843  else
845 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD base
Definition: calc.h:189
static void convert_text2number(calc_number_t *a)
Definition: winmain.c:681
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDC_RADIO_DEG
Definition: resource.h:86
#define BITMASK_DEC_MASK
Definition: winmain.c:47
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
calc_number_t code
Definition: calc.h:178
#define IDC_RADIO_GRAD
Definition: resource.h:88
#define IDC_RADIO_DEC
Definition: resource.h:22
#define SW_HIDE
Definition: winuser.h:762
calc_t calc
Definition: winmain.c:247
#define IDR_MENU_SCIENTIFIC_2
Definition: resource.h:17
static void update_menu(HWND hWnd)
Definition: winmain.c:724
GLdouble n
Definition: glext.h:7729
static void enable_allowed_controls(HWND hwnd, DWORD base)
Definition: winmain.c:757
void convert_real_integer(unsigned int base)
Definition: utl_ieee.c:112
DWORD degr
Definition: calc.h:191
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_RADIO_BIN
Definition: resource.h:24
#define SIZEOF(_ar)
Definition: calc.h:97
GLenum GLint GLuint mask
Definition: glext.h:6028
#define IDC_RADIO_QWORD
Definition: resource.h:82
GLuint base
Definition: 3dtext.c:35
#define IDC_RADIO_HEX
Definition: resource.h:21
DWORD size
Definition: calc.h:190
HINSTANCE hInstance
Definition: calc.h:167
#define SW_SHOW
Definition: winuser.h:769
static const radio_config_t radio_setup[]
Definition: winmain.c:746
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define IDR_MENU_SCIENTIFIC_1
Definition: resource.h:16
unsigned short WORD
Definition: ntddk_ex.h:93
#define BITMASK_OCT_MASK
Definition: winmain.c:48
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:663
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define BITMASK_HEX_MASK
Definition: winmain.c:46
#define IDC_RADIO_OCT
Definition: resource.h:23
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 IDC_RADIO_BYTE
Definition: resource.h:85
#define BITMASK_BIN_MASK
Definition: winmain.c:49

Referenced by DlgMainProc().

◆ UpdateNumberIntl()

static void UpdateNumberIntl ( void  )
static

Definition at line 253 of file winmain.c.

254 {
255  /* Get current user defaults */
257  _tcscpy(calc.sDecimal, _T("."));
258 
260  _tcscpy(calc.sThousand, _T(","));
261 
262  /* get the string lengths */
265 }
calc_t calc
Definition: winmain.c:247
#define LOCALE_USER_DEFAULT
unsigned int sThousand_len
Definition: calc.h:202
#define GetLocaleInfo
Definition: winnls.h:1183
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define SIZEOF(_ar)
Definition: calc.h:97
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define LOCALE_SDECIMAL
Definition: winnls.h:42
TCHAR sThousand[8]
Definition: calc.h:200
TCHAR sDecimal[8]
Definition: calc.h:199
#define _T(x)
Definition: vfdio.h:22
unsigned int sDecimal_len
Definition: calc.h:201

Referenced by load_config(), and OnSettingChange().

◆ upload_stat_number()

static statistic_t* upload_stat_number ( int  n)
static

Definition at line 1143 of file winmain.c.

1144 {
1145  statistic_t *p = calc.stat;
1146 
1147  if (p == NULL)
1148  return p;
1149 
1150  while (n--) {
1151  p = (statistic_t *)(p->next);
1152  if (p == NULL)
1153  return p;
1154  }
1155 
1156 #ifndef ENABLE_MULTI_PRECISION
1157  if (calc.base != p->base) {
1158  if (calc.base == IDC_RADIO_DEC)
1159  calc.code.f = (double)p->num.i;
1160  else {
1161  calc.code.i = (__int64)p->num.f;
1163  }
1164  } else
1165 #endif
1166  rpn_copy(&calc.code, &p->num);
1167 
1168  calc.is_nan = FALSE;
1169 
1170  return p;
1171 }
statistic_t * stat
Definition: calc.h:181
DWORD base
Definition: calc.h:189
void rpn_copy(calc_number_t *dst, calc_number_t *src)
Definition: fun_ieee.c:591
calc_number_t code
Definition: calc.h:178
#define IDC_RADIO_DEC
Definition: resource.h:22
calc_t calc
Definition: winmain.c:247
double f
Definition: calc.h:126
GLdouble n
Definition: glext.h:7729
BOOL is_nan
Definition: calc.h:183
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
INT64 i
Definition: calc.h:127
GLfloat GLfloat p
Definition: glext.h:8902
#define __int64
Definition: basetyps.h:16
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26

Referenced by DlgMainProc().

◆ vk2ascii()

static int vk2ascii ( unsigned int  vk)
static

Definition at line 391 of file winmain.c.

392 {
393  unsigned short int s;
394  int scan;
395  BYTE state[256];
397 
398  if(!GetKeyboardState(state))
399  return 0;
400 
401  scan=MapVirtualKeyEx(vk, 0, layout);
402  s = 0;
403  if (ToAsciiEx(vk, scan, state, &s, 0, layout)>0) {
404  /* convert to upper case */
405  if (s >= 'a' && s <= 'z')
406  s = s - 'a' + 'A';
407  /* add check to CTRL key */
408  if (vk >= 'A' && vk <= 'Z' &&
409  s >= CTRL_A && s <= CTRL_Z)
410  s |= CTRL_FLAG;
411  else
412  if (GetAsyncKeyState(VK_MENU) < 0)
413  s |= ALT_FLAG;
414  return s;
415  }
416  return 0;
417 }
#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:68
static int state
Definition: maze.c:121
static DWORD layout
Definition: bitmap.c:46
SHORT WINAPI GetAsyncKeyState(_In_ int)
unsigned char BYTE
Definition: mem.h:68
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)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define CTRL_A
Definition: winmain.c:70
#define CTRL_Z
Definition: winmain.c:80
#define CTRL_FLAG
Definition: winmain.c:67

Referenced by process_vk_key().

Variable Documentation

◆ BtnCount

UINT BtnCount

Definition at line 251 of file winmain.c.

Referenced by DlgMainProc().

◆ BtnInfo

BTNINFO BtnInfo[255]

Definition at line 250 of file winmain.c.

Referenced by EnumChildProc().

◆ calc

calc_t calc

Definition at line 247 of file winmain.c.

Referenced by _tWinMain(), apply_int_mask(), build_operand(), check_csum(), clean_stat_list(), ConvAdjust(), convert_real_integer(), convert_text2number(), convert_text2number_2(), ConvExecute(), ConvInit(), delete_stat_item(), display_rpn_result(), DlgMainProc(), DlgStatProc(), enable_allowed_controls(), evalStack(), exec_closeparent(), exec_infix2postfix(), flush_postfix(), handle_context_menu(), handle_copy_command(), handle_sequence_input(), load_config(), logic_dbl2int(), OnSettingChange(), post_key_press(), prepare_rpn_result(), prepare_rpn_result_2(), process_vk_key(), ReadConversion(), rpn_acos(), rpn_acosh(), rpn_asin(), rpn_asinh(), rpn_atan(), rpn_atanh(), rpn_ave(), rpn_ave2(), rpn_cbrt(), rpn_cos(), rpn_cosh(), rpn_div_f(), rpn_div_i(), rpn_div_p(), rpn_exp(), rpn_exp10(), rpn_exp2(), rpn_exp3(), rpn_fact(), rpn_frac(), rpn_int(), rpn_ln(), rpn_log(), rpn_mod_f(), rpn_mod_i(), rpn_not(), rpn_pow_f(), rpn_reci(), rpn_s_ex(), rpn_shl_f(), rpn_shr_f(), rpn_sign(), rpn_sin(), rpn_sinh(), rpn_sqr_f(), rpn_sqrt(), rpn_sum(), rpn_sum2(), rpn_tan(), rpn_tanh(), run_canc(), run_dat_sta(), run_fe(), run_mm(), run_mp(), run_ms(), run_mw(), run_operator(), save_config(), set_rpn_result(), start_rpn_engine(), stat_sum(), stat_sum2(), stop_rpn_engine(), SubclassButtonProc(), update_lcd_display(), update_memory_flag(), update_menu(), update_radio(), UpdateNumberIntl(), upload_stat_number(), validate_angle2rad(), and validate_rad2angle().

◆ function_table