diff options
Diffstat (limited to 'alf/alfpanel.cpp')
| -rw-r--r-- | alf/alfpanel.cpp | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/alf/alfpanel.cpp b/alf/alfpanel.cpp index 9496e43..2f39ef1 100644 --- a/alf/alfpanel.cpp +++ b/alf/alfpanel.cpp @@ -4,6 +4,7 @@ TCHAR *_alf_panelClass = NULL; typedef struct { ALFLayout layout; + ALFColor bgcolor; HFONT font; } ALFPanelPriv; @@ -11,6 +12,7 @@ static void ALF_Panel_IntializePriv(ALFPanelPriv *priv) { ALF_Layout_Init(&priv->layout); + priv->bgcolor = ALF_COLOR_TRANSPARENT; } static void @@ -22,29 +24,11 @@ ALF_Panel_ClearPriv(ALFPanelPriv *priv) static void ALF_Panel_Paint(ALFPanelPriv *priv, HWND hwnd, HDC dc, RECT *r) { - (void)priv; - ALF_Compat_DrawThemeParentBackground(hwnd, dc, r); - - int textlen = GetWindowTextLength(hwnd); - if (textlen < 1) - return; - - TCHAR *textbuf = ALF_New(TCHAR, (SIZE_T)textlen + 1); - GetWindowText(hwnd, textbuf, textlen+1); - - HFONT oldFont = SelectFont(dc, priv->font); - - SetTextColor(dc, GetSysColor(COLOR_BTNTEXT)); - SetBkMode(dc, TRANSPARENT); - - RECT rc; - GetClientRect(hwnd, &rc); - - DrawText(dc, textbuf, -1, &rc, DT_SINGLELINE | DT_EXPANDTABS | DT_HIDEPREFIX | DT_CENTER | DT_VCENTER); - - ALF_Free(textbuf); - - SelectFont(dc, oldFont); + if (priv->bgcolor == ALF_COLOR_TRANSPARENT) { + ALF_Compat_DrawThemeParentBackground(hwnd, dc, r); + } else { + ALF_FillRect(dc, r, priv->bgcolor); + } } static LRESULT WINAPI @@ -78,6 +62,18 @@ ALF__PanelWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) // fallthrough to layout, will propagate font to children } + if (msg == ALF_WM_GETBGCOLOR) { + return (LRESULT)priv->bgcolor; + } + + if (msg == ALF_WM_SETBGCOLOR) { + priv->bgcolor = (ALFColor)wparam; + + InvalidateRect(window, NULL, TRUE); + + // fallthrough to layout, will propagate color to children + } + if (msg == WM_GETFONT) { return (LRESULT)priv->font; } @@ -160,7 +156,7 @@ ALF_AddPanel(HWND parent, WORD id, int x, int y) { HWND hwndPanel = ALF_CreatePanelWindow(parent, id); - ALF_AddWidget(parent, x, y, hwndPanel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT); + ALF_AddWidget(parent, x, y, hwndPanel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_INHERITBGCOLOR); return hwndPanel; } |
