summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--new/button_windows.c5
-rw-r--r--new/checkbox_windows.c5
-rw-r--r--new/entry_windows.c8
-rw-r--r--new/newcontrol_windows.c5
-rw-r--r--new/ui_windows.h4
5 files changed, 11 insertions, 16 deletions
diff --git a/new/button_windows.c b/new/button_windows.c
index 149c52b..0bd3021 100644
--- a/new/button_windows.c
+++ b/new/button_windows.c
@@ -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;
diff --git a/new/checkbox_windows.c b/new/checkbox_windows.c
index 4f903ef..28433d2 100644
--- a/new/checkbox_windows.c
+++ b/new/checkbox_windows.c
@@ -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;
diff --git a/new/entry_windows.c b/new/entry_windows.c
index 41614c5..2297c28 100644
--- a/new/entry_windows.c
+++ b/new/entry_windows.c
@@ -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;
diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c
index 0122db7..5ca9ad1 100644
--- a/new/newcontrol_windows.c
+++ b/new/newcontrol_windows.c
@@ -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;
}
diff --git a/new/ui_windows.h b/new/ui_windows.h
index cfea287..0fba593 100644
--- a/new/ui_windows.h
+++ b/new/ui_windows.h
@@ -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