diff --git a/redo/ui_windows.h b/redo/ui_windows.h index 55ea7498..5d6d2850 100644 --- a/redo/ui_windows.h +++ b/redo/ui_windows.h @@ -101,6 +101,8 @@ _UI_EXTERN int uiWindowsUtilHasTabStops(HWND hwnd); // InternalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning. // CoordFrom and CoordTo are the window handles to convert coordinates passed to uiControlResize() from and to (viaa MapWindowRect()) before passing to one of the Windows API resizing functions. struct uiWindowsSizing { + intmax_t XPadding; + intmax_t YPadding; int BaseX; int BaseY; LONG InternalLeading; diff --git a/redo/windows/OLDradiobuttons.c b/redo/windows/OLDradiobuttons.c index 7ab9f8d9..01d6223e 100644 --- a/redo/windows/OLDradiobuttons.c +++ b/redo/windows/OLDradiobuttons.c @@ -76,7 +76,7 @@ static void radiobuttonsCommitSetParent(uiControl *c, uiControl *parent) // from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx #define radiobuttonXFromLeftOfBoxToLeftOfLabel 12 -static void radiobuttonsPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) +static void radiobuttonsPreferredSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { struct radiobuttons *r = (struct radiobuttons *) c; uintmax_t i; @@ -92,7 +92,7 @@ static void radiobuttonsPreferredSize(uiControl *c, uiSizing *d, intmax_t *width *height = uiWindowsDlgUnitsToY(radiobuttonHeight, d->Sys->BaseY) * r->hwnds->len; } -static void radiobuttonsResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) +static void radiobuttonsResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiWindowsSizing *d) { struct radiobuttons *r = (struct radiobuttons *) c; intmax_t height1; @@ -114,7 +114,7 @@ static void radiobuttonsResize(uiControl *c, intmax_t x, intmax_t y, intmax_t wi } } -static uiSizing *radiobuttonsSizing(uiControl *c) +static uiWindowsSizing *radiobuttonsSizing(uiControl *c) { complain("attempt to call uiControlSizing() on uiRadioButtons %p", c); return NULL; diff --git a/redo/windows/OLDspinbox.c b/redo/windows/OLDspinbox.c index ac730a91..b8eb6838 100644 --- a/redo/windows/OLDspinbox.c +++ b/redo/windows/OLDspinbox.c @@ -88,7 +88,7 @@ static void spinboxCommitSetParent(uiControl *c, uiControl *parent) #define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define entryHeight 14 -static void spinboxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) +static void spinboxPreferredSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = uiWindowsDlgUnitsToX(entryWidth, d->Sys->BaseX); *height = uiWindowsDlgUnitsToY(entryHeight, d->Sys->BaseY); @@ -136,7 +136,7 @@ static void recreateUpDown(struct spinbox *s) s->inhibitChanged = FALSE; } -static void spinboxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) +static void spinboxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiWindowsSizing *d) { struct spinbox *s = (struct spinbox *) c; @@ -144,7 +144,7 @@ static void spinboxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, recreateUpDown(s); } -static uiSizing *spinboxSizing(uiControl *c) +static uiWindowsSizing *spinboxSizing(uiControl *c) { complain("attempt to call uiControlSizing() on uiSpinbox %p", c); return NULL; diff --git a/redo/windows/box.c b/redo/windows/box.c index 311f34ef..7f2803bb 100644 --- a/redo/windows/box.c +++ b/redo/windows/box.c @@ -1,8 +1,7 @@ // 7 april 2015 -#include "out/ui.h" -#include "uipriv.h" +#include "uipriv_windows.h" -struct box { +struct uiBox { uiWindowsControl c; HWND hwnd; struct ptrArray *controls; @@ -31,14 +30,14 @@ static void onDestroy(uiBox *b) struct child *bc; while (b->controls->len != 0) { - bc = ptrArrayIndex(b->controls, struct boxControl *, 0); + bc = ptrArrayIndex(b->controls, struct child *, 0); ptrArrayDelete(b->controls, 0); childDestroy(bc); } ptrArrayDestroy(b->controls); } -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { /* TODO uiBox *b = uiBox(c); @@ -77,7 +76,7 @@ static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intma maxStretchyWidth = 0; maxStretchyHeight = 0; for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); if (!uiControlContainerVisible(bc->c)) continue; uiControlPreferredSize(bc->c, d, &preferredWidth, &preferredHeight); @@ -109,17 +108,17 @@ static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intma */ } -static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) +static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiWindowsSizing *d) { /* TODO uibox *b = uiBox(c); - struct boxControl *bc; + struct child *bc; int xpadding, ypadding; uintmax_t nStretchy; intmax_t stretchywid, stretchyht; uintmax_t i; intmax_t preferredWidth, preferredHeight; - uiSizing *dchild; + uiWindowsSizing *dchild; (*(b->baseResize))(uiControl(b), x, y, width, height, d); @@ -147,7 +146,7 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi stretchyht = height; nStretchy = 0; for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); if (!uiControlContainerVisible(bc->c)) continue; if (bc->stretchy) { @@ -173,7 +172,7 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi else stretchywid /= nStretchy; for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); if (!uiControlContainerVisible(bc->c)) continue; if (bc->stretchy) { @@ -185,7 +184,7 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi // 3) now we can position controls dchild = uiControlSizing(uiControl(b)); for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); if (!uiControlContainerVisible(bc->c)) continue; uiControlResize(bc->c, x, y, bc->width, bc->height, dchild); @@ -201,12 +200,12 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi /* TODO static int boxHasTabStops(uiControl *c) { - struct box *b = (struct box *) c; - struct boxControl *bc; + uiBox *b = uiBox(c); + struct child *bc; uintmax_t i; for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); if (uiControlHasTabStops(bc->c)) return 1; } @@ -216,7 +215,7 @@ static int boxHasTabStops(uiControl *c) static void boxContainerUpdateState(uiControl *c) { - struct box *b = (struct box *) c; + uiBox *b = uiBox(c); struct child *bc; uintmax_t i; @@ -239,12 +238,12 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) dozorder = 0; if (b->controls->len != 0) { dozorder = 1; - bc = ptrArrayIndex(b->controls, struct boxControl *, 0); + bc = ptrArrayIndex(b->controls, struct child *, 0); zorder = uiControlStartZOrder(bc->c); } */ - bc = newChild(child, uiControl(b), b->hwnd); + bc = newChild(c, uiControl(b), b->hwnd); ctrlSetStretchy(bc, stretchy); ptrArrayAppend(b->controls, bc); uiControlQueueResize(uiControl(b)); @@ -253,7 +252,7 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) // and now update the zorder for all controls if (dozorder) for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct boxControl *, i); + bc = ptrArrayIndex(b->controls, struct child *, i); zorder = uiControlSetZOrder(bc->c, zorder); } */ @@ -286,7 +285,7 @@ static uiBox *finishNewBox(int vertical) b = (uiBox *) uiNewControl(uiBoxType()); - b->hwnd = makeContainer(); + b->hwnd = newContainer(); b->vertical = vertical; b->controls = newPtrArray(); diff --git a/redo/windows/button.c b/redo/windows/button.c index 8c5aa952..4906294f 100644 --- a/redo/windows/button.c +++ b/redo/windows/button.c @@ -28,7 +28,7 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult) // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing #define buttonHeight 14 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiButton *b = uiButton(c); SIZE size; diff --git a/redo/windows/checkbox.c b/redo/windows/checkbox.c index d4df3ffb..bd7a1984 100644 --- a/redo/windows/checkbox.c +++ b/redo/windows/checkbox.c @@ -38,7 +38,7 @@ static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult) // from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx #define checkboxXFromLeftOfBoxToLeftOfLabel 12 -static void minimumSize(uiControl *cc, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *cc, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiCheckbox *c = uiCheckbox(cc); diff --git a/redo/windows/child.c b/redo/windows/child.c index adfc8b63..2d28e01b 100644 --- a/redo/windows/child.c +++ b/redo/windows/child.c @@ -51,7 +51,7 @@ struct child *newChildWithTabPage(uiControl *child, uiControl *parent, HWND pare void childRemove(struct child *c) { - uiWindowsEnsureSetParent(c->hwnd, utilwin); + uiWindowsEnsureSetParent(c->hwnd, utilWindow); uiControlSetParent(c->c, NULL); if (c->tabpage != NULL) uiWindowsEnsureDestroyWindow(c->tabpage); @@ -75,7 +75,7 @@ HWND childHWND(struct child *c) void childMinimumSize(struct child *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiWindowsControl *wc; - intmax_t left, top, right, bottom + intmax_t left, top, right, bottom; wc = uiWindowsControl(c->c); (*(wc->MinimumSize))(wc, d, width, height); @@ -122,7 +122,7 @@ int childMargined(struct child *c) return c->margined; } -void childSetMargined(struct child *c) +void childSetMargined(struct child *c, int margined) { c->margined = margined; uiControlQueueResize(c->c); diff --git a/redo/windows/combobox.c b/redo/windows/combobox.c index 33ae1c2b..b56724f4 100644 --- a/redo/windows/combobox.c +++ b/redo/windows/combobox.c @@ -17,7 +17,7 @@ uiWindowsDefineControl( #define comboboxWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define comboboxHeight 14 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = uiWindowsDlgUnitsToX(comboboxWidth, d->BaseX); *height = uiWindowsDlgUnitsToY(comboboxHeight, d->BaseY); diff --git a/redo/windows/datetimepicker.c b/redo/windows/datetimepicker.c index 33e5c5c4..44f3f3ed 100644 --- a/redo/windows/datetimepicker.c +++ b/redo/windows/datetimepicker.c @@ -110,16 +110,16 @@ static void setDateTimeFormat(HWND hwnd) // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing #define entryHeight 14 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *dd, intmax_t *width, intmax_t *height) { uiDateTimePicker *d = uiDateTimePicker(c); SIZE s; s.cx = 0; s.cy = 0; - SendMessageW(dd->hwnd, DTM_GETIDEALSIZE, 0, (LPARAM) (&s)); + SendMessageW(d->hwnd, DTM_GETIDEALSIZE, 0, (LPARAM) (&s)); *width = s.cx; - *height = uiWindowsDlgUnitsToY(entryHeight, d->BaseY); + *height = uiWindowsDlgUnitsToY(entryHeight, dd->BaseY); } static uiDateTimePicker *finishNewDateTimePicker(DWORD style) diff --git a/redo/windows/entry.c b/redo/windows/entry.c index 7341c429..01de551c 100644 --- a/redo/windows/entry.c +++ b/redo/windows/entry.c @@ -32,7 +32,7 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult) #define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define entryHeight 14 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = uiWindowsDlgUnitsToX(entryWidth, d->BaseX); *height = uiWindowsDlgUnitsToY(entryHeight, d->BaseY); @@ -83,7 +83,7 @@ uiEntry *uiNewEntry(void) { uiEntry *e; - e = (uiEntry *) uiWindowsNewSingleHWNDControl(uiNewControl()); + e = (uiEntry *) uiNewControl(uiEntryType()); e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", diff --git a/redo/windows/group.c b/redo/windows/group.c index a2930c8c..ab96a2ef 100644 --- a/redo/windows/group.c +++ b/redo/windows/group.c @@ -34,7 +34,7 @@ static void onDestroy(uiGroup *g) #define groupUnmarginedYMarginTop 8 #define groupUnmarginedYMarginBottom 3 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiGroup *g = uiGroup(c); @@ -51,13 +51,12 @@ static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intma } } -static void groupRelayout(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height) +static void groupRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height) { - struct group *g = (struct group *) c; - uiSizing *d; + uiGroup *g = uiGroup(c); + uiWindowsSizing *d; - // TODO - (*(g->baseResize))(uiControl(g), x, y, width, height, d); + uiWindowsEnsureMoveWindow(g->hwnd, x, y, width, height); if (g->child == NULL) return; @@ -136,8 +135,8 @@ uiGroup *uiNewGroup(const char *text) // TODO subclass uiGroup to call parent.c functions uiWindowsFinishNewControl(g, uiGroup); - uiControl(g)->Resize = groupRelayout; uiControl(g)->ContainerUpdateState = groupContainerUpdateState; + uiWindowsControl(g)->Relayout = groupRelayout; return g; } diff --git a/redo/windows/label.c b/redo/windows/label.c index 5c435594..f80c207f 100644 --- a/redo/windows/label.c +++ b/redo/windows/label.c @@ -14,7 +14,7 @@ uiWindowsDefineControl( // via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing #define labelHeight 8 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiLabel *l = uiLabel(c); diff --git a/redo/windows/menu.c b/redo/windows/menu.c index 15707566..32f820ba 100644 --- a/redo/windows/menu.c +++ b/redo/windows/menu.c @@ -76,36 +76,36 @@ static void onQuitClicked(uiMenuItem *item, uiWindow *w, void *data) void uiMenuItemEnable(uiMenuItem *i) { - item->disabled = FALSE; - sync(item); + i->disabled = FALSE; + sync(i); } void uiMenuItemDisable(uiMenuItem *i) { - item->disabled = TRUE; - sync(item); + i->disabled = TRUE; + sync(i); } void uiMenuItemOnClicked(uiMenuItem *i, void (*f)(uiMenuItem *, uiWindow *, void *), void *data) { - if (item->type == typeQuit) + if (i->type == typeQuit) complain("attempt to call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead"); - item->onClicked = f; - item->onClickedData = data; + i->onClicked = f; + i->onClickedData = data; } int uiMenuItemChecked(uiMenuItem *i) { - return item->checked != FALSE; + return i->checked != FALSE; } void uiMenuItemSetChecked(uiMenuItem *i, int checked) { // use explicit values - item->checked = FALSE; + i->checked = FALSE; if (checked) - item->checked = TRUE; - sync(item); + i->checked = TRUE; + sync(i); } static uiMenuItem *newItem(uiMenu *m, int type, const char *name) @@ -185,7 +185,7 @@ uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m) return newItem(m, typePreferences, NULL); } -uiMenuItem *uiMenuAppendAboutItem(uiMenu *mm) +uiMenuItem *uiMenuAppendAboutItem(uiMenu *m) { if (hasAbout) complain("attempt to add multiple About menu items"); diff --git a/redo/windows/progressbar.c b/redo/windows/progressbar.c index 4f28c778..749a327f 100644 --- a/redo/windows/progressbar.c +++ b/redo/windows/progressbar.c @@ -15,10 +15,10 @@ uiWindowsDefineControl( #define pbarWidth 237 #define pbarHeight 8 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { - *width = uiWindowsDlgUnitsToX(pbarWidth, d->Sys->BaseX); - *height = uiWindowsDlgUnitsToY(pbarHeight, d->Sys->BaseY); + *width = uiWindowsDlgUnitsToX(pbarWidth, d->BaseX); + *height = uiWindowsDlgUnitsToY(pbarHeight, d->BaseY); } // unfortunately, as of Vista progress bars have a forced animation on increase diff --git a/redo/windows/radiobuttons.c b/redo/windows/radiobuttons.c index 3eace2e0..f502f962 100644 --- a/redo/windows/radiobuttons.c +++ b/redo/windows/radiobuttons.c @@ -60,7 +60,7 @@ static void onDestroy(uiRadioButtons *r) // from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx #define radiobuttonXFromLeftOfBoxToLeftOfLabel 12 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { uiRadioButtons *r = uiRadioButtons(c); uintmax_t i; @@ -76,7 +76,7 @@ static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intma *height = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY) * r->hwnds->len; } -static void radiobuttonsRelayout(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height) +static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height) { /* TODO struct radiobuttons *r = (struct radiobuttons *) c; @@ -176,7 +176,7 @@ uiRadioButtons *uiNewRadioButtons(void) r->hwnds = newPtrArray(); uiWindowsFinishNewControl(r, uiRadioButtons); - uiControl(r)->Relayout = radiobuttonsRelayout; + uiWindowsControl(r)->Relayout = radiobuttonsRelayout; return r; } diff --git a/redo/windows/resize.c b/redo/windows/resize.c index d2ad0f4b..7366ac7e 100644 --- a/redo/windows/resize.c +++ b/redo/windows/resize.c @@ -53,7 +53,7 @@ void doResizes(void) } } -void moveWindow(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) +void moveWindow(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiWindowsSizing *d) { RECT r; @@ -61,7 +61,6 @@ void moveWindow(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t heig r.top = y; r.right = x + width; r.bottom = y + height; - mapWindowRect(d->Sys->CoordFrom, d->Sys->CoordTo, &r); if (SetWindowPos(hwnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER) == 0) logLastError("error moving window in moveWindow()"); } @@ -79,7 +78,7 @@ void setWindowInsertAfter(HWND hwnd, HWND insertAfter) uiWindowsSizing *uiWindowsNewSizing(HWND hwnd) { - uiSizing *d; + uiWindowsSizing *d; HDC dc; HFONT prevfont; TEXTMETRICW tm; diff --git a/redo/windows/separator.c b/redo/windows/separator.c index 77087570..94dc8961 100644 --- a/redo/windows/separator.c +++ b/redo/windows/separator.c @@ -18,10 +18,10 @@ uiWindowsDefineControl( // via https://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx #define separatorHeight 1 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = 1; // TODO - *height = uiWindowsDlgUnitsToY(separatorHeight, d->Sys->BaseY); + *height = uiWindowsDlgUnitsToY(separatorHeight, d->BaseY); } uiSeparator *uiNewHorizontalSeparator(void) diff --git a/redo/windows/slider.c b/redo/windows/slider.c index 5aded7c4..c6564671 100644 --- a/redo/windows/slider.c +++ b/redo/windows/slider.c @@ -27,7 +27,7 @@ static BOOL onWM_HSCROLL(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult) #define sliderWidth 107 /* this is actually the shorter progress bar width, but Microsoft doesn't indicate a width */ #define sliderHeight 15 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = uiWindowsDlgUnitsToX(sliderWidth, d->BaseX); *height = uiWindowsDlgUnitsToY(sliderHeight, d->BaseY); diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index 923cc6da..245675e8 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -76,7 +76,7 @@ static void onDestroy(uiSpinbox *s) #define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define entryHeight 14 -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { *width = uiWindowsDlgUnitsToX(entryWidth, d->BaseX); *height = uiWindowsDlgUnitsToY(entryHeight, d->BaseY); diff --git a/redo/windows/tab.c b/redo/windows/tab.c index 8ae74e10..6f398900 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -70,7 +70,7 @@ static void onDestroy(uiTab *t) uiWindowsUnregisterWM_NOTIFYHandler(t->hwnd); } -static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) +static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height) { /* TODO uiTab *t = uiTab(c); @@ -109,7 +109,7 @@ static void tabRelayout(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in LRESULT n; uiControl *page; RECT r; - uiSizing *dchild; + uiWindowsSizing *dchild; (*(t->baseResize))(uiControl(t), x, y, width, height, d); n = curpage(t); @@ -149,7 +149,7 @@ static void tabContainerUpdateState(uiControl *c) void uiTabAppend(uiTab *t, const char *name, uiControl *child) { - uiTabInsertAt(tt, name, t->pages->len, child); + uiTabInsertAt(t, name, t->pages->len, child); } void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) @@ -222,9 +222,9 @@ void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) uiTab *uiNewTab(void) { - struct tab *t; + uiTab *t; - t = (struct tab *) uiWindowsNewSingleHWNDControl(uiTypeTab()); + t = (uiTab *) uiNewControl(uiTabType()); t->hwnd = uiWindowsEnsureCreateControlHWND(0, // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see below) WC_TABCONTROLW, L"", diff --git a/redo/windows/tabpage.c b/redo/windows/tabpage.c index c3675f12..ea30d4d0 100644 --- a/redo/windows/tabpage.c +++ b/redo/windows/tabpage.c @@ -7,7 +7,7 @@ // from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx #define tabMargin 7 -static void tabPageMargins(HWND hwnd, intmax_t *left, intmax_t *right, intmax_t *right, intmax_t *bottom) +void tabPageMargins(HWND hwnd, intmax_t *left, intmax_t *top, intmax_t *right, intmax_t *bottom) { uiWindowsSizing *d; @@ -51,10 +51,10 @@ HWND newTabPage(void) // unfortunately this needs to be a proper dialog for EnableThemeDialogTexture() to work; CreateWindowExW() won't suffice hwnd = CreateDialogW(hInstance, MAKEINTRESOURCE(rcTabPageDialog), utilWindow, dlgproc); - if (t->hwnd == NULL) + if (hwnd == NULL) logLastError("error creating tab page in newTabPage()"); - hr = EnableThemeDialogTexture(t->hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB); + hr = EnableThemeDialogTexture(hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB); if (hr != S_OK) logHRESULT("error setting tab page background in newTabPage()", hr); diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index 5cdf34b3..025cbc51 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -1,6 +1,6 @@ // 6 january 2015 #include "winapi.h" -#include "../out/ui.h" +#include "../ui.h" #include "../ui_windows.h" #include "../uipriv.h" #include "resources.h" @@ -106,8 +106,12 @@ extern void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t widt extern void childUpdateState(struct child *c); extern HWND childTabPage(struct child *c); extern int childMargined(struct child *c); -extern void childSetMargined(struct child *c); +extern void childSetMargined(struct child *c, int margined); extern int childFlag(struct child *c); extern void childSetFlag(struct child *c, int flag); extern intmax_t childIntmax(struct child *c, int n); extern void childSetIntmax(struct child *c, int n, intmax_t to); + +// tabpage.c +extern void tabPageMargins(HWND, intmax_t *, intmax_t *, intmax_t *, intmax_t *); +extern HWND newTabPage(void); diff --git a/redo/windows/window.c b/redo/windows/window.c index f6502ce3..d8f354db 100644 --- a/redo/windows/window.c +++ b/redo/windows/window.c @@ -140,7 +140,7 @@ void uiWindowSetTitle(uiWindow *w, const char *title) // don't queue resize; the caption isn't part of what affects layout and sizing of the client area (it'll be ellipsized if too long) } -void uiWindowOnClosing(uiWindow *ww, int (*f)(uiWindow *, void *), void *data) +void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data) { w->onClosing = f; w->onClosingData = data; @@ -169,11 +169,11 @@ void uiWindowSetMargined(uiWindow *w, int margined) // from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing #define windowMargin 7 -static void windowResizeChild(uiWindow *ww) +/* TODO +static void windowResizeChild(uiWindow *w) { - struct window *w = (struct window *) ww; RECT r; - uiSizing *d; + uiWindowsSizing *d; if (w->child == NULL) return; @@ -189,6 +189,7 @@ static void windowResizeChild(uiWindow *ww) uiControlResize(w->child, r.left, r.top, r.right - r.left, r.bottom - r.top, d); uiFreeSizing(d); } +*/ // see http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/09/13/54917.aspx static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, DWORD style, DWORD exstyle)