diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-23 15:43:55 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-23 15:46:02 +0200 |
| commit | 6280671b1897ac0a47cb7e8f3463d4f60f2490cc (patch) | |
| tree | 5db441a60096e85444b7f3ef3357f17a9aefb3fd /alf/alfwindow.cpp | |
| parent | 51daba89072cb66fe5e43015484a554555a40499 (diff) | |
move background color and font handling into layout
It's the same for window and all panel-like widgets, so it makes
sense to share it. Might need to refactor it out if we ever need
a layout without background and fonts
Diffstat (limited to 'alf/alfwindow.cpp')
| -rw-r--r-- | alf/alfwindow.cpp | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/alf/alfwindow.cpp b/alf/alfwindow.cpp index d372ebc..188f791 100644 --- a/alf/alfwindow.cpp +++ b/alf/alfwindow.cpp @@ -7,9 +7,7 @@ typedef struct { ALFLayout layout; WORD defid; HWND hwndFocus; - HFONT font; HFONT hMessageFont; - ALFColor bgcolor; } ALFWindowPriv; static void @@ -18,8 +16,8 @@ ALF_InitializeWindowPriv(HWND hwnd, ALFWindowPriv *priv, void *closure) priv->vtbl = (ALFWindowVTable*)GetClassLongPtr(hwnd, 0); priv->closure = closure; priv->defid = (WORD)-1; - priv->bgcolor = ALF_COLOR_SYS(COLOR_BTNFACE); ALF_Layout_Init(&priv->layout); + priv->layout.bgcolor = ALF_COLOR_SYS(COLOR_BTNFACE); } static void @@ -151,7 +149,7 @@ ALF_Window_Paint(ALFWindowPriv *priv, HWND hwnd, HDC dc, RECT *r) if (priv->vtbl && priv->vtbl->paint) { priv->vtbl->paint(priv->closure, hwnd, dc, r); } else { - ALF_FillRect(dc, r, priv->bgcolor); + ALF_FillRect(dc, r, priv->layout.bgcolor); } } @@ -183,27 +181,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 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 == ALF_WM_SETBGCOLOR) { - priv->bgcolor = (ALFColor)lparam; - - InvalidateRect(hwnd, NULL, TRUE); - - // fallthrough to layout, will propagate color to children - // and invalidate the background of transparent children - } - - if (msg == ALF_WM_GETBGCOLOR) { - return (LRESULT)priv->bgcolor; - } - if (msg == WM_ERASEBKGND) { return TRUE; // handled in WM_PAINT } @@ -227,10 +204,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) return 0; } - if (msg == WM_GETFONT) { - return (LRESULT)priv->font; - } - if (msg == ALF_WM_PRETRANSLATEMSG) { return (LRESULT)ALF_PreTranslateMessagePriv(hwnd, priv, (MSG *)lparam); } @@ -377,15 +350,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) InvalidateRect(hwnd, NULL, TRUE); } - if (msg == ALF_WM_BACKGROUNDCHANGE) { - if (priv->bgcolor != ALF_COLOR_TRANSPARENT) - return 0; // nothing to do here, background is our own solid color - - InvalidateRect(hwnd, NULL, TRUE); - - // fallthrough to layout, will propagate to transparent children - } - if (msg == DM_GETDEFID) { if (priv->defid == (WORD)-1) { return 0; |
