Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Commit last experimental bits (dated December 6th, 2013). master
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 4 Nov 2022 20:20:14 +0000 (21:20 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 4 Nov 2022 20:20:14 +0000 (21:20 +0100)
simpledw/SimpleDW.cpp [new file with mode: 0644]
simpledw/SimpleDW.h [new file with mode: 0644]
simpledw/a.cpp [new file with mode: 0644]
simpledw/a.pro [new file with mode: 0644]

diff --git a/simpledw/SimpleDW.cpp b/simpledw/SimpleDW.cpp
new file mode 100644 (file)
index 0000000..f9ccf15
--- /dev/null
@@ -0,0 +1,38 @@
+#include <QApplication>
+#include <DrawingWindow.h>
+
+extern void simpleDW_user_main_wrapper();
+
+namespace {
+    DrawingWindow *global_w;
+    int global_argc;
+    char **global_argv;
+
+    void drawing_function(DrawingWindow& w)
+    {
+        global_w = &w;
+        simpleDW_user_main_wrapper();
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    QApplication application(argc, argv);
+    global_argc = argc;
+    global_argv = argv;
+    DrawingWindow window(drawing_function);
+    window.show();
+    return application.exec();
+}
+
+#include <SimpleDW.h>
+
+void drawText(int x, int y, const char *text, int flags)
+{
+    global_w->drawText(x, y, text, flags);
+}
+
+void drawText(int x, int y, const std::string &text, int flags)
+{
+    global_w->drawText(x, y, text, flags);
+}
diff --git a/simpledw/SimpleDW.h b/simpledw/SimpleDW.h
new file mode 100644 (file)
index 0000000..370d670
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef SIMPLE_DW_H
+#define SIMPLE_DW_H
+
+#include <string>
+
+void drawText(int x, int y, const char *text, int flags = 0);
+void drawText(int x, int y, const std::string &text, int flags = 0);
+
+#define SDW_CHECK_ARGS(A, B, ...) SDW_CHECK_ARGS_(__VA_ARGS__, B, A)
+#define SDW_CHECK_ARGS_(a2, a1, X, ...) X
+
+#define call0()                                         \
+    simpleDW_user_main()
+
+#define call2()                                         \
+    extern int global_argc;                             \
+    extern char **global_argv;                          \
+    simpleDW_user_main(global_argc, global_argv)
+
+#define main(...)                                         \
+    simpleDW_user_main(__VA_ARGS__);                      \
+    void simpleDW_user_main_wrapper()                     \
+    {                                                     \
+        SDW_CHECK_ARGS(call0(), call2(), __VA_ARGS__);    \
+    }                                                     \
+    int simpleDW_user_main(__VA_ARGS__)
+
+#endif // !SIMPLE_DW_H
diff --git a/simpledw/a.cpp b/simpledw/a.cpp
new file mode 100644 (file)
index 0000000..a8d433b
--- /dev/null
@@ -0,0 +1,9 @@
+#include <iostream>
+#include "SimpleDW.h"
+
+int main()
+{
+    std::cout << "Coucou !\n";
+    drawText(50, 50, "Coucou!");
+    return 0;
+}
diff --git a/simpledw/a.pro b/simpledw/a.pro
new file mode 100644 (file)
index 0000000..800a1dd
--- /dev/null
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = a
+
+CONFIG += qt
+CONFIG += debug
+
+HEADERS += SimpleDW.h DrawingWindow.h
+SOURCES += SimpleDW.cpp DrawingWindow.cpp
+
+SOURCES += a.cpp