Implemented uiWindowSetMargined() on Mac OS X.
This commit is contained in:
parent
7148b26afb
commit
da0f0b3d69
|
@ -8,7 +8,9 @@
|
|||
// - NSTab switching tabs calls both -[setFrame:] and -[setFrameSize:] on the new tab
|
||||
// so we just override setFrameSize:
|
||||
// thanks to mikeash and JtRip in irc.freenode.net/#macdev
|
||||
@implementation uiContainer
|
||||
@implementation uiContainer {
|
||||
BOOL uimargined;
|
||||
}
|
||||
|
||||
uiLogObjCClassAllocations
|
||||
|
||||
|
@ -28,12 +30,37 @@ uiLogObjCClassAllocations
|
|||
[self uiUpdateNow];
|
||||
}
|
||||
|
||||
// These are based on measurements from Interface Builder.
|
||||
// TODO reverify these against /layout rects/, not /frame rects/
|
||||
#define macXMargin 20
|
||||
#define macYMargin 20
|
||||
|
||||
- (void)uiUpdateNow
|
||||
{
|
||||
uiSizing d;
|
||||
intmax_t x, y, width, height;
|
||||
|
||||
if (self.child != NULL)
|
||||
(*(self.child->resize))(self.child, [self bounds].origin.y, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height, &d);
|
||||
if (self.child == NULL)
|
||||
return;
|
||||
x = [self bounds].origin.x;
|
||||
y = [self bounds].origin.y;
|
||||
width = [self bounds].size.width;
|
||||
height = [self bounds].size.height;
|
||||
if (self->uimargined) {
|
||||
x += macXMargin;
|
||||
y += macYMargin;
|
||||
width -= 2 * macXMargin;
|
||||
height -= 2 * macYMargin;
|
||||
}
|
||||
(*(self.child->resize))(self.child, x, y, width, height, &d);
|
||||
}
|
||||
|
||||
// TODO margined
|
||||
|
||||
- (void)uiSetMargined:(BOOL)margined
|
||||
{
|
||||
self->uimargined = margined;
|
||||
[self uiUpdateNow];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,4 +40,5 @@ extern void setStandardControlFont(NSControl *);
|
|||
// TODO rename to uiChild
|
||||
@property uiControl *child;
|
||||
- (void)uiUpdateNow;
|
||||
- (void)uiSetMargined:(BOOL)margined;
|
||||
@end
|
||||
|
|
|
@ -110,3 +110,15 @@ void uiWindowSetChild(uiWindow *w, uiControl *c)
|
|||
D.container.child = c;
|
||||
(*(D.container.child->setParent))(D.container.child, (uintptr_t) (D.container));
|
||||
}
|
||||
|
||||
// TODO margined
|
||||
|
||||
void uiWindowSetMargined(uiWindow *w, int margined)
|
||||
{
|
||||
BOOL m;
|
||||
|
||||
m = NO;
|
||||
if (margined)
|
||||
m = YES;
|
||||
[D.container uiSetMargined:m];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue