Have controls whose size depends on their text request a resize on text changed. This fixes the TODO removed in the previous commit. Also removed the single-HWND control text functions and added more TODOs.
This commit is contained in:
parent
0b7dc94822
commit
f01b6303e9
1
TODO.md
1
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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue