1 #import <AppKit/AppKit.h>
2 // clang -o nibless nibless.m -framework AppKit
3
4 @interface TestView : NSView <NSWindowDelegate> { }
5 -(void)drawRect:(NSRect)rect;
6 @end
7
8 @implementation TestView
9
10 -(void)drawRect:(NSRect)rect {
11 [[NSColor blueColor] set];
12 NSRectFill( [self bounds] );
13 }
14
15 -(void)windowWillClose:(NSNotification *)note {
16 [[NSApplication sharedApplication] terminate:self];
17 }
18
19 @end
20
21 int main(int argc, const char *argv[]) {
22 NSAutoreleasePool *pool = [NSAutoreleasePool new];
23 NSApplication *app = [NSApplication sharedApplication];
24 NSRect frame = NSMakeRect( 100., 100., 300., 300. );
25
26 NSWindow *window = [[NSWindow alloc]
27 initWithContentRect:frame
28 styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask
29 backing:NSBackingStoreBuffered
30 defer:false];
31
32 [window setTitle:@"Testing"];
33
34 TestView *view = [[[TestView alloc] initWithFrame:frame] autorelease];
35 [window setContentView:view];
36 [window setDelegate:view];
37 [window makeKeyAndOrderFront:nil];
38
39 [app run];
40
41 [pool release];
42 return( EXIT_SUCCESS );
43 }