]> git.jsancho.org Git - c-irrlicht.git/blobdiff - src/IGUIEnvironment.cpp
Use structs with casting, without classes replication
[c-irrlicht.git] / src / IGUIEnvironment.cpp
index b5bc9e1b97ab6306319081463cb645f473fc3d0e..6fc3cfa05ae254ad8448fdf797fb5a4d8c12047c 100644 (file)
 #include "IGUIEnvironment.h"
 
 extern "C" {
-  void* irr_gui_IGUIEnvironment_addStaticText(void* guienv,
-                                              const char* text,
-                                              const irr_core_rect_s32* rectangle,
-                                              bool border,
-                                              bool wordWrap,
-                                              void* parent,
-                                              int32_t id,
-                                              bool fillBackground)
+  irr_gui_IGUIStaticText*
+  irr_gui_addStaticText(irr_gui_IGUIEnvironment* guienv,
+                        const char* text,
+                        const irr_core_rect_s32* rectangle,
+                        bool border,
+                        bool wordWrap,
+                        irr_gui_IGUIElement* parent,
+                        int32_t id,
+                        bool fillBackground)
   {
     // Convert to wide char text
     wchar_t *wtext = (wchar_t*)malloc((strlen(text) + 1) * sizeof(wchar_t));
-    mbsrtowcs(wtext, &text, strlen(text) + 1, NULL);
-
-    // Make rectangle
-    irr::core::rect<irr::s32> rect =            \
-      irr::core::rect<irr::s32>(rectangle->x,
-                                rectangle->y,
-                                rectangle->x2,
-                                rectangle->y2);
+    mbstowcs(wtext, text, strlen(text) + 1);
 
     // Add static text
-    irr::gui::IGUIStaticText *staticText =                              \
-      ((irr::gui::IGUIEnvironment*)guienv)->addStaticText(wtext,
-                                                          rect,
-                                                          border,
-                                                          wordWrap,
-                                                          (irr::gui::IGUIElement*)parent,
-                                                          id,
-                                                          fillBackground);
+    irr::gui::IGUIStaticText *staticText =
+      ((irr::gui::IGUIEnvironment*)guienv)
+      ->addStaticText(wtext,
+                      *(irr::core::rect<irr::s32>*)rectangle,
+                      border,
+                      wordWrap,
+                      (irr::gui::IGUIElement*)parent,
+                      id,
+                      fillBackground);
     return staticText;
   }
+
+  void
+  irr_gui_drawAll(irr_gui_IGUIEnvironment* guienv)
+  {
+    ((irr::gui::IGUIEnvironment*)guienv)->drawAll();
+  }
 }