diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index b3d604ce..d17e3440 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -37,20 +37,23 @@ }]; } -- (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n +- (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)nn { - [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { - NSObject *c; + __block uintmax_t n = nn; - c = (NSObject *) obj; + [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + id c; + + c = (id) obj; n = [c tAddToAutoLayoutDictionary:views keyNumber:n]; }]; return n; } -- (NSString *)tBuildAutoLayoutConstraintsKeyNumber:(uintmax_t)n +- (NSString *)tBuildAutoLayoutConstraintsKeyNumber:(uintmax_t)nn { NSMutableString *constraints; + __block uintmax_t n = nn; if (self->vertical) constraints = [NSMutableString stringWithString:@"V:"]; diff --git a/redo/osxaltest/main.m b/redo/osxaltest/main.m index c1d1a65c..49c5e6a5 100644 --- a/redo/osxaltest/main.m +++ b/redo/osxaltest/main.m @@ -1,6 +1,8 @@ // 31 july 2015 #import "osxaltest.h" +// #qo LDFLAGS: -framework Foundation -framework AppKit + @interface appDelegate : NSObject @end @@ -8,6 +10,20 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note { + NSWindow *mainwin; + tWindowDelegate *delegate; + + mainwin = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 320, 240) + styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask) + backing:NSBackingStoreBuffered + defer:YES]; + [mainwin setTitle:@"Auto Layout Test"]; + + delegate = [tWindowDelegate new]; + [mainwin setDelegate:delegate]; + + [mainwin cascadeTopLeftFromPoint:NSMakePoint(20, 20)]; + [mainwin makeKeyAndOrderFront:self]; } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)a diff --git a/redo/osxaltest/osxaltest b/redo/osxaltest/osxaltest new file mode 100755 index 00000000..f20c5c9c Binary files /dev/null and b/redo/osxaltest/osxaltest differ diff --git a/redo/osxaltest/osxaltest.h b/redo/osxaltest/osxaltest.h index 6049d056..dd56a4c7 100644 --- a/redo/osxaltest/osxaltest.h +++ b/redo/osxaltest/osxaltest.h @@ -8,4 +8,9 @@ - (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n; @end +@interface tWindowDelegate : NSObject +- (void)tSetControl:(NSObject *)cc; +- (void)tRelayout; +@end + extern NSString *tAutoLayoutKey(uintmax_t); diff --git a/redo/osxaltest/util.m b/redo/osxaltest/util.m new file mode 100644 index 00000000..c5ab8ea2 --- /dev/null +++ b/redo/osxaltest/util.m @@ -0,0 +1,7 @@ +// 1 august 2015 +#import "osxaltest.h" + +NSString *tAutoLayoutKey(uintmax_t n) +{ + return [NSString stringWithFormat:@"[view%ju]", n]; +} diff --git a/redo/osxaltest/windelegate.m b/redo/osxaltest/windelegate.m new file mode 100644 index 00000000..c7dd2f58 --- /dev/null +++ b/redo/osxaltest/windelegate.m @@ -0,0 +1,28 @@ +// 1 august 2015 +#import "osxaltest.h" + +@implementation tWindowDelegate { + NSObject *c; +} + +- (id)init +{ + self = [super init]; + if (self) + self->c = NULL; + return self; +} + +- (void)tSetControl:(NSObject *)cc +{ + self->c = cc; +} + +- (void)tRelayout +{ + if (self->c == NULL) + return; + // TODO +} + +@end