diff options
Diffstat (limited to 'alf/alfwindow.cpp')
| -rw-r--r-- | alf/alfwindow.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/alf/alfwindow.cpp b/alf/alfwindow.cpp index 0b395b6..c3f8573 100644 --- a/alf/alfwindow.cpp +++ b/alf/alfwindow.cpp @@ -9,6 +9,7 @@ typedef struct { WORD defid; HWND hwndFocus; HFONT font; + ALFColor bgcolor; } ALFWindowPriv; static void @@ -17,6 +18,7 @@ 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); } @@ -148,6 +150,13 @@ ALF_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) } } +static void +ALF_Window_Paint(ALFWindowPriv *priv, HWND hwnd, HDC dc, RECT *r) +{ + (void)hwnd; + ALF_FillRect(dc, r, priv->bgcolor); +} + LRESULT ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { @@ -184,6 +193,41 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) // fallthrough to layout, will propagate font to children } + if (msg == ALF_WM_SETBGCOLOR) { + priv->bgcolor = (ALFColor)wparam; + + InvalidateRect(hwnd, NULL, TRUE); + + // fallthrough to layout, will propagate color to children + } + + if (msg == ALF_WM_GETBGCOLOR) { + return (LRESULT)priv->bgcolor; + } + + if (msg == WM_ERASEBKGND) { + return TRUE; // handled in WM_PAINT + } + + if (msg == WM_PRINTCLIENT) { + RECT r = { 0, 0, 0, 0 }; + GetClientRect(hwnd, &r); + + ALF_Window_Paint(priv, hwnd, (HDC)wparam, &r); + return TRUE; + } + + if (msg == WM_PAINT) { + PAINTSTRUCT ps; + HDC dc = BeginPaint(hwnd, &ps); + + ALF_Window_Paint(priv, hwnd, dc, &ps.rcPaint); + + EndPaint(hwnd, &ps); + + return 0; + } + if (msg == WM_GETFONT) { return (LRESULT)priv->font; } @@ -390,7 +434,7 @@ ALF_RegisterWindowClass(HINSTANCE hInstance, const ALFWindowClassParams *params) cls.style = params->classStyle; cls.hInstance = hInstance; cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + cls.hbrBackground = NULL; cls.lpszClassName = classNamePtr; cls.cbWndExtra = sizeof(void*); cls.cbClsExtra = sizeof(void*); |
