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>
36 init_gui_skin_type ();
37 DEFINE_GSUBR ("set-font!", 2, 0, 1, irr_gui_setFont);
40 DEFINE_WRAPPED_TYPE (irr::gui::IGUISkin*, "gui-skin",
41 init_gui_skin_type, gui_skin_p,
42 wrap_gui_skin, unwrap_gui_skin);
45 irr_gui_IGUISkin_getColor (SCM wrapped_gui_skin,
48 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
49 irr::video::SColor scolor = skin->getColor (scm_to_default_color (color));
50 return scm_from_color (scolor);
54 irr_gui_IGUISkin_getFont (SCM wrapped_gui_skin,
57 SCM which = scm_from_utf8_symbol ("default");
59 scm_c_bind_keyword_arguments ("get-font", rest, (scm_t_keyword_arguments_flags)0,
60 scm_from_utf8_keyword ("which"), &which,
63 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
64 irr::gui::IGUIFont* font = skin->getFont (scm_to_default_font (which));
65 return wrap_gui_font (font);
69 irr_gui_IGUISkin_setColor (SCM wrapped_gui_skin,
73 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
74 skin->setColor (scm_to_default_color (which),
75 scm_to_color (new_color));
76 return SCM_UNSPECIFIED;
80 irr_gui_setFont (SCM wrapped_gui_skin,
84 SCM which = scm_from_utf8_symbol ("default");
86 scm_c_bind_keyword_arguments ("set-font!", rest, (scm_t_keyword_arguments_flags)0,
87 scm_from_utf8_keyword ("which"), &which,
90 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
91 skin->setFont (unwrap_gui_font (font),
92 scm_to_default_font (which));
93 return SCM_UNSPECIFIED;
96 irr::gui::EGUI_DEFAULT_COLOR
97 scm_to_default_color (SCM default_color)
99 char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL);
100 if (!strcmp (color, "3d-dark-shadow"))
102 return irr::gui::EGDC_3D_DARK_SHADOW;
104 else if (!strcmp (color, "3d-shadow"))
106 return irr::gui::EGDC_3D_SHADOW;
108 else if (!strcmp (color, "3d-face"))
110 return irr::gui::EGDC_3D_FACE;
112 else if (!strcmp (color, "3d-high-light"))
114 return irr::gui::EGDC_3D_HIGH_LIGHT;
116 else if (!strcmp (color, "3d-light"))
118 return irr::gui::EGDC_3D_LIGHT;
120 else if (!strcmp (color, "active-border"))
122 return irr::gui::EGDC_ACTIVE_BORDER;
124 else if (!strcmp (color, "active-caption"))
126 return irr::gui::EGDC_ACTIVE_CAPTION;
128 else if (!strcmp (color, "app-workspace"))
130 return irr::gui::EGDC_APP_WORKSPACE;
132 else if (!strcmp (color, "button-text"))
134 return irr::gui::EGDC_BUTTON_TEXT;
136 else if (!strcmp (color, "gray-text"))
138 return irr::gui::EGDC_GRAY_TEXT;
140 else if (!strcmp (color, "high-light"))
142 return irr::gui::EGDC_HIGH_LIGHT;
144 else if (!strcmp (color, "high-light-text"))
146 return irr::gui::EGDC_HIGH_LIGHT_TEXT;
148 else if (!strcmp (color, "inactive-border"))
150 return irr::gui::EGDC_INACTIVE_BORDER;
152 else if (!strcmp (color, "inactive-caption"))
154 return irr::gui::EGDC_INACTIVE_CAPTION;
156 else if (!strcmp (color, "tooltip"))
158 return irr::gui::EGDC_TOOLTIP;
160 else if (!strcmp (color, "tooltip-background"))
162 return irr::gui::EGDC_TOOLTIP_BACKGROUND;
164 else if (!strcmp (color, "scrollbar"))
166 return irr::gui::EGDC_SCROLLBAR;
168 else if (!strcmp (color, "window"))
170 return irr::gui::EGDC_WINDOW;
172 else if (!strcmp (color, "window-symbol"))
174 return irr::gui::EGDC_WINDOW_SYMBOL;
176 else if (!strcmp (color, "icon"))
178 return irr::gui::EGDC_ICON;
180 else if (!strcmp (color, "icon-high-light"))
182 return irr::gui::EGDC_ICON_HIGH_LIGHT;
184 else if (!strcmp (color, "gray-window-symbol"))
186 return irr::gui::EGDC_GRAY_WINDOW_SYMBOL;
188 else if (!strcmp (color, "editable"))
190 return irr::gui::EGDC_EDITABLE;
192 else if (!strcmp (color, "gray-editable"))
194 return irr::gui::EGDC_GRAY_EDITABLE;
196 else if (!strcmp (color, "focused-editable"))
198 return irr::gui::EGDC_FOCUSED_EDITABLE;
202 scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S",
203 scm_list_1 (default_color), scm_list_1 (default_color));
207 irr::gui::EGUI_DEFAULT_FONT
208 scm_to_default_font (SCM default_font)
210 char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL);
211 if (!strcmp (font, "default"))
213 return irr::gui::EGDF_DEFAULT;
215 else if (!strcmp (font, "button"))
217 return irr::gui::EGDF_BUTTON;
219 else if (!strcmp (font, "window"))
221 return irr::gui::EGDF_WINDOW;
223 else if (!strcmp (font, "menu"))
225 return irr::gui::EGDF_MENU;
227 else if (!strcmp (font, "tooltip"))
229 return irr::gui::EGDF_TOOLTIP;
233 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
234 scm_list_1 (default_font), scm_list_1 (default_font));