Fixed public/private namespace clobbering in the Windows backend and a wrong name in ui_darwin.h.

This commit is contained in:
Pietro Gagliardi 2015-05-07 12:58:33 -04:00
parent 91f7096257
commit 38a5341603
10 changed files with 19 additions and 19 deletions

View File

@ -13,7 +13,7 @@ This file assumes that you have imported <Cocoa/Cocoa.h> and "ui.h" beforehand.
// The two onDestroy parameters define a function and its parameter to call when the widget is destroyed.
extern void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData);
// You can use this function from within your control implementations to return text strings that can be freed with uiTextFree().
// You can use this function from within your control implementations to return text strings that can be freed with uiFreeText().
extern char *uiDarwinNSStringToText(NSString *);
struct uiSizingSys {

View File

@ -43,8 +43,8 @@ struct uiSizingSys {
LONG internalLeading;
};
// Use these in your preferredSize() implementation with baseX and baseY.
#define uiDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
#define uiWindowsDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
#define uiWindowsDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
// and use this if you need the text of the window width
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);

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 = uiDlgUnitsToX(b->marginLeft, d->sys->baseX) + uiDlgUnitsToX(b->marginRight, d->sys->baseX);
marginY = uiDlgUnitsToY(b->marginTop, d->sys->baseY) + uiDlgUnitsToY(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 = uiDlgUnitsToX(b->marginLeft, d->sys->baseX);
marginTop = uiDlgUnitsToY(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 + uiDlgUnitsToX(b->marginRight, d->sys->baseX);
height -= marginTop + uiDlgUnitsToY(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 = uiDlgUnitsToY(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 = uiDlgUnitsToX(checkboxXFromLeftOfBoxToLeftOfLabel, d->sys->baseX) + uiWindowsWindowTextWidth(c->hwnd);
*height = uiDlgUnitsToY(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

@ -147,8 +147,8 @@ static HRESULT resize(uiContainer *cc, RECT *r)
if (ReleaseDC(c->hwnd, dc) == 0)
return logLastError("error releasing DC in resize()");
d.xPadding = uiDlgUnitsToX(winXPadding, sys.baseX);
d.yPadding = uiDlgUnitsToY(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 = uiDlgUnitsToX(entryWidth, d->sys->baseX);
*height = uiDlgUnitsToY(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 = uiDlgUnitsToY(labelHeight, d->sys->baseY);
*height = uiWindowsDlgUnitsToY(labelHeight, d->sys->baseY);
}
static char *labelText(uiLabel *l)

View File

@ -43,7 +43,7 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
// and we're changing to a real page
uiControlShow(uiControl(page->bin));
// because we only resize the current child on resize, we'll need to trigger an update here
// don't call uiParentUpdate(); doing that won't size the content area (so we'll still have a 0x0 content area, for instance)
// don't call uiContainerUpdate(); doing that won't size the content area (so we'll still have a 0x0 content area, for instance)
SendMessageW(t->hwnd, msgUpdateChild, 0, 0);
*lResult = 0;
return TRUE;

View File

@ -45,7 +45,7 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
// fall through
case msgUpdateChild:
if (GetClientRect(w->hwnd, &r) == 0)
logLastError("error getting window client rect for resize in uiWindowWndProc()");
logLastError("error getting window client rect for resize in windowWndProc()");
binhwnd = (HWND) uiControlHandle(uiControl(w->bin));
if (MoveWindow(binhwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0)
logLastError("error resizing uiWindow box in windowWndProc()");