]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/gui-listbox.cpp
Some doc
[guile-irrlicht.git] / src / gui-listbox.cpp
index 599eca70a0f29408cfc3712d97df0d765be16130..a839690c1034711cd93910f74c733514bdbaff3f 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
 #include "gui-listbox.h"
 #include "gsubr.h"
-#include "wchar.h"
 #include "wrapped.h"
 
-extern "C" {
-
-  void
-  init_gui_listbox (void)
-  {
-    init_gui_listbox_type ();
-    DEFINE_GSUBR ("add-listbox-item!", 2, 1, 0, irr_gui_IGUIListBox_addItem);
-  }
-
-  DEFINE_WRAPPED_TYPE (irr::gui::IGUIListBox*, "gui-listbox",
-                       init_gui_listbox_type, gui_listbox_p,
-                       wrap_gui_listbox, unwrap_gui_listbox);
-
-  SCM
-  irr_gui_IGUIListBox_addItem (SCM wrapped_gui_listbox,
-                               SCM text,
-                               SCM icon)
-  {
-    irr::gui::IGUIListBox* listbox = unwrap_gui_listbox (wrapped_gui_listbox);
-    irr::u32 item_id;
-    if (icon == SCM_UNDEFINED)
-      {
-        item_id = listbox->addItem (scm_to_wide_char_string (text));
-      }
-    else
-      {
-        item_id = listbox->addItem (scm_to_wide_char_string (text),
-                                    scm_to_int32 (icon));
-      }
-    return scm_from_uint32 (item_id);
-  }
+using namespace irr;
+
+SCM
+IGUIListBox_addItem (SCM gui_listbox,
+                     SCM text,
+                     SCM icon)
+{
+  gui::IGUIListBox* listbox = (gui::IGUIListBox*)scm_to_irr_pointer (gui_listbox);
+  wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
+  u32 item_id;
+  if (icon == SCM_UNDEFINED)
+    {
+      item_id = listbox->addItem (wtext);
+    }
+  else
+    {
+      item_id = listbox->addItem (wtext,
+                                  scm_to_int32 (icon));
+    }
+  free (wtext);
+  return scm_from_uint32 (item_id);
+}
 
+void
+init_gui_listbox (void)
+{
+  DEFINE_GSUBR ("IGUIListBox_addItem", 2, 1, 0, IGUIListBox_addItem);
 }