summaryrefslogtreecommitdiff
path: root/alf/alfbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alfbutton.cpp')
-rw-r--r--alf/alfbutton.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp
index dcf0898..6721dc7 100644
--- a/alf/alfbutton.cpp
+++ b/alf/alfbutton.cpp
@@ -306,12 +306,13 @@ ALF_NtButton_RenderClassic(HWND hwnd, ALFNtButtonPriv *priv, HDC dc, RECT *rcPai
DrawFrameControl(dc, &r, DFC_BUTTON, dfcs);
- RECT textbounds = rcClient;
+ RECT textbounds = r;
DrawTextW(dc, priv->text, -1, &textbounds, DT_LEFT | DT_CALCRECT);
+ textbounds.bottom++; // this appears to be the secret for correct vertical centering
- RECT texttarget = rcClient;
- texttarget.top += ((rcClient.bottom - rcClient.top) - (textbounds.bottom - textbounds.top)) / 2 - 1;
- texttarget.left += ((rcClient.right - rcClient.left) - (textbounds.right - textbounds.left)) / 2;
+ RECT texttarget = r;
+ texttarget.top += (texttarget.bottom - texttarget.top - textbounds.bottom + textbounds.top) / 2;
+ texttarget.left += (texttarget.right - texttarget.left - textbounds.right + textbounds.left) / 2;
texttarget.right = texttarget.left + (textbounds.right - textbounds.left);
texttarget.bottom = texttarget.top + (textbounds.bottom - textbounds.top);
@@ -694,7 +695,7 @@ ALF_NtButton_Create(HWND win, WORD id, int x, int y, const TCHAR *text)
ALF_HINSTANCE,
NULL);
- ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE | ALF_LAYOUT_TRANSPARENTBG);
+ ALF_AddWidget(win, x, y, hwndButton, 5625, 1725, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE | ALF_LAYOUT_TRANSPARENTBG);
return hwndButton;
}
@@ -777,12 +778,13 @@ ALF_ClassicButton_Paint(HWND hwnd, ALFClassicButtonPriv *priv, DRAWITEMSTRUCT *d
DrawFrameControl(dis->hDC, &r, DFC_BUTTON, dfcs);
- RECT textbounds = dis->rcItem;
+ RECT textbounds = r;
DrawText(dis->hDC, textbuf, -1, &textbounds, DT_LEFT | DT_CALCRECT);
+ textbounds.bottom++; // this appears to be the secret for correct vertical centering
- RECT texttarget = dis->rcItem;
- texttarget.top += ((dis->rcItem.bottom - dis->rcItem.top) - (textbounds.bottom - textbounds.top)) / 2 - 1;
- texttarget.left += ((dis->rcItem.right - dis->rcItem.left) - (textbounds.right - textbounds.left)) / 2;
+ RECT texttarget = r;
+ texttarget.top += (texttarget.bottom - texttarget.top - textbounds.bottom + textbounds.top) / 2;
+ texttarget.left += (texttarget.right - texttarget.left - textbounds.right + textbounds.left) / 2;
texttarget.right = texttarget.left + (textbounds.right - textbounds.left);
texttarget.bottom = texttarget.top + (textbounds.bottom - textbounds.top);
@@ -874,7 +876,7 @@ ALF_ClassicButton_Create(HWND win, WORD id, int x, int y, const TCHAR *text)
SetWindowLongPtr(hwndButton, GWLP_USERDATA, (LONG_PTR)priv);
priv->origWndProc = (WNDPROC)SetWindowLongPtr(hwndButton, GWLP_WNDPROC, (LONG_PTR)ALF_ClassicButton_WndProc);
- ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT);
+ ALF_AddWidget(win, x, y, hwndButton, 5625, 1725, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT);
return hwndButton;
}