]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/gui-element.cpp
Cast to the proper wrapped object when a gui event is raised
[guile-irrlicht.git] / src / gui-element.cpp
index e93872d7600a51f537b6cd44e907dedd2ba85140..6ee3dccc3dd395434ee5c51b0e78d7dd92cb0574 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
+#include "gsubr.h"
 #include "gui-element.h"
 #include "wrapped.h"
 
-extern "C" {
+using namespace irr;
 
-  void
-  init_gui_element (void)
-  {
-    init_gui_element_type ();
-  }
-
-  DEFINE_WRAPPED_TYPE (irr::gui::IGUIElement*, "gui-element",
-                       init_gui_element_type, gui_element_p,
-                       wrap_gui_element, unwrap_gui_element);
+template <typename T>
+SCM
+IGUIElement_getID (SCM gui_element)
+{
+  T element = (T) scm_to_irr_pointer (gui_element);
+  return scm_from_int32 (element->getID ());
+}
 
+void
+init_gui_element (void)
+{
+  DEFINE_GSUBR ("IGUIButton_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIButton*>);
+  DEFINE_GSUBR ("IGUIEditBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIEditBox*>);
+  DEFINE_GSUBR ("IGUIElement_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIElement*>);
+  DEFINE_GSUBR ("IGUIImage_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIImage*>);
+  DEFINE_GSUBR ("IGUIListBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIListBox*>);
+  DEFINE_GSUBR ("IGUIScrollBar_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIScrollBar*>);
+  DEFINE_GSUBR ("IGUIStaticText_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIStaticText*>);
 }