Made uiSpinbox not use singleHWNDControls. More TODOs.

This commit is contained in:
Pietro Gagliardi 2015-06-05 16:22:50 -04:00
parent 7ff81f69b3
commit fb9d7a2a99
2 changed files with 36 additions and 10 deletions

View File

@ -141,6 +141,7 @@ static uintptr_t singleHWNDSetZOrder(uiControl *c, uintptr_t insertAfter)
return uiWindowsUtilSetZOrder(HWND(c), insertAfter); return uiWindowsUtilSetZOrder(HWND(c), insertAfter);
} }
// TODO should disabled controls return 1? test tabbing across a tab with only disabled controls
int uiWindowsUtilHasTabStops(HWND hwnd) int uiWindowsUtilHasTabStops(HWND hwnd)
{ {
return (getStyle(hwnd) & WS_TABSTOP) != 0; return (getStyle(hwnd) & WS_TABSTOP) != 0;

View File

@ -5,11 +5,9 @@ struct spinbox {
uiSpinbox s; uiSpinbox s;
HWND hwnd; HWND hwnd;
HWND updown; HWND updown;
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
void (*onChanged)(uiSpinbox *, void *); void (*onChanged)(uiSpinbox *, void *);
void *onChangedData; void *onChangedData;
BOOL inhibitChanged; BOOL inhibitChanged;
void (*baseCommitDestroy)(uiControl *);
}; };
uiDefineControlType(uiSpinbox, uiTypeSpinbox, struct spinbox) uiDefineControlType(uiSpinbox, uiTypeSpinbox, struct spinbox)
@ -66,7 +64,7 @@ static void spinboxCommitDestroy(uiControl *c)
uiWindowsUnregisterWM_COMMANDHandler(s->hwnd); uiWindowsUnregisterWM_COMMANDHandler(s->hwnd);
if (DestroyWindow(s->updown) == 0) if (DestroyWindow(s->updown) == 0)
logLastError("error destroying updown in spinboxCommitDestroy()"); logLastError("error destroying updown in spinboxCommitDestroy()");
(*(s->baseCommitDestroy))(uiControl(s)); uiWindowsUtilDestroy(s->hwnd);
} }
// the edit control is the one to return here // the edit control is the one to return here
@ -78,6 +76,14 @@ static uintptr_t spinboxHandle(uiControl *c)
return (uintptr_t) (s->hwnd); return (uintptr_t) (s->hwnd);
} }
static void spinboxCommitSetParent(uiControl *c, uiControl *parent)
{
struct spinbox *s = (struct spinbox *) c;
uiWindowsUtilSetParent(s->hwnd, parent);
uiWindowsUtilSetParent(s->updown, parent);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
#define entryHeight 14 #define entryHeight 14
@ -134,10 +140,16 @@ static void spinboxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width,
{ {
struct spinbox *s = (struct spinbox *) c; struct spinbox *s = (struct spinbox *) c;
(*(s->baseResize))(uiControl(s), x, y, width, height, d); moveWindow(s->hwnd, x, y, width, height, d);
recreateUpDown(s); recreateUpDown(s);
} }
static uiSizing *spinboxSizing(uiControl *c)
{
complain("attempt to call uiControlSizing() on uiSpinbox %p", c);
return NULL;
}
#define COMMIT(n, f) \ #define COMMIT(n, f) \
static void spinboxCommit ## n(uiControl *c) \ static void spinboxCommit ## n(uiControl *c) \
{ \ { \
@ -150,9 +162,13 @@ COMMIT(Hide, uiWindowsUtilHide)
COMMIT(Enable, uiWindowsUtilEnable) COMMIT(Enable, uiWindowsUtilEnable)
COMMIT(Disable, uiWindowsUtilDisable) COMMIT(Disable, uiWindowsUtilDisable)
// StartZOrder() is fine (the edit is the first control, and that's satisfied by the singleHWND interface) static uintptr_t spinboxStartZOrder(uiControl *c)
// SetZOrder() is not {
// TODO don't even bother with singleHWND at all struct spinbox *s = (struct spinbox *) c;
return uiWindowsUtilStartZOrder(s->hwnd);
}
static uintptr_t spinboxSetZOrder(uiControl *c, uintptr_t insertAfter) static uintptr_t spinboxSetZOrder(uiControl *c, uintptr_t insertAfter)
{ {
struct spinbox *s = (struct spinbox *) c; struct spinbox *s = (struct spinbox *) c;
@ -162,6 +178,13 @@ static uintptr_t spinboxSetZOrder(uiControl *c, uintptr_t insertAfter)
return (uintptr_t) (s->updown); return (uintptr_t) (s->updown);
} }
static int spinboxHasTabStops(uiControl *c)
{
struct spinbox *s = (struct spinbox *) c;
return uiWindowsUtilHasTabStops(s->hwnd);
}
static void defaultOnChanged(uiSpinbox *s, void *data) static void defaultOnChanged(uiSpinbox *s, void *data)
{ {
// do nothing // do nothing
@ -195,7 +218,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
{ {
struct spinbox *s; struct spinbox *s;
s = (struct spinbox *) uiWindowsNewSingleHWNDControl(uiTypeSpinbox()); s = (struct spinbox *) uiNewControl(uiTypeSpinbox());
s->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, s->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE,
L"edit", L"", L"edit", L"",
@ -216,15 +239,17 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
uiControl(s)->Handle = spinboxHandle; uiControl(s)->Handle = spinboxHandle;
uiControl(s)->PreferredSize = spinboxPreferredSize; uiControl(s)->PreferredSize = spinboxPreferredSize;
s->baseResize = uiControl(s)->Resize;
uiControl(s)->Resize = spinboxResize; uiControl(s)->Resize = spinboxResize;
s->baseCommitDestroy = uiControl(s)->CommitDestroy; uiControl(s)->Sizing = spinboxSizing;
uiControl(s)->CommitDestroy = spinboxCommitDestroy; uiControl(s)->CommitDestroy = spinboxCommitDestroy;
uiControl(s)->CommitSetParent = spinboxCommitSetParent;
uiControl(s)->CommitShow = spinboxCommitShow; uiControl(s)->CommitShow = spinboxCommitShow;
uiControl(s)->CommitHide = spinboxCommitHide; uiControl(s)->CommitHide = spinboxCommitHide;
uiControl(s)->CommitEnable = spinboxCommitEnable; uiControl(s)->CommitEnable = spinboxCommitEnable;
uiControl(s)->CommitDisable = spinboxCommitDisable; uiControl(s)->CommitDisable = spinboxCommitDisable;
uiControl(s)->StartZOrder = spinboxStartZOrder;
uiControl(s)->SetZOrder = spinboxSetZOrder; uiControl(s)->SetZOrder = spinboxSetZOrder;
uiControl(s)->HasTabStops = spinboxHasTabStops;
uiSpinbox(s)->Value = spinboxValue; uiSpinbox(s)->Value = spinboxValue;
uiSpinbox(s)->SetValue = spinboxSetValue; uiSpinbox(s)->SetValue = spinboxSetValue;