aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/test/page12.c
blob: 5a8e963fba9b8c798d3ca2e0bf8bfa3381334304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 22 may 2016
#include "test.h"

// 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();

	b = half(uiNewMultilineEntry, "wrap");
	uiBoxAppend(page12, uiControl(b), 1);
	b = half(uiNewNonWrappingMultilineEntry, "no wrap");
	uiBoxAppend(page12, uiControl(b), 1);

	return page12;
}