]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
add-listbox-item!
authorJavier Sancho <jsf@jsancho.org>
Tue, 28 Apr 2020 06:27:32 +0000 (08:27 +0200)
committerJavier Sancho <jsf@jsancho.org>
Tue, 28 Apr 2020 06:27:32 +0000 (08:27 +0200)
src/gui-listbox.cpp
src/gui-listbox.h

index 1c81998d4070b948c0cabf47088a8e9ca7fc04f8..599eca70a0f29408cfc3712d97df0d765be16130 100644 (file)
@@ -23,6 +23,8 @@
 #include <libguile.h>
 
 #include "gui-listbox.h"
+#include "gsubr.h"
+#include "wchar.h"
 #include "wrapped.h"
 
 extern "C" {
@@ -31,10 +33,30 @@ extern "C" {
   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);
+  }
+
 }
index 9e2baf36647cb92f05f9988cd8c83a0dad364b6e..23da3322d28d541fa688793a4783f5be75d44376 100644 (file)
@@ -34,6 +34,11 @@ extern "C" {
   DECLARE_WRAPPED_TYPE (irr::gui::IGUIListBox*, 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);
+
 }
 
 #endif