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>
26 #include "gui-environment.h"
27 #include "position2d.h"
35 template <typename TParent>
37 irr_gui_IGUIEnvironment_addButton (SCM gui_environment,
44 gui::IGUIButton* button =
45 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
46 addButton (scm_to_rect_s32 (rectangle),
47 (TParent)scm_to_pointer (parent),
49 scm_to_wide_char_string (text),
50 scm_to_wide_char_string (tooltiptext));
51 return scm_from_pointer ((void*)button, NULL);
55 template <typename TParent>
57 irr_gui_IGUIEnvironment_addEditBox (SCM gui_environment,
64 gui::IGUIEditBox* editbox =
65 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
66 addEditBox (scm_to_wide_char_string (text),
67 scm_to_rect_s32 (rectangle),
69 (TParent)scm_to_pointer (parent),
71 return scm_from_pointer ((void*)editbox, NULL);
75 template <typename TParent>
77 irr_gui_IGUIEnvironment_addImage (SCM gui_environment,
80 SCM use_alpha_channel,
85 gui::IGUIImage* image =
86 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
87 addImage ((video::ITexture*)scm_to_pointer (image),
88 scm_to_position2d_s32 (position),
89 scm_to_bool (use_alpha_channel),
90 (TParent)scm_to_pointer (parent),
92 scm_to_wide_char_string (text));
93 return scm_from_pointer ((void*)image, NULL);
97 template <typename TParent>
99 irr_gui_IGUIEnvironment_addListBox (SCM gui_environment,
105 gui::IGUIListBox* listbox =
106 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
107 addListBox (scm_to_rect_s32 (rectangle),
108 (TParent)scm_to_pointer (parent),
110 scm_to_bool (draw_background));
111 return scm_from_pointer ((void*)listbox, NULL);
115 template <typename TParent>
117 irr_gui_IGUIEnvironment_addScrollBar (SCM gui_environment,
123 gui::IGUIScrollBar* scrollbar =
124 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
125 addScrollBar (scm_to_bool (horizontal),
126 scm_to_rect_s32 (rectangle),
127 (TParent)scm_to_pointer (parent),
129 return scm_from_pointer ((void*)scrollbar, NULL);
133 template <typename TParent>
135 irr_gui_IGUIEnvironment_addStaticText (SCM gui_environment,
144 gui::IGUIStaticText* static_text =
145 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
146 addStaticText (scm_to_wide_char_string (text),
147 scm_to_rect_s32 (rectangle),
148 scm_to_bool (border),
149 scm_to_bool (word_wrap),
150 (TParent)scm_to_pointer (parent),
152 scm_to_bool (fill_background));
153 return scm_from_pointer ((void*)static_text, NULL);
157 template <typename TParent>
159 irr_gui_IGUIEnvironment_addWindow (SCM gui_environment,
166 gui::IGUIWindow* window =
167 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
168 addWindow (scm_to_rect_s32 (rectangle),
170 scm_to_wide_char_string (text),
171 (TParent)scm_to_pointer (parent),
173 return scm_from_pointer ((void*)window, NULL);
178 irr_gui_IGUIEnvironment_getBuiltInFont (SCM gui_environment)
180 gui::IGUIFont* font =
181 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getBuiltInFont ();
182 return scm_from_pointer ((void*)font, NULL);
187 irr_gui_IGUIEnvironment_getFont (SCM gui_environment,
190 gui::IGUIFont* font =
191 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
192 getFont (scm_to_utf8_stringn (filename, NULL));
193 return scm_from_pointer ((void*)font, NULL);
198 irr_gui_IGUIEnvironment_getSkin (SCM gui_environment)
200 gui::IGUISkin* skin =
201 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getSkin ();
202 return scm_from_pointer ((void*)skin, NULL);
209 init_gui_environment (void)
211 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addButton_IGUIElement", 6, 0, 0,
212 irr_gui_IGUIEnvironment_addButton<gui::IGUIElement*>);
213 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
214 irr_gui_IGUIEnvironment_addEditBox<gui::IGUIElement*>);
215 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
216 irr_gui_IGUIEnvironment_addImage<gui::IGUIElement*>);
217 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
218 irr_gui_IGUIEnvironment_addListBox<gui::IGUIElement*>);
219 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addScrollBar_IGUIElement", 5, 0, 0,
220 irr_gui_IGUIEnvironment_addScrollBar<gui::IGUIElement*>);
221 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addStaticText_IGUIElement", 8, 0, 0,
222 irr_gui_IGUIEnvironment_addStaticText<gui::IGUIElement*>);
223 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0,
224 irr_gui_IGUIEnvironment_addWindow<gui::IGUIElement*>);
225 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_getBuiltInFont", 1, 0, 0,
226 irr_gui_IGUIEnvironment_getBuiltInFont);
227 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_getFont", 2, 0, 0,
228 irr_gui_IGUIEnvironment_getFont);
229 DEFINE_GSUBR ("irr_gui_IGUIEnvironment_getSkin", 1, 0, 0,
230 irr_gui_IGUIEnvironment_getSkin);