Migrated darwin/control.m. Forgot the SetParent/SetSuperview rule! One more commit before we can build...
This commit is contained in:
parent
189d661b7f
commit
23c2998040
|
@ -1,68 +1,9 @@
|
||||||
// 16 august 2015
|
// 16 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODO refine this
|
void uiDarwinControlSetSuperview(uiControl *c, NSView *superview)
|
||||||
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
|
|
||||||
{
|
{
|
||||||
NSView *view;
|
(*(c->SetSuperview))(c, superview);
|
||||||
uiWindow *p;
|
|
||||||
|
|
||||||
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);
|
|
||||||
c = uiDarwinControl(p);
|
|
||||||
(*(c->Relayout))(uiDarwinControl(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void defaultCommitShow(uiControl *c)
|
|
||||||
{
|
|
||||||
NSView *view;
|
|
||||||
|
|
||||||
view = (NSView *) uiControlHandle(c);
|
|
||||||
[view setHidden:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void defaultCommitHide(uiControl *c)
|
|
||||||
{
|
|
||||||
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];
|
|
||||||
if (!isToplevel(c))
|
|
||||||
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
|
|
||||||
c->CommitShow = defaultCommitShow;
|
|
||||||
c->CommitHide = defaultCommitHide;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDarwinSetControlFont(NSControl *c, NSControlSize size)
|
void uiDarwinSetControlFont(NSControl *c, NSControlSize size)
|
||||||
|
|
|
@ -93,6 +93,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
|
||||||
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
|
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
|
||||||
static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \
|
static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \
|
||||||
{ \
|
{ \
|
||||||
|
[type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \
|
||||||
if (superview == nil) \
|
if (superview == nil) \
|
||||||
[type(c)->handlefield removeFromSuperview]; \
|
[type(c)->handlefield removeFromSuperview]; \
|
||||||
else \
|
else \
|
||||||
|
|
Loading…
Reference in New Issue