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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
#if 0
/* To check for memory leaks */
#define VLD_MAX_DATA_DUMP 80
#include <vld.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"
#include "iupcontrols.h"
#include "iupkey.h"
/* Must define BIG_TEST on the Project and include in the build all test files */
#ifdef BIG_TEST
void ButtonTest(void);
void CanvasScrollbarTest(void);
void CanvasTest(void);
void CanvasCDDBufferTest(void);
void CanvasCDSimpleTest(void);
void DialogTest(void);
void FrameTest(void);
void TabsTest(void);
void SysInfoTest(void);
void GetColorTest(void);
#ifdef USE_OPENGL
void GLCanvasTest(void);
void GLCanvasCubeTest(void);
#endif
void HboxTest(void);
void IdleTest(void);
void LabelTest(void);
void ListTest(void);
void MatrixTest(void);
void MatrixCbModeTest(void);
void MatrixCbsTest(void);
void MdiTest(void);
void VboxTest(void);
void MenuTest(void);
void ColorBrowserTest(void);
void ColorbarTest(void);
void CellsNumberingTest(void);
void DialTest(void);
void GaugeTest(void);
void CellsDegradeTest(void);
void CellsCheckboardTest(void);
void ValTest(void);
void TreeTest(void);
void TrayTest(void);
void ToggleTest(void);
void TimerTest(void);
void TextSpinTest(void);
void TextTest(void);
void SpinTest(void);
void SampleTest(void);
void ProgressbarTest(void);
void PreDialogsTest(void);
#ifdef PPLOT_TEST
void PPlotTest(void);
#endif
void GetParamTest(void);
void ConfTest(void);
void ZboxTest(void);
void ScanfTest(void);
void SboxTest(void);
void SplitTest(void);
void ClipboardTest(void);
void HelpTest(void)
{
IupHelp("http://www.tecgraf.puc-rio.br/iup");
//IupHelp("..\\html\\index.html");
}
typedef struct _TestItems{
char* title;
void (*func)(void);
}TestItems;
static TestItems test_list[] = {
{"Button", ButtonTest},
{"Canvas", CanvasTest},
{"CanvasCDSimpleTest", CanvasCDSimpleTest},
{"CanvasCDDBuffer", CanvasCDDBufferTest},
{"CanvasScrollbar", CanvasScrollbarTest},
{"CellsCheckboard", CellsCheckboardTest},
{"CellsDegrade", CellsDegradeTest},
{"CellsNumbering", CellsNumberingTest},
{"Class Conference", ConfTest},
{"Clipboard", ClipboardTest},
{"ColorBrowser", ColorBrowserTest},
{"Colorbar", ColorbarTest},
{"Dial", DialTest},
{"Dialog", DialogTest},
{"Frame", FrameTest},
#ifdef USE_OPENGL
{"GLCanvas", GLCanvasTest},
{"GLCanvasCube", GLCanvasCubeTest},
#endif
{"Gauge", GaugeTest},
{"GetColor", GetColorTest},
{"GetParam", GetParamTest},
{"Help", HelpTest},
{"Hbox", HboxTest},
{"Idle", IdleTest},
{"Label", LabelTest},
{"List", ListTest},
{"Matrix", MatrixTest},
{"MatrixCbMode", MatrixCbModeTest},
{"MatrixCbs", MatrixCbsTest},
{"Mdi", MdiTest},
{"Menu", MenuTest},
#ifdef PPLOT_TEST
{"PPlot", PPlotTest},
#endif
{"PreDialogs", PreDialogsTest},
{"Progressbar", ProgressbarTest},
{"Sample", SampleTest},
{"Sbox", SboxTest},
{"Split", SplitTest},
{"Scanf", ScanfTest},
{"Spin", SpinTest},
{"SysInfo", SysInfoTest},
{"Tabs", TabsTest},
{"Text", TextTest},
{"TextSpin", TextSpinTest},
{"Timer", TimerTest},
{"Toggle", ToggleTest},
{"Tray", TrayTest},
{"Tree", TreeTest},
{"Val", ValTest},
{"Vbox", VboxTest},
{"Zbox", ZboxTest},
};
static int k_enter_cb(Ihandle*ih)
{
int pos = IupGetInt(ih, "VALUE");
if (pos > 0)
test_list[pos-1].func();
return IUP_DEFAULT;
}
static int button_cb(Ihandle *ih,int but,int pressed,int x,int y,char* status)
{
(void)pressed;
if (but==IUP_BUTTON1 && iup_isdouble(status))
{
int pos = IupConvertXYToPos(ih, x, y);
test_list[pos-1].func();
return IUP_IGNORE;
}
return IUP_DEFAULT;
}
static int close_cb(Ihandle *ih)
{
(void)ih;
return IUP_CLOSE;
}
int main(int argc, char* argv[])
{
int i, count = sizeof(test_list)/sizeof(TestItems);
char str[50];
Ihandle *dlg, *list;
IupOpen(&argc, &argv);
IupControlsOpen();
dlg = IupDialog(IupVbox(list = IupList(NULL), NULL));
IupSetAttribute(dlg, "MARGIN", "10x10");
IupSetAttribute(dlg, "TITLE", "IupTests");
IupSetCallback(dlg, "CLOSE_CB", close_cb);
IupSetAttribute(list, "VISIBLELINES", "15");
IupSetAttribute(list, "EXPAND", "YES");
IupSetCallback(list, "BUTTON_CB", (Icallback)button_cb);
IupSetCallback(list, "K_CR", k_enter_cb);
for (i=0; i<count; i++)
{
sprintf(str, "%d", i+1);
IupSetAttribute(list, str, test_list[i].title);
}
IupShowXY(dlg, 100, IUP_CENTER);
IupMainLoop();
IupClose();
return EXIT_SUCCESS;
}
#endif
|