]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
gui-toolbar
authorJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 07:10:39 +0000 (09:10 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 07:10:39 +0000 (09:10 +0200)
src/gui-toolbar.cpp
src/gui-toolbar.h

index eec05c71a3714c4fbaa93fb93440ab2dc35c2ef2..3eac3772beddb973413e924528d5f8ef888375e9 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
-#include "gui-button.h"
 #include "gui-toolbar.h"
-#include "texture.h"
 #include "wchar.h"
-#include "wrapped.h"
+
+
+using namespace irr;
+
+
+SCM
+irr_gui_IGUIToolBar_addButton (SCM gui_toolbar,
+                               SCM id,
+                               SCM text,
+                               SCM tooltiptext,
+                               SCM img,
+                               SCM pressedimg,
+                               SCM is_push_button,
+                               SCM use_alpha_channel)
+{
+  gui::IGUIToolBar* toolbar = (gui::IGUIToolBar*) scm_to_pointer (gui_toolbar);
+  gui::IGUIButton* button =
+    toolbar->addButton (scm_to_int32 (id),
+                        scm_to_wide_char_string (text),
+                        scm_to_wide_char_string (tooltiptext),
+                        (video::ITexture*) scm_to_pointer (img),
+                        (video::ITexture*) scm_to_pointer (pressedimg),
+                        scm_to_bool (is_push_button),
+                        scm_to_bool (use_alpha_channel));
+  return scm_from_pointer ((void*) button, NULL);
+}
+
 
 extern "C" {
 
   void
   init_gui_toolbar (void)
   {
-    init_gui_toolbar_type ();
-  }
-
-  DEFINE_WRAPPED_TYPE (irr::gui::IGUIToolBar*, "gui-toolbar",
-                       init_gui_toolbar_type, gui_toolbar_p,
-                       wrap_gui_toolbar, unwrap_gui_toolbar);
-
-  SCM
-  irr_gui_IGUIToolBar_addButton (SCM wrapped_gui_toolbar,
-                                 SCM rest)
-  {
-    SCM id = scm_from_int32 (-1);
-    SCM text = SCM_UNDEFINED;
-    SCM tooltiptext = SCM_UNDEFINED;
-    SCM img = SCM_UNDEFINED;
-    SCM pressedimg = SCM_UNDEFINED;
-    SCM is_push_button = SCM_BOOL_F;
-    SCM use_alpha_channel = SCM_BOOL_F;
-
-    scm_c_bind_keyword_arguments ("add-button!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("text"), &text,
-                                  scm_from_utf8_keyword ("tooltiptext"), &tooltiptext,
-                                  scm_from_utf8_keyword ("img"), &img,
-                                  scm_from_utf8_keyword ("pressedimg"), &pressedimg,
-                                  scm_from_utf8_keyword ("is_push_button"), &is_push_button,
-                                  scm_from_utf8_keyword ("use_alpha_channel"), &use_alpha_channel,
-                                  SCM_UNDEFINED);
-
-    irr::gui::IGUIToolBar* toolbar = unwrap_gui_toolbar (wrapped_gui_toolbar);
-    irr::gui::IGUIButton* button =
-      toolbar->addButton (scm_to_int32 (id),
-                          text == SCM_UNDEFINED ? 0 : scm_to_wide_char_string (text),
-                          tooltiptext == SCM_UNDEFINED ? 0 : scm_to_wide_char_string (tooltiptext),
-                          img == SCM_UNDEFINED ? 0 : unwrap_texture (img),
-                          pressedimg == SCM_UNDEFINED ? 0 : unwrap_texture (pressedimg),
-                          scm_to_bool (is_push_button),
-                          scm_to_bool (use_alpha_channel));
-    return wrap_gui_button (button);
+    DEFINE_GSUBR ("irr_gui_IGUIToolBar_addButton", 8, 0, 0, irr_gui_IGUIToolBar_addButton);
   }
 
 }
index 4d09b6c7ed5ee0cc6737d9223f339000ae121e1a..e40a96fd532976efd09d961a1781e548b2aabef1 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "wrapped.h"
 
 extern "C" {
-
   void
   init_gui_toolbar (void);
-
-  DECLARE_WRAPPED_TYPE (irr::gui::IGUIToolBar*, init_gui_toolbar_type,
-                        gui_toolbar_p, wrap_gui_toolbar, unwrap_gui_toolbar);
-
-  SCM
-  irr_gui_IGUIToolBar_addButton (SCM wrapped_gui_toolbar,
-                                 SCM rest);
-
 }
 
 #endif