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"
34 template <typename TParent>
36 IGUIEnvironment_addButton (SCM gui_environment,
43 gui::IGUIButton* button =
44 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
45 addButton (scm_to_rect_s32 (rectangle),
46 (TParent)scm_to_pointer (parent),
48 scm_to_wide_char_string (text),
49 scm_to_wide_char_string (tooltiptext));
50 return scm_from_pointer ((void*)button, NULL);
54 template <typename TParent>
56 IGUIEnvironment_addEditBox (SCM gui_environment,
63 gui::IGUIEditBox* editbox =
64 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
65 addEditBox (scm_to_wide_char_string (text),
66 scm_to_rect_s32 (rectangle),
68 (TParent)scm_to_pointer (parent),
70 return scm_from_pointer ((void*)editbox, NULL);
74 template <typename TParent>
76 IGUIEnvironment_addImage (SCM gui_environment,
79 SCM use_alpha_channel,
84 gui::IGUIEnvironment* guienv = (gui::IGUIEnvironment*)scm_to_pointer (gui_environment);
85 gui::IGUIImage* new_image =
86 guienv->addImage ((video::ITexture*)scm_to_pointer (image),
87 scm_to_position2d_s32 (position),
88 scm_to_bool (use_alpha_channel),
89 (TParent)scm_to_pointer (parent),
91 scm_to_wide_char_string (text));
92 return scm_from_pointer ((void*) new_image, NULL);
96 template <typename TParent>
98 IGUIEnvironment_addListBox (SCM gui_environment,
104 gui::IGUIListBox* listbox =
105 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
106 addListBox (scm_to_rect_s32 (rectangle),
107 (TParent)scm_to_pointer (parent),
109 scm_to_bool (draw_background));
110 return scm_from_pointer ((void*)listbox, NULL);
114 template <typename TParent>
116 IGUIEnvironment_addScrollBar (SCM gui_environment,
122 gui::IGUIScrollBar* scrollbar =
123 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
124 addScrollBar (scm_to_bool (horizontal),
125 scm_to_rect_s32 (rectangle),
126 (TParent)scm_to_pointer (parent),
128 return scm_from_pointer ((void*)scrollbar, NULL);
132 template <typename TParent>
134 IGUIEnvironment_addStaticText (SCM gui_environment,
143 gui::IGUIStaticText* static_text =
144 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
145 addStaticText (scm_to_wide_char_string (text),
146 scm_to_rect_s32 (rectangle),
147 scm_to_bool (border),
148 scm_to_bool (word_wrap),
149 (TParent)scm_to_pointer (parent),
151 scm_to_bool (fill_background));
152 return scm_from_pointer ((void*)static_text, NULL);
156 template <typename TParent>
158 IGUIEnvironment_addWindow (SCM gui_environment,
165 gui::IGUIWindow* window =
166 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
167 addWindow (scm_to_rect_s32 (rectangle),
169 scm_to_wide_char_string (text),
170 (TParent)scm_to_pointer (parent),
172 return scm_from_pointer ((void*)window, NULL);
177 IGUIEnvironment_drawAll (SCM gui_environment)
179 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->drawAll ();
180 return SCM_UNSPECIFIED;
185 IGUIEnvironment_getBuiltInFont (SCM gui_environment)
187 gui::IGUIFont* font =
188 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getBuiltInFont ();
189 return scm_from_pointer ((void*)font, NULL);
194 IGUIEnvironment_getFont (SCM gui_environment,
197 gui::IGUIFont* font =
198 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
199 getFont (scm_to_utf8_stringn (filename, NULL));
200 return scm_from_pointer ((void*)font, NULL);
205 IGUIEnvironment_getSkin (SCM gui_environment)
207 gui::IGUISkin* skin =
208 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getSkin ();
209 return scm_from_pointer ((void*)skin, NULL);
216 init_gui_environment (void)
218 DEFINE_GSUBR ("IGUIEnvironment_addButton_IGUIElement", 6, 0, 0,
219 IGUIEnvironment_addButton<gui::IGUIElement*>);
220 DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
221 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
222 DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
223 IGUIEnvironment_addImage<gui::IGUIElement*>);
224 DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
225 IGUIEnvironment_addListBox<gui::IGUIElement*>);
226 DEFINE_GSUBR ("IGUIEnvironment_addScrollBar_IGUIElement", 5, 0, 0,
227 IGUIEnvironment_addScrollBar<gui::IGUIElement*>);
228 DEFINE_GSUBR ("IGUIEnvironment_addStaticText_IGUIElement", 8, 0, 0,
229 IGUIEnvironment_addStaticText<gui::IGUIElement*>);
230 DEFINE_GSUBR ("IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0,
231 IGUIEnvironment_addWindow<gui::IGUIElement*>);
232 DEFINE_GSUBR ("IGUIEnvironment_drawAll", 1, 0, 0, IGUIEnvironment_drawAll);
233 DEFINE_GSUBR ("IGUIEnvironment_getBuiltInFont", 1, 0, 0, IGUIEnvironment_getBuiltInFont);
234 DEFINE_GSUBR ("IGUIEnvironment_getFont", 2, 0, 0, IGUIEnvironment_getFont);
235 DEFINE_GSUBR ("IGUIEnvironment_getSkin", 1, 0, 0, IGUIEnvironment_getSkin);