all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
55
Task/Window-creation/Objective-C/window-creation.m
Normal file
55
Task/Window-creation/Objective-C/window-creation.m
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface Win : NSWindow
|
||||
{
|
||||
}
|
||||
- (void)applicationDidFinishLaunching: (NSNotification *)notification;
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification;
|
||||
@end
|
||||
|
||||
|
||||
@implementation Win : NSWindow
|
||||
-(id) init
|
||||
{
|
||||
[self
|
||||
initWithContentRect: NSMakeRect(0, 0, 800, 600)
|
||||
styleMask: (NSTitledWindowMask | NSClosableWindowMask)
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: NO];
|
||||
|
||||
[self setTitle: @"A Window"];
|
||||
[self center];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching: (NSNotification *)notification
|
||||
{
|
||||
[self orderFront: self];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
int main()
|
||||
{
|
||||
Win *mywin;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
[NSApplication sharedApplication];
|
||||
mywin = [[Win alloc] init];
|
||||
[NSApp setDelegate: mywin];
|
||||
[NSApp runModalForWindow: mywin];
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue