2015-07-31 22:06:29 -05:00
|
|
|
// 31 july 2015
|
|
|
|
#import "osxaltest.h"
|
|
|
|
|
2015-08-01 13:22:45 -05:00
|
|
|
@implementation tButton {
|
2015-07-31 22:06:29 -05:00
|
|
|
NSButton *b;
|
2015-08-01 20:41:36 -05:00
|
|
|
id<tControl> parent;
|
2015-07-31 22:06:29 -05:00
|
|
|
}
|
|
|
|
|
2015-08-01 13:22:45 -05:00
|
|
|
- (id)tInitWithText:(NSString *)text
|
2015-07-31 22:06:29 -05:00
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self) {
|
|
|
|
self->b = [[NSButton alloc] initWithFrame:NSZeroRect];
|
|
|
|
[self->b setTitle:text];
|
|
|
|
[self->b setButtonType:NSMomentaryPushInButton];
|
|
|
|
[self->b setBordered:YES];
|
|
|
|
[self->b setBezelStyle:NSRoundedBezelStyle];
|
|
|
|
[self->b setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
|
2015-08-01 14:38:59 -05:00
|
|
|
[self->b setTranslatesAutoresizingMaskIntoConstraints:NO];
|
2015-08-01 20:41:36 -05:00
|
|
|
|
|
|
|
self->parent = nil;
|
2015-07-31 22:06:29 -05:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-08-01 20:41:36 -05:00
|
|
|
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v
|
2015-07-31 22:06:29 -05:00
|
|
|
{
|
2015-08-01 20:41:36 -05:00
|
|
|
self->parent = p;
|
2015-07-31 22:06:29 -05:00
|
|
|
[v addSubview:self->b];
|
2015-08-01 21:13:41 -05:00
|
|
|
[self tRelayout];
|
2015-07-31 22:06:29 -05:00
|
|
|
}
|
|
|
|
|
2015-08-02 10:25:39 -05:00
|
|
|
- (void)tFillAutoLayout:(tAutoLayoutParams *)p
|
2015-08-01 14:38:59 -05:00
|
|
|
{
|
2015-08-01 17:05:50 -05:00
|
|
|
NSString *key;
|
|
|
|
|
2015-08-02 10:25:39 -05:00
|
|
|
key = tAutoLayoutKey(p->n);
|
|
|
|
p->n++;
|
|
|
|
[p->horz addObject:[NSString stringWithFormat:@"[%@]", key]];
|
|
|
|
[p->vert addObject:[NSString stringWithFormat:@"[%@]", key]];
|
|
|
|
[p->views setObject:self->b forKey:key];
|
2015-08-01 14:38:59 -05:00
|
|
|
}
|
|
|
|
|
2015-08-01 21:13:41 -05:00
|
|
|
- (void)tRelayout
|
|
|
|
{
|
|
|
|
if (self->parent != nil)
|
|
|
|
[self->parent tRelayout];
|
|
|
|
}
|
|
|
|
|
2015-07-31 22:06:29 -05:00
|
|
|
@end
|