]> git.jsancho.org Git - guile-irrlicht.git/blob - src/gui-toolbar.cpp
Use SCM_UNDEFINED for undefined arguments
[guile-irrlicht.git] / src / gui-toolbar.cpp
1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
2
3    Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
4
5    This file is part of guile-irrlicht.
6
7    guile-irrlicht is free software; you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 3 of the
10    License, or (at your option) any later version.
11
12    guile-irrlicht is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with guile-irrlicht. If not, see
19    <http://www.gnu.org/licenses/>.
20 */
21
22 #include <irrlicht/irrlicht.h>
23 #include <libguile.h>
24
25 #include "gui-button.h"
26 #include "gui-toolbar.h"
27 #include "texture.h"
28 #include "wchar.h"
29 #include "wrapped.h"
30
31 extern "C" {
32
33   void
34   init_gui_toolbar (void)
35   {
36     init_gui_toolbar_type ();
37   }
38
39   DEFINE_WRAPPED_TYPE (irr::gui::IGUIToolBar*, "gui-toolbar",
40                        init_gui_toolbar_type, gui_toolbar_p,
41                        wrap_gui_toolbar, unwrap_gui_toolbar);
42
43   SCM
44   irr_gui_IGUIToolBar_addButton (SCM wrapped_gui_toolbar,
45                                  SCM rest)
46   {
47     SCM id = scm_from_int32 (-1);
48     SCM text = SCM_UNDEFINED;
49     SCM tooltiptext = SCM_UNDEFINED;
50     SCM img = SCM_UNDEFINED;
51     SCM pressedimg = SCM_UNDEFINED;
52     SCM is_push_button = SCM_BOOL_F;
53     SCM use_alpha_channel = SCM_BOOL_F;
54
55     scm_c_bind_keyword_arguments ("add-button!", rest, (scm_t_keyword_arguments_flags)0,
56                                   scm_from_utf8_keyword ("id"), &id,
57                                   scm_from_utf8_keyword ("text"), &text,
58                                   scm_from_utf8_keyword ("tooltiptext"), &tooltiptext,
59                                   scm_from_utf8_keyword ("img"), &img,
60                                   scm_from_utf8_keyword ("pressedimg"), &pressedimg,
61                                   scm_from_utf8_keyword ("is_push_button"), &is_push_button,
62                                   scm_from_utf8_keyword ("use_alpha_channel"), &use_alpha_channel,
63                                   SCM_UNDEFINED);
64
65     irr::gui::IGUIToolBar* toolbar = unwrap_gui_toolbar (wrapped_gui_toolbar);
66     irr::gui::IGUIButton* button =
67       toolbar->addButton (scm_to_int32 (id),
68                           text == SCM_UNDEFINED ? 0 : scm_to_wide_char_string (text),
69                           tooltiptext == SCM_UNDEFINED ? 0 : scm_to_wide_char_string (tooltiptext),
70                           img == SCM_UNDEFINED ? 0 : unwrap_texture (img),
71                           pressedimg == SCM_UNDEFINED ? 0 : unwrap_texture (pressedimg),
72                           scm_to_bool (is_push_button),
73                           scm_to_bool (use_alpha_channel));
74     return wrap_gui_button (button);
75   }
76
77 }