diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-11 18:17:46 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-11 18:17:46 -0400 |
| commit | 52d28a619623f0f722cda5f5505f830e8995c437 (patch) | |
| tree | 438525b4328a8ad94b53ee3f2d51f94bf61bfd97 | |
| parent | 1ed1eb8dece851e623c4fff4548739e334b4d1ba (diff) | |
Implemented show/hide/enable/disable on Mac OS X new controls.
| -rw-r--r-- | new/newcontrol_darwin.m | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/new/newcontrol_darwin.m b/new/newcontrol_darwin.m index 5f70075..b2bcdd5 100644 --- a/new/newcontrol_darwin.m +++ b/new/newcontrol_darwin.m @@ -8,6 +8,10 @@ struct singleView { NSScrollView *scrollView; NSView *immediate; // the control that is added to the parent container; either view or scrollView uintptr_t parent; + BOOL userHid; + BOOL containerHid; + BOOL userDisabled; + BOOL containerDisabled; }; static void singleDestroy(uiControl *c) @@ -75,6 +79,101 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i [s->immediate setFrame:frame]; } +static int singleVisible(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + if (s->userHid) + return 0; + return 1; +} + +static void singleShow(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->userHid = NO; + if (!s->containerHid) { + [s->immediate setHidden:NO]; + updateParent(s->parent); + } +} + +static void singleHide(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->userHid = YES; + [s->immediate setHidden:YES]; + updateParent(s->parent); +} + +static void singleContainerShow(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->containerHid = NO; + if (!s->userHid) { + [s->immediate setHidden:NO]; + updateParent(s->parent); + } +} + +static void singleContainerHide(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->containerHid = YES; + [s->immediate setHidden:YES]; + updateParent(s->parent); +} + +static void enable(singleView *s) +{ + if ([s->view respondsToSelector:@selector(setEnabled:)]) + [((NSControl *) (s->view)) setEnabled:YES]; +} + +static void disable(singleView *s) +{ + if ([s->view respondsToSelector:@selector(setEnabled:)]) + [((NSControl *) (s->view)) setEnabled:NO]; +} + +static void singleEnable(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->userDisabled = NO; + if (!s->containerDisabled) + enable(s); +} + +static void singleDisable(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->userDisabled = YES; + disable(s); +} + +static void singleContainerEnable(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->containerDisabled = NO; + if (!s->userDisabled) + enable(s); +} + +static void singleContainerDisable(uiControl *c) +{ + singleView *s = (singleView *) (c->internal); + + s->containerDisabled = YES; + disable(s); +} + uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHasBorder) { uiControl *c; @@ -109,6 +208,15 @@ uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHas c->removeParent = singleRemoveParent; c->preferredSize = singlePreferredSize; c->resize = singleResize; + c->visible = singleVisible; + c->show = singleShow; + c->hide = singleHide; + c->containerShow = singleContainerShow; + c->containerHide = singleContainerHide; + c->enable = singleEnable; + c->disable = singleDisable; + c->containerEnable = singleContainerEnable; + c->containerDisable = singleContainerDisable; return c; } |
