More conversions. Almost done!
This commit is contained in:
parent
840e21456c
commit
1956270ed1
|
@ -2,10 +2,6 @@
|
|||
#include "uipriv_windows.hpp"
|
||||
#include "area.hpp"
|
||||
|
||||
uiWindowsDefineControl(
|
||||
uiArea // type name
|
||||
)
|
||||
|
||||
static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
uiArea *a;
|
||||
|
@ -54,7 +50,9 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
|
||||
// control implementation
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
uiWindowsControlAllDefaults(uiArea)
|
||||
|
||||
static void uiAreaMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
// TODO
|
||||
*width = 0;
|
||||
|
@ -105,7 +103,7 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
|||
{
|
||||
uiArea *a;
|
||||
|
||||
a = (uiArea *) uiNewControl(uiArea);
|
||||
uiWindowsNewControl(uiArea, a);
|
||||
|
||||
a->ah = ah;
|
||||
a->scrolling = FALSE;
|
||||
|
@ -118,8 +116,6 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
|||
hInstance, a,
|
||||
FALSE);
|
||||
|
||||
uiWindowsFinishNewControl(a, uiArea);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -127,7 +123,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height)
|
|||
{
|
||||
uiArea *a;
|
||||
|
||||
a = (uiArea *) uiNewControl(uiArea);
|
||||
uiWindowsNewControl(uiArea, a);
|
||||
|
||||
a->ah = ah;
|
||||
a->scrolling = TRUE;
|
||||
|
@ -145,7 +141,5 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height)
|
|||
// set initial scrolling parameters
|
||||
areaUpdateScroll(a);
|
||||
|
||||
uiWindowsFinishNewControl(a, uiArea);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void uiComboboxDestroy(uiControl *cc)
|
|||
uiFreeControl(uiControl(c));
|
||||
}
|
||||
|
||||
uiWindowsControlDefaultMinimumSizeChanged(uiCombobox)
|
||||
uiWindowsControlAllDefaultsExceptDestroy(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; TODO */
|
||||
|
|
|
@ -6,11 +6,6 @@ struct uiDateTimePicker {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiDateTimePicker, // type name
|
||||
uiWindowsUnregisterReceiveWM_WININICHANGE(me->hwnd); // on destroy
|
||||
)
|
||||
|
||||
// utility functions
|
||||
|
||||
#define GLI(what, buf, n) GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, what, buf, n)
|
||||
|
@ -103,27 +98,44 @@ static void setDateTimeFormat(HWND hwnd)
|
|||
|
||||
// control implementation
|
||||
|
||||
static void uiDateTimePickerDestroy(uiControl *c)
|
||||
{
|
||||
uiDateTimePicker *d = uiDateTimePicker(c);
|
||||
|
||||
uiWindowsUnregisterReceiveWM_WININICHANGE(d->hwnd);
|
||||
uiWindowsEnsureDestroyWindow(d->hwnd);
|
||||
uiFreeControl(d);
|
||||
}
|
||||
|
||||
uiWindowsControlAllDefaultsExceptDestroy(uiDateTimePicker)
|
||||
|
||||
// the height returned from DTM_GETIDEALSIZE is unreliable; see http://stackoverflow.com/questions/30626549/what-is-the-proper-use-of-dtm-getidealsize-treating-the-returned-size-as-pixels
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define entryHeight 14
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *dd, intmax_t *width, intmax_t *height)
|
||||
static void uiDateTimePickerMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
uiDateTimePicker *d = uiDateTimePicker(c);
|
||||
SIZE s;
|
||||
uiWindowsSizing sizing;
|
||||
int y;
|
||||
|
||||
s.cx = 0;
|
||||
s.cy = 0;
|
||||
SendMessageW(d->hwnd, DTM_GETIDEALSIZE, 0, (LPARAM) (&s));
|
||||
*width = s.cx;
|
||||
*height = uiWindowsDlgUnitsToY(entryHeight, dd->BaseY);
|
||||
|
||||
y = entryHeight;
|
||||
uiWindowsGetSizing(d->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y);
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static uiDateTimePicker *finishNewDateTimePicker(DWORD style)
|
||||
{
|
||||
uiDateTimePicker *d;
|
||||
|
||||
d = (uiDateTimePicker *) uiNewControl(uiDateTimePicker);
|
||||
uiWindowsNewControl(uiDateTimePicker, d);
|
||||
|
||||
d->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
DATETIMEPICK_CLASSW, L"",
|
||||
|
@ -136,8 +148,6 @@ static uiDateTimePicker *finishNewDateTimePicker(DWORD style)
|
|||
// for our date/time mode, we do it in a subclass assigned in uiNewDateTimePicker()
|
||||
uiWindowsRegisterReceiveWM_WININICHANGE(d->hwnd);
|
||||
|
||||
uiWindowsFinishNewControl(d, uiDateTimePicker);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,6 @@ struct uiEntry {
|
|||
BOOL inhibitChanged;
|
||||
};
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiEntry, // type name
|
||||
uiWindowsUnregisterWM_COMMANDHandler(me->hwnd); // on destroy
|
||||
)
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
uiEntry *e = uiEntry(c);
|
||||
|
@ -27,14 +22,33 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void uiEntryDestroy(uiControl *c)
|
||||
{
|
||||
uiEntry *e = uiEntry(c);
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(e->hwnd);
|
||||
uiWindowsEnsureDestroyWindow(e->hwnd);
|
||||
uiFreeControl(uiControl(e));
|
||||
}
|
||||
|
||||
uiWindowsControlAllDefaultsExceptDestroy(uiEntry)
|
||||
|
||||
// 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 entryHeight 14
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiEntryMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
*width = uiWindowsDlgUnitsToX(entryWidth, d->BaseX);
|
||||
*height = uiWindowsDlgUnitsToY(entryHeight, d->BaseY);
|
||||
uiEntry *e = uiEntry(c);
|
||||
uiWindowsSizing sizing;
|
||||
int x, y;
|
||||
|
||||
x = entryWidth;
|
||||
y = entryHeight;
|
||||
uiWindowsGetSizing(e->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||
*width = x;
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static void defaultOnChanged(uiEntry *e, void *data)
|
||||
|
@ -82,7 +96,7 @@ uiEntry *uiNewEntry(void)
|
|||
{
|
||||
uiEntry *e;
|
||||
|
||||
e = (uiEntry *) uiNewControl(uiEntry);
|
||||
uiWindowsNewControl(uiEntry, e);
|
||||
|
||||
e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
|
@ -93,7 +107,5 @@ uiEntry *uiNewEntry(void)
|
|||
uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e));
|
||||
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
||||
|
||||
uiWindowsFinishNewControl(e, uiEntry);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -10,17 +10,14 @@ struct uiFontButton {
|
|||
void *onChangedData;
|
||||
};
|
||||
|
||||
static void onDestroy(uiFontButton *);
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiFontButton, // type name
|
||||
onDestroy(me); // on destroy
|
||||
)
|
||||
|
||||
static void onDestroy(uiFontButton *b)
|
||||
static void uiFontButtonDestroy(uiControl *c)
|
||||
{
|
||||
uiFontButton *b = uiFontButton(c);
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
|
||||
destroyFontDialogParams(&(b->params));
|
||||
uiWindowsEnsureDestroyWindow(b->hwnd);
|
||||
uiFreeControl(uiControl(b));
|
||||
}
|
||||
|
||||
static void updateFontButtonLabel(uiFontButton *b)
|
||||
|
@ -54,13 +51,17 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
uiWindowsControlAllDefaultsExceptDestroy(uiFontButton)
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define buttonHeight 14
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiFontButtonMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
uiFontButton *b = uiFontButton(c);
|
||||
SIZE size;
|
||||
uiWindowsSizing sizing;
|
||||
int y;
|
||||
|
||||
// try the comctl32 version 6 way
|
||||
size.cx = 0; // explicitly ask for ideal size
|
||||
|
@ -75,7 +76,10 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width
|
|||
// Microsoft says to use a fixed width for all buttons; this isn't good enough
|
||||
// use the text width instead, with some edge padding
|
||||
*width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
|
||||
*height = uiWindowsDlgUnitsToY(buttonHeight, d->BaseY);
|
||||
y = buttonHeight;
|
||||
uiWindowsGetSizing(b->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y);
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static void defaultOnChanged(uiFontButton *b, void *data)
|
||||
|
@ -102,7 +106,7 @@ uiFontButton *uiNewFontButton(void)
|
|||
{
|
||||
uiFontButton *b;
|
||||
|
||||
b = (uiFontButton *) uiNewControl(uiFontButton);
|
||||
uiWindowsNewControl(uiFontButton, b);
|
||||
|
||||
b->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
L"button", L"you should not be seeing this",
|
||||
|
@ -115,9 +119,6 @@ uiFontButton *uiNewFontButton(void)
|
|||
uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b));
|
||||
uiFontButtonOnChanged(b, defaultOnChanged, NULL);
|
||||
|
||||
uiWindowsFinishNewControl(b, uiFontButton);
|
||||
|
||||
// TODO move this back above the previous when merging with uiNewControl(); it's here because this calls Handle()
|
||||
updateFontButtonLabel(b);
|
||||
|
||||
return b;
|
||||
|
|
|
@ -6,19 +6,22 @@ struct uiLabel {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
uiWindowsDefineControl(
|
||||
uiLabel // type name
|
||||
)
|
||||
uiWindowsControlAllDefaults(uiLabel)
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define labelHeight 8
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiLabelMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
uiLabel *l = uiLabel(c);
|
||||
uiWindowsSizing sizing;
|
||||
int y;
|
||||
|
||||
*width = uiWindowsWindowTextWidth(l->hwnd);
|
||||
*height = uiWindowsDlgUnitsToY(labelHeight, d->BaseY);
|
||||
y = labelHeight;
|
||||
uiWindowsGetSizing(l->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToY(&sizing, NULL, &y);
|
||||
*height = y;
|
||||
}
|
||||
|
||||
char *uiLabelText(uiLabel *l)
|
||||
|
@ -38,7 +41,7 @@ uiLabel *uiNewLabel(const char *text)
|
|||
uiLabel *l;
|
||||
WCHAR *wtext;
|
||||
|
||||
l = (uiLabel *) uiNewControl(uiLabel);
|
||||
uiWindowsNewControl(uiLabel, l);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
l->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
|
@ -50,7 +53,5 @@ uiLabel *uiNewLabel(const char *text)
|
|||
TRUE);
|
||||
uiFree(wtext);
|
||||
|
||||
uiWindowsFinishNewControl(l, uiLabel);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,6 @@ struct uiMultilineEntry {
|
|||
BOOL inhibitChanged;
|
||||
};
|
||||
|
||||
uiWindowsDefineControlWithOnDestroy(
|
||||
uiMultilineEntry, // type name
|
||||
uiWindowsUnregisterWM_COMMANDHandler(me->hwnd); // on destroy
|
||||
)
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||
|
@ -30,6 +25,17 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void uiMultilineEntryDestroy(uiControl *c)
|
||||
{
|
||||
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(e->hwnd);
|
||||
uiWindowsEnsureDestroyWindow(e->hwnd);
|
||||
uiFreeControl(uiControl(e));
|
||||
}
|
||||
|
||||
uiWindowsControlAllDefaultsExceptDestroy(uiEntry)
|
||||
|
||||
// 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 */
|
||||
// TODO change this for multiline text boxes
|
||||
|
@ -37,8 +43,16 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
*width = uiWindowsDlgUnitsToX(entryWidth, d->BaseX);
|
||||
*height = uiWindowsDlgUnitsToY(entryHeight, d->BaseY);
|
||||
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||
uiWindowsSizing sizing;
|
||||
int x, y;
|
||||
|
||||
x = entryWidth;
|
||||
y = entryHeight;
|
||||
uiWindowsGetSizing(e->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||
*width = x;
|
||||
*height = y;
|
||||
}
|
||||
|
||||
static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
||||
|
@ -46,11 +60,13 @@ static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
// TODO apply crlf conversion
|
||||
char *uiMultilineEntryText(uiMultilineEntry *e)
|
||||
{
|
||||
return uiWindowsWindowText(e->hwnd);
|
||||
}
|
||||
|
||||
// TODO apply crlf conversion
|
||||
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||
{
|
||||
// doing this raises an EN_CHANGED
|
||||
|
@ -60,6 +76,7 @@ void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
|||
// don't queue the control for resize; entry sizes are independent of their contents
|
||||
}
|
||||
|
||||
// TOOD crlf stuff
|
||||
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
||||
{
|
||||
LRESULT n;
|
||||
|
@ -101,7 +118,7 @@ uiMultilineEntry *uiNewMultilineEntry(void)
|
|||
{
|
||||
uiMultilineEntry *e;
|
||||
|
||||
e = (uiMultilineEntry *) uiNewControl(uiMultilineEntry);
|
||||
uiWindowsNewControl(uiMultilineEntry, e);
|
||||
|
||||
e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
|
@ -112,7 +129,5 @@ uiMultilineEntry *uiNewMultilineEntry(void)
|
|||
uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e));
|
||||
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
||||
|
||||
uiWindowsFinishNewControl(e, uiMultilineEntry);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -6,18 +6,24 @@ struct uiProgressBar {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
uiWindowsDefineControl(
|
||||
uiProgressBar // type name
|
||||
)
|
||||
uiWindowsControlAllDefaults(uiProgressBar)
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define pbarWidth 237
|
||||
#define pbarHeight 8
|
||||
|
||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||
static void uiProgressBarMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
*width = uiWindowsDlgUnitsToX(pbarWidth, d->BaseX);
|
||||
*height = uiWindowsDlgUnitsToY(pbarHeight, d->BaseY);
|
||||
uiProgressBar *p = uiProgressBar(c);
|
||||
uiWindowsSizing sizing;
|
||||
int x, y;
|
||||
|
||||
x = pbarWidth;
|
||||
y = pbarHeight;
|
||||
uiWindowsGetSizing(p->hwnd, &sizing);
|
||||
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
|
||||
*width = x;
|
||||
*height = y;
|
||||
}
|
||||
|
||||
// unfortunately, as of Vista progress bars have a forced animation on increase
|
||||
|
@ -43,7 +49,7 @@ uiProgressBar *uiNewProgressBar(void)
|
|||
{
|
||||
uiProgressBar *p;
|
||||
|
||||
p = (uiProgressBar *) uiNewControl(uiProgressBar);
|
||||
uiWindowsNewControl(uiProgressBar, p);
|
||||
|
||||
p->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
PROGRESS_CLASSW, L"",
|
||||
|
@ -51,7 +57,5 @@ uiProgressBar *uiNewProgressBar(void)
|
|||
hInstance, NULL,
|
||||
FALSE);
|
||||
|
||||
uiWindowsFinishNewControl(p, uiProgressBar);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue