diff options
-rw-r--r-- | src/Document.h | 3 | ||||
-rw-r--r-- | src/Document.m | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/Document.h b/src/Document.h index e566ac0..e54c71a 100644 --- a/src/Document.h +++ b/src/Document.h @@ -1,4 +1,7 @@ #import <Cocoa/Cocoa.h> @interface Document : NSDocument +{ + NSTextField *_label; +} @end diff --git a/src/Document.m b/src/Document.m index 7b514eb..e50737d 100644 --- a/src/Document.m +++ b/src/Document.m @@ -6,10 +6,23 @@ { self = [super init]; if (self) { + _label = [[NSTextField alloc] + initWithFrame:NSMakeRect(0, 0, 180, 20)]; + [_label setStringValue:@"Your document contents here"]; + [_label setBezeled:NO]; + [_label setDrawsBackground:NO]; + [_label setEditable:NO]; + [_label setFont:[NSFont systemFontOfSize:18]]; } return self; } +- (void)dealloc +{ + [_label release]; + [super dealloc]; +} + // TODO: Are window controllers deallocated automatically by the parent? // [[NSWindowController alloc] initWithWindow:]? @@ -27,6 +40,30 @@ backing:NSBackingStoreBuffered defer:NO]; // [window setFrameAutosaveName:@"document"]; // document name? + [[window contentView] addSubview:_label]; + + // Center the label. + NSRect content_view_frame = [[window contentView] frame]; + // NSSize window_size = [[window contentView] bounds].size; + NSPoint content_view_center = NSMakePoint( + NSMidX(content_view_frame), + NSMidY(content_view_frame) + ); + NSRect label_frame = NSMakeRect( + content_view_center.x - 125, + content_view_center.y, + 250, + 28 + ); + [_label setFrame:label_frame]; + [_label setAutoresizingMask: + NSViewMinXMargin + | NSViewMaxXMargin + | NSViewMinYMargin + | NSViewMaxYMargin]; + + // TODO: Cascade, store previous top-left position. + // [window cascadeTopLeftFromPoint:NSMakePoint(100, 100)]; NSWindowController *window_controller = [[NSWindowController alloc] initWithWindow:window]; |