]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/gui-toolbar.cpp
add-button!
[guile-irrlicht.git] / src / gui-toolbar.cpp
diff --git a/src/gui-toolbar.cpp b/src/gui-toolbar.cpp
new file mode 100644 (file)
index 0000000..cc571e8
--- /dev/null
@@ -0,0 +1,77 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+#include "gui-button.h"
+#include "gui-toolbar.h"
+#include "texture.h"
+#include "wchar.h"
+#include "wrapped.h"
+
+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_BOOL_F;
+    SCM tooltiptext = SCM_BOOL_F;
+    SCM img = SCM_BOOL_F;
+    SCM pressedimg = SCM_BOOL_F;
+    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),
+                          scm_is_false (text) ? 0 : scm_to_wide_char_string (text),
+                          scm_is_false (tooltiptext) ? 0 : scm_to_wide_char_string (tooltiptext),
+                          scm_is_false (img) ? 0 : unwrap_texture (img),
+                          scm_is_false (pressedimg) ? 0 : unwrap_texture (pressedimg),
+                          scm_to_bool (is_push_button),
+                          scm_to_bool (use_alpha_channel));
+    return wrap_gui_button (button);
+  }
+
+}