Migrated checkbox.cpp and combobox.cpp.
This commit is contained in:
parent
abf9e202ef
commit
840e21456c
|
@ -8,11 +8,6 @@ struct uiCheckbox {
|
|||
void *onToggledData;
|
||||
};
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiCheckbox, // type name
|
||||
uiWindowsUnregisterWM_COMMANDHandler(me->hwnd); // on destroy
|
||||
)
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
uiCheckbox *c = uiCheckbox(cc);
|
||||
|
@ -32,17 +27,34 @@ static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void uiCheckboxDestroy(uiControl *cc)
|
||||
{
|
||||
uiCheckbox *c = uiCheckbox(cc);
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
|
||||
uiWindowsEnsureDestroyHWND(c->hwnd);
|
||||
uiFreeControl(uiControl(c));
|
||||
}
|
||||
|
||||
uiWindowsControlAllDefaultsExceptDestroy(uiCheckbox)
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define checkboxHeight 10
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
|
||||
#define checkboxXFromLeftOfBoxToLeftOfLabel 12
|
||||
|
||||
static void minimumSize(uiWindowsControl *cc, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiCheckboxinimumSize(uiWindowsControl *cc, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
uiCheckbox *c = uiCheckbox(cc);
|
||||
uiWindowsSizing sizing;
|
||||
int x, y;
|
||||
|
||||
*width = uiWindowsDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->BaseX) + uiWindowsWindowTextWidth(c->hwnd);
|
||||
*height = uiWindowsDlgUnitsToY(checkboxHeight, d->BaseY);
|
||||
x = checkboxXFromLeftOfBoxToLeftOfLabel;
|
||||
y = checkboxHeight;
|
||||
uiWindowsGetSizing(c->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||
*width = x + uiWindowsWindowTextWidth(c->hwnd);
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static void defaultOnToggled(uiCheckbox *c, void *data)
|
||||
|
@ -88,7 +100,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
uiCheckbox *c;
|
||||
WCHAR *wtext;
|
||||
|
||||
c = (uiCheckbox *) uiNewControl(uiCheckbox);
|
||||
uiWindowsNewControl(uiCheckbox, c);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
c->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
|
@ -101,7 +113,5 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c));
|
||||
uiCheckboxOnToggled(c, defaultOnToggled, NULL);
|
||||
|
||||
uiWindowsFinishNewControl(c, uiCheckbox);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -13,12 +13,7 @@ struct uiCombobox {
|
|||
void *onSelectedData;
|
||||
};
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiCombobox, // type name
|
||||
uiWindowsUnregisterWM_COMMANDHandler(me->hwnd); // on destroy
|
||||
)
|
||||
|
||||
// note: NOT triggered on entering text
|
||||
// TODO: NOT triggered on entering text
|
||||
static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
uiCombobox *c = uiCombobox(cc);
|
||||
|
@ -30,14 +25,33 @@ static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void uiComboboxDestroy(uiControl *cc)
|
||||
{
|
||||
uiCombobox *c = uiCombobox(cc);
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
|
||||
uiWindowsEnsureDestroyWindow(c->hwnd);
|
||||
uiFreeControl(uiControl(c));
|
||||
}
|
||||
|
||||
uiWindowsControlDefaultMinimumSizeChanged(uiCombobox)
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define comboboxWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
|
||||
#define comboboxWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary; TODO */
|
||||
#define comboboxHeight 14
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiComboboxMinimumSize(uiWindowsControl *cc, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
*width = uiWindowsDlgUnitsToX(comboboxWidth, d->BaseX);
|
||||
*height = uiWindowsDlgUnitsToY(comboboxHeight, d->BaseY);
|
||||
uiCombobox *c = uiCombobox(cc);
|
||||
uiWindowsSizing sizing;
|
||||
int x, y;
|
||||
|
||||
x = comboboxWidth;
|
||||
y = comboboxHeight;
|
||||
uiWindowsGetSizing(c->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||
*width = x;
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static void defaultOnSelected(uiCombobox *c, void *data)
|
||||
|
@ -85,7 +99,7 @@ static uiCombobox *finishNewCombobox(DWORD style)
|
|||
{
|
||||
uiCombobox *c;
|
||||
|
||||
c = (uiCombobox *) uiNewControl(uiCombobox);
|
||||
uiWindowsNewControl(uiCombobox, c);
|
||||
|
||||
c->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"combobox", L"",
|
||||
|
@ -96,8 +110,6 @@ static uiCombobox *finishNewCombobox(DWORD style)
|
|||
uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c));
|
||||
uiComboboxOnSelected(c, defaultOnSelected, NULL);
|
||||
|
||||
uiWindowsFinishNewControl(c, uiCombobox);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue