Defined an interface for menus.

This commit is contained in:
Pietro Gagliardi 2015-04-20 18:06:27 -04:00
parent 845104a1a1
commit fbe806a348
2 changed files with 36 additions and 3 deletions

8
menu.c
View File

@ -6,7 +6,9 @@
static volatile char dummyQuit = 'q';
static volatile char dummyPreferences = 'p';
static volatile char dummyAbout = 'a';
static volatile char dummySeparator = 's';
const char *const uiMenuQuitItem = &dummyQuit;
const char *const uiMenuPreferencesItem = &dummyPreferences;
const char *const uiMenuAboutItem = &dummyAbout;
const char *const uiMenuItemQuit = &dummyQuit;
const char *const uiMenuItemPreferences = &dummyPreferences;
const char *const uiMenuItemAbout = &dummyAbout;
const char *const uiMenuItemSeparator = &dummySeparator;

31
ui.idl
View File

@ -20,6 +20,13 @@ struct InitOptions {
// If nonzero, allocations will be logged to stderr.
// See leaks.awk.
field debugLogAllocations int;
// This is the menu that the application will use.
// To give this menu to a uiWindow, specify nonzero for the hasMenu parameter to uiNewWindow().
// This value, nor any element of the array it points to, should never change during execution of the program.
// TODO make it a proper const *const
// TODO idl2h doesn't support making this even const * yet...
field Menu *Menu;
};
// TODO const char
@ -128,6 +135,30 @@ interface Tab from Control {
};
func NewTab(void) *Tab;
struct Menu {
field Name *const char;
// TODO make a proper const *const
// TODO idl2h doesn't support making this even const * yet...
field Items *MenuItem;
};
struct MenuItem {
field Name *const char;
field Type MenuItemType;
};
enum MenuItemType {
Command,
Checkbox,
Separator,
};
// TODO allow these to be specified directly in the IDL
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 "#endif";
};