00001
00002 #undef BUILDING_QT4_GUI
00003
00004 #include "qt4_gui.hpp"
00005 #include "../testdialogs/dlg_test.h"
00006
00007 #include <gwenhywfar/gwenhywfar.h>
00008 #include <gwenhywfar/gui.h>
00009 #include <gwenhywfar/dialog.h>
00010 #include <gwenhywfar/debug.h>
00011
00012 #include <qapplication.h>
00013
00014
00015 int test1(int argc, char **argv) {
00016 QApplication a(argc, argv);
00017 QT4_Gui *gui;
00018 int rv;
00019 GWEN_DIALOG *dlg;
00020
00021 rv=GWEN_Init();
00022 if (rv) {
00023 DBG_ERROR_ERR(0, rv);
00024 return 2;
00025 }
00026
00027 GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
00028
00029
00030 gui=new QT4_Gui();
00031 GWEN_Gui_SetGui(gui->getCInterface());
00032
00033 dlg=Dlg_Test1_new();
00034 if (dlg==NULL) {
00035 fprintf(stderr, "Could not create dialog.\n");
00036 return 2;
00037 }
00038
00039 rv=GWEN_Gui_ExecDialog(dlg, 0);
00040 fprintf(stderr, "Result: %d\n", rv);
00041
00042 return 0;
00043 }
00044
00045
00046
00047 int test2(int argc, char **argv) {
00048 QApplication a(argc, argv);
00049 QT4_Gui *gui;
00050 QString lf;
00051 int rv;
00052 uint32_t pid;
00053
00054 rv=GWEN_Init();
00055 if (rv) {
00056 DBG_ERROR_ERR(0, rv);
00057 return 2;
00058 }
00059
00060 GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
00061
00062
00063 gui=new QT4_Gui();
00064 GWEN_Gui_SetGui(gui->getCInterface());
00065
00066
00067 #if 0
00068 pid=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_PROGRESS | GWEN_GUI_PROGRESS_KEEP_OPEN,
00069 "Progress-Title",
00070 "This is an example progress with 2 steps"
00071 "<html>This is an <strong>example</strong> progress with 2 steps</html>",
00072 2,
00073 0);
00074 #else
00075 pid=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_PROGRESS | GWEN_GUI_PROGRESS_KEEP_OPEN,
00076 "Progress-Title",
00077 "This is an <b>example</b> progress with 2 steps",
00078 2,
00079 0);
00080 #endif
00081
00082 GWEN_Gui_ProgressAdvance(pid, 1);
00083 rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_INFO,
00084 "MessageBox-Title",
00085 "This message box should appear in the context of the open progress dialog",
00086 "Button1",
00087 "Button2",
00088 "Button3",
00089 pid);
00090 GWEN_Gui_ProgressAdvance(pid, 2);
00091 GWEN_Gui_ProgressEnd(pid);
00092
00093 return 0;
00094 }
00095
00096
00097
00098 int test3(int argc, char **argv) {
00099 int rv;
00100 uint32_t id1;
00101 uint32_t id2;
00102 uint64_t i1;
00103 uint64_t i2;
00104 QApplication a(argc, argv);
00105 QT4_Gui *gui;
00106
00107 gui=new QT4_Gui();
00108 GWEN_Gui_SetGui(gui->getCInterface());
00109
00110 id1=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG |
00111 GWEN_GUI_PROGRESS_SHOW_ABORT |
00112 GWEN_GUI_PROGRESS_KEEP_OPEN,
00113 "Progress-Title",
00114 "<html>"
00115 "<p><b>This</b> is an example <i>text</i>..</p>"
00116 "<p>As you can see <font color=red>colors</font> can "
00117 "be used.</p>"
00118 "</html>",
00119 10,
00120 0);
00121 for (i1=1; i1<=10; i1++) {
00122 char numbuf[128];
00123
00124 snprintf(numbuf, sizeof(numbuf)-1, "Step %d\n", (int)i1);
00125 GWEN_Gui_ProgressLog(id1, GWEN_LoggerLevel_Notice, numbuf);
00126 id2=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG |
00127 GWEN_GUI_PROGRESS_DELAY |
00128 GWEN_GUI_PROGRESS_SHOW_ABORT,
00129 "2nd progress",
00130 "Starting 2nd progress...",
00131 10,
00132 id1);
00133 for (i2=1; i2<=10; i2++) {
00134 sleep(1);
00135 fprintf(stderr, "Advancing %d/%d\n", (int)i1, (int)i2);
00136 rv=GWEN_Gui_ProgressAdvance(id2, i2);
00137 if (rv==GWEN_ERROR_USER_ABORTED) {
00138 fprintf(stderr, "Aborted by user (2)\n");
00139 break;
00140 }
00141 }
00142 GWEN_Gui_ProgressEnd(id2);
00143
00144 rv=GWEN_Gui_ProgressAdvance(id1, i1);
00145 if (rv==GWEN_ERROR_USER_ABORTED) {
00146 fprintf(stderr, "Aborted by user (1)\n");
00147 break;
00148 }
00149 }
00150
00151 GWEN_Gui_ProgressEnd(id1);
00152
00153 return 0;
00154 }
00155
00156
00157
00158 int main(int argc, char **argv) {
00159 return test1(argc, argv);
00160
00161
00162 }
00163