Added uiComboboxSetSelected(), which we need for the uiArea drawing tests. Will implement next.
This commit is contained in:
parent
6424ea00ab
commit
581cbaecc9
|
@ -223,9 +223,18 @@ static void drawOriginal(uiAreaDrawParams *p)
|
|||
|
||||
static const struct drawtest tests[] = {
|
||||
{ "Original uiArea test", drawOriginal },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
void runDrawTest(intmax_t n, uiAreaDrawParams *p)
|
||||
{
|
||||
(*(tests[n].draw))(p);
|
||||
}
|
||||
|
||||
void populateComboboxWithTests(uiCombobox *c)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; test[i].name != NULL; i++)
|
||||
uiComboboxAppend(c, tests[i].name);
|
||||
}
|
||||
|
|
15
test/page6.c
15
test/page6.c
|
@ -78,6 +78,16 @@ static void onAmountChanged(uiSpinbox *s, void *data)
|
|||
uiAreaUpdateScroll(area);
|
||||
}
|
||||
|
||||
static void shouldntHappen(uiCombobox *c, void *data)
|
||||
{
|
||||
fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not.");
|
||||
}
|
||||
|
||||
static void redraw(uiCombobox *c, void *data)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
uiBox *makePage6(void)
|
||||
{
|
||||
uiBox *page6;
|
||||
|
@ -97,6 +107,11 @@ uiBox *makePage6(void)
|
|||
uiBoxAppend(page6, uiControl(hbox), 0);
|
||||
|
||||
which = uiNewCombobox();
|
||||
populateComboboxWithTests(which);
|
||||
// this is to make sure that uiComboboxOnSelected() doesn't trigger with uiComboboxSetSelected()
|
||||
uiComboboxOnSelected(which, shouldntHappen, NULL);
|
||||
uiComboboxSetSelected(which, 0);
|
||||
uiComboboxOnSelected(which, redraw, NULL);
|
||||
uiBoxAppend(hbox, uiControl(which), 0);
|
||||
|
||||
// make these first in case the area handler calls the information as part of the constructor
|
||||
|
|
|
@ -52,3 +52,4 @@ extern uiBox *makePage6(void);
|
|||
|
||||
// drawtests.c
|
||||
extern void runDrawTest(intmax_t, uiAreaDrawParams *);
|
||||
extern void populateComboboxWithTests(uiCombobox *);
|
||||
|
|
2
ui.h
2
ui.h
|
@ -203,7 +203,7 @@ _UI_EXTERN uintmax_t uiComboboxType(void);
|
|||
#define uiCombobox(this) ((uiCombobox *) uiIsA((this), uiComboboxType(), 1))
|
||||
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
||||
_UI_EXTERN intmax_t uiComboboxSelected(uiCombobox *c);
|
||||
// TODO SetSelected
|
||||
_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, intmax_t n);
|
||||
_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data);
|
||||
_UI_EXTERN uiCombobox *uiNewCombobox(void);
|
||||
_UI_EXTERN uiCombobox *uiNewEditableCombobox(void);
|
||||
|
|
Loading…
Reference in New Issue