summaryrefslogtreecommitdiff
path: root/alf
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-29 14:59:38 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-29 14:59:38 +0200
commitd28cd7fb71a6fe56a04d4e21f2b95907a1ec105c (patch)
treeb8b529e63d520e604418b077a2ae91bdd343c909 /alf
parentd752fd2f1ff39fc27b8703fdb8c7f0d68dd87c53 (diff)
layout: make minimum size actually work as a minimum
Diffstat (limited to 'alf')
-rw-r--r--alf/alfcombobox.cpp15
-rw-r--r--alf/alfedit.cpp2
-rw-r--r--alf/alflabel.cpp23
-rw-r--r--alf/alflayout.cpp42
-rw-r--r--alf/alfnotebook.cpp4
5 files changed, 46 insertions, 40 deletions
diff --git a/alf/alfcombobox.cpp b/alf/alfcombobox.cpp
index 994806e..f94c744 100644
--- a/alf/alfcombobox.cpp
+++ b/alf/alfcombobox.cpp
@@ -171,15 +171,16 @@ ALF__ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (GetTextMetrics(hDc, &tm)) {
SIZE *ps = (SIZE*)lParam;
- if (!ps->cx) {
- ps->cx = ALF_CentipointsToPixels(12000, priv->dpi);
- }
-
- if (!ps->cy) {
- ps->cy = tm.tmHeight + 2*ALF_Compat_GetSystemMetricsForDpi(
+ int cx = ALF_CentipointsToPixels(12000, priv->dpi);
+ int cy = ps->cy = tm.tmHeight + 2*ALF_Compat_GetSystemMetricsForDpi(
SM_CYEDGE, (UINT)priv->dpi)
+ 4 /* padding internal to the edit control */;
- }
+
+ if (ps->cx < cx)
+ ps->cx = cx;
+
+ if (ps->cy < cy)
+ ps->cy = cy;
}
SelectFont(hDc, oldfont);
diff --git a/alf/alfedit.cpp b/alf/alfedit.cpp
index f732452..1fadbc8 100644
--- a/alf/alfedit.cpp
+++ b/alf/alfedit.cpp
@@ -28,7 +28,7 @@ ALF_AddEdit(HWND win, WORD id, int x, int y, const TCHAR *text)
SetWindowPos(hwndEdit, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
- ALF_AddWidget(win, x, y, hwndEdit, 0, 0, ALF_LAYOUT_SIZE_EDIT | ALF_LAYOUT_INHERITFONT);
+ ALF_AddWidget(win, x, y, hwndEdit, 12000, 0, ALF_LAYOUT_SIZE_EDIT | ALF_LAYOUT_INHERITFONT);
return hwndEdit;
}
diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp
index 87d5baa..6f01cce 100644
--- a/alf/alflabel.cpp
+++ b/alf/alflabel.cpp
@@ -162,16 +162,19 @@ ALF_Label_CalculateSize(HWND hwnd, ALFLabelPriv *priv, SIZE *pSize)
ALF_Free(textbuf);
- if (pSize->cx == 0) {
- pSize->cx = r.right - r.left;
- if ((priv->style & ALF_LABEL_HALIGN_MASK) == ALF_LABEL_ALIGN_LEFT_LIKE_EDIT)
- pSize->cx += ALF__LabelLeftPadding(hwnd, hdcLabel, priv);
- }
- if (pSize->cy == 0) {
- pSize->cy = r.bottom - r.top;
- if ((priv->style & ALF_LABEL_VALIGN_MASK) == ALF_LABEL_ALIGN_TOP_LIKE_EDIT)
- pSize->cy += ALF__LabelTopPadding(hwnd, priv);
- }
+ int cx = r.right - r.left;
+ if ((priv->style & ALF_LABEL_HALIGN_MASK) == ALF_LABEL_ALIGN_LEFT_LIKE_EDIT)
+ cx += ALF__LabelLeftPadding(hwnd, hdcLabel, priv);
+
+ int cy = r.bottom - r.top;
+ if ((priv->style & ALF_LABEL_VALIGN_MASK) == ALF_LABEL_ALIGN_TOP_LIKE_EDIT)
+ cy += ALF__LabelTopPadding(hwnd, priv);
+
+
+ if (pSize->cx < cx)
+ pSize->cx = cx;
+ if (pSize->cy < cy)
+ pSize->cy = cy;
SelectFont(hdcLabel, oldFont);
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;
}
diff --git a/alf/alfnotebook.cpp b/alf/alfnotebook.cpp
index 6ffbe5d..342bd92 100644
--- a/alf/alfnotebook.cpp
+++ b/alf/alfnotebook.cpp
@@ -379,11 +379,11 @@ ALF__NotebookWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
TabCtrl_AdjustRect(priv->hwndTabCtrl, TRUE, &r);
SIZE *ps = (SIZE*)lParam;
- if (!ps->cx) {
+ if (ps->cx < r.right - r.left) {
ps->cx = r.right - r.left;
}
- if (!ps->cy) {
+ if (ps->cy < r.bottom - r.top) {
ps->cy = r.bottom - r.top;
}