diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-11 15:34:16 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-11 15:34:16 -0400 |
| commit | a1b4b96bb962c4d69e7af7229efa52f3e2767433 (patch) | |
| tree | 345862168333c172b18fa5296c1f889a0097888b | |
| parent | 9ea35db265a3a9a0ae0d697aa1ef871713151c82 (diff) | |
Added the enable/disable/show/hide code to the Windows new control. Something is clobbering stacks; need to debug this...
| -rw-r--r-- | new/newcontrol_windows.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c index 375488b..eb06d94 100644 --- a/new/newcontrol_windows.c +++ b/new/newcontrol_windows.c @@ -9,6 +9,10 @@ struct singleHWND { BOOL (*onWM_NOTIFY)(uiControl *, NMHDR *, LRESULT *); void (*onWM_DESTROY)(uiControl *); uintptr_t parent; + BOOL userHid; + BOOL containerHid; + BOOL userDisabled; + BOOL containerDisabled; }; static void singleDestroy(uiControl *c) @@ -57,6 +61,89 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i logLastError("error moving control in singleResize()"); } +static int singleVisible(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + if (s->userHid) + return 0; + return 1; +} + +static void singleShow(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->userHid = FALSE; + if (!s->containerHid) { + ShowWindow(s->hwnd, SW_SHOW); + updateParent(s->parent); + } +} + +static void singleHide(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->userHid = TRUE; + ShowWindow(s->hwnd, SW_HIDE); + updateParent(s->parent); +} + +static void singleContainerShow(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->containerHid = FALSE; + if (!s->userHid) { + ShowWindow(s->hwnd, SW_SHOW); + updateParent(s->parent); + } +} + +static void singleContainerHide(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->containerHid = TRUE; + ShowWindow(s->hwnd, SW_HIDE); + updateParent(s->parent); +} + +static void singleEnable(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->userDisabled = FALSE; + if (!s->containerDisabled) + EnableWindow(s->hwnd, TRUE); +} + +static void singleDisable(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->userDisabled = TRUE; + EnableWindow(s->hwnd, FALSE); +} + +static void singleContainerEnable(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->containerDisabled = FALSE; + if (!s->userDisabled) + EnableWindow(s->hwnd, TRUE); +} + +static void singleContainerDisable(uiControl *c) +{ + singleHWND *s = (singleHWND *) (c->internal); + + s->containerDisabled = TRUE; + EnableWindow(s->hwnd, FALSE); +} + static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { uiControl *c = (uiControl *) dwRefData; @@ -110,6 +197,15 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p) c->setParent = singleSetParent; c->removeParent = singleRemoveParent; 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; if (p->useStandardControlFont) SendMessageW(s->hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE); |
