Implemented uiWindowSetMargined() on Mac OS X.
This commit is contained in:
parent
73f6841272
commit
7c6beec879
|
@ -8,7 +8,9 @@
|
||||||
// - NSTab switching tabs calls both -[setFrame:] and -[setFrameSize:] on the new tab
|
// - NSTab switching tabs calls both -[setFrame:] and -[setFrameSize:] on the new tab
|
||||||
// so we just override setFrameSize:
|
// so we just override setFrameSize:
|
||||||
// thanks to mikeash and JtRip in irc.freenode.net/#macdev
|
// thanks to mikeash and JtRip in irc.freenode.net/#macdev
|
||||||
@implementation uiContainer
|
@implementation uiContainer {
|
||||||
|
BOOL uimargined;
|
||||||
|
}
|
||||||
|
|
||||||
uiLogObjCClassAllocations
|
uiLogObjCClassAllocations
|
||||||
|
|
||||||
|
@ -28,12 +30,37 @@ uiLogObjCClassAllocations
|
||||||
[self uiUpdateNow];
|
[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
|
- (void)uiUpdateNow
|
||||||
{
|
{
|
||||||
uiSizing d;
|
uiSizing d;
|
||||||
|
intmax_t x, y, width, height;
|
||||||
|
|
||||||
if (self.child != NULL)
|
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);
|
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
|
@end
|
||||||
|
|
|
@ -40,4 +40,5 @@ extern void setStandardControlFont(NSControl *);
|
||||||
// TODO rename to uiChild
|
// TODO rename to uiChild
|
||||||
@property uiControl *child;
|
@property uiControl *child;
|
||||||
- (void)uiUpdateNow;
|
- (void)uiUpdateNow;
|
||||||
|
- (void)uiSetMargined:(BOOL)margined;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -110,3 +110,15 @@ void uiWindowSetChild(uiWindow *w, uiControl *c)
|
||||||
D.container.child = c;
|
D.container.child = c;
|
||||||
(*(D.container.child->setParent))(D.container.child, (uintptr_t) (D.container));
|
(*(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