From ce65817f3b6ff2b8d65378bb61f85667ab183fb1 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 4 Nov 2022 21:20:14 +0100 Subject: [PATCH] Commit last experimental bits (dated December 6th, 2013). --- simpledw/SimpleDW.cpp | 38 ++++++++++++++++++++++++++++++++++++++ simpledw/SimpleDW.h | 28 ++++++++++++++++++++++++++++ simpledw/a.cpp | 9 +++++++++ simpledw/a.pro | 10 ++++++++++ 4 files changed, 85 insertions(+) create mode 100644 simpledw/SimpleDW.cpp create mode 100644 simpledw/SimpleDW.h create mode 100644 simpledw/a.cpp create mode 100644 simpledw/a.pro diff --git a/simpledw/SimpleDW.cpp b/simpledw/SimpleDW.cpp new file mode 100644 index 0000000..f9ccf15 --- /dev/null +++ b/simpledw/SimpleDW.cpp @@ -0,0 +1,38 @@ +#include +#include + +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 + +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 index 0000000..370d670 --- /dev/null +++ b/simpledw/SimpleDW.h @@ -0,0 +1,28 @@ +#ifndef SIMPLE_DW_H +#define SIMPLE_DW_H + +#include + +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 index 0000000..a8d433b --- /dev/null +++ b/simpledw/a.cpp @@ -0,0 +1,9 @@ +#include +#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 index 0000000..800a1dd --- /dev/null +++ b/simpledw/a.pro @@ -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 -- 2.20.1