Fixed up uiSpinbox now that we can do it without having an extra container in the way.
This commit is contained in:
parent
7abf662076
commit
8df022f806
|
@ -8,6 +8,7 @@ struct uiSpinbox {
|
||||||
void (*onChanged)(uiSpinbox *, void *);
|
void (*onChanged)(uiSpinbox *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
BOOL inhibitChanged;
|
BOOL inhibitChanged;
|
||||||
|
HWND parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void onDestroy(uiSpinbox *);
|
static void onDestroy(uiSpinbox *);
|
||||||
|
@ -70,7 +71,14 @@ static void onDestroy(uiSpinbox *s)
|
||||||
logLastError("error destroying updown in spinboxCommitDestroy()");
|
logLastError("error destroying updown in spinboxCommitDestroy()");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO set spinbox parent
|
static void spinboxCommitSetParent(uiWindowsControl *c, HWND parent)
|
||||||
|
{
|
||||||
|
uiSpinbox *s = uiSpinbox(c);
|
||||||
|
|
||||||
|
s->parent = parent;
|
||||||
|
uiWindowsEnsureSetParent(s->hwnd, s->parent);
|
||||||
|
uiWindowsEnsureSetParent(s->updown, s->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 */
|
||||||
|
@ -87,20 +95,16 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width
|
||||||
// alas, we have to make a new up/down control each time :(
|
// alas, we have to make a new up/down control each time :(
|
||||||
static void recreateUpDown(uiSpinbox *s)
|
static void recreateUpDown(uiSpinbox *s)
|
||||||
{
|
{
|
||||||
/* TODO
|
|
||||||
HWND parent;
|
|
||||||
BOOL preserve = FALSE;
|
BOOL preserve = FALSE;
|
||||||
intmax_t current;
|
intmax_t current;
|
||||||
// Microsoft's commctrl.h says to use this type
|
// Microsoft's commctrl.h says to use this type
|
||||||
INT min, max;
|
INT min, max;
|
||||||
|
|
||||||
parent = GetAncestor(s->hwnd, GA_PARENT);
|
|
||||||
if (s->updown != NULL) {
|
if (s->updown != NULL) {
|
||||||
preserve = TRUE;
|
preserve = TRUE;
|
||||||
current = value(s);
|
current = value(s);
|
||||||
SendMessageW(s->updown, UDM_GETRANGE32, (WPARAM) (&min), (LPARAM) (&max));
|
SendMessageW(s->updown, UDM_GETRANGE32, (WPARAM) (&min), (LPARAM) (&max));
|
||||||
if (DestroyWindow(s->updown) == 0)
|
uiWindowsEnsureDestroyWindow(s->updown);
|
||||||
logLastError("error destroying old updown in recreateUpDown()");
|
|
||||||
}
|
}
|
||||||
s->inhibitChanged = TRUE;
|
s->inhibitChanged = TRUE;
|
||||||
s->updown = CreateWindowExW(0,
|
s->updown = CreateWindowExW(0,
|
||||||
|
@ -110,7 +114,7 @@ static void recreateUpDown(uiSpinbox *s)
|
||||||
WS_CHILD | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT,
|
WS_CHILD | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT,
|
||||||
// this is important; it's necessary for autosizing to work
|
// this is important; it's necessary for autosizing to work
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
parent, NULL, hInstance, NULL);
|
s->parent, NULL, hInstance, NULL);
|
||||||
if (s->updown == NULL)
|
if (s->updown == NULL)
|
||||||
logLastError("error creating updown in recreateUpDown()");
|
logLastError("error creating updown in recreateUpDown()");
|
||||||
SendMessageW(s->updown, UDM_SETBUDDY, (WPARAM) (s->hwnd), 0);
|
SendMessageW(s->updown, UDM_SETBUDDY, (WPARAM) (s->hwnd), 0);
|
||||||
|
@ -119,41 +123,30 @@ static void recreateUpDown(uiSpinbox *s)
|
||||||
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) current);
|
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) current);
|
||||||
}
|
}
|
||||||
// preserve the z-order
|
// preserve the z-order
|
||||||
uiWindowsUtilSetZOrder(s->updown, (uintptr_t) (s->hwnd));
|
uiWindowsRearrangeControlIDsZOrder(uiControl(s));
|
||||||
if (uiControlContainerVisible(uiControl(s)))
|
// TODO properly show/enable
|
||||||
uiWindowsUtilShow(s->updown);
|
ShowWindow(s->updown, SW_SHOW);
|
||||||
s->inhibitChanged = FALSE;
|
s->inhibitChanged = FALSE;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spinboxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
static void spinboxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||||
{
|
{
|
||||||
/* TODO
|
|
||||||
uiSpinbox *s = uiSpinbox(c);
|
uiSpinbox *s = uiSpinbox(c);
|
||||||
|
|
||||||
moveWindow(s->hwnd, x, y, width, height, d);
|
uiWindowsEnsureMoveWindow(s->hwnd, x, y, width, height);
|
||||||
recreateUpDown(s);
|
recreateUpDown(s);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
static void spinboxAssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *controlID, HWND *insertAfter)
|
||||||
static uintptr_t spinboxStartZOrder(uiControl *c)
|
|
||||||
{
|
{
|
||||||
struct spinbox *s = (struct spinbox *) c;
|
uiSpinbox *s = uiSpinbox(c);
|
||||||
|
|
||||||
return uiWindowsUtilStartZOrder(s->hwnd);
|
uiWindowsEnsureAssignControlIDZOrder(s->hwnd, *controlID, *insertAfter);
|
||||||
|
uiWindowsEnsureAssignControlIDZOrder(s->updown, *controlID + 1, s->hwnd);
|
||||||
|
*controlID += 2;
|
||||||
|
*insertAfter = s->updown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t spinboxSetZOrder(uiControl *c, uintptr_t insertAfter)
|
|
||||||
{
|
|
||||||
struct spinbox *s = (struct spinbox *) c;
|
|
||||||
|
|
||||||
uiWindowsUtilSetZOrder(s->hwnd, insertAfter);
|
|
||||||
uiWindowsUtilSetZOrder(s->updown, (uintptr_t) (s->hwnd));
|
|
||||||
return (uintptr_t) (s->updown);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void defaultOnChanged(uiSpinbox *s, void *data)
|
static void defaultOnChanged(uiSpinbox *s, void *data)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -196,6 +189,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
||||||
uiWindowsRegisterWM_COMMANDHandler(s->hwnd, onWM_COMMAND, uiControl(s));
|
uiWindowsRegisterWM_COMMANDHandler(s->hwnd, onWM_COMMAND, uiControl(s));
|
||||||
uiSpinboxOnChanged(s, defaultOnChanged, NULL);
|
uiSpinboxOnChanged(s, defaultOnChanged, NULL);
|
||||||
|
|
||||||
|
s->parent = utilWindow;
|
||||||
recreateUpDown(s);
|
recreateUpDown(s);
|
||||||
s->inhibitChanged = TRUE;
|
s->inhibitChanged = TRUE;
|
||||||
SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max);
|
SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max);
|
||||||
|
@ -203,7 +197,9 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
||||||
s->inhibitChanged = FALSE;
|
s->inhibitChanged = FALSE;
|
||||||
|
|
||||||
uiWindowsFinishNewControl(s, uiSpinbox);
|
uiWindowsFinishNewControl(s, uiSpinbox);
|
||||||
|
uiWindowsControl(s)->CommitSetParent = spinboxCommitSetParent;
|
||||||
uiWindowsControl(s)->Relayout = spinboxRelayout;
|
uiWindowsControl(s)->Relayout = spinboxRelayout;
|
||||||
|
uiWindowsControl(s)->AssignControlIDZOrder = spinboxAssignControlIDZOrder;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue