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 wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
43 wchar_t* wtooltiptext = (wchar_t*) scm_to_utf32_string (tooltiptext);
45 gui::IGUIButton* button =
46 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
47 addButton (scm_to_rect_s32 (rectangle),
48 (TParent)scm_to_irr_pointer (parent),
55 return scm_from_irr_pointer ("<gui-button>", (void*) button);
58 template <typename TParent>
60 IGUIEnvironment_addEditBox (SCM gui_environment,
67 wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
69 gui::IGUIEditBox* editbox =
70 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
72 scm_to_rect_s32 (rectangle),
74 (TParent)scm_to_irr_pointer (parent),
78 return scm_from_irr_pointer ("<gui-editbox>", (void*) editbox);
81 template <typename TParent>
83 IGUIEnvironment_addImage (SCM gui_environment,
86 SCM use_alpha_channel,
91 gui::IGUIEnvironment* guienv = (gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment);
92 wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
94 gui::IGUIImage* new_image =
95 guienv->addImage ((video::ITexture*)scm_to_irr_pointer (image),
96 scm_to_position2d_s32 (position),
97 scm_to_bool (use_alpha_channel),
98 (TParent)scm_to_irr_pointer (parent),
103 return scm_from_irr_pointer ("<gui-image>", (void*) new_image);
106 template <typename TParent>
108 IGUIEnvironment_addListBox (SCM gui_environment,
114 gui::IGUIListBox* listbox =
115 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
116 addListBox (scm_to_rect_s32 (rectangle),
117 (TParent)scm_to_irr_pointer (parent),
119 scm_to_bool (draw_background));
120 return scm_from_irr_pointer ("<gui-listbox>", (void*) listbox);
123 template <typename TParent>
125 IGUIEnvironment_addScrollBar (SCM gui_environment,
131 gui::IGUIScrollBar* scrollbar =
132 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
133 addScrollBar (scm_to_bool (horizontal),
134 scm_to_rect_s32 (rectangle),
135 (TParent)scm_to_irr_pointer (parent),
137 return scm_from_irr_pointer ("<gui-scrollbar>", (void*) scrollbar);
140 template <typename TParent>
142 IGUIEnvironment_addStaticText (SCM gui_environment,
151 wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
153 gui::IGUIStaticText* static_text =
154 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
155 addStaticText (wtext,
156 scm_to_rect_s32 (rectangle),
157 scm_to_bool (border),
158 scm_to_bool (word_wrap),
159 (TParent)scm_to_irr_pointer (parent),
161 scm_to_bool (fill_background));
164 return scm_from_irr_pointer ("<gui-static-text>", (void*) static_text);
167 template <typename TParent>
169 IGUIEnvironment_addWindow (SCM gui_environment,
176 wchar_t* wtext = (wchar_t*) scm_to_utf32_string (text);
178 gui::IGUIWindow* window =
179 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->
180 addWindow (scm_to_rect_s32 (rectangle),
183 (TParent)scm_to_irr_pointer (parent),
187 return scm_from_irr_pointer ("<gui-window>", (void*) window);
191 IGUIEnvironment_drawAll (SCM gui_environment)
193 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->drawAll ();
194 return SCM_UNSPECIFIED;
198 IGUIEnvironment_getBuiltInFont (SCM gui_environment)
200 gui::IGUIFont* font =
201 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->getBuiltInFont ();
202 return scm_from_irr_pointer ("<gui-font>", (void*) font);
206 IGUIEnvironment_getFont (SCM gui_environment,
209 char* cfilename = scm_to_utf8_string (filename);
210 gui::IGUIFont* font =
211 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->getFont (cfilename);
213 return scm_from_irr_pointer ("<gui-font>", (void*) font);
217 IGUIEnvironment_getSkin (SCM gui_environment)
219 gui::IGUISkin* skin =
220 ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))->getSkin ();
221 return scm_from_irr_pointer ("<gui-skin>", (void*) skin);
225 init_gui_environment (void)
227 DEFINE_GSUBR ("IGUIEnvironment_addButton_IGUIElement", 6, 0, 0,
228 IGUIEnvironment_addButton<gui::IGUIElement*>);
229 DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
230 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
231 DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
232 IGUIEnvironment_addImage<gui::IGUIElement*>);
233 DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
234 IGUIEnvironment_addListBox<gui::IGUIElement*>);
235 DEFINE_GSUBR ("IGUIEnvironment_addScrollBar_IGUIElement", 5, 0, 0,
236 IGUIEnvironment_addScrollBar<gui::IGUIElement*>);
237 DEFINE_GSUBR ("IGUIEnvironment_addStaticText_IGUIElement", 8, 0, 0,
238 IGUIEnvironment_addStaticText<gui::IGUIElement*>);
239 DEFINE_GSUBR ("IGUIEnvironment_addStaticText_IGUIWindow", 8, 0, 0,
240 IGUIEnvironment_addStaticText<gui::IGUIWindow*>);
241 DEFINE_GSUBR ("IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0,
242 IGUIEnvironment_addWindow<gui::IGUIElement*>);
243 DEFINE_GSUBR ("IGUIEnvironment_drawAll", 1, 0, 0, IGUIEnvironment_drawAll);
244 DEFINE_GSUBR ("IGUIEnvironment_getBuiltInFont", 1, 0, 0, IGUIEnvironment_getBuiltInFont);
245 DEFINE_GSUBR ("IGUIEnvironment_getFont", 2, 0, 0, IGUIEnvironment_getFont);
246 DEFINE_GSUBR ("IGUIEnvironment_getSkin", 1, 0, 0, IGUIEnvironment_getSkin);