gwenhywfar
4.8.0beta
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
gui
qt4
qt4/libtest.cpp
Go to the documentation of this file.
1
2
#undef BUILDING_QT4_GUI
3
4
#include "
qt4_gui.hpp
"
5
#include "../testdialogs/dlg_test.h"
6
7
#include <gwenhywfar/gwenhywfar.h>
8
#include <gwenhywfar/gui.h>
9
#include <gwenhywfar/dialog.h>
10
#include <gwenhywfar/debug.h>
11
12
#include <qapplication.h>
13
14
#include <unistd.h>
15
16
17
18
int
test1
(
int
argc,
char
**argv) {
19
QApplication a(argc, argv);
20
QT4_Gui
*gui;
21
int
rv;
22
GWEN_DIALOG
*dlg;
23
24
rv=
GWEN_Init
();
25
if
(rv) {
26
DBG_ERROR_ERR
(0, rv);
27
return
2;
28
}
29
30
GWEN_Logger_SetLevel
(0,
GWEN_LoggerLevel_Info
);
31
32
/* create GUI */
33
gui=
new
QT4_Gui
();
34
GWEN_Gui_SetGui
(gui->
getCInterface
());
35
36
dlg=
Dlg_Test1_new
();
37
if
(dlg==
NULL
) {
38
fprintf(stderr,
"Could not create dialog.\n"
);
39
return
2;
40
}
41
42
rv=
GWEN_Gui_ExecDialog
(dlg, 0);
43
fprintf(stderr,
"Result: %d\n"
, rv);
44
45
return
0;
46
}
47
48
49
50
int
test2
(
int
argc,
char
**argv) {
51
QApplication a(argc, argv);
52
QT4_Gui
*gui;
53
QString lf;
54
int
rv;
55
uint32_t pid;
56
57
rv=
GWEN_Init
();
58
if
(rv) {
59
DBG_ERROR_ERR
(0, rv);
60
return
2;
61
}
62
63
GWEN_Logger_SetLevel
(0,
GWEN_LoggerLevel_Info
);
64
65
/* create GUI */
66
gui=
new
QT4_Gui
();
67
GWEN_Gui_SetGui
(gui->
getCInterface
());
68
69
70
#if 0
71
pid=
GWEN_Gui_ProgressStart
(
GWEN_GUI_PROGRESS_SHOW_PROGRESS
|
GWEN_GUI_PROGRESS_KEEP_OPEN
,
72
"Progress-Title"
,
73
"This is an example progress with 2 steps"
74
"<html>This is an <strong>example</strong> progress with 2 steps</html>"
,
75
2,
76
0);
77
#else
78
pid=
GWEN_Gui_ProgressStart
(
GWEN_GUI_PROGRESS_SHOW_PROGRESS
|
GWEN_GUI_PROGRESS_KEEP_OPEN
,
79
"Progress-Title"
,
80
"This is an <b>example</b> progress with 2 steps"
,
81
2,
82
0);
83
#endif
84
85
GWEN_Gui_ProgressAdvance
(pid, 1);
86
rv=
GWEN_Gui_MessageBox
(
GWEN_GUI_MSG_FLAGS_TYPE_INFO
,
87
"MessageBox-Title"
,
88
"This message box should appear in the context of the open progress dialog"
,
89
"Button1"
,
90
"Button2"
,
91
"Button3"
,
92
pid);
93
GWEN_Gui_ProgressAdvance
(pid, 2);
94
GWEN_Gui_ProgressEnd
(pid);
95
96
return
0;
97
}
98
99
100
101
int
test3
(
int
argc,
char
**argv) {
102
int
rv;
103
uint32_t id1;
104
uint32_t id2;
105
uint64_t i1;
106
uint64_t i2;
107
QApplication a(argc, argv);
108
QT4_Gui
*gui;
109
110
gui=
new
QT4_Gui
();
111
GWEN_Gui_SetGui
(gui->
getCInterface
());
112
113
id1=
GWEN_Gui_ProgressStart
(
GWEN_GUI_PROGRESS_SHOW_LOG
|
114
GWEN_GUI_PROGRESS_SHOW_ABORT
|
115
GWEN_GUI_PROGRESS_KEEP_OPEN
,
116
"Progress-Title"
,
117
"<html>"
118
"<p><b>This</b> is an example <i>text</i>..</p>"
119
"<p>As you can see <font color=red>colors</font> can "
120
"be used.</p>"
121
"</html>"
,
122
10,
123
0);
124
for
(i1=1; i1<=10; i1++) {
125
char
numbuf[128];
126
127
snprintf(numbuf,
sizeof
(numbuf)-1,
"Step %d\n"
, (
int
)i1);
128
GWEN_Gui_ProgressLog
(id1,
GWEN_LoggerLevel_Notice
, numbuf);
129
id2=
GWEN_Gui_ProgressStart
(
GWEN_GUI_PROGRESS_SHOW_LOG
|
130
GWEN_GUI_PROGRESS_DELAY
|
131
GWEN_GUI_PROGRESS_SHOW_ABORT
,
132
"2nd progress"
,
133
"Starting 2nd progress..."
,
134
10,
135
id1);
136
for
(i2=1; i2<=10; i2++) {
137
sleep(1);
138
fprintf(stderr,
"Advancing %d/%d\n"
, (
int
)i1, (
int
)i2);
139
rv=
GWEN_Gui_ProgressAdvance
(id2, i2);
140
if
(rv==
GWEN_ERROR_USER_ABORTED
) {
141
fprintf(stderr,
"Aborted by user (2)\n"
);
142
break
;
143
}
144
}
145
GWEN_Gui_ProgressEnd
(id2);
146
147
rv=
GWEN_Gui_ProgressAdvance
(id1, i1);
148
if
(rv==
GWEN_ERROR_USER_ABORTED
) {
149
fprintf(stderr,
"Aborted by user (1)\n"
);
150
break
;
151
}
152
}
153
154
GWEN_Gui_ProgressEnd
(id1);
155
156
return
0;
157
}
158
159
160
161
int
main
(
int
argc,
char
**argv) {
162
return
test1
(argc, argv);
163
//return test2(argc, argv);
164
//return test3(argc, argv);
165
}
166
Generated on Tue Nov 12 2013 10:50:21 for gwenhywfar by
1.8.1.2