bindings/cpp/samples: Added sample without macros
authorJerome St-Louis <jerome@ecere.com>
Wed, 1 Jun 2016 04:52:10 +0000 (00:52 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 21 Nov 2016 14:18:56 +0000 (09:18 -0500)
- Lacking eC registration however...
- Also fixed APP_SET_ARGS macro not using argument for app

bindings/cpp/eC.hpp
bindings/cpp/samples/sample5.cpp [new file with mode: 0644]

index 5a846ca..f70666d 100644 (file)
@@ -55,7 +55,7 @@
    _CONSTRUCT(c, b)
 
 #if !defined(__WIN32__) || defined(__CONSOLE_APP__)
-   #define APP_SET_ARGS(a) eC_setArgs(app, argc, argv)
+   #define APP_SET_ARGS(a) eC_setArgs(a, argc, argv)
 #else
    #define APP_SET_ARGS(a)
 #endif
diff --git a/bindings/cpp/samples/sample5.cpp b/bindings/cpp/samples/sample5.cpp
new file mode 100644 (file)
index 0000000..d990fe9
--- /dev/null
@@ -0,0 +1,53 @@
+#define MODULE_NAME  "HelloForm"
+
+#include "ecere.hpp"
+
+class HelloForm : public Window
+{
+public:
+   Button button;
+
+   HelloForm()
+   {
+      caption = $("Sample App using Ecere Toolkit/C++ Bindings");
+      borderStyle = sizable;
+      clientSize = { 640, 480 };
+      hasClose = true;
+      hasMaximize = true;
+      hasMinimize = true;
+      background = formColor;
+      font = { "Arial", 30 };
+
+      button.parent = this;
+      button.position = { 200, 200 };
+      button.caption = $("Yay!!");
+      button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
+      {
+         HelloForm & self = (HelloForm &)owner;
+         MessageBox msgBox;
+         msgBox.caption = self.button.caption;
+         msgBox.contents = $("C++ Bindings!");
+         msgBox.modal();
+         return true;
+      };
+
+      onRedraw = [](Window & w, Surface & surface) { surface.writeTextf(100, 100, $("Instance Method!")); };
+   }
+};
+GuiApplication app;
+HelloForm hello;
+
+extern "C" int
+#if defined(__WIN32__) && !defined(__CONSOLE_APP__)
+   __stdcall WinMain(void * hInstance, void * hPrevInst, char * cmdLine, int show)
+#else
+   main(int argc, char * argv[])
+#endif
+{
+#if !defined(__WIN32__) || defined(__CONSOLE_APP__)
+   eC_setArgs(app, argc, argv)
+#endif
+   app.main();
+   unloadTranslatedStrings(MODULE_NAME);
+   return app.exitCode;
+}