Changed things around a bit; going to build things from tWindow's perspective first.

This commit is contained in:
Pietro Gagliardi 2015-08-01 15:21:03 -04:00
parent cdbf2d5b5c
commit 9ecf15f4e0
3 changed files with 9 additions and 40 deletions

View File

@ -10,20 +10,15 @@
- (void)applicationDidFinishLaunching:(NSNotification *)note - (void)applicationDidFinishLaunching:(NSNotification *)note
{ {
NSWindow *mainwin; tWindow *mainwin;
tWindowDelegate *delegate; tButton *button;
mainwin = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 320, 240) mainwin = [[tWindow alloc] init];
styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
backing:NSBackingStoreBuffered
defer:YES];
[mainwin setTitle:@"Auto Layout Test"];
delegate = [tWindowDelegate new]; button = [[tButton alloc] tInitWithText:@"Button"];
[mainwin setDelegate:delegate]; [mainwin tSetControl:button];
[mainwin cascadeTopLeftFromPoint:NSMakePoint(20, 20)]; [mainwin tShow];
[mainwin makeKeyAndOrderFront:self];
} }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)a - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)a

View File

@ -8,8 +8,10 @@
- (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n; - (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n;
@end @end
@interface tWindowDelegate : NSObject<NSWindowDelegate> @interface tWindow : NSObject<tControl>
- (void)tSetControl:(id<tControl>)cc; - (void)tSetControl:(id<tControl>)cc;
- (void)tShow;
// TODO this should probably in tControl
- (void)tRelayout; - (void)tRelayout;
@end @end

View File

@ -1,28 +0,0 @@
// 1 august 2015
#import "osxaltest.h"
@implementation tWindowDelegate {
id<tControl> c;
}
- (id)init
{
self = [super init];
if (self)
self->c = NULL;
return self;
}
- (void)tSetControl:(id<tControl>)cc
{
self->c = cc;
}
- (void)tRelayout
{
if (self->c == NULL)
return;
// TODO
}
@end