Restructured the uiMenu type system. Will apply to the backends soon.
This commit is contained in:
parent
b45be6e5ab
commit
a1e720bc05
|
@ -19,7 +19,6 @@ endif
|
|||
|
||||
CFILES = \
|
||||
box.c \
|
||||
menu.c \
|
||||
test.c
|
||||
HFILES = \
|
||||
ui.h \
|
||||
|
|
19
menu.c
19
menu.c
|
@ -1,19 +0,0 @@
|
|||
// 20 april 2015
|
||||
#include "uipriv.h"
|
||||
|
||||
#if 0
|
||||
TODO
|
||||
|
||||
// dummy items for various predefined menu identifiers
|
||||
// these are so we can get a definite unique pointer value
|
||||
static volatile char dummyQuit = 'q';
|
||||
static volatile char dummyPreferences = 'p';
|
||||
static volatile char dummyAbout = 'a';
|
||||
static volatile char dummySeparator = 's';
|
||||
|
||||
const char *const uiMenuItemQuit = &dummyQuit;
|
||||
const char *const uiMenuItemPreferences = &dummyPreferences;
|
||||
const char *const uiMenuItemAbout = &dummyAbout;
|
||||
const char *const uiMenuItemSeparator = &dummySeparator;
|
||||
|
||||
#endif
|
32
test.c
32
test.c
|
@ -6,26 +6,26 @@
|
|||
// TODO convert to using the new conversion macros
|
||||
// TODO why can't these be const?
|
||||
|
||||
static uiMenuItem fileMenu[] = {
|
||||
{ "New", uiMenuItemTypeCommand },
|
||||
{ "Open", uiMenuItemTypeCommand },
|
||||
{ uiMenuItemQuit, uiMenuItemTypeCommand },
|
||||
{ NULL, 0 },
|
||||
static const uiMenuItem fileMenu[] = {
|
||||
{ uiMenuItemTypeCommand, "New" },
|
||||
{ uiMenuItemTypeCommand, "Open" },
|
||||
{ uiMenuItemTypeQuit, NULL },
|
||||
{ 0, NULL },
|
||||
};
|
||||
|
||||
static uiMenuItem editMenu[] = {
|
||||
{ "Undo", uiMenuItemTypeCommand },
|
||||
{ uiMenuItemSeparator, uiMenuItemTypeSeparator },
|
||||
{ "Check Me", uiMenuItemTypeCheckbox },
|
||||
{ "A&ccelerator T_est", uiMenuItemTypeCommand },
|
||||
{ uiMenuItemPreferences, uiMenuItemTypeCommand },
|
||||
{ NULL, 0 },
|
||||
static const uiMenuItem editMenu[] = {
|
||||
{ uiMenuItemTypeCommand, "Undo" },
|
||||
{ uiMenuItemTypeSeparator, NULL },
|
||||
{ uiMenuItemTypeCheckbox, "Check Me" },
|
||||
{ uiMenuItemTypeCommand, "A&ccelerator T_est" },
|
||||
{ uiMenuItemTypePreferences, NULL },
|
||||
{ 0, NULL },
|
||||
};
|
||||
|
||||
static uiMenuItem helpMenu[] = {
|
||||
{ "Help", uiMenuItemTypeCommand },
|
||||
{ uiMenuItemAbout, uiMenuItemTypeCommand },
|
||||
{ NULL, 0 },
|
||||
static const uiMenuItem helpMenu[] = {
|
||||
{ uiMenuItemTypeCommand, "Help" },
|
||||
{ uiMenuItemTypeAbout, NULL },
|
||||
{ 0, NULL },
|
||||
};
|
||||
|
||||
static uiMenu menu[] = {
|
||||
|
|
20
ui.idl
20
ui.idl
|
@ -143,28 +143,20 @@ struct Menu {
|
|||
};
|
||||
|
||||
struct MenuItem {
|
||||
field Name *const char;
|
||||
field Type MenuItemType;
|
||||
field Name *const char;
|
||||
};
|
||||
|
||||
enum MenuItemType {
|
||||
End, // Name must be NULL; specicfy this as 0
|
||||
Command,
|
||||
Checkbox,
|
||||
Separator,
|
||||
Quit, // Name must be NULL
|
||||
Preferences, // Name must be NULL
|
||||
About, // Name must be NULL
|
||||
Separator, // Name must be NULL
|
||||
};
|
||||
|
||||
// TODO allow these to be specified directly in the IDL
|
||||
/* TODO
|
||||
raw "extern const char *const uiMenuItemQuit;";
|
||||
raw "extern const char *const uiMenuItemPreferences;";
|
||||
raw "extern const char *const uiMenuItemAbout;";
|
||||
raw "extern const char *const uiMenuItemSeparator;";
|
||||
*/
|
||||
raw "#define uiMenuItemQuit ((char *)1)";
|
||||
raw "#define uiMenuItemPreferences ((char *)2)";
|
||||
raw "#define uiMenuItemAbout ((char *)3)";
|
||||
raw "#define uiMenuItemSeparator ((char *)4)";
|
||||
|
||||
raw "#endif";
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue