2015-08-16 22:08:00 -05:00
|
|
|
// 16 august 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2016-04-24 17:23:00 -05:00
|
|
|
// TODO refine this
|
2015-08-18 18:57:16 -05:00
|
|
|
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
|
2015-08-17 18:11:35 -05:00
|
|
|
{
|
2016-04-24 17:23:00 -05:00
|
|
|
NSView *view;
|
|
|
|
uiWindow *p;
|
2015-08-17 18:11:35 -05:00
|
|
|
|
2016-04-24 17:23:00 -05:00
|
|
|
view = (NSView *) uiControlHandle(uiControl(c));
|
|
|
|
// this can be a NSWindow
|
|
|
|
if (![view isKindOfClass:[NSWindow class]]) {
|
|
|
|
p = windowFromNSWindow([view window]);
|
|
|
|
if (p == NULL) // not in a window
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
p = uiWindow(c);
|
2015-08-18 18:57:16 -05:00
|
|
|
c = uiDarwinControl(p);
|
|
|
|
(*(c->Relayout))(uiDarwinControl(c));
|
2015-08-17 18:11:35 -05:00
|
|
|
}
|
|
|
|
|
2015-08-25 19:31:43 -05:00
|
|
|
static void defaultCommitShow(uiControl *c)
|
2015-08-16 22:08:00 -05:00
|
|
|
{
|
|
|
|
NSView *view;
|
|
|
|
|
|
|
|
view = (NSView *) uiControlHandle(c);
|
|
|
|
[view setHidden:NO];
|
|
|
|
}
|
|
|
|
|
2015-08-25 19:31:43 -05:00
|
|
|
static void defaultCommitHide(uiControl *c)
|
2015-08-16 22:08:00 -05:00
|
|
|
{
|
|
|
|
NSView *view;
|
|
|
|
|
|
|
|
view = (NSView *) uiControlHandle(c);
|
|
|
|
[view setHidden:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
void osCommitEnable(uiControl *c)
|
|
|
|
{
|
|
|
|
NSControl *view;
|
|
|
|
|
|
|
|
view = (NSControl *) uiControlHandle(c);
|
|
|
|
if ([view respondsToSelector:@selector(setEnabled:)])
|
|
|
|
[view setEnabled:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
void osCommitDisable(uiControl *c)
|
|
|
|
{
|
|
|
|
NSControl *view;
|
|
|
|
|
|
|
|
view = (NSControl *) uiControlHandle(c);
|
|
|
|
if ([view respondsToSelector:@selector(setEnabled:)])
|
|
|
|
[view setEnabled:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiDarwinFinishControl(uiControl *c)
|
|
|
|
{
|
|
|
|
NSView *view;
|
|
|
|
|
|
|
|
view = (NSView *) uiControlHandle(c);
|
|
|
|
[view retain];
|
2015-08-26 20:57:38 -05:00
|
|
|
if (!isToplevel(c))
|
2015-08-17 00:52:06 -05:00
|
|
|
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
|
2015-08-25 19:31:43 -05:00
|
|
|
c->CommitShow = defaultCommitShow;
|
|
|
|
c->CommitHide = defaultCommitHide;
|
2015-08-16 22:08:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiDarwinSetControlFont(NSControl *c, NSControlSize size)
|
|
|
|
{
|
|
|
|
[c setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:size]]];
|
|
|
|
}
|
2016-04-24 14:46:29 -05:00
|
|
|
|
|
|
|
#define uiDarwinControlSignature 0x44617277
|
|
|
|
|
2016-04-24 16:38:48 -05:00
|
|
|
uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr)
|
2016-04-24 14:46:29 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return uiDarwinControl(uiAllocControl(n, uiDarwinControlSignature, typesig, typenamestr));
|
2016-04-24 14:46:29 -05:00
|
|
|
}
|