1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
3 Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
5 This file is part of guile-irrlicht.
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.
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.
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/>.
22 #include <irrlicht/irrlicht.h>
25 #include "gui-environment.h"
26 #include "position2d.h"
33 template <typename TParent>
35 IGUIEnvironment_addButton (SCM gui_environment,
42 gui::IGUIButton* button =
43 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
44 addButton (scm_to_rect_s32 (rectangle),
45 (TParent)scm_to_irr_pointer (parent),
47 scm_to_wide_char_string (text),
48 scm_to_wide_char_string (tooltiptext));
49 return scm_from_pointer ((void*)button, NULL);
52 template <typename TParent>
54 IGUIEnvironment_addEditBox (SCM gui_environment,
61 gui::IGUIEditBox* editbox =
62 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
63 addEditBox (scm_to_wide_char_string (text),
64 scm_to_rect_s32 (rectangle),
66 (TParent)scm_to_irr_pointer (parent),
68 return scm_from_pointer ((void*)editbox, NULL);
71 template <typename TParent>
73 IGUIEnvironment_addImage (SCM gui_environment,
76 SCM use_alpha_channel,
81 gui::IGUIEnvironment* guienv = (gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment);
82 gui::IGUIImage* new_image =
83 guienv->addImage ((video::ITexture*)scm_to_irr_pointer (image),
84 scm_to_position2d_s32 (position),
85 scm_to_bool (use_alpha_channel),
86 (TParent)scm_to_irr_pointer (parent),
88 scm_to_wide_char_string (text));
89 return scm_from_pointer ((void*) new_image, NULL);
92 template <typename TParent>
94 IGUIEnvironment_addListBox (SCM gui_environment,
100 gui::IGUIListBox* listbox =
101 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
102 addListBox (scm_to_rect_s32 (rectangle),
103 (TParent)scm_to_irr_pointer (parent),
105 scm_to_bool (draw_background));
106 return scm_from_pointer ((void*)listbox, NULL);
109 template <typename TParent>
111 IGUIEnvironment_addScrollBar (SCM gui_environment,
117 gui::IGUIScrollBar* scrollbar =
118 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
119 addScrollBar (scm_to_bool (horizontal),
120 scm_to_rect_s32 (rectangle),
121 (TParent)scm_to_irr_pointer (parent),
123 return scm_from_pointer ((void*)scrollbar, NULL);
126 template <typename TParent>
128 IGUIEnvironment_addStaticText (SCM gui_environment,
137 gui::IGUIStaticText* static_text =
138 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
139 addStaticText (scm_to_wide_char_string (text),
140 scm_to_rect_s32 (rectangle),
141 scm_to_bool (border),
142 scm_to_bool (word_wrap),
143 (TParent)scm_to_irr_pointer (parent),
145 scm_to_bool (fill_background));
146 return scm_from_pointer ((void*)static_text, NULL);
149 template <typename TParent>
151 IGUIEnvironment_addWindow (SCM gui_environment,
158 gui::IGUIWindow* window =
159 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
160 addWindow (scm_to_rect_s32 (rectangle),
162 scm_to_wide_char_string (text),
163 (TParent)scm_to_irr_pointer (parent),
165 return scm_from_pointer ((void*)window, NULL);
169 IGUIEnvironment_drawAll (SCM gui_environment)
171 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->drawAll ();
172 return SCM_UNSPECIFIED;
176 IGUIEnvironment_getBuiltInFont (SCM gui_environment)
178 gui::IGUIFont* font =
179 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->getBuiltInFont ();
180 return scm_from_pointer ((void*)font, NULL);
184 IGUIEnvironment_getFont (SCM gui_environment,
187 gui::IGUIFont* font =
188 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
189 getFont (scm_to_utf8_string (filename));
190 return scm_from_pointer ((void*)font, NULL);
194 IGUIEnvironment_getSkin (SCM gui_environment)
196 gui::IGUISkin* skin =
197 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->getSkin ();
198 return scm_from_pointer ((void*)skin, NULL);
202 init_gui_environment (void)
204 DEFINE_GSUBR ("IGUIEnvironment_addButton_IGUIElement", 6, 0, 0,
205 IGUIEnvironment_addButton<gui::IGUIElement*>);
206 DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
207 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
208 DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
209 IGUIEnvironment_addImage<gui::IGUIElement*>);
210 DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
211 IGUIEnvironment_addListBox<gui::IGUIElement*>);
212 DEFINE_GSUBR ("IGUIEnvironment_addScrollBar_IGUIElement", 5, 0, 0,
213 IGUIEnvironment_addScrollBar<gui::IGUIElement*>);
214 DEFINE_GSUBR ("IGUIEnvironment_addStaticText_IGUIElement", 8, 0, 0,
215 IGUIEnvironment_addStaticText<gui::IGUIElement*>);
216 DEFINE_GSUBR ("IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0,
217 IGUIEnvironment_addWindow<gui::IGUIElement*>);
218 DEFINE_GSUBR ("IGUIEnvironment_drawAll", 1, 0, 0, IGUIEnvironment_drawAll);
219 DEFINE_GSUBR ("IGUIEnvironment_getBuiltInFont", 1, 0, 0, IGUIEnvironment_getBuiltInFont);
220 DEFINE_GSUBR ("IGUIEnvironment_getFont", 2, 0, 0, IGUIEnvironment_getFont);
221 DEFINE_GSUBR ("IGUIEnvironment_getSkin", 1, 0, 0, IGUIEnvironment_getSkin);