Made SyncEnableState() a uiDarwinControl method instead of a uiControl method since it's not needed on GTK+.

This commit is contained in:
Pietro Gagliardi 2016-04-25 17:52:16 -04:00
parent a651caac89
commit 7b0780be2a
8 changed files with 21 additions and 21 deletions

View File

@ -57,11 +57,6 @@ void uiControlDisable(uiControl *c)
(*(c->Disable))(c); (*(c->Disable))(c);
} }
void uiControlSyncEnableState(uiControl *c, int state)
{
(*(c->SyncEnableState))(c, state);
}
#define uiControlSignature 0x7569436F #define uiControlSignature 0x7569436F
uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr) uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr)

View File

@ -65,7 +65,7 @@ uiDarwinControlDefaultEnabled(uiBox, view)
uiDarwinControlDefaultEnable(uiBox, view) uiDarwinControlDefaultEnable(uiBox, view)
uiDarwinControlDefaultDisable(uiBox, view) uiDarwinControlDefaultDisable(uiBox, view)
static void uiBoxSyncEnableState(uiControl *c, int enabled) static void uiBoxSyncEnableState(uiDarwinControl *c, int enabled)
{ {
uiBox *b = uiBox(c); uiBox *b = uiBox(c);
NSUInteger i; NSUInteger i;
@ -77,7 +77,7 @@ static void uiBoxSyncEnableState(uiControl *c, int enabled)
v = (NSValue *) [b->children objectAtIndex:i]; v = (NSValue *) [b->children objectAtIndex:i];
// TODO change all these other instances of casts to conversions // TODO change all these other instances of casts to conversions
child = uiControl([v pointerValue]); child = uiControl([v pointerValue]);
uiControlSyncEnableState(child, enabled); uiDarwinControlSyncEnableState(uiDarwinControl(child), enabled);
} }
} }
@ -229,7 +229,7 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
uiControlSetParent(c, uiControl(b)); uiControlSetParent(c, uiControl(b));
uiDarwinControlSetSuperview(uiDarwinControl(c), b->view); uiDarwinControlSetSuperview(uiDarwinControl(c), b->view);
uiControlSyncEnableState(c, uiControlEnabledToUser(uiControl(b))); uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(uiControl(b)));
// TODO save the old hugging priorities // TODO save the old hugging priorities
// if a control is stretchy, it should not hug in the primary direction // if a control is stretchy, it should not hug in the primary direction

View File

@ -1,6 +1,11 @@
// 16 august 2015 // 16 august 2015
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
void uiDarwinControlSyncEnableState(uiDarwinControl *c, int state)
{
(*(c->SyncEnableState))(c, state);
}
void uiDarwinControlSetSuperview(uiDarwinControl *c, NSView *superview) void uiDarwinControlSetSuperview(uiDarwinControl *c, NSView *superview)
{ {
(*(c->SetSuperview))(c, superview); (*(c->SetSuperview))(c, superview);

View File

@ -31,12 +31,12 @@ uiDarwinControlDefaultEnabled(uiGroup, box)
uiDarwinControlDefaultEnable(uiGroup, box) uiDarwinControlDefaultEnable(uiGroup, box)
uiDarwinControlDefaultDisable(uiGroup, box) uiDarwinControlDefaultDisable(uiGroup, box)
static void uiGroupSyncEnableState(uiControl *c, int enabled) static void uiGroupSyncEnableState(uiDarwinControl *c, int enabled)
{ {
uiGroup *g = uiGroup(c); uiGroup *g = uiGroup(c);
if (g->child != NULL) if (g->child != NULL)
uiControlSyncEnableState(g->child, enabled); uiDarwinControlSyncEnableState(uiDarwinControl(g->child), enabled);
} }
uiDarwinControlDefaultSetSuperview(uiGroup, box) uiDarwinControlDefaultSetSuperview(uiGroup, box)
@ -89,7 +89,7 @@ void uiGroupSetChild(uiGroup *g, uiControl *child)
// otherwise, things get really glitchy // otherwise, things get really glitchy
// we also need to call -sizeToFit, but we'll do that in the relayout that's triggered below (see above) // we also need to call -sizeToFit, but we'll do that in the relayout that's triggered below (see above)
uiDarwinControlSetSuperview(uiDarwinControl(g->child), g->box); uiDarwinControlSetSuperview(uiDarwinControl(g->child), g->box);
uiControlSyncEnableState(g->child, uiControlEnabledToUser(uiControl(g))); uiDarwinControlSyncEnableState(uiDarwinControl(g->child), uiControlEnabledToUser(uiControl(g)));
} }
groupRelayout(g); groupRelayout(g);
} }

View File

@ -98,7 +98,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
view = [[NSView alloc] initWithFrame:NSZeroRect]; view = [[NSView alloc] initWithFrame:NSZeroRect];
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere? // TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
uiDarwinControlSetSuperview(uiDarwinControl(child), view); uiDarwinControlSetSuperview(uiDarwinControl(child), view);
uiControlSyncEnableState(child, uiControlEnabledToUser(uiControl(t))); uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
[t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n]; [t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n];
[t->views insertObject:view atIndex:n]; [t->views insertObject:view atIndex:n];

View File

