"Exported" uiSizing fields.

This commit is contained in:
Pietro Gagliardi 2015-05-07 14:33:46 -04:00
parent f74394fbac
commit 2107595ce7
11 changed files with 34 additions and 34 deletions

8
box.c
View File

@ -69,8 +69,8 @@ static void boxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
xpadding = 0; xpadding = 0;
ypadding = 0; ypadding = 0;
if (b->padded) { if (b->padded) {
xpadding = d->xPadding; xpadding = d->XPadding;
ypadding = d->yPadding; ypadding = d->YPadding;
} }
// 1) initialize the desired rect with the needed padding // 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; xpadding = 0;
ypadding = 0; ypadding = 0;
if (b->padded) { if (b->padded) {
xpadding = d->xPadding; xpadding = d->XPadding;
ypadding = d->yPadding; ypadding = d->YPadding;
} }
// 0) inset the available rect by the needed padding // 0) inset the available rect by the needed padding

View File

@ -35,8 +35,8 @@
y = [self bounds].origin.y; y = [self bounds].origin.y;
width = [self bounds].size.width; width = [self bounds].size.width;
height = [self bounds].size.height; height = [self bounds].size.height;
d.xPadding = macXPadding; d.XPadding = macXPadding;
d.yPadding = macYPadding; d.YPadding = macYPadding;
uiContainerResizeChildren(self->c, x, y, width, height, &d); uiContainerResizeChildren(self->c, x, y, width, height, &d);
} }

6
ui.idl
View File

@ -26,9 +26,9 @@ func FreeText(text *char);
raw "typedef struct uiSizingSys uiSizingSys;"; raw "typedef struct uiSizingSys uiSizingSys;";
struct Sizing { struct Sizing {
field xPadding intmax_t; field XPadding intmax_t;
field yPadding intmax_t; field YPadding intmax_t;
field sys *uiSizingSys; field Sys *uiSizingSys;
}; };
raw "typedef struct uiControlSysFuncParams uiControlSysFuncParams;"; raw "typedef struct uiControlSysFuncParams uiControlSysFuncParams;";

View File

@ -70,8 +70,8 @@ static void containerWidget_size_allocate(GtkWidget *widget, GtkAllocation *allo
uiSizing d; uiSizing d;
gtk_widget_set_allocation(GTK_WIDGET(c), allocation); gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
d.xPadding = gtkXPadding; d.XPadding = gtkXPadding;
d.yPadding = gtkYPadding; d.YPadding = gtkYPadding;
uiContainerResizeChildren(c->c, allocation->x, allocation->y, allocation->width, allocation->height, &d); 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; intmax_t width, height;
uiSizing d; uiSizing d;
d.xPadding = gtkXPadding; d.XPadding = gtkXPadding;
d.yPadding = gtkYPadding; d.YPadding = gtkYPadding;
uiControlPreferredSize(uiControl(c->c), &d, &width, &height); uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
*minimum = 0; // allow arbitrary resize *minimum = 0; // allow arbitrary resize
*natural = height; *natural = height;
@ -94,8 +94,8 @@ static void containerWidget_get_preferred_width(GtkWidget *widget, gint *minimum
intmax_t width, height; intmax_t width, height;
uiSizing d; uiSizing d;
d.xPadding = gtkXPadding; d.XPadding = gtkXPadding;
d.yPadding = gtkYPadding; d.YPadding = gtkYPadding;
uiControlPreferredSize(uiControl(c->c), &d, &width, &height); uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
*minimum = 0; // allow arbitrary resize *minimum = 0; // allow arbitrary resize
*natural = width; *natural = width;

View File

@ -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);
} }

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 // 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)

View File

@ -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)

View File

@ -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 // 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;
} }
@ -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); 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()"); logLastError("error resizing uiContainer in containerResize()");
d->sys->InsertAfter = c->hwnd; d->Sys->InsertAfter = c->hwnd;
// under some circumstances this might not be sufficient // 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 // 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); SendMessageW(c->hwnd, msgUpdateChild, 0, 0);

View File

@ -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)

View File

@ -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)

View File

@ -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); 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()"); logLastError("error moving control in singleResize()");
d->sys->InsertAfter = s->hwnd; d->Sys->InsertAfter = s->hwnd;
} }
static int singleVisible(uiControl *c) static int singleVisible(uiControl *c)