"Exported" uiSizingSys fields.
This commit is contained in:
parent
6e4845f11f
commit
f74394fbac
10
ui_windows.h
10
ui_windows.h
|
@ -35,12 +35,12 @@ struct uiWindowsMakeControlParams {
|
||||||
void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p);
|
void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p);
|
||||||
|
|
||||||
// This contains the Windows-specific parts of the uiSizing structure.
|
// This contains the Windows-specific parts of the uiSizing structure.
|
||||||
// baseX and baseY are the dialog base units.
|
// 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.
|
// InternalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
|
||||||
struct uiSizingSys {
|
struct uiSizingSys {
|
||||||
int baseX;
|
int BaseX;
|
||||||
int baseY;
|
int BaseY;
|
||||||
LONG internalLeading;
|
LONG InternalLeading;
|
||||||
|
|
||||||
// This is the window handle to pass to the hWndInsertAfter parameter of SetWindowPos().
|
// This is the window handle to pass to the hWndInsertAfter parameter of SetWindowPos().
|
||||||
// You should set this to your own window handle when done.
|
// You should set this to your own window handle when done.
|
||||||
|
|
|
@ -41,8 +41,8 @@ static void binPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uiControlPreferredSize(b->mainControl, d, width, height);
|
uiControlPreferredSize(b->mainControl, d, width, height);
|
||||||
marginX = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->baseX) + uiWindowsDlgUnitsToX(b->marginRight, d->sys->baseX);
|
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);
|
marginY = uiWindowsDlgUnitsToY(b->marginTop, d->sys->BaseY) + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->BaseY);
|
||||||
*width += marginX;
|
*width += marginX;
|
||||||
*height += marginY;
|
*height += marginY;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ static void binResizeChildren(uiContainer *c, intmax_t x, intmax_t y, intmax_t w
|
||||||
|
|
||||||
if (b->mainControl == NULL)
|
if (b->mainControl == NULL)
|
||||||
return;
|
return;
|
||||||
marginLeft = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->baseX);
|
marginLeft = uiWindowsDlgUnitsToX(b->marginLeft, d->sys->BaseX);
|
||||||
marginTop = uiWindowsDlgUnitsToY(b->marginTop, d->sys->baseY);
|
marginTop = uiWindowsDlgUnitsToY(b->marginTop, d->sys->BaseY);
|
||||||
x += marginLeft;
|
x += marginLeft;
|
||||||
y += marginTop;
|
y += marginTop;
|
||||||
width -= marginLeft + uiWindowsDlgUnitsToX(b->marginRight, d->sys->baseX);
|
width -= marginLeft + uiWindowsDlgUnitsToX(b->marginRight, d->sys->BaseX);
|
||||||
height -= marginTop + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->baseY);
|
height -= marginTop + uiWindowsDlgUnitsToY(b->marginBottom, d->sys->BaseY);
|
||||||
uiControlResize(b->mainControl, x, y, width, height, d);
|
uiControlResize(b->mainControl, x, y, width, height, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// Microsoft says to use a fixed width for all buttons; this isn't good enough
|
||||||
// use the text width instead, with some edge padding
|
// use the text width instead, with some edge padding
|
||||||
*width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
|
*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)
|
static void defaultOnClicked(uiButton *b, void *data)
|
||||||
|
|
|
@ -48,8 +48,8 @@ static void checkboxPreferredSize(uiControl *cc, uiSizing *d, intmax_t *width, i
|
||||||
{
|
{
|
||||||
struct checkbox *c = (struct checkbox *) cc;
|
struct checkbox *c = (struct checkbox *) cc;
|
||||||
|
|
||||||
*width = uiWindowsDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->baseX) + uiWindowsWindowTextWidth(c->hwnd);
|
*width = uiWindowsDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->BaseX) + uiWindowsWindowTextWidth(c->hwnd);
|
||||||
*height = uiWindowsDlgUnitsToY(checkboxHeight, d->sys->baseY);
|
*height = uiWindowsDlgUnitsToY(checkboxHeight, d->sys->BaseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defaultOnToggled(uiCheckbox *c, void *data)
|
static void defaultOnToggled(uiCheckbox *c, void *data)
|
||||||
|
|
|
@ -138,9 +138,9 @@ static HRESULT resize(uiContainer *cc, RECT *r)
|
||||||
if (GetTextExtentPoint32W(dc, L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size) == 0)
|
if (GetTextExtentPoint32W(dc, L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size) == 0)
|
||||||
return logLastError("error getting text extent point in resize()");
|
return logLastError("error getting text extent point in resize()");
|
||||||
|
|
||||||
sys.baseX = (int) ((size.cx / 26 + 1) / 2);
|
sys.BaseX = (int) ((size.cx / 26 + 1) / 2);
|
||||||
sys.baseY = (int) tm.tmHeight;
|
sys.BaseY = (int) tm.tmHeight;
|
||||||
sys.internalLeading = tm.tmInternalLeading;
|
sys.InternalLeading = tm.tmInternalLeading;
|
||||||
|
|
||||||
if (SelectObject(dc, prevfont) != hMessageFont)
|
if (SelectObject(dc, prevfont) != hMessageFont)
|
||||||
return logLastError("error restoring previous font into device context in resize()");
|
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
|
// the first control gets the topmost z-order and thus the first tab stop
|
||||||
sys.InsertAfter = HWND_TOP;
|
sys.InsertAfter = HWND_TOP;
|
||||||
|
|
||||||
d.xPadding = uiWindowsDlgUnitsToX(winXPadding, sys.baseX);
|
d.xPadding = uiWindowsDlgUnitsToX(winXPadding, sys.BaseX);
|
||||||
d.yPadding = uiWindowsDlgUnitsToY(winYPadding, sys.baseY);
|
d.yPadding = uiWindowsDlgUnitsToY(winYPadding, sys.BaseY);
|
||||||
d.sys = &sys;
|
d.sys = &sys;
|
||||||
uiContainerResizeChildren(cc, r->left, r->top, r->right - r->left, r->bottom - r->top, &d);
|
uiContainerResizeChildren(cc, r->left, r->top, r->right - r->left, r->bottom - r->top, &d);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
|
@ -37,8 +37,8 @@ static void onDestroy(void *data)
|
||||||
|
|
||||||
static void entryPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
static void entryPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
*width = uiWindowsDlgUnitsToX(entryWidth, d->sys->baseX);
|
*width = uiWindowsDlgUnitsToX(entryWidth, d->sys->BaseX);
|
||||||
*height = uiWindowsDlgUnitsToY(entryHeight, d->sys->baseY);
|
*height = uiWindowsDlgUnitsToY(entryHeight, d->sys->BaseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defaultOnChanged(uiEntry *e, void *data)
|
static void defaultOnChanged(uiEntry *e, void *data)
|
||||||
|
|
|
@ -31,7 +31,7 @@ static void labelPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
|
||||||
struct label *l = (struct label *) c;
|
struct label *l = (struct label *) c;
|
||||||
|
|
||||||
*width = uiWindowsWindowTextWidth(l->hwnd);
|
*width = uiWindowsWindowTextWidth(l->hwnd);
|
||||||
*height = uiWindowsDlgUnitsToY(labelHeight, d->sys->baseY);
|
*height = uiWindowsDlgUnitsToY(labelHeight, d->sys->BaseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *labelText(uiLabel *l)
|
static char *labelText(uiLabel *l)
|
||||||
|
|
Loading…
Reference in New Issue