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