summaryrefslogtreecommitdiff
path: root/alf/alf.cpp
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-16 11:24:43 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-16 11:24:43 +0200
commitd56bd75ee5bc28daddb429b1fb850854970bc5f5 (patch)
treecb1061c483d50b3627d375062ad5195aefa9ed19 /alf/alf.cpp
parent090203fff7a05929816b49b19ea24959e2f518e5 (diff)
font handling change: allow controls to inherit fonts
also do it automatically when adding widget to layout, no more calling applyfonts manually
Diffstat (limited to 'alf/alf.cpp')
-rw-r--r--alf/alf.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index b4d9052..ad4295d 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -43,16 +43,6 @@ ALF_UpdateFonts(HWND win)
}
void
-ALF_ApplyFontsPriv(HWND win, ALFWindowPriv *priv)
-{
- ALF_Layout_ApplyFonts(&priv->layout, win, &priv->fonts);
-
- if (priv->vtbl->applyfonts) {
- priv->vtbl->applyfonts(priv->closure, win, &priv->fonts);
- }
-}
-
-void
ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv)
{
priv->fonts.dpi = ALF_Compat_GetDpiForWindow(win);
@@ -81,13 +71,7 @@ ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv)
}
priv->fonts.hMessageFont = CreateFontIndirect(&priv->fonts.lfMessageFont);
- ALF_ApplyFontsPriv(win, priv);
-}
-
-void
-ALF_ApplyFonts(HWND win)
-{
- SendMessage(win, ALF_WM_APPLYFONTS, 0, 0);
+ SendMessage(win, WM_SETFONT, (WPARAM)priv->fonts.hMessageFont, (LPARAM)1);
}
void
@@ -164,9 +148,16 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
}
- if (msg == ALF_WM_APPLYFONTS) {
- ALF_ApplyFontsPriv(hwnd, priv);
- return 0;
+ if (msg == WM_SETFONT) {
+ priv->font = (HFONT)wparam;
+ if (LOWORD(lparam) != 0)
+ InvalidateRect(hwnd, NULL, TRUE);
+
+ // fallthrough to layout, will propagate font to children
+ }
+
+ if (msg == WM_GETFONT) {
+ return (LRESULT)priv->font;
}
if (msg == ALF_WM_PRETRANSLATEMSG) {