home *** CD-ROM | disk | FTP | other *** search
- #import <appkit/appkit.h>
- #import "WindowDelegate.h"
-
- // minimal program to demonstrate the
- // windowWillClose: method
-
- main()
- {
- // create an application object
- // to establish connection to
- // Window Server
- id NXApp = [Application new];
- id theWindow;
- id theMenu;
- id theWindowDelegate;
- NXRect theRect;
- NXSize theSize;
-
- // create a window that's at 125, 125
- // and is 200 by 300 pixels
- NXSetRect(&theRect, 125, 125, 200, 300);
- theWindow = [ [Window alloc]
- initContent:&theRect
- style:NX_RESIZEBARSTYLE
- backing:NX_BUFFERED
- buttonMask:NX_CLOSEBUTTONMASK
- defer:YES];
-
- // set the minimum size of window
- theSize.width = 100;
- theSize.height = 100;
- [theWindow setMinSize:&theSize];
-
- // create the menu
- theMenu = [ [Menu alloc]
- initTitle: [NXApp appName]];
- // create the menu option
- [theMenu addItem:"Quit"
- action:@selector(terminate:)
- keyEquivalent:'q'];
-
- // resize menu to accommodate menu option
- [theMenu sizeToFit];
- [NXApp setMainMenu:theMenu];
-
- theWindowDelegate =
- [ [WindowDelegate alloc] init];
- [theWindow setDelegate:theWindowDelegate];
-
- // send the window to the front
- // and display it
- [theWindow makeKeyAndOrderFront:nil];
-
- // go into event loop to wait for events
- [NXApp run];
- }
-