summaryrefslogtreecommitdiff
path: root/alf/alflayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alflayout.cpp')
-rw-r--r--alf/alflayout.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp
index 15b8f5d..2e56886 100644
--- a/alf/alflayout.cpp
+++ b/alf/alflayout.cpp
@@ -77,6 +77,7 @@ ALF_Layout_Init(ALFLayout *layout)
layout->nColumns = 1;
layout->columns = ALF_New(ALFLayoutRowOrColumn, (SIZE_T)layout->nColumns);
layout->dpi = 96;
+ layout->bgcolor = ALF_COLOR_TRANSPARENT;
}
void
@@ -391,8 +392,6 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window)
// now apply positions to widgets
HDWP hdwp = BeginDeferWindowPos(layout->nColumns * layout->nRows);
- ALFColor bgcolor = (ALFColor)SendMessage(window, ALF_WM_GETBGCOLOR, 0, 0);
-
ALF_FOR_LIST(ALFWidgetPriv, list, &layout->widgets, c) {
int col = c->x;
int row = c->y;
@@ -415,7 +414,7 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window)
flags |= SWP_NOCOPYBITS;
// transparent background: invalidate if widget moved
- if (bgcolor == ALF_COLOR_TRANSPARENT) {
+ if (layout->bgcolor == ALF_COLOR_TRANSPARENT) {
RECT oldR;
GetWindowRect(c->hwnd, &oldR);
MapWindowRect(NULL, window, &oldR);
@@ -457,10 +456,10 @@ ALF_Layout_AddWidget(ALFLayout* layout, HWND window, const ALFAddWidgetParams* p
SetParent(w->hwnd, window);
if (w->flags & ALF_LAYOUT_INHERITFONT) {
- ALF_Layout_ForwardFontToWidget(layout, window, w, (HFONT)SendMessage(window, WM_GETFONT, 0, 0), 0);
+ ALF_Layout_ForwardFontToWidget(layout, window, w, layout->font, 0);
}
if (w->flags & ALF_LAYOUT_INHERITBGCOLOR) {
- SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, 0, (LPARAM)ALF_BackgroundColor(window));
+ SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, 0, (LPARAM)layout->bgcolor);
}
if (w->flags & ALF_LAYOUT_SENDDPICHANGE) {
SendMessage(w->hwnd, ALF_WM_DPICHANGE, 0, (LPARAM)layout->dpi);
@@ -617,9 +616,9 @@ ALF_Layout_SetWidgetFlags(ALFLayout *layout, HWND window, HWND needle, DWORD fla
w->flags = flags;
if (flags & ALF_LAYOUT_INHERITFONT)
- ALF_Layout_ForwardFontToWidget(layout, window, w, (HFONT)SendMessage(window, WM_GETFONT, 0, 0), 0);
+ ALF_Layout_ForwardFontToWidget(layout, window, w, layout->font, 0);
if (flags & ALF_LAYOUT_INHERITBGCOLOR)
- SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, 0, (LPARAM)ALF_BackgroundColor(window));
+ SendMessage(w->hwnd, ALF_WM_SETBGCOLOR, 0, (LPARAM)layout->bgcolor);
if (flags & ALF_LAYOUT_SENDDPICHANGE)
SendMessage(w->hwnd, ALF_WM_DPICHANGE, 0, (LPARAM)layout->dpi);
@@ -797,17 +796,42 @@ ALF_Layout_HandleMessage(ALFLayout *layout, HWND hwnd, UINT msg, WPARAM wparam,
}
if (msg == WM_SETFONT) {
+ *pRet = 1;
+ if (layout->font == (HFONT)wparam)
+ return TRUE;
+
+ layout->font = (HFONT)wparam;
ALF_Layout_ForwardFont(layout, hwnd, (HFONT)wparam, lparam);
return TRUE;
}
+ if (msg == WM_GETFONT) {
+ *pRet = (LRESULT)layout->font;
+ return TRUE;
+ }
+
if (msg == ALF_WM_SETBGCOLOR) {
+ *pRet = 1;
+ if (layout->bgcolor == (ALFColor)lparam)
+ return TRUE;
+
+ layout->bgcolor = (ALFColor)lparam;
ALF_Layout_ForwardBgColor(layout, hwnd, wparam, lparam);
ALF_Layout_HandleBackgroundChange(layout, hwnd);
+ InvalidateRect(hwnd, NULL, TRUE);
+ return TRUE;
+ }
+
+ if (msg == ALF_WM_GETBGCOLOR) {
+ *pRet = (LRESULT)layout->bgcolor;
return TRUE;
}
if (msg == ALF_WM_BACKGROUNDCHANGE) {
+ if (layout->bgcolor != ALF_COLOR_TRANSPARENT)
+ return TRUE; // solid bg -> nothing to do
+
+ InvalidateRect(hwnd, NULL, TRUE);
ALF_Layout_HandleBackgroundChange(layout, hwnd);
return TRUE;
}
@@ -823,7 +847,8 @@ ALF_Layout_HandleMessage(ALFLayout *layout, HWND hwnd, UINT msg, WPARAM wparam,
}
if (msg == ALF_WM_GETDPI) {
- return (LRESULT)layout->dpi;
+ *pRet = (LRESULT)layout->dpi;
+ return TRUE;
}
if (msg == ALF_WM_INVALIDATELAYOUT) {