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