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