"Exported" uiSizingSys fields.

This commit is contained in:
Pietro Gagliardi 2015-05-07 14:22:31 -04:00
parent 6e4845f11f
commit f74394fbac
7 changed files with 22 additions and 22 deletions

View File

@ -35,12 +35,12 @@ struct uiWindowsMakeControlParams {
void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p);
// This contains the Windows-specific parts of the uiSizing structure.
// baseX and baseY are the dialog base units.
// internalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
// BaseX and BaseY are the dialog base units.
// InternalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
struct uiSizingSys {
int baseX;
int baseY;
LONG internalLeading;
int BaseX;
int BaseY;
LONG InternalLeading;
// This is the window handle to pass to the hWndInsertAfter parameter of SetWindowPos().
// You should set this to your own window handle when done.

View File

@ -41,8 +41,8 @@ static void binPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
return;
}
uiControlPreferredSize(b->mainControl, d, width, height);
marginX = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->baseX) + uiWindowsDlgUnitsToX(b->marginRight, d->sys->baseX);
marginY = uiWindowsDlgUnitsToY(b->marginTop, d->sys->baseY) + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->baseY);
marginX = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->BaseX) + uiWindowsDlgUnitsToX(b->marginRight, d->sys->BaseX);
marginY = uiWindowsDlgUnitsToY(b->marginTop, d->sys->BaseY) + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->BaseY);
*width += marginX;
*height += marginY;
}
@ -62,12 +62,12 @@ static void binResizeChildren(uiContainer *c, intmax_t x, intmax_t y, intmax_t w
if (b->mainControl == NULL)
return;
marginLeft = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->baseX);
marginTop = uiWindowsDlgUnitsToY(b->marginTop, d->sys->baseY);
marginLeft = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->BaseX);
marginTop = uiWindowsDlgUnitsToY(b->marginTop, d->sys->BaseY);
x += marginLeft;
y += marginTop;
width -= marginLeft + uiWindowsDlgUnitsToX(b->marginRight, d->sys->baseX);
height -= marginTop + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->baseY);
width -= marginLeft + uiWindowsDlgUnitsToX(b->marginRight, d->sys->BaseX);
height -= marginTop + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->BaseY);
uiControlResize(b->mainControl, x, y, width, height, d);
}

View File

@ -52,7 +52,7 @@ static void buttonPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intm
// 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(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
*height = uiWindowsDlgUnitsToY(buttonHeight, d->sys->baseY);
*height = uiWindowsDlgUnitsToY(buttonHeight, d->sys->BaseY);
}
static void defaultOnClicked(uiButton *b, void *data)

View File

@ -48,8 +48,8 @@ static void checkboxPreferredSize(uiControl *cc, uiSizing *d, intmax_t *width, i
{
struct checkbox *c = (struct checkbox *) cc;
*width = uiWindowsDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->baseX) + uiWindowsWindowTextWidth(c->hwnd);
*height = uiWindowsDlgUnitsToY(checkboxHeight, d->sys->baseY);
*width = uiWindowsDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->BaseX) + uiWindowsWindowTextWidth(c->hwnd);
*height = uiWindowsDlgUnitsToY(checkboxHeight, d->sys->BaseY);
}
static void defaultOnToggled(uiCheckbox *c, void *data)

View File

@ -138,9 +138,9 @@ static HRESULT resize(uiContainer *cc, RECT *r)
if (GetTextExtentPoint32W(dc, L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size) == 0)
return logLastError("error getting text extent point in resize()");
sys.baseX = (int) ((size.cx / 26 + 1) / 2);
sys.baseY = (int) tm.tmHeight;
sys.internalLeading = tm.tmInternalLeading;
sys.BaseX = (int) ((size.cx / 26 + 1) / 2);
sys.BaseY = (int) tm.tmHeight;
sys.InternalLeading = tm.tmInternalLeading;
if (SelectObject(dc, prevfont) != hMessageFont)
return logLastError("error restoring previous font into device context in resize()");
@ -150,8 +150,8 @@ static HRESULT resize(uiContainer *cc, RECT *r)
// the first control gets the topmost z-order and thus the first tab stop
sys.InsertAfter = HWND_TOP;
d.xPadding = uiWindowsDlgUnitsToX(winXPadding, sys.baseX);
d.yPadding = uiWindowsDlgUnitsToY(winYPadding, sys.baseY);
d.xPadding = uiWindowsDlgUnitsToX(winXPadding, sys.BaseX);
d.yPadding = uiWindowsDlgUnitsToY(winYPadding, sys.BaseY);
d.sys = &sys;
uiContainerResizeChildren(cc, r->left, r->top, r->right - r->left, r->bottom - r->top, &d);
return S_OK;

View File

@ -37,8 +37,8 @@ static void onDestroy(void *data)
static void entryPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
*width = uiWindowsDlgUnitsToX(entryWidth, d->sys->baseX);
*height = uiWindowsDlgUnitsToY(entryHeight, d->sys->baseY);
*width = uiWindowsDlgUnitsToX(entryWidth, d->sys->BaseX);
*height = uiWindowsDlgUnitsToY(entryHeight, d->sys->BaseY);
}
static void defaultOnChanged(uiEntry *e, void *data)

View File

@ -31,7 +31,7 @@ static void labelPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
struct label *l = (struct label *) c;
*width = uiWindowsWindowTextWidth(l->hwnd);
*height = uiWindowsDlgUnitsToY(labelHeight, d->sys->baseY);
*height = uiWindowsDlgUnitsToY(labelHeight, d->sys->BaseY);
}
static char *labelText(uiLabel *l)