diff --git a/TODO.md b/TODO.md index 59ab34db..cf7c9407 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,4 @@ +- make OS X uiEntry width based on default in Interface Builder, not from sizeToFit - update state whenever setting parent - make the various onDestroy() functions take the uiControl instead - make sure all calls to uiControlResize() are preceded with calls to uiControlGetSizing() diff --git a/redo/ui_windows.h b/redo/ui_windows.h index 3d0150d6..b16cbc11 100644 --- a/redo/ui_windows.h +++ b/redo/ui_windows.h @@ -41,11 +41,9 @@ extern uiSizing *uiWindowsSizing(uiControl *); // and use this if you need the text of the window width _UI_EXTERN intmax_t uiWindowsWindowTextWidth(HWND hwnd); -// these functions get and set the window text for either a single HWND or a single-HWND uiControl +// these functions get and set the window text for a single HWND // the value returned should be freed with uiFreeText() _UI_EXTERN char *uiWindowsUtilText(HWND); -_UI_EXTERN char *uiWindowsSingleHWNDControlText(uiControl *); _UI_EXTERN void uiWindowsUtilSetText(HWND, const char *); -_UI_EXTERN void uiWindowsSingleHWNDControlSetText(uiControl *, const char *); #endif diff --git a/redo/windows/button.c b/redo/windows/button.c index 253317d3..5ddbd984 100644 --- a/redo/windows/button.c +++ b/redo/windows/button.c @@ -66,14 +66,20 @@ static void defaultOnClicked(uiButton *b, void *data) // do nothing } -static char *buttonText(uiButton *b) +static char *buttonText(uiButton *bb) { - return uiWindowsSingleHWNDControlText(uiControl(b)); + struct button *b = (struct button *) bb; + + return uiWindowsUtilText(b->hwnd); } -static void buttonSetText(uiButton *b, const char *text) +static void buttonSetText(uiButton *bb, const char *text) { - uiWindowsSingleHWNDControlSetText(uiControl(b), text); + struct button *b = (struct button *) bb; + + uiWindowsUtilSetText(b->hwnd, text); + // changing the text might necessitate a change in the button's size + uiControlQueueResize(uiControl(b)); } static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data) diff --git a/redo/windows/checkbox.c b/redo/windows/checkbox.c index 5faffe26..d73b42f9 100644 --- a/redo/windows/checkbox.c +++ b/redo/windows/checkbox.c @@ -63,14 +63,20 @@ static void defaultOnToggled(uiCheckbox *c, void *data) // do nothing } -static char *checkboxText(uiCheckbox *c) +static char *checkboxText(uiCheckbox *cc) { - return uiWindowsSingleHWNDControlText(uiControl(c)); + struct checkbox *c = (struct checkbox *) cc; + + return uiWindowsUtilText(c->hwnd); } -static void checkboxSetText(uiCheckbox *c, const char *text) +static void checkboxSetText(uiCheckbox *cc, const char *text) { - uiWindowsSingleHWNDControlSetText(uiControl(c), text); + struct checkbox *c = (struct checkbox *) cc; + + uiWindowsUtilSetText(c->hwnd, text); + // changing the text might necessitate a change in the checkbox's size + uiControlQueueResize(uiControl(c)); } static void checkboxOnToggled(uiCheckbox *cc, void (*f)(uiCheckbox *, void *), void *data) diff --git a/redo/windows/control.c b/redo/windows/control.c index eb099a27..348f070f 100644 --- a/redo/windows/control.c +++ b/redo/windows/control.c @@ -188,12 +188,6 @@ char *uiWindowsUtilText(HWND hwnd) return text; } -// TODO get rid of these I guess -char *uiWindowsSingleHWNDControlText(uiControl *c) -{ - return uiWindowsUtilText(HWND(c)); -} - void uiWindowsUtilSetText(HWND hwnd, const char *text) { WCHAR *wtext; @@ -203,8 +197,3 @@ void uiWindowsUtilSetText(HWND hwnd, const char *text) logLastError("error setting control text in uiWindowsControlSetText()"); uiFree(wtext); } - -void uiWindowsSingleHWNDControlSetText(uiControl *c, const char *text) -{ - uiWindowsUtilSetText(HWND(c), text); -} diff --git a/redo/windows/entry.c b/redo/windows/entry.c index 10370b82..3260a519 100644 --- a/redo/windows/entry.c +++ b/redo/windows/entry.c @@ -55,9 +55,11 @@ static void defaultOnChanged(uiEntry *e, void *data) // do nothing } -static char *entryText(uiEntry *e) +static char *entryText(uiEntry *ee) { - return uiWindowsSingleHWNDControlText(uiControl(e)); + struct entry *e = (struct entry *) ee; + + return uiWindowsUtilText(e->hwnd); } static void entrySetText(uiEntry *ee, const char *text) @@ -66,8 +68,9 @@ static void entrySetText(uiEntry *ee, const char *text) // doing this raises an EN_CHANGED e->inhibitChanged = TRUE; - uiWindowsSingleHWNDControlSetText(uiControl(e), text); + uiWindowsUtilSetText(e->hwnd, text); e->inhibitChanged = FALSE; + // don't queue the control for resize; entry sizes are independent of their contents } static void entryOnChanged(uiEntry *ee, void (*f)(uiEntry *, void *), void *data) diff --git a/redo/windows/label.c b/redo/windows/label.c index a86118a6..27180fce 100644 --- a/redo/windows/label.c +++ b/redo/windows/label.c @@ -26,14 +26,20 @@ static void labelPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma *height = uiWindowsDlgUnitsToY(labelHeight, d->Sys->BaseY); } -static char *labelText(uiLabel *l) +static char *labelText(uiLabel *ll) { - return uiWindowsSingleHWNDControlText(uiControl(l)); + struct label *l = (struct label *) ll; + + return uiWindowsUtilText(l->hwnd); } -static void labelSetText(uiLabel *l, const char *text) +static void labelSetText(uiLabel *ll, const char *text) { - uiWindowsSingleHWNDControlSetText(uiControl(l), text); + struct label *l = (struct label *) ll; + + uiWindowsUtilSetText(l->hwnd, text); + // changing the text might necessitate a change in the label's size + uiControlQueueResize(uiControl(l)); } uiLabel *uiNewLabel(const char *text) diff --git a/redo/windows/window.c b/redo/windows/window.c index ddade42f..24f25466 100644 --- a/redo/windows/window.c +++ b/redo/windows/window.c @@ -130,14 +130,19 @@ static void windowCommitShow(uiControl *c) // TODO container update state -static char *windowTitle(uiWindow *w) +static char *windowTitle(uiWindow *ww) { - return uiWindowsSingleHWNDControlText(uiControl(w)); + struct window *w = (struct window *) ww; + + return uiWindowsUtilText(w->hwnd); } -static void windowSetTitle(uiWindow *w, const char *title) +static void windowSetTitle(uiWindow *ww, const char *title) { - uiWindowsSingleHWNDControlSetText(uiControl(w), title); + struct window *w = (struct window *) ww; + + uiWindowsUtilSetText(w->hwnd, 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) } static void windowOnClosing(uiWindow *ww, int (*f)(uiWindow *, void *), void *data)