Converted the OS X menu code to the changes in the past few commits and made a few other small changes.
This commit is contained in:
parent
b6a2233d0b
commit
e26257006f
|
@ -11,33 +11,30 @@ void appendMenuItem(NSMenu *menu, const uiMenuItem *item, struct menuConfig *men
|
|||
{
|
||||
NSMenuItem *mitem;
|
||||
|
||||
if (item->Name == uiMenuItemQuit) {
|
||||
// TODO verify type
|
||||
menuConfig->hasQuit = YES;
|
||||
return;
|
||||
}
|
||||
if (item->Name == uiMenuItemPreferences) {
|
||||
// TODO verify type
|
||||
menuConfig->hasPreferences = YES;
|
||||
return;
|
||||
}
|
||||
if (item->Name == uiMenuItemAbout) {
|
||||
// TODO verify type
|
||||
menuConfig->hasAbout = YES;
|
||||
return;
|
||||
}
|
||||
if (item->Name == uiMenuItemSeparator) {
|
||||
// TODO verify type
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
return;
|
||||
}
|
||||
switch (item->Type) {
|
||||
case uiMenuItemTypeCommand:
|
||||
case uiMenuItemTypeCheckbox:
|
||||
mitem = [[NSMenuItem alloc] initWithTitle:toNSString(item->Name) action:NULL keyEquivalent:@""];
|
||||
[menu addItem:mitem];
|
||||
return;
|
||||
case uiMenuItemTypeQuit:
|
||||
// TODO verify name
|
||||
menuConfig->hasQuit = YES;
|
||||
return;
|
||||
case uiMenuItemTypePreferences:
|
||||
// TODO verify name
|
||||
menuConfig->hasPreferences = YES;
|
||||
return;
|
||||
case uiMenuItemTypeAbout:
|
||||
// TODO verify name
|
||||
menuConfig->hasAbout = YES;
|
||||
return;
|
||||
case uiMenuItemTypeSeparator:
|
||||
// TODO verify name
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
return;
|
||||
}
|
||||
// TODO complain
|
||||
}
|
||||
|
||||
NSMenuItem *makeMenu(const char *name, const uiMenuItem *items, struct menuConfig *menuConfig)
|
||||
|
@ -48,7 +45,7 @@ NSMenuItem *makeMenu(const char *name, const uiMenuItem *items, struct menuConfi
|
|||
|
||||
menubarItem = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:NULL keyEquivalent:@""];
|
||||
menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
||||
for (i = items; i->Name != NULL; i++)
|
||||
for (i = items; i->Type != 0; i++)
|
||||
appendMenuItem(menu, i, menuConfig);
|
||||
[menubarItem setSubmenu:menu];
|
||||
return menubarItem;
|
||||
|
@ -57,11 +54,19 @@ NSMenuItem *makeMenu(const char *name, const uiMenuItem *items, struct menuConfi
|
|||
NSMenu *makeMenubar(void)
|
||||
{
|
||||
NSMenu *menubar;
|
||||
NSMenuItem *applicationMenuItem;
|
||||
NSMenu *applicationMenu;
|
||||
struct menuConfig menuConfig;
|
||||
const uiMenu *m;
|
||||
|
||||
menubar = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
// TODO give the application name?
|
||||
applicationMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
applicationMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
[applicationMenuItem setSubmenu:applicationMenu];
|
||||
[menubar addItem:applicationMenuItem];
|
||||
|
||||
memset(&menuConfig, 0, sizeof (struct menuConfig));
|
||||
for (m = options.Menu; m->Name != NULL; m++)
|
||||
[menubar addItem:makeMenu(m->Name, m->Items, &menuConfig)];
|
||||
|
|
Loading…
Reference in New Issue