"Exported" uiSizing fields.
This commit is contained in:
parent
f74394fbac
commit
2107595ce7
8
box.c
8
box.c
|
@ -69,8 +69,8 @@ static void boxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
|
|||
xpadding = 0;
|
||||
ypadding = 0;
|
||||
if (b->padded) {
|
||||
xpadding = d->xPadding;
|
||||
ypadding = d->yPadding;
|
||||
xpadding = d->XPadding;
|
||||
ypadding = d->YPadding;
|
||||
}
|
||||
|
||||
// 1) initialize the desired rect with the needed padding
|
||||
|
@ -140,8 +140,8 @@ static void boxResizeChildren(uiContainer *c, intmax_t x, intmax_t y, intmax_t w
|
|||
xpadding = 0;
|
||||
ypadding = 0;
|
||||
if (b->padded) {
|
||||
xpadding = d->xPadding;
|
||||
ypadding = d->yPadding;
|
||||
xpadding = d->XPadding;
|
||||
ypadding = d->YPadding;
|
||||
}
|
||||
|
||||
// 0) inset the available rect by the needed padding
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
y = [self bounds].origin.y;
|
||||
width = [self bounds].size.width;
|
||||
height = [self bounds].size.height;
|
||||
d.xPadding = macXPadding;
|
||||
d.yPadding = macYPadding;
|
||||
d.XPadding = macXPadding;
|
||||
d.YPadding = macYPadding;
|
||||
uiContainerResizeChildren(self->c, x, y, width, height, &d);
|
||||
}
|
||||
|
||||
|
|
6
ui.idl
6
ui.idl
|
@ -26,9 +26,9 @@ func FreeText(text *char);
|
|||
raw "typedef struct uiSizingSys uiSizingSys;";
|
||||
|
||||
struct Sizing {
|
||||
field xPadding intmax_t;
|
||||
field yPadding intmax_t;
|
||||
field sys *uiSizingSys;
|
||||
field XPadding intmax_t;
|
||||
field YPadding intmax_t;
|
||||
field Sys *uiSizingSys;
|
||||
};
|
||||
|
||||
raw "typedef struct uiControlSysFuncParams uiControlSysFuncParams;";
|
||||
|
|
|
@ -70,8 +70,8 @@ static void containerWidget_size_allocate(GtkWidget *widget, GtkAllocation *allo
|
|||
uiSizing d;
|
||||
|
||||
gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
|
||||
d.xPadding = gtkXPadding;
|
||||
d.yPadding = gtkYPadding;
|
||||
d.XPadding = gtkXPadding;
|
||||
d.YPadding = gtkYPadding;
|
||||
uiContainerResizeChildren(c->c, allocation->x, allocation->y, allocation->width, allocation->height, &d);
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ static void containerWidget_get_preferred_height(GtkWidget *widget, gint *minimu
|
|||
intmax_t width, height;
|
||||
uiSizing d;
|
||||
|
||||
d.xPadding = gtkXPadding;
|
||||
d.yPadding = gtkYPadding;
|
||||
d.XPadding = gtkXPadding;
|
||||
d.YPadding = gtkYPadding;
|
||||
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
||||
*minimum = 0; // allow arbitrary resize
|
||||
*natural = height;
|
||||
|
@ -94,8 +94,8 @@ static void containerWidget_get_preferred_width(GtkWidget *widget, gint *minimum
|
|||
intmax_t width, height;
|
||||
uiSizing d;
|
||||
|
||||
d.xPadding = gtkXPadding;
|
||||
d.yPadding = gtkYPadding;
|
||||
d.XPadding = gtkXPadding;
|
||||
d.YPadding = gtkYPadding;
|
||||
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
||||
*minimum = 0; // allow arbitrary resize
|
||||
*natural = width;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -150,9 +150,9 @@ 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.sys = &sys;
|
||||
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;
|
||||
}
|
||||
|
@ -319,9 +319,9 @@ static void containerResize(uiControl *cc, intmax_t x, intmax_t y, intmax_t widt
|
|||
{
|
||||
struct container *c = (struct container *) (cc->Internal);
|
||||
|
||||
if (SetWindowPos(c->hwnd, d->sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0)
|
||||
if (SetWindowPos(c->hwnd, d->Sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0)
|
||||
logLastError("error resizing uiContainer in containerResize()");
|
||||
d->sys->InsertAfter = c->hwnd;
|
||||
d->Sys->InsertAfter = c->hwnd;
|
||||
// under some circumstances this might not be sufficient
|
||||
// example: check the Spaced checkbox; inside boxes will have been resized already before they get a chance to update their padded
|
||||
SendMessageW(c->hwnd, msgUpdateChild, 0, 0);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -55,9 +55,9 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i
|
|||
{
|
||||
struct singleHWND *s = (struct singleHWND *) (c->Internal);
|
||||
|
||||
if (SetWindowPos(s->hwnd, d->sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0)
|
||||
if (SetWindowPos(s->hwnd, d->Sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0)
|
||||
logLastError("error moving control in singleResize()");
|
||||
d->sys->InsertAfter = s->hwnd;
|
||||
d->Sys->InsertAfter = s->hwnd;
|
||||
}
|
||||
|
||||
static int singleVisible(uiControl *c)
|
||||
|
|
Loading…
Reference in New Issue