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_setFont (SCM wrapped_gui_skin,
73 SCM which = scm_from_utf8_symbol ("default");
75 scm_c_bind_keyword_arguments ("set-font!", rest, (scm_t_keyword_arguments_flags)0,
76 scm_from_utf8_keyword ("which"), &which,
79 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
80 skin->setFont (unwrap_gui_font (font),
81 scm_to_default_font (which));
82 return SCM_UNSPECIFIED;
85 irr::gui::EGUI_DEFAULT_COLOR
86 scm_to_default_color (SCM default_color)
88 char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL);
89 if (!strcmp (color, "3d-dark-shadow"))
91 return irr::gui::EGDC_3D_DARK_SHADOW;
93 else if (!strcmp (color, "3d-shadow"))
95 return irr::gui::EGDC_3D_SHADOW;
97 else if (!strcmp (color, "3d-face"))
99 return irr::gui::EGDC_3D_FACE;
101 else if (!strcmp (color, "3d-high-light"))
103 return irr::gui::EGDC_3D_HIGH_LIGHT;
105 else if (!strcmp (color, "3d-light"))
107 return irr::gui::EGDC_3D_LIGHT;
109 else if (!strcmp (color, "active-border"))
111 return irr::gui::EGDC_ACTIVE_BORDER;
113 else if (!strcmp (color, "active-caption"))
115 return irr::gui::EGDC_ACTIVE_CAPTION;
117 else if (!strcmp (color, "app-workspace"))
119 return irr::gui::EGDC_APP_WORKSPACE;
121 else if (!strcmp (color, "button-text"))
123 return irr::gui::EGDC_BUTTON_TEXT;
125 else if (!strcmp (color, "gray-text"))
127 return irr::gui::EGDC_GRAY_TEXT;
129 else if (!strcmp (color, "high-light"))
131 return irr::gui::EGDC_HIGH_LIGHT;
133 else if (!strcmp (color, "high-light-text"))
135 return irr::gui::EGDC_HIGH_LIGHT_TEXT;
137 else if (!strcmp (color, "inactive-border"))
139 return irr::gui::EGDC_INACTIVE_BORDER;
141 else if (!strcmp (color, "inactive-caption"))
143 return irr::gui::EGDC_INACTIVE_CAPTION;
145 else if (!strcmp (color, "tooltip"))
147 return irr::gui::EGDC_TOOLTIP;
149 else if (!strcmp (color, "tooltip-background"))
151 return irr::gui::EGDC_TOOLTIP_BACKGROUND;
153 else if (!strcmp (color, "scrollbar"))
155 return irr::gui::EGDC_SCROLLBAR;
157 else if (!strcmp (color, "window"))
159 return irr::gui::EGDC_WINDOW;
161 else if (!strcmp (color, "window-symbol"))
163 return irr::gui::EGDC_WINDOW_SYMBOL;
165 else if (!strcmp (color, "icon"))
167 return irr::gui::EGDC_ICON;
169 else if (!strcmp (color, "icon-high-light"))
171 return irr::gui::EGDC_ICON_HIGH_LIGHT;
173 else if (!strcmp (color, "gray-window-symbol"))
175 return irr::gui::EGDC_GRAY_WINDOW_SYMBOL;
177 else if (!strcmp (color, "editable"))
179 return irr::gui::EGDC_EDITABLE;
181 else if (!strcmp (color, "gray-editable"))
183 return irr::gui::EGDC_GRAY_EDITABLE;
185 else if (!strcmp (color, "focused-editable"))
187 return irr::gui::EGDC_FOCUSED_EDITABLE;
191 scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S",
192 scm_list_1 (default_color), scm_list_1 (default_color));
196 irr::gui::EGUI_DEFAULT_FONT
197 scm_to_default_font (SCM default_font)
199 char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL);
200 if (!strcmp (font, "default"))
202 return irr::gui::EGDF_DEFAULT;
204 else if (!strcmp (font, "button"))
206 return irr::gui::EGDF_BUTTON;
208 else if (!strcmp (font, "window"))
210 return irr::gui::EGDF_WINDOW;
212 else if (!strcmp (font, "menu"))
214 return irr::gui::EGDF_MENU;
216 else if (!strcmp (font, "tooltip"))
218 return irr::gui::EGDF_TOOLTIP;
222 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
223 scm_list_1 (default_font), scm_list_1 (default_font));