summaryrefslogtreecommitdiff
path: root/alf/alflabel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alflabel.cpp')
-rw-r--r--alf/alflabel.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp
index 8a878a0..dbb6367 100644
--- a/alf/alflabel.cpp
+++ b/alf/alflabel.cpp
@@ -3,8 +3,9 @@
/* LABEL */
typedef struct {
- DWORD style;
- HFONT font;
+ DWORD style;
+ HFONT font;
+ ALFColor bgcolor;
} ALFLabelPriv;
TCHAR *_alf_labelClass;
@@ -90,7 +91,11 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
- ALF_Compat_DrawThemeParentBackground(hwnd, hdc, &ps.rcPaint);
+ if (priv->bgcolor == ALF_COLOR_TRANSPARENT) {
+ ALF_Compat_DrawThemeParentBackground(hwnd, hdc, &ps.rcPaint);
+ } else {
+ ALF_FillRect(hdc, &ps.rcPaint, priv->bgcolor);
+ }
HFONT oldFont = NULL;
if (priv->font)
@@ -216,6 +221,22 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InvalidateRect(hwnd, NULL, TRUE);
}
}
+ } else if (uMsg == ALF_WM_BACKGROUNDCHANGE) {
+ if (priv->bgcolor == ALF_COLOR_TRANSPARENT) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ }
+ return TRUE;
+ } else if (uMsg == ALF_WM_SETBGCOLOR) {
+ ALFColor newcolor = (ALFColor)lParam;
+ if (priv->bgcolor == newcolor)
+ return TRUE;
+
+ priv->bgcolor = newcolor;
+ InvalidateRect(hwnd, NULL, TRUE);
+
+ return TRUE;
+ } else if (uMsg == ALF_WM_GETBGCOLOR) {
+ return (LRESULT)priv->bgcolor;
} else if (uMsg == WM_DESTROY) {
ALF_Free(priv);
SetWindowLongPtr(hwnd, 0, 0);
@@ -238,9 +259,10 @@ ALF_AddLabel(HWND win, WORD id, int x, int y, const TCHAR *text)
ALFLabelPriv *priv = ALF_New(ALFLabelPriv, 1);
priv->style = ALF_LABEL_ALIGN_LEFT | ALF_LABEL_ALIGN_TOP_LIKE_EDIT;
+ priv->bgcolor = ALF_COLOR_SYS(COLOR_BTNFACE);
SetWindowLongPtr(hwndLabel, 0, (LONG_PTR)priv);
- ALF_AddWidget(win, x, y, hwndLabel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG);
+ ALF_AddWidget(win, x, y, hwndLabel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_INHERITBGCOLOR | ALF_LAYOUT_SENDBGCHANGE);
return hwndLabel;
}