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>
31 IGUISkin_getColor (SCM gui_skin,
34 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin);
35 video::SColor scolor = skin->getColor (scm_to_default_color (color));
36 return scm_from_color (scolor);
40 IGUISkin_getFont (SCM gui_skin,
43 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin);
44 gui::IGUIFont* font = skin->getFont (scm_to_default_font (which));
45 return scm_from_pointer ((void*) font, NULL);
49 IGUISkin_setColor (SCM gui_skin,
53 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin);
54 skin->setColor (scm_to_default_color (which),
55 scm_to_color (new_color));
56 return SCM_UNSPECIFIED;
60 IGUISkin_setFont (SCM gui_skin,
64 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin);
65 skin->setFont ((gui::IGUIFont*) scm_to_pointer (font),
66 scm_to_default_font (which));
67 return SCM_UNSPECIFIED;
73 DEFINE_GSUBR ("IGUISkin_getColor", 2, 0, 0, IGUISkin_getColor);
74 DEFINE_GSUBR ("IGUISkin_getFont", 2, 0, 0, IGUISkin_getFont);
75 DEFINE_GSUBR ("IGUISkin_setColor", 3, 0, 0, IGUISkin_setColor);
76 DEFINE_GSUBR ("IGUISkin_setFont", 3, 0, 0, IGUISkin_setFont);
79 gui::EGUI_DEFAULT_COLOR
80 scm_to_default_color (SCM default_color)
82 char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL);
83 if (!strcmp (color, "3d-dark-shadow"))
85 return gui::EGDC_3D_DARK_SHADOW;
87 else if (!strcmp (color, "3d-shadow"))
89 return gui::EGDC_3D_SHADOW;
91 else if (!strcmp (color, "3d-face"))
93 return gui::EGDC_3D_FACE;
95 else if (!strcmp (color, "3d-high-light"))
97 return gui::EGDC_3D_HIGH_LIGHT;
99 else if (!strcmp (color, "3d-light"))
101 return gui::EGDC_3D_LIGHT;
103 else if (!strcmp (color, "active-border"))
105 return gui::EGDC_ACTIVE_BORDER;
107 else if (!strcmp (color, "active-caption"))
109 return gui::EGDC_ACTIVE_CAPTION;
111 else if (!strcmp (color, "app-workspace"))
113 return gui::EGDC_APP_WORKSPACE;
115 else if (!strcmp (color, "button-text"))
117 return gui::EGDC_BUTTON_TEXT;
119 else if (!strcmp (color, "gray-text"))
121 return gui::EGDC_GRAY_TEXT;
123 else if (!strcmp (color, "high-light"))
125 return gui::EGDC_HIGH_LIGHT;
127 else if (!strcmp (color, "high-light-text"))
129 return gui::EGDC_HIGH_LIGHT_TEXT;
131 else if (!strcmp (color, "inactive-border"))
133 return gui::EGDC_INACTIVE_BORDER;
135 else if (!strcmp (color, "inactive-caption"))
137 return gui::EGDC_INACTIVE_CAPTION;
139 else if (!strcmp (color, "tooltip"))
141 return gui::EGDC_TOOLTIP;
143 else if (!strcmp (color, "tooltip-background"))
145 return gui::EGDC_TOOLTIP_BACKGROUND;
147 else if (!strcmp (color, "scrollbar"))
149 return gui::EGDC_SCROLLBAR;
151 else if (!strcmp (color, "window"))
153 return gui::EGDC_WINDOW;
155 else if (!strcmp (color, "window-symbol"))
157 return gui::EGDC_WINDOW_SYMBOL;
159 else if (!strcmp (color, "icon"))
161 return gui::EGDC_ICON;
163 else if (!strcmp (color, "icon-high-light"))
165 return gui::EGDC_ICON_HIGH_LIGHT;
167 else if (!strcmp (color, "gray-window-symbol"))
169 return gui::EGDC_GRAY_WINDOW_SYMBOL;
171 else if (!strcmp (color, "editable"))
173 return gui::EGDC_EDITABLE;
175 else if (!strcmp (color, "gray-editable"))
177 return gui::EGDC_GRAY_EDITABLE;
179 else if (!strcmp (color, "focused-editable"))
181 return gui::EGDC_FOCUSED_EDITABLE;
185 scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S",
186 scm_list_1 (default_color), scm_list_1 (default_color));
190 gui::EGUI_DEFAULT_FONT
191 scm_to_default_font (SCM default_font)
193 char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL);
194 if (!strcmp (font, "default"))
196 return gui::EGDF_DEFAULT;
198 else if (!strcmp (font, "button"))
200 return gui::EGDF_BUTTON;
202 else if (!strcmp (font, "window"))
204 return gui::EGDF_WINDOW;
206 else if (!strcmp (font, "menu"))
208 return gui::EGDF_MENU;
210 else if (!strcmp (font, "tooltip"))
212 return gui::EGDF_TOOLTIP;
216 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
217 scm_list_1 (default_font), scm_list_1 (default_font));