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.pull/3/head
parent
37063840db
commit
9da2a3a6c7
|
@ -15,9 +15,11 @@
|
||||||
#define mGrp (&Group::MenuGroup)
|
#define mGrp (&Group::MenuGroup)
|
||||||
#define mAna (&SolveSpace::MenuAnalyze)
|
#define mAna (&SolveSpace::MenuAnalyze)
|
||||||
#define mHelp (&SolveSpace::MenuHelp)
|
#define mHelp (&SolveSpace::MenuHelp)
|
||||||
#define S 0x100
|
#define DEL DELETE_KEY
|
||||||
#define C 0x200
|
#define ESC ESCAPE_KEY
|
||||||
#define F(k) (0xf0+(k))
|
#define S SHIFT_MASK
|
||||||
|
#define C CTRL_MASK
|
||||||
|
#define F(k) (FUNCTION_KEY_BASE+(k))
|
||||||
const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
|
const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
|
||||||
{ 0, "&File", 0, 0, NULL },
|
{ 0, "&File", 0, 0, NULL },
|
||||||
{ 1, "&New\tCtrl+N", MNU_NEW, 'N'|C, mFile },
|
{ 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, "&Copy\tCtrl+C", MNU_COPY, 'C'|C, mClip },
|
||||||
{ 1, "&Paste\tCtrl+V", MNU_PASTE, 'V'|C, mClip },
|
{ 1, "&Paste\tCtrl+V", MNU_PASTE, 'V'|C, mClip },
|
||||||
{ 1, "Paste &Transformed...\tCtrl+T", MNU_PASTE_TRANSFORM,'T'|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, NULL, 0, 0, NULL },
|
||||||
{ 1, "Select &Edge Chain\tCtrl+E", MNU_SELECT_CHAIN, 'E'|C, mEdit },
|
{ 1, "Select &Edge Chain\tCtrl+E", MNU_SELECT_CHAIN, 'E'|C, mEdit },
|
||||||
{ 1, "Select &All\tCtrl+A", MNU_SELECT_ALL, 'A'|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 },
|
{ 0, "&View", 0, 0, NULL },
|
||||||
{ 1, "Zoom &In\t+", MNU_ZOOM_IN, '+', mView },
|
{ 1, "Zoom &In\t+", MNU_ZOOM_IN, '+', mView },
|
||||||
|
|
9
ui.h
9
ui.h
|
@ -425,6 +425,15 @@ public:
|
||||||
MNU_ABOUT
|
MNU_ABOUT
|
||||||
} MenuId;
|
} MenuId;
|
||||||
typedef void MenuHandler(int id);
|
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 {
|
typedef struct {
|
||||||
int level; // 0 == on menu bar, 1 == one level down
|
int level; // 0 == on menu bar, 1 == one level down
|
||||||
const char *label; // or NULL for a separator
|
const char *label; // or NULL for a separator
|
||||||
|
|
|
@ -566,8 +566,8 @@ static BOOL ProcessKeyDown(WPARAM wParam)
|
||||||
c = (int)wParam;
|
c = (int)wParam;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(GetAsyncKeyState(VK_SHIFT) & 0x8000) c |= 0x100;
|
if(GetAsyncKeyState(VK_SHIFT) & 0x8000) c |= GraphicsWindow::SHIFT_MASK;
|
||||||
if(GetAsyncKeyState(VK_CONTROL) & 0x8000) c |= 0x200;
|
if(GetAsyncKeyState(VK_CONTROL) & 0x8000) c |= GraphicsWindow::CTRL_MASK;
|
||||||
|
|
||||||
for(int i = 0; SS.GW.menu[i].level >= 0; i++) {
|
for(int i = 0; SS.GW.menu[i].level >= 0; i++) {
|
||||||
if(c == SS.GW.menu[i].accel) {
|
if(c == SS.GW.menu[i].accel) {
|
||||||
|
|
Loading…
Reference in New Issue