libui/redo/osxaltest/button.m

49 lines
1.1 KiB
Mathematica
Raw Normal View History

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;
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]]];
[self->b setTranslatesAutoresizingMaskIntoConstraints:NO];
self->parent = nil;
2015-07-31 22:06:29 -05:00
}
return self;
}
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v
2015-07-31 22:06:29 -05:00
{
self->parent = p;
2015-07-31 22:06:29 -05:00
[v addSubview:self->b];
}
- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz
vert:(NSMutableArray *)vert
extra:(NSMutableArray *)extra
extraVert:(NSMutableArray *)extraVert
views:(NSMutableDictionary *)views
first:(uintmax_t *)n
{
NSString *key;
key = tAutoLayoutKey(*n);
(*n)++;
[horz addObject:[NSString stringWithFormat:@"[%@]", key]];
[vert addObject:[NSString stringWithFormat:@"[%@]", key]];
[views setObject:self->b forKey:key];
}
2015-07-31 22:06:29 -05:00
@end