From d4271c8ceb26180ba3c06bba5cbc1ca4af4a4cae Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 9 Apr 2015 18:45:58 -0400 Subject: [PATCH] DlgUnit -> DlgUnits --- button_windows.c | 2 +- checkbox_windows.c | 4 ++-- container_windows.c | 12 ++++++------ entry_windows.c | 4 ++-- ui_windows.h | 5 ++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/button_windows.c b/button_windows.c index 099fa6b7..c331e89b 100644 --- a/button_windows.c +++ b/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/checkbox_windows.c b/checkbox_windows.c index 00981de7..55699a67 100644 --- a/checkbox_windows.c +++ b/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/container_windows.c b/container_windows.c index cf19ad4f..ec7b4bd8 100644 --- a/container_windows.c +++ b/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/entry_windows.c b/entry_windows.c index 23796d9b..f8521b45 100644 --- a/entry_windows.c +++ b/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/ui_windows.h b/ui_windows.h index 6932ff4f..4ade067a 100644 --- a/ui_windows.h +++ b/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?