Added margined to tWindow.
This commit is contained in:
parent
391f6dd265
commit
554454f036
|
@ -3,6 +3,8 @@
|
|||
|
||||
// #qo LDFLAGS: -framework Foundation -framework AppKit
|
||||
|
||||
BOOL margined = NO;
|
||||
|
||||
@interface appDelegate : NSObject<NSApplicationDelegate>
|
||||
@end
|
||||
|
||||
|
@ -14,6 +16,7 @@
|
|||
tButton *button;
|
||||
|
||||
mainwin = [[tWindow alloc] init];
|
||||
[mainwin tSetMargined:margined];
|
||||
|
||||
button = [[tButton alloc] tInitWithText:@"Button"];
|
||||
[mainwin tSetControl:button];
|
||||
|
@ -32,6 +35,8 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
NSApplication *app;
|
||||
|
||||
margined = argc > 1;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[app setDelegate:[appDelegate new]];
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
@interface tWindow : NSObject<tControl>
|
||||
- (void)tSetControl:(id<tControl>)cc;
|
||||
- (void)tSetMargined:(BOOL)m;
|
||||
- (void)tShow;
|
||||
// TODO this should probably in tControl
|
||||
- (void)tRelayout;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
@implementation tWindow {
|
||||
NSWindow *w;
|
||||
id<tControl> c;
|
||||
BOOL margined;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
|
@ -26,6 +27,12 @@
|
|||
[self tRelayout];
|
||||
}
|
||||
|
||||
- (void)tSetMargined:(BOOL)m
|
||||
{
|
||||
self->margined = m;
|
||||
[self tRelayout];
|
||||
}
|
||||
|
||||
- (void)tShow
|
||||
{
|
||||
[self->w cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
|
||||
|
@ -39,7 +46,10 @@
|
|||
NSMutableArray *extra, *extraVert;
|
||||
NSMutableDictionary *views;
|
||||
NSInteger i;
|
||||
NSString *margin;
|
||||
|
||||
if (self->c == nil)
|
||||
return;
|
||||
contentView = [self->w contentView];
|
||||
[contentView removeConstraints:[contentView constraints]];
|
||||
horz = [NSMutableString new];
|
||||
|
@ -48,9 +58,12 @@
|
|||
extraVert = [NSMutableArray new];
|
||||
views = [NSMutableDictionary new];
|
||||
[self->c tFillAutoLayoutHorz:horz vert:vert extra:extra extraVert:extraVert views:views];
|
||||
[extra addObject:[NSString stringWithFormat:@"|%@|", horz]];
|
||||
margin = @"";
|
||||
if (self->margined)
|
||||
margin = @"-";
|
||||
[extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, horz, margin]];
|
||||
[extraVert addObject:@NO];
|
||||
[extra addObject:[NSString stringWithFormat:@"|%@|", vert]];
|
||||
[extra addObject:[NSString stringWithFormat:@"|%@%@%@|", margin, vert, margin]];
|
||||
[extraVert addObject:@YES];
|
||||
for (i = 0; i < [extra count]; i++) {
|
||||
NSString *constraint;
|
||||
|
|
Loading…
Reference in New Issue