From 60627e13a1e7f1ffdb6090e815a1aee44881f5fa Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 22 May 2016 23:05:37 -0400 Subject: [PATCH] Fleshed out page 12. --- test/page12.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/test/page12.c b/test/page12.c index dc06e279..5a8e963f 100644 --- a/test/page12.c +++ b/test/page12.c @@ -1,16 +1,60 @@ // 22 may 2016 #include "test.h" -// TODO add buttons for event testing and Append scroll/selection changing. +// TODO OS X: if the hboxes are empty, the text views don't show up + +static void meChanged(uiMultilineEntry *e, void *data) +{ + printf("%s changed\n", (char *) data); +} + +static void setClicked(uiButton *b, void *data) +{ + uiMultilineEntrySetText(uiMultilineEntry(data), "set"); +} + +static void appendClicked(uiButton *b, void *data) +{ + uiMultilineEntryAppend(uiMultilineEntry(data), "append\n"); +} + +static uiBox *half(uiMultilineEntry *(*mk)(void), const char *which) +{ + uiBox *vbox, *hbox; + uiMultilineEntry *me; + uiButton *button; + + vbox = newVerticalBox(); + + me = (*mk)(); + uiMultilineEntryOnChanged(me, meChanged, (void *) which); + uiBoxAppend(vbox, uiControl(me), 1); + + hbox = newHorizontalBox(); + uiBoxAppend(vbox, uiControl(hbox), 0); + + button = uiNewButton("Set"); + uiButtonOnClicked(button, setClicked, me); + uiBoxAppend(hbox, uiControl(button), 0); + + button = uiNewButton("Append"); + uiButtonOnClicked(button, appendClicked, me); + uiBoxAppend(hbox, uiControl(button), 0); + + return vbox; +} uiBox *makePage12(void) { uiBox *page12; + uiBox *b; page12 = newHorizontalBox(); - uiBoxAppend(page12, uiControl(uiNewMultilineEntry()), 1); - uiBoxAppend(page12, uiControl(uiNewNonWrappingMultilineEntry()), 1); + b = half(uiNewMultilineEntry, "wrap"); + uiBoxAppend(page12, uiControl(b), 1); + b = half(uiNewNonWrappingMultilineEntry, "no wrap"); + uiBoxAppend(page12, uiControl(b), 1); return page12; }