More uiBox mock work.

This commit is contained in:
Pietro Gagliardi 2015-08-01 02:16:35 -04:00
parent 0d27b4e30f
commit 52152f0f9d
1 changed files with 35 additions and 4 deletions

View File

@ -4,17 +4,19 @@
@interface tBox : NSObject<tControl> { @interface tBox : NSObject<tControl> {
NSMutableArray *children; NSMutableArray *children;
NSView *sv; NSView *sv;
BOOL vertical;
} }
@end @end
@implementation tBox @implementation tBox
- (id)init - (id)initVertical:(BOOL)vert
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self->children = [NSMutableArray new]; self->children = [NSMutableArray new];
self->sv = nil; self->sv = nil;
self->vertical = vert;
} }
return self; return self;
} }
@ -27,14 +29,43 @@
- (void)tAddToView:(NSView *)v - (void)tAddToView:(NSView *)v
{ {
self->sv = 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 - (uintmax_t)tAddToAutoLayoutDictionary:(NSMutableDictionary *)views keyNumber:(uintmax_t)n
{ {
// TODO [self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSObject<tControl> *c;
c = (NSObject<tControl> *) 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 @end