Changed the Windows new control system to automatically assign the standard control font if a flag is set in the creation parameters structure.
This commit is contained in:
parent
f650237614
commit
a788c1b212
|
@ -66,7 +66,6 @@ uiControl *uiNewButton(const char *text)
|
||||||
struct button *b;
|
struct button *b;
|
||||||
uiWindowsNewControlParams p;
|
uiWindowsNewControlParams p;
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
p.dwExStyle = 0;
|
p.dwExStyle = 0;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -74,6 +73,7 @@ uiControl *uiNewButton(const char *text)
|
||||||
p.lpWindowName = wtext;
|
p.lpWindowName = wtext;
|
||||||
p.dwStyle = BS_PUSHBUTTON | WS_TABSTOP;
|
p.dwStyle = BS_PUSHBUTTON | WS_TABSTOP;
|
||||||
p.hInstance = hInstance;
|
p.hInstance = hInstance;
|
||||||
|
p.useStandardControlFont = TRUE;
|
||||||
p.onWM_COMMAND = onWM_COMMAND;
|
p.onWM_COMMAND = onWM_COMMAND;
|
||||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||||
p.onWM_DESTROY = onWM_DESTROY;
|
p.onWM_DESTROY = onWM_DESTROY;
|
||||||
|
@ -82,9 +82,6 @@ uiControl *uiNewButton(const char *text)
|
||||||
|
|
||||||
c->preferredSize = preferredSize;
|
c->preferredSize = preferredSize;
|
||||||
|
|
||||||
hwnd = (HWND) uiControlHandle(c);
|
|
||||||
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
|
||||||
|
|
||||||
b = uiNew(struct button);
|
b = uiNew(struct button);
|
||||||
b->onClicked = defaultOnClicked;
|
b->onClicked = defaultOnClicked;
|
||||||
c->data = b;
|
c->data = b;
|
||||||
|
|
|
@ -61,7 +61,6 @@ uiControl *uiNewCheckbox(const char *text)
|
||||||
struct checkbox *cc;
|
struct checkbox *cc;
|
||||||
uiWindowsNewControlParams p;
|
uiWindowsNewControlParams p;
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
p.dwExStyle = 0;
|
p.dwExStyle = 0;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -69,6 +68,7 @@ uiControl *uiNewCheckbox(const char *text)
|
||||||
p.lpWindowName = wtext;
|
p.lpWindowName = wtext;
|
||||||
p.dwStyle = BS_CHECKBOX | WS_TABSTOP;
|
p.dwStyle = BS_CHECKBOX | WS_TABSTOP;
|
||||||
p.hInstance = hInstance;
|
p.hInstance = hInstance;
|
||||||
|
p.useStandardControlFont = TRUE;
|
||||||
p.onWM_COMMAND = onWM_COMMAND;
|
p.onWM_COMMAND = onWM_COMMAND;
|
||||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||||
p.onWM_DESTROY = onWM_DESTROY;
|
p.onWM_DESTROY = onWM_DESTROY;
|
||||||
|
@ -77,9 +77,6 @@ uiControl *uiNewCheckbox(const char *text)
|
||||||
|
|
||||||
c->preferredSize = preferredSize;
|
c->preferredSize = preferredSize;
|
||||||
|
|
||||||
hwnd = (HWND) uiControlHandle(c);
|
|
||||||
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
|
||||||
|
|
||||||
cc = uiNew(struct checkbox);
|
cc = uiNew(struct checkbox);
|
||||||
cc->onToggled = defaultOnToggled;
|
cc->onToggled = defaultOnToggled;
|
||||||
c->data = cc;
|
c->data = cc;
|
||||||
|
|
|
@ -36,14 +36,13 @@ uiControl *uiNewEntry(void)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
uiWindowsNewControlParams p;
|
uiWindowsNewControlParams p;
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||||
p.lpClassName = L"edit";
|
p.lpClassName = L"edit";
|
||||||
p.lpWindowName = L"";
|
p.lpWindowName = L"";
|
||||||
// TODO ES_NOHIDESEL?
|
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP;
|
||||||
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP;
|
|
||||||
p.hInstance = hInstance;
|
p.hInstance = hInstance;
|
||||||
|
p.useStandardControlFont = TRUE;
|
||||||
p.onWM_COMMAND = onWM_COMMAND;
|
p.onWM_COMMAND = onWM_COMMAND;
|
||||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||||
p.onWM_DESTROY = onWM_DESTROY;
|
p.onWM_DESTROY = onWM_DESTROY;
|
||||||
|
@ -51,9 +50,6 @@ uiControl *uiNewEntry(void)
|
||||||
|
|
||||||
c->preferredSize = preferredSize;
|
c->preferredSize = preferredSize;
|
||||||
|
|
||||||
hwnd = (HWND) uiControlHandle(c);
|
|
||||||
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
|
||||||
|
|
||||||
e = uiNew(struct entry);
|
e = uiNew(struct entry);
|
||||||
c->data = e;
|
c->data = e;
|
||||||
|
|
||||||
|
|
|
@ -105,16 +105,19 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
|
||||||
s->onWM_DESTROY = p->onWM_DESTROY;
|
s->onWM_DESTROY = p->onWM_DESTROY;
|
||||||
|
|
||||||
c = uiNew(uiControl);
|
c = uiNew(uiControl);
|
||||||
c->internal = s;
|
|
||||||
c->destroy = singleDestroy;
|
c->destroy = singleDestroy;
|
||||||
c->handle = singleHandle;
|
c->handle = singleHandle;
|
||||||
c->setParent = singleSetParent;
|
c->setParent = singleSetParent;
|
||||||
c->removeParent = singleRemoveParent;
|
c->removeParent = singleRemoveParent;
|
||||||
c->resize = singleResize;
|
c->resize = singleResize;
|
||||||
|
|
||||||
|
if (p->useStandardControlFont)
|
||||||
|
SendMessageW(s->hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
||||||
|
|
||||||
if ((*fv_SetWindowSubclass)(s->hwnd, singleSubclassProc, 0, (DWORD_PTR) c) == FALSE)
|
if ((*fv_SetWindowSubclass)(s->hwnd, singleSubclassProc, 0, (DWORD_PTR) c) == FALSE)
|
||||||
logLastError("error subclassing Windows control in uiWindowsNewControl()");
|
logLastError("error subclassing Windows control in uiWindowsNewControl()");
|
||||||
|
|
||||||
|
c->internal = s;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ struct uiWindowsNewControlParams {
|
||||||
DWORD dwStyle; // WS_CHILD and WS_VISIBLE are automatically applied.
|
DWORD dwStyle; // WS_CHILD and WS_VISIBLE are automatically applied.
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
|
|
||||||
|
// Set this to non-FALSE to use the standard control font used by other ui controls.
|
||||||
|
BOOL useStandardControlFont;
|
||||||
|
|
||||||
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent.
|
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent.
|
||||||
// ui redirects the message back and calls these functions.
|
// ui redirects the message back and calls these functions.
|
||||||
// Store the result in *lResult and return any non-FALSE value (such as TRUE) to return the given result; return FALSE to pass the notification up to your window procedure.
|
// Store the result in *lResult and return any non-FALSE value (such as TRUE) to return the given result; return FALSE to pass the notification up to your window procedure.
|
||||||
|
@ -42,7 +45,6 @@ struct uiSizingSys {
|
||||||
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
|
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
|
||||||
|
|
||||||
// and use this if you need the text of the window width
|
// and use this if you need the text of the window width
|
||||||
// TODO really export?
|
|
||||||
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);
|
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);
|
||||||
|
|
||||||
// these functions get and set the window text for such a uiControl
|
// these functions get and set the window text for such a uiControl
|
||||||
|
|
Loading…
Reference in New Issue