diff --git a/new/button_windows.c b/new/button_windows.c index 099fa6b..c331e89 100644 --- a/new/button_windows.c +++ b/new/button_windows.c @@ -52,7 +52,7 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t * // Microsoft says to use a fixed width for all buttons; this isn't good enough // use the text width instead, with some edge padding *width = uiWindowsWindowTextWidth(hwnd) + (2 * GetSystemMetrics(SM_CXEDGE)); - *height = uiDlgUnitToY(buttonHeight, d->sys->baseY); + *height = uiDlgUnitsToY(buttonHeight, d->sys->baseY); } static void defaultOnClicked(uiControl *c, void *data) diff --git a/new/checkbox_windows.c b/new/checkbox_windows.c index 00981de..55699a6 100644 --- a/new/checkbox_windows.c +++ b/new/checkbox_windows.c @@ -46,8 +46,8 @@ static void onWM_DESTROY(uiControl *c) static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - *width = uiDlgUnitToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->baseX) + uiWindowsWindowTextWidth((HWND) uiControlHandle(c)); - *height = uiDlgUnitToY(checkboxHeight, d->sys->baseY); + *width = uiDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->baseX) + uiWindowsWindowTextWidth((HWND) uiControlHandle(c)); + *height = uiDlgUnitsToY(checkboxHeight, d->sys->baseY); } static void defaultOnToggled(uiControl *c, void *data) diff --git a/new/container_windows.c b/new/container_windows.c index cf19ad4..ec7b4bd 100644 --- a/new/container_windows.c +++ b/new/container_windows.c @@ -88,12 +88,12 @@ void resize(uiControl *control, HWND parent, RECT r, RECT margin) logLastError("error restoring previous font into device context in resize()"); if (ReleaseDC(parent, dc) == 0) logLastError("error releasing DC in resize()"); - r.left += uiDlgUnitToX(margin.left, sys.baseX); - r.top += uiDlgUnitToY(margin.top, sys.baseY); - r.right -= uiDlgUnitToX(margin.right, sys.baseX); - r.bottom -= uiDlgUnitToY(margin.bottom, sys.baseY); - d.xPadding = uiDlgUnitToX(winXPadding, sys.baseX); - d.yPadding = uiDlgUnitToY(winYPadding, sys.baseY); + r.left += uiDlgUnitsToX(margin.left, sys.baseX); + r.top += uiDlgUnitsToY(margin.top, sys.baseY); + r.right -= uiDlgUnitsToX(margin.right, sys.baseX); + r.bottom -= uiDlgUnitsToY(margin.bottom, sys.baseY); + d.xPadding = uiDlgUnitsToX(winXPadding, sys.baseX); + d.yPadding = uiDlgUnitsToY(winYPadding, sys.baseY); d.sys = &sys; uiControlResize(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d); } diff --git a/new/entry_windows.c b/new/entry_windows.c index 23796d9..f8521b4 100644 --- a/new/entry_windows.c +++ b/new/entry_windows.c @@ -27,8 +27,8 @@ static void onWM_DESTROY(uiControl *c) static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - *width = uiDlgUnitToX(entryWidth, d->sys->baseX); - *height = uiDlgUnitToY(entryHeight, d->sys->baseY); + *width = uiDlgUnitsToX(entryWidth, d->sys->baseX); + *height = uiDlgUnitsToY(entryHeight, d->sys->baseY); } uiControl *uiNewEntry(void) diff --git a/new/ui_windows.h b/new/ui_windows.h index 6932ff4..4ade067 100644 --- a/new/ui_windows.h +++ b/new/ui_windows.h @@ -39,9 +39,8 @@ struct uiSizingSys { LONG internalLeading; }; // Use these in your preferredSize() implementation with baseX and baseY. -// TODO rename to DlgUnits? -#define uiDlgUnitToX(dlg, baseX) MulDiv((dlg), baseX, 4) -#define uiDlgUnitToY(dlg, baseY) MulDiv((dlg), baseY, 8) +#define uiDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4) +#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8) // and use this if you need the text of the window width // TODO really export?