@ -126,12 +126,12 @@ uiDarwinControlDefaultEnabled(uiWindow, window)
uiDarwinControlDefaultEnable(uiWindow, window) uiDarwinControlDefaultEnable(uiWindow, window)
uiDarwinControlDefaultDisable(uiWindow, window) uiDarwinControlDefaultDisable(uiWindow, window)
static void uiWindowSyncEnableState(uiControl *c, int enabled) static void uiWindowSyncEnableState(uiDarwinControl *c, int enabled)
{ {
uiWindow *w = uiWindow(c); uiWindow *w = uiWindow(c);
if (w->child != NULL) if (w->child != NULL)
uiControlSyncEnableState(w->child, enabled); uiDarwinControlSyncEnableState(uiDarwinControl(w->child), enabled);
} }
static void uiWindowSetSuperview(uiDarwinControl *c, NSView *superview) static void uiWindowSetSuperview(uiDarwinControl *c, NSView *superview)
@ -187,7 +187,7 @@ void uiWindowSetChild(uiWindow *w, uiControl *child)
uiControlSetParent(w->child, uiControl(w)); uiControlSetParent(w->child, uiControl(w));
childView = (NSView *) uiControlHandle(w->child); childView = (NSView *) uiControlHandle(w->child);
uiDarwinControlSetSuperview(uiDarwinControl(w->child), [w->window contentView]); uiDarwinControlSetSuperview(uiDarwinControl(w->child), [w->window contentView]);
uiControlSyncEnableState(w->child, uiControlEnabledToUser(uiControl(w))); uiDarwinControlSyncEnableState(uiDarwinControl(w->child), uiControlEnabledToUser(uiControl(w)));
} }
windowRelayout(w); windowRelayout(w);
} }

2
ui.h
View File

@ -58,7 +58,6 @@ struct uiControl {
int (*Enabled)(uiControl *); int (*Enabled)(uiControl *);
void (*Enable)(uiControl *); void (*Enable)(uiControl *);
void (*Disable)(uiControl *); void (*Disable)(uiControl *);
void (*SyncEnableState)(uiControl *, int);
}; };
// TOOD add argument names to all arguments // TOOD add argument names to all arguments
#define uiControl(this) ((uiControl *) (this)) #define uiControl(this) ((uiControl *) (this))
@ -73,7 +72,6 @@ _UI_EXTERN void uiControlHide(uiControl *);
_UI_EXTERN int uiControlEnabled(uiControl *); _UI_EXTERN int uiControlEnabled(uiControl *);
_UI_EXTERN void uiControlEnable(uiControl *); _UI_EXTERN void uiControlEnable(uiControl *);
_UI_EXTERN void uiControlDisable(uiControl *); _UI_EXTERN void uiControlDisable(uiControl *);
_UI_EXTERN void uiControlSyncEnableState(uiControl *, int);
_UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); _UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
_UI_EXTERN void uiFreeControl(uiControl *); _UI_EXTERN void uiFreeControl(uiControl *);

View File

@ -17,10 +17,12 @@ struct uiDarwinControl {
uiControl *parent; uiControl *parent;
BOOL enabled; BOOL enabled;
BOOL visible; BOOL visible;
void (*SyncEnableState)(uiDarwinControl *, int);
void (*SetSuperview)(uiDarwinControl *, NSView *); void (*SetSuperview)(uiDarwinControl *, NSView *);
}; };
#define uiDarwinControl(this) ((uiDarwinControl *) (this)) #define uiDarwinControl(this) ((uiDarwinControl *) (this))
// TODO document // TODO document
_UI_EXTERN void uiDarwinControlSyncEnableState(uiDarwinControl *, int);
_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
#define uiDarwinControlDefaultDestroy(type, handlefield) \ #define uiDarwinControlDefaultDestroy(type, handlefield) \
@ -77,16 +79,16 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
static void type ## Enable(uiControl *c) \ static void type ## Enable(uiControl *c) \
{ \ { \
uiDarwinControl(c)->enabled = YES; \ uiDarwinControl(c)->enabled = YES; \
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \ uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \
} }
#define uiDarwinControlDefaultDisable(type, handlefield) \ #define uiDarwinControlDefaultDisable(type, handlefield) \
static void type ## Disable(uiControl *c) \ static void type ## Disable(uiControl *c) \
{ \ { \
uiDarwinControl(c)->enabled = NO; \ uiDarwinControl(c)->enabled = NO; \
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \ uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \
} }
#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \ #define uiDarwinControlDefaultSyncEnableState(type, handlefield) \
static void type ## SyncEnableState(uiControl *c, int enabled) \ static void type ## SyncEnableState(uiDarwinControl *c, int enabled) \
{ \ { \
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \ if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \ [((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
@ -133,7 +135,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
uiControl(var)->Enabled = type ## Enabled; \ uiControl(var)->Enabled = type ## Enabled; \
uiControl(var)->Enable = type ## Enable; \ uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \ uiControl(var)->Disable = type ## Disable; \
uiControl(var)->SyncEnableState = type ## SyncEnableState; \ uiDarwinControl(var)->SyncEnableState = type ## SyncEnableState; \
uiDarwinControl(var)->SetSuperview = type ## SetSuperview; \ uiDarwinControl(var)->SetSuperview = type ## SetSuperview; \
uiDarwinControl(var)->visible = YES; \ uiDarwinControl(var)->visible = YES; \
uiDarwinControl(var)->enabled = YES; uiDarwinControl(var)->enabled = YES;