From 9da2a3a6c71246d883727cc119cb86723faf7aac Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Fri, 20 Sep 2013 13:54:57 -0400 Subject: [PATCH] Use symbolic names for special keys and modifiers Easier to remember e.g. DELETE_KEY instead of 127 or CTRL_MASK instead of 0x200, and better to have a single definition of each. --- graphicswin.cpp | 12 +++++++----- ui.h | 9 +++++++++ win32/w32main.cpp | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/graphicswin.cpp b/graphicswin.cpp index ab233b3a..0df9d965 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -15,9 +15,11 @@ #define mGrp (&Group::MenuGroup) #define mAna (&SolveSpace::MenuAnalyze) #define mHelp (&SolveSpace::MenuHelp) -#define S 0x100 -#define C 0x200 -#define F(k) (0xf0+(k)) +#define DEL DELETE_KEY +#define ESC ESCAPE_KEY +#define S SHIFT_MASK +#define C CTRL_MASK +#define F(k) (FUNCTION_KEY_BASE+(k)) const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 0, "&File", 0, 0, NULL }, { 1, "&New\tCtrl+N", MNU_NEW, 'N'|C, mFile }, @@ -47,11 +49,11 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 1, "&Copy\tCtrl+C", MNU_COPY, 'C'|C, mClip }, { 1, "&Paste\tCtrl+V", MNU_PASTE, 'V'|C, mClip }, { 1, "Paste &Transformed...\tCtrl+T", MNU_PASTE_TRANSFORM,'T'|C, mClip }, -{ 1, "&Delete\tDel", MNU_DELETE, 127, mClip }, +{ 1, "&Delete\tDel", MNU_DELETE, DEL, mClip }, { 1, NULL, 0, 0, NULL }, { 1, "Select &Edge Chain\tCtrl+E", MNU_SELECT_CHAIN, 'E'|C, mEdit }, { 1, "Select &All\tCtrl+A", MNU_SELECT_ALL, 'A'|C, mEdit }, -{ 1, "&Unselect All\tEsc", MNU_UNSELECT_ALL, 27, mEdit }, +{ 1, "&Unselect All\tEsc", MNU_UNSELECT_ALL, ESC, mEdit }, { 0, "&View", 0, 0, NULL }, { 1, "Zoom &In\t+", MNU_ZOOM_IN, '+', mView }, diff --git a/ui.h b/ui.h index b601836e..5e540092 100644 --- a/ui.h +++ b/ui.h @@ -425,6 +425,15 @@ public: MNU_ABOUT } MenuId; typedef void MenuHandler(int id); + enum { + ESCAPE_KEY = 27, + DELETE_KEY = 127, + FUNCTION_KEY_BASE = 0xf0 + }; + enum { + SHIFT_MASK = 0x100, + CTRL_MASK = 0x200 + }; typedef struct { int level; // 0 == on menu bar, 1 == one level down const char *label; // or NULL for a separator diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 72918ee9..9ceaea9f 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -566,8 +566,8 @@ static BOOL ProcessKeyDown(WPARAM wParam) c = (int)wParam; break; } - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) c |= 0x100; - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) c |= 0x200; + if(GetAsyncKeyState(VK_SHIFT) & 0x8000) c |= GraphicsWindow::SHIFT_MASK; + if(GetAsyncKeyState(VK_CONTROL) & 0x8000) c |= GraphicsWindow::CTRL_MASK; for(int i = 0; SS.GW.menu[i].level >= 0; i++) { if(c == SS.GW.menu[i].accel) {