Migrated darwin/control.m. Forgot the SetParent/SetSuperview rule! One more commit before we can build...

This commit is contained in:
Pietro Gagliardi 2016-04-25 12:55:51 -04:00
parent 189d661b7f
commit 23c2998040
2 changed files with 3 additions and 61 deletions

View File

@ -1,68 +1,9 @@
// 16 august 2015
#import "uipriv_darwin.h"
// TODO refine this
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
void uiDarwinControlSetSuperview(uiControl *c, NSView *superview)
{
NSView *view;
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;
(*(c->SetSuperview))(c, superview);
}
void uiDarwinSetControlFont(NSControl *c, NSControlSize size)

View File

@ -93,6 +93,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \
{ \
[type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \
if (superview == nil) \
[type(c)->handlefield removeFromSuperview]; \
else \