Implemented menu finalization on OS X.
This commit is contained in:
parent
9e6678b635
commit
82312861e9
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// general TODO: release Objective-C objects in dealloc since we can't use ARC
|
// general TODO: release Objective-C objects in dealloc since we can't use ARC
|
||||||
|
|
||||||
// TODO menu finalization
|
static BOOL menusFinalized = NO;
|
||||||
|
|
||||||
struct menu {
|
struct menu {
|
||||||
uiMenu m;
|
uiMenu m;
|
||||||
|
@ -241,6 +241,9 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
||||||
{
|
{
|
||||||
struct menuItem *item;
|
struct menuItem *item;
|
||||||
|
|
||||||
|
if (menusFinalized)
|
||||||
|
complain("attempt to create a new menu item after menus have been finalized");
|
||||||
|
|
||||||
item = uiNew(struct menuItem);
|
item = uiNew(struct menuItem);
|
||||||
|
|
||||||
item->type = type;
|
item->type = type;
|
||||||
|
@ -317,6 +320,9 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
{
|
{
|
||||||
struct menu *m;
|
struct menu *m;
|
||||||
|
|
||||||
|
if (menusFinalized)
|
||||||
|
complain("attempt to create a new menu after menus have been finalized");
|
||||||
|
|
||||||
m = uiNew(struct menu);
|
m = uiNew(struct menu);
|
||||||
|
|
||||||
m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
||||||
|
@ -336,3 +342,8 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
|
|
||||||
return uiMenu(m);
|
return uiMenu(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void finalizeMenus(void)
|
||||||
|
{
|
||||||
|
menusFinalized = YES;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||||
- (NSMenu *)makeMenubar;
|
- (NSMenu *)makeMenubar;
|
||||||
@end
|
@end
|
||||||
|
extern void finalizeMenus(void);
|
||||||
|
|
||||||
// init.m
|
// init.m
|
||||||
@interface appDelegate : NSObject <NSApplicationDelegate>
|
@interface appDelegate : NSObject <NSApplicationDelegate>
|
||||||
|
|
|
@ -182,6 +182,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
struct window *w;
|
struct window *w;
|
||||||
NSView *binView;
|
NSView *binView;
|
||||||
|
|
||||||
|
finalizeMenus();
|
||||||
|
|
||||||
w = uiNew(struct window);
|
w = uiNew(struct window);
|
||||||
|
|
||||||
w->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
w->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
||||||
|
|
Loading…
Reference in New Issue