summaryrefslogtreecommitdiff
path: root/alf/alfbutton.cpp
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-23 15:07:21 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-23 15:07:21 +0200
commit51daba89072cb66fe5e43015484a554555a40499 (patch)
tree372502daebee3c3f3b2cfa68047e03f164f3d95c /alf/alfbutton.cpp
parentd17d8f49777d802b56aa332077afbfa83af691e1 (diff)
changed DPI handling: dpi is now pushed into every control and saved there
Diffstat (limited to 'alf/alfbutton.cpp')
-rw-r--r--alf/alfbutton.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp
index ddf607d..579fdce 100644
--- a/alf/alfbutton.cpp
+++ b/alf/alfbutton.cpp
@@ -19,6 +19,7 @@ typedef struct {
UINT itemStateCurrent;
DWORD uxDefaultAnimationDuration;
BOOL uxIsDefaultAnimating;
+ int dpi;
} ALFButtonPriv;
static void CALLBACK
@@ -294,9 +295,9 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT
ALF_Free(textbuf);
int xpadding = ALF_Compat_GetSystemMetricsForDpi(SM_CXEDGE,
- (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 6;
+ (UINT)priv->dpi) * 2 + 6;
int ypadding = ALF_Compat_GetSystemMetricsForDpi(SM_CYEDGE,
- (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 4;
+ (UINT)priv->dpi) * 2 + 4;
SIZE *pSize = (SIZE*)(void*)lParam;
if (pSize->cx < r.right - r.left + xpadding) {
@@ -473,6 +474,10 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT
ALF_InvalidateLayout(GetParent(hwnd));
} else if (uMsg == WM_SETFONT) {
ALF_InvalidateLayout(GetParent(hwnd));
+ } else if (uMsg == ALF_WM_DPICHANGE) {
+ priv->dpi = (int)lParam;
+ ALF_InvalidateLayout(GetParent(hwnd));
+ return TRUE;
}
return ALF_Compat_DefSubclassProc(hwnd, uMsg, wParam, lParam);
@@ -494,12 +499,13 @@ ALF_AddButton(HWND win, WORD id, int x, int y, const TCHAR *text)
ALFButtonPriv *priv = ALF_New(ALFButtonPriv, 1);
priv->uxStateCurrent = -1;
priv->uxStatePrev = -1;
+ priv->dpi = 96;
ALF_Compat_SetWindowSubclass(hwndButton, ALF__ButtonSubclassProc, 0, (DWORD_PTR)priv);
SendMessage(hwndButton, WM_THEMECHANGED, 0, 0);
- ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT);
+ ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE);
return hwndButton;
}