Advertisement
Guest User

Untitled

a guest
Jul 17th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void make_cocoa_window()
  2. {
  3.     NSApplication *app = [NSApplication sharedApplication];
  4.     [app setActivationPolicy: NSApplicationActivationPolicyRegular];
  5.     NSMenu *menu_bar = [[NSMenu alloc] init];
  6.     NSMenuItem *app_menu_item = [[NSMenuItem alloc] init];
  7.     [menu_bar addItem:app_menu_item];
  8.     app.mainMenu = menu_bar;
  9.     NSMenu *app_menu = [[NSMenu alloc] init];
  10.     NSMenuItem *quit_menu_item = [[NSMenuItem alloc] initWithTitle:@"Quit"
  11.                                                             action:@selector(terminate:)
  12.                                                      keyEquivalent:@"q"];
  13.     [app_menu addItem:quit_menu_item];
  14.     [app_menu_item setSubmenu:app_menu];
  15.     [app activateIgnoringOtherApps:YES];
  16.  
  17.  
  18.     NSWindow *window = nil;
  19.     NSRect contentRet = NSMakeRect(0, 0, 1025, 768);
  20.     { // create window
  21.         window = [[NSWindow alloc] initWithContentRect:contentRet
  22.                                              styleMask:NSTitledWindowMask
  23.                                                backing:NSBackingStoreBuffered
  24.                                                  defer:NO
  25.                                                 screen:nil];
  26.         [window cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
  27.         [window setTitle:@"Lol Window"];
  28.     }    
  29.     // show window
  30.     [window makeKeyAndOrderFront:nil];
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement