Implemented uiControlEnable() and uiControlDisable() for containers and uiWIndow on Mac OS X.
This commit is contained in:
parent
d237449060
commit
d23fae34be
1
TODO.md
1
TODO.md
|
@ -51,7 +51,6 @@
|
|||
- drop "Page" from uiTab method names? (uiTabAppendPage() -> uiTabAppend())
|
||||
- override dock menu quit item to act like our app menu quit item
|
||||
- consider calling setAppleMenu: for the application menu; it doesn't seem to make much of a difference but
|
||||
- we might need to bring ContainerEnable() and ContainerDisable() back because of OS X and Windows :(
|
||||
|
||||
ultimately:
|
||||
- add some sort of runtime type checking
|
||||
|
|
|
@ -50,6 +50,14 @@ void binPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *heig
|
|||
*height += marginY;
|
||||
}
|
||||
|
||||
void binSysFunc(uiControl *c, uiControlSysFuncParams *p)
|
||||
{
|
||||
struct bin *b = (struct bin *) c;
|
||||
|
||||
if (b->mainControl != NULL)
|
||||
uiControlSysFunc(b->mainControl, p);
|
||||
}
|
||||
|
||||
void binResizeChildren(uiContainer *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||
{
|
||||
struct bin *b = (struct bin *) c;
|
||||
|
@ -74,6 +82,7 @@ uiContainer *newBin(void)
|
|||
b->baseDestroy = uiControl(b)->Destroy;
|
||||
uiControl(b)->Destroy = binDestroy;
|
||||
uiControl(b)->PreferredSize = binPreferredSize;
|
||||
uiControl(b)->SysFunc = binSysFunc;
|
||||
|
||||
uiContainer(b)->ResizeChildren = binResizeChildren;
|
||||
|
||||
|
|
|
@ -131,15 +131,19 @@ static void containerHide(uiControl *cc)
|
|||
static void containerEnable(uiControl *cc)
|
||||
{
|
||||
containerView *c = (containerView *) (cc->Internal);
|
||||
uiControlSysFuncParams p;
|
||||
|
||||
// TODO
|
||||
p.Func = uiDarwinSysFuncContainerEnable;
|
||||
uiControlSysFunc(cc, &p);
|
||||
}
|
||||
|
||||
static void containerDisable(uiControl *cc)
|
||||
{
|
||||
containerView *c = (containerView *) (cc->Internal);
|
||||
uiControlSysFuncParams p;
|
||||
|
||||
// TODO
|
||||
p.Func = uiDarwinSysFuncContainerDisable;
|
||||
uiControlSysFunc(cc, &p);
|
||||
}
|
||||
|
||||
static void containerUpdate(uiContainer *cc)
|
||||
|
@ -169,6 +173,7 @@ void uiMakeContainer(uiContainer *cc)
|
|||
uiControl(cc)->Hide = containerHide;
|
||||
uiControl(cc)->Enable = containerEnable;
|
||||
uiControl(cc)->Disable = containerDisable;
|
||||
// SysFunc() is provided by subclasses
|
||||
|
||||
// ResizeChildren() is provided by subclasses
|
||||
uiContainer(cc)->Update = containerUpdate;
|
||||
|
|
|
@ -9,6 +9,8 @@ struct singleView {
|
|||
NSView *immediate; // the control that is added to the parent container; either view or scrollView
|
||||
uiContainer *parent;
|
||||
int hidden;
|
||||
int userDisabled;
|
||||
int containerDisabled;
|
||||
void (*onDestroy)(void *);
|
||||
void *onDestroyData;
|
||||
};
|
||||
|
@ -112,18 +114,41 @@ static void singleEnable(uiControl *c)
|
|||
{
|
||||
singleView *s = (singleView *) (c->Internal);
|
||||
|
||||
if ([s->view respondsToSelector:@selector(setEnabled:)])
|
||||
[((NSControl *) (s->view)) setEnabled:YES];
|
||||
s->userDisabled = 0;
|
||||
if (!s->containerDisabled)
|
||||
if ([s->view respondsToSelector:@selector(setEnabled:)])
|
||||
[((NSControl *) (s->view)) setEnabled:YES];
|
||||
}
|
||||
|
||||
static void singleDisable(uiControl *c)
|
||||
{
|
||||
singleView *s = (singleView *) (c->Internal);
|
||||
|
||||
s->userDisabled = 1;
|
||||
if ([s->view respondsToSelector:@selector(setEnabled:)])
|
||||
[((NSControl *) (s->view)) setEnabled:NO];
|
||||
}
|
||||
|
||||
static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p)
|
||||
{
|
||||
singleView *s = (singleView *) (c->Internal);
|
||||
|
||||
switch (p->Func) {
|
||||
case uiDarwinSysFuncContainerEnable:
|
||||
s->containerDisabled = 0;
|
||||
if (!s->userDisabled)
|
||||
if ([s->view respondsToSelector:@selector(setEnabled:)])
|
||||
[((NSControl *) (s->view)) setEnabled:YES];
|
||||
return;
|
||||
case uiDarwinSysFuncContainerDisable:
|
||||
s->containerDisabled = 1;
|
||||
if ([s->view respondsToSelector:@selector(setEnabled:)])
|
||||
[((NSControl *) (s->view)) setEnabled:NO];
|
||||
return;
|
||||
}
|
||||
complain("unknown p->Func %d in singleSysFunc()", p->Func);
|
||||
}
|
||||
|
||||
void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData)
|
||||
{
|
||||
singleView *s;
|
||||
|
@ -163,4 +188,5 @@ void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scro
|
|||
uiControl(c)->Hide = singleHide;
|
||||
uiControl(c)->Enable = singleEnable;
|
||||
uiControl(c)->Disable = singleDisable;
|
||||
uiControl(c)->SysFunc = singleSysFunc;
|
||||
}
|
||||
|
|
|
@ -121,14 +121,14 @@ static void windowEnable(uiControl *c)
|
|||
{
|
||||
struct window *w = (struct window *) c;
|
||||
|
||||
// TODO
|
||||
uiControlEnable(uiControl(w->bin));
|
||||
}
|
||||
|
||||
static void windowDisable(uiControl *c)
|
||||
{
|
||||
struct window *w = (struct window *) c;
|
||||
|
||||
// TODO
|
||||
uiControlDisable(uiControl(w->bin));
|
||||
}
|
||||
|
||||
static char *windowTitle(uiWindow *ww)
|
||||
|
|
11
ui_darwin.h
11
ui_darwin.h
|
@ -20,4 +20,15 @@ struct uiSizingSys {
|
|||
// this structure currently left blank
|
||||
};
|
||||
|
||||
struct uiControlSysFuncParams {
|
||||
int Func;
|
||||
};
|
||||
|
||||
enum {
|
||||
// These should enable and disable the uiControl while preserving the user enable/disable setting.
|
||||
// These are needed because enabling and disabling of views on OS X is available on a view-by-view basis, and is not transitive to subviews by default as a result.
|
||||
uiDarwinSysFuncContainerEnable,
|
||||
uiDarwinSysFuncContainerDisable,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue