2015-08-16 22:08:00 -05:00
|
|
|
// 16 august 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2015-08-16 22:16:42 -05:00
|
|
|
static uintmax_t type_uiDarwinControl = 0;
|
|
|
|
|
2015-08-16 22:44:23 -05:00
|
|
|
uintmax_t uiDarwinControlType(void)
|
2015-08-16 22:16:42 -05:00
|
|
|
{
|
|
|
|
if (type_uiDarwinControl == 0)
|
|
|
|
type_uiDarwinControl = uiRegisterType("uiDarwinControl", uiControlType(), sizeof (uiDarwinControl));
|
|
|
|
return type_uiDarwinControl;
|
|
|
|
}
|
|
|
|
|
2015-08-18 18:57:16 -05:00
|
|
|
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
|
2015-08-17 18:11:35 -05:00
|
|
|
{
|
|
|
|
uiControl *p;
|
|
|
|
|
2015-08-18 18:57:16 -05:00
|
|
|
p = toplevelOwning(uiControl(c));
|
|
|
|
if (p == NULL) // not in a window
|
2015-08-17 18:11:35 -05:00
|
|
|
return;
|
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]]];
|
|
|
|
}
|