gwenhywfar 5.14.1
qt4/libtest.cpp
Go to the documentation of this file.
1
2#undef BUILDING_QT4_GUI
3
4#include "qt4_gui.hpp"
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
18int 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
31
32 /* create GUI */
33 gui=new QT4_Gui();
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
50int 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
64
65 /* create GUI */
66 gui=new QT4_Gui();
68
69
70#if 0
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
79 "Progress-Title",
80 "This is an <b>example</b> progress with 2 steps",
81 2,
82 0);
83#endif
84
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);
95
96 return 0;
97}
98
99
100
101int 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();
112
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);
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 }
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
155
156 return 0;
157}
158
159
160
161int main(int argc, char **argv) {
162 return test1(argc, argv);
163 //return test2(argc, argv);
164 //return test3(argc, argv);
165}
166
#define NULL
Definition binreloc.c:300
GWEN_GUI * getCInterface()
Definition cppgui.cpp:373
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
Definition debug.h:113
struct GWEN_DIALOG GWEN_DIALOG
Definition dialog.h:54
GWEN_DIALOG * Dlg_Test1_new()
Definition dlg_test.c:293
#define GWEN_ERROR_USER_ABORTED
Definition error.h:65
void GWEN_Gui_SetGui(GWEN_GUI *gui)
Definition gui.c:170
GWENHYWFAR_API int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid)
#define GWEN_GUI_PROGRESS_DELAY
Definition gui.h:192
#define GWEN_GUI_PROGRESS_KEEP_OPEN
Definition gui.h:198
GWENHYWFAR_API uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags, const char *title, const char *text, uint64_t total, uint32_t guiid)
#define GWEN_GUI_PROGRESS_SHOW_PROGRESS
Definition gui.h:197
#define GWEN_GUI_MSG_FLAGS_TYPE_INFO
Definition gui.h:281
GWENHYWFAR_API int GWEN_Gui_ProgressEnd(uint32_t id)
GWENHYWFAR_API int GWEN_Gui_MessageBox(uint32_t flags, const char *title, const char *text, const char *b1, const char *b2, const char *b3, uint32_t guiid)
GWENHYWFAR_API int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
#define GWEN_GUI_PROGRESS_SHOW_ABORT
Definition gui.h:194
#define GWEN_GUI_PROGRESS_SHOW_LOG
Definition gui.h:193
GWENHYWFAR_API int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress)
int GWEN_Init(void)
Definition gwenhywfar.c:92
int test1()
Definition libtest.m:63
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
Definition logger.c:472
@ GWEN_LoggerLevel_Notice
Definition logger.h:67
@ GWEN_LoggerLevel_Info
Definition logger.h:68
int main(int argc, char **argv)
int test3(int argc, char **argv)
int test2(int argc, char **argv)