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:
Pietro Gagliardi 2015-04-10 17:53:59 -04:00
parent c205427bfb
commit e03d9ae2bd
5 changed files with 11 additions and 16 deletions

View File

@ -66,7 +66,6 @@ uiControl *uiNewButton(const char *text)
struct button *b;
uiWindowsNewControlParams p;
WCHAR *wtext;
HWND hwnd;
p.dwExStyle = 0;
p.lpClassName = L"button";
@ -74,6 +73,7 @@ uiControl *uiNewButton(const char *text)
p.lpWindowName = wtext;
p.dwStyle = BS_PUSHBUTTON | WS_TABSTOP;
p.hInstance = hInstance;
p.useStandardControlFont = TRUE;
p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY;
@ -82,9 +82,6 @@ uiControl *uiNewButton(const char *text)
c->preferredSize = preferredSize;
hwnd = (HWND) uiControlHandle(c);
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
b = uiNew(struct button);
b->onClicked = defaultOnClicked;
c->data = b;

View File

@ -61,7 +61,6 @@ uiControl *uiNewCheckbox(const char *text)
struct checkbox *cc;
uiWindowsNewControlParams p;
WCHAR *wtext;
HWND hwnd;
p.dwExStyle = 0;
p.lpClassName = L"button";
@ -69,6 +68,7 @@ uiControl *uiNewCheckbox(const char *text)
p.lpWindowName = wtext;
p.dwStyle = BS_CHECKBOX | WS_TABSTOP;
p.hInstance = hInstance;
p.useStandardControlFont = TRUE;
p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY;
@ -77,9 +77,6 @@ uiControl *uiNewCheckbox(const char *text)
c->preferredSize = preferredSize;
hwnd = (HWND) uiControlHandle(c);
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
cc = uiNew(struct checkbox);
cc->onToggled = defaultOnToggled;
c->data = cc;

View File

@ -36,14 +36,13 @@ uiControl *uiNewEntry(void)
uiControl *c;
struct entry *e;
uiWindowsNewControlParams p;
HWND hwnd;
p.dwExStyle = WS_EX_CLIENTEDGE;
p.lpClassName = L"edit";
p.lpWindowName = L"";
// TODO ES_NOHIDESEL?
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP;
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP;
p.hInstance = hInstance;
p.useStandardControlFont = TRUE;
p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY;
@ -51,9 +50,6 @@ uiControl *uiNewEntry(void)
c->preferredSize = preferredSize;
hwnd = (HWND) uiControlHandle(c);
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
e = uiNew(struct entry);
c->data = e;

View File

@ -105,16 +105,19 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
s->onWM_DESTROY = p->onWM_DESTROY;
c = uiNew(uiControl);
c->internal = s;
c->destroy = singleDestroy;
c->handle = singleHandle;
c->setParent = singleSetParent;
c->removeParent = singleRemoveParent;
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)
logLastError("error subclassing Windows control in uiWindowsNewControl()");
c->internal = s;
return c;
}

View File

@ -18,6 +18,9 @@ struct uiWindowsNewControlParams {
DWORD dwStyle; // WS_CHILD and WS_VISIBLE are automatically applied.
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.
// 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.
@ -42,7 +45,6 @@ struct uiSizingSys {
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
// and use this if you need the text of the window width
// TODO really export?
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);
// these functions get and set the window text for such a uiControl