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"
32 template <typename TParent>
34 IGUIEnvironment_addButton (SCM gui_environment,
41 gui::IGUIButton* button =
42 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
43 addButton (scm_to_rect_s32 (rectangle),
44 (TParent)scm_to_pointer (parent),
46 scm_to_wide_char_string (text),
47 scm_to_wide_char_string (tooltiptext));
48 return scm_from_pointer ((void*)button, NULL);
51 template <typename TParent>
53 IGUIEnvironment_addEditBox (SCM gui_environment,
60 gui::IGUIEditBox* editbox =
61 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
62 addEditBox (scm_to_wide_char_string (text),
63 scm_to_rect_s32 (rectangle),
65 (TParent)scm_to_pointer (parent),
67 return scm_from_pointer ((void*)editbox, NULL);
70 template <typename TParent>
72 IGUIEnvironment_addImage (SCM gui_environment,
75 SCM use_alpha_channel,
80 gui::IGUIEnvironment* guienv = (gui::IGUIEnvironment*)scm_to_pointer (gui_environment);
81 gui::IGUIImage* new_image =
82 guienv->addImage ((video::ITexture*)scm_to_pointer (image),
83 scm_to_position2d_s32 (position),
84 scm_to_bool (use_alpha_channel),
85 (TParent)scm_to_pointer (parent),
87 scm_to_wide_char_string (text));
88 return scm_from_pointer ((void*) new_image, NULL);
91 template <typename TParent>
93 IGUIEnvironment_addListBox (SCM gui_environment,
99 gui::IGUIListBox* listbox =
100 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
101 addListBox (scm_to_rect_s32 (rectangle),
102 (TParent)scm_to_pointer (parent),
104 scm_to_bool (draw_background));
105 return scm_from_pointer ((void*)listbox, NULL);
108 template <typename TParent>
110 IGUIEnvironment_addScrollBar (SCM gui_environment,
116 gui::IGUIScrollBar* scrollbar =
117 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
118 addScrollBar (scm_to_bool (horizontal),
119 scm_to_rect_s32 (rectangle),
120 (TParent)scm_to_pointer (parent),
122 return scm_from_pointer ((void*)scrollbar, NULL);
125 template <typename TParent>
127 IGUIEnvironment_addStaticText (SCM gui_environment,
136 gui::IGUIStaticText* static_text =
137 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
138 addStaticText (scm_to_wide_char_string (text),
139 scm_to_rect_s32 (rectangle),
140 scm_to_bool (border),
141 scm_to_bool (word_wrap),
142 (TParent)scm_to_pointer (parent),
144 scm_to_bool (fill_background));
145 return scm_from_pointer ((void*)static_text, NULL);
148 template <typename TParent>
150 IGUIEnvironment_addWindow (SCM gui_environment,
157 gui::IGUIWindow* window =
158 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
159 addWindow (scm_to_rect_s32 (rectangle),
161 scm_to_wide_char_string (text),
162 (TParent)scm_to_pointer (parent),
164 return scm_from_pointer ((void*)window, NULL);
168 IGUIEnvironment_drawAll (SCM gui_environment)
170 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->drawAll ();
171 return SCM_UNSPECIFIED;
175 IGUIEnvironment_getBuiltInFont (SCM gui_environment)
177 gui::IGUIFont* font =
178 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getBuiltInFont ();
179 return scm_from_pointer ((void*)font, NULL);
183 IGUIEnvironment_getFont (SCM gui_environment,
186 gui::IGUIFont* font =
187 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->
188 getFont (scm_to_utf8_stringn (filename, NULL));
189 return scm_from_pointer ((void*)font, NULL);
193 IGUIEnvironment_getSkin (SCM gui_environment)
195 gui::IGUISkin* skin =
196 ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->getSkin ();
197 return scm_from_pointer ((void*)skin, NULL);
201 init_gui_environment (void)
203 DEFINE_GSUBR ("IGUIEnvironment_addButton_IGUIElement", 6, 0, 0,
204 IGUIEnvironment_addButton<gui::IGUIElement*>);
205 DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
206 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
207 DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
208 IGUIEnvironment_addImage<gui::IGUIElement*>);
209 DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
210 IGUIEnvironment_addListBox<gui::IGUIElement*>);
211 DEFINE_GSUBR ("IGUIEnvironment_addScrollBar_IGUIElement", 5, 0, 0,
212 IGUIEnvironment_addScrollBar<gui::IGUIElement*>);
213 DEFINE_GSUBR ("IGUIEnvironment_addStaticText_IGUIElement", 8, 0, 0,
214 IGUIEnvironment_addStaticText<gui::IGUIElement*>);
215 DEFINE_GSUBR ("IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0,
216 IGUIEnvironment_addWindow<gui::IGUIElement*>);
217 DEFINE_GSUBR ("IGUIEnvironment_drawAll", 1, 0, 0, IGUIEnvironment_drawAll);
218 DEFINE_GSUBR ("IGUIEnvironment_getBuiltInFont", 1, 0, 0, IGUIEnvironment_getBuiltInFont);
219 DEFINE_GSUBR ("IGUIEnvironment_getFont", 2, 0, 0, IGUIEnvironment_getFont);
220 DEFINE_GSUBR ("IGUIEnvironment_getSkin", 1, 0, 0, IGUIEnvironment_getSkin);