summaryrefslogtreecommitdiff
path: root/alf/alflayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alflayout.cpp')
-rw-r--r--alf/alflayout.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp
index 6c5326d..1cdd328 100644
--- a/alf/alflayout.cpp
+++ b/alf/alflayout.cpp
@@ -196,15 +196,12 @@ ALF_Layout_CalcEditSize(HWND hwndWindow, ALFLayout *layout, HWND hwndEdit, SIZE
ZeroMemory(&tm, sizeof(tm));
if (GetTextMetrics(hDc, &tm)) {
- if (!ps->cx) {
- ps->cx = ALF_CentipointsToPixels(12000, layout->dpi);
- }
-
- if (!ps->cy) {
- ps->cy = tm.tmHeight + 2*ALF_Compat_GetSystemMetricsForDpi(
+ int cy = tm.tmHeight + 2*ALF_Compat_GetSystemMetricsForDpi(
SM_CYEDGE, (UINT)layout->dpi)
+ 4 /* padding internal to the edit control */;
- }
+
+ if (ps->cy < cy)
+ ps->cy = cy;
}
SelectFont(hDc, oldfont);
@@ -229,20 +226,20 @@ ALF_Layout_CalcCheckboxSize(HWND hwndWindow, ALFLayout *layout, HWND hwndCheckbo
DrawText(hDC, textbuf, -1, &r, DT_CALCRECT);
ALF_Free(textbuf);
- if (!ps->cx) {
- // lol
- int cw = 0;
- GetCharWidth(hDC, '0', '0', &cw);
+ // lol
+ int cx = 0;
+ GetCharWidth(hDC, '0', '0', &cx);
- ps->cx = checkwidth + r.right - r.left + cw;
- }
+ cx += checkwidth + r.right - r.left;
- if (!ps->cy) {
- int height = r.bottom - r.top;
- if (checkwidth > height)
- height = checkwidth;
- ps->cy = height;
- }
+ int cy = r.bottom - r.top;
+ if (checkwidth > cy)
+ cy = checkwidth;
+
+ if (ps->cx < cx)
+ ps->cx = cx;
+ if (ps->cy < cy)
+ ps->cy = cy;
SelectFont(hDC, oldfont);
ReleaseDC(hwndCheckbox, hDC);
@@ -823,7 +820,12 @@ ALF_Layout_HandleMessage(ALFLayout *layout, HWND hwnd, UINT msg, WPARAM wparam,
*pRet = 0;
if (msg == ALF_WM_QUERYSIZE) {
- ALF_Layout_GetMinSize(layout, hwnd, (SIZE*)lparam);
+ SIZE s = { 0, 0 };
+ ALF_Layout_GetMinSize(layout, hwnd, &s);
+ if (((SIZE*)lparam)->cx < s.cx)
+ ((SIZE*)lparam)->cx = s.cx;
+ if (((SIZE*)lparam)->cy < s.cy)
+ ((SIZE*)lparam)->cy = s.cy;
return TRUE;
}