From d56bd75ee5bc28daddb429b1fb850854970bc5f5 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Thu, 16 Apr 2020 11:24:43 +0200 Subject: font handling change: allow controls to inherit fonts also do it automatically when adding widget to layout, no more calling applyfonts manually --- alf/alf.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'alf/alf.cpp') diff --git a/alf/alf.cpp b/alf/alf.cpp index b4d9052..ad4295d 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -42,16 +42,6 @@ ALF_UpdateFonts(HWND win) SendMessage(win, ALF_WM_UPDATEFONTS, 0, 0); } -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) { @@ -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) { -- cgit v1.2.3