From 52152f0f9df1c616fae45c66c75e0f353c793552 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 1 Aug 2015 02:16:35 -0400 Subject: [PATCH] More uiBox mock work. --- redo/osxaltest/box.m | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/redo/osxaltest/box.m b/redo/osxaltest/box.m index 521871fe..b7952511 100644 --- a/redo/osxaltest/box.m +++ b/redo/osxaltest/box.m @@ -4,17 +4,19 @@ @interface tBox : NSObject { NSMutableArray *children; NSView *sv; + BOOL vertical; } @end @implementation tBox -- (id)init +- (id)initVertical:(BOOL)vert { self = [super init]; if (self) { self->children = [NSMutableArray new]; self->sv = nil; + self->vertical = vert; } return self; } @@ -27,14 +29,43 @@ - (void)tAddToView:(NSView *)v { self->sv = v; - // TODO + [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + NSView *vv; + + vv = (NSView *) obj; + [v addSubview:vv]; + }]; } - (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n { - // TODO + [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + NSObject *c; + + c = (NSObject *) obj; + n = [c tAddToAutoLayoutDictionary:views keyNumber:n]; + }]; + return n; } -// TODO build auto layout constraints +- (NSString *)tBuildAutoLayoutConstraintsKeyNumber:(uintmax_t)n +{ + NSMutableString *constraints; + + if (self->vertical) + constraints = [NSMutableString stringWithString:@"V:"]; + else + constraints = [NSMutableString stringWithString:@"H:"]; + [constraints appendString:@"|"]; + [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + NSString *thisView; + + // TODO have every control do this + [constraints appendString:tAutoLayoutKey(n)]; + n++; + }]; + [constraints appendString:@"|"]; + return constraints; +} @end