diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-22 21:28:13 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-22 21:28:13 +0200 |
| commit | 863cc559af7382c8a9b71a5f76edfd94171a1950 (patch) | |
| tree | 2a25614a1c3b5a1610ec54be9af813a93f8a69db /alf/alflabel.cpp | |
| parent | a61c62ff6d9e95c9cc9a0f55de8e40b8e7339007 (diff) | |
label: add way to customize text color
Diffstat (limited to 'alf/alflabel.cpp')
| -rw-r--r-- | alf/alflabel.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp index dbb6367..cc408d7 100644 --- a/alf/alflabel.cpp +++ b/alf/alflabel.cpp @@ -6,6 +6,7 @@ typedef struct { DWORD style; HFONT font; ALFColor bgcolor; + ALFColor textcolor; } ALFLabelPriv; TCHAR *_alf_labelClass; @@ -101,7 +102,7 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (priv->font) oldFont = SelectFont(hdc, priv->font); - SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT)); + SetTextColor(hdc, ALF_ColorToGdi(priv->textcolor)); SetBkMode(hdc, TRANSPARENT); // calc drawtext style @@ -237,6 +238,17 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; } else if (uMsg == ALF_WM_GETBGCOLOR) { return (LRESULT)priv->bgcolor; + } else if (uMsg == ALF_WM_SETTEXTCOLOR) { + ALFColor newcolor = (ALFColor)lParam; + if (priv->textcolor == newcolor) + return TRUE; + + priv->textcolor = newcolor; + InvalidateRect(hwnd, NULL, TRUE); + + return TRUE; + } else if (uMsg == ALF_WM_GETTEXTCOLOR) { + return (LRESULT)priv->textcolor; } else if (uMsg == WM_DESTROY) { ALF_Free(priv); SetWindowLongPtr(hwnd, 0, 0); @@ -260,6 +272,7 @@ 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); + priv->textcolor = ALF_COLOR_SYS(COLOR_BTNTEXT); SetWindowLongPtr(hwndLabel, 0, (LONG_PTR)priv); ALF_AddWidget(win, x, y, hwndLabel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_INHERITBGCOLOR | ALF_LAYOUT_SENDBGCHANGE); |
