summaryrefslogtreecommitdiff
path: root/alf/alfpanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alfpanel.cpp')
-rw-r--r--alf/alfpanel.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/alf/alfpanel.cpp b/alf/alfpanel.cpp
index b8ef8b3..ce640a2 100644
--- a/alf/alfpanel.cpp
+++ b/alf/alfpanel.cpp
@@ -4,6 +4,7 @@ TCHAR *_alf_panelClass = NULL;
typedef struct {
ALFLayout layout;
+ HFONT font;
} ALFPanelPriv;
static void
@@ -23,6 +24,27 @@ 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, 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);
}
static LRESULT WINAPI
@@ -48,6 +70,22 @@ ALF__PanelWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam)
return TRUE;
}
+ if (msg == WM_SETFONT) {
+ priv->font = (HFONT)wparam;
+ if (LOWORD(lparam) != 0)
+ InvalidateRect(window, NULL, TRUE);
+
+ return 0;
+ }
+
+ if (msg == WM_GETFONT) {
+ return (LRESULT)priv->font;
+ }
+
+ if (msg == WM_SETTEXT) {
+ InvalidateRect(window, NULL, TRUE);
+ }
+
if (msg == WM_PRINTCLIENT) {
RECT r = { 0, 0, 0, 0 };
GetClientRect(window, &r);
@@ -129,7 +167,7 @@ ALF_AddPanel(HWND parent, WORD id, UINT x, UINT y)
p.y = y;
p.width = 0;
p.height = 0;
- p.flags = ALF_QUERYSIZE | ALF_SENDAPPLYFONTS;
+ p.flags = ALF_QUERYSIZE | ALF_SENDAPPLYFONTS | ALF_MESSAGEFONT;
ALF_AddWidgetEx(parent, &p);