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>
32 IGUISkin_getColor (SCM gui_skin,
35 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_irr_pointer (gui_skin);
36 video::SColor scolor = skin->getColor (scm_to_default_color (color));
37 return scm_from_color (scolor);
41 IGUISkin_getFont (SCM gui_skin,
44 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_irr_pointer (gui_skin);
45 gui::IGUIFont* font = skin->getFont (scm_to_default_font (which));
46 return scm_from_pointer ((void*) font, NULL);
50 IGUISkin_setColor (SCM gui_skin,
54 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_irr_pointer (gui_skin);
55 skin->setColor (scm_to_default_color (which),
56 scm_to_color (new_color));
57 return SCM_UNSPECIFIED;
61 IGUISkin_setFont (SCM gui_skin,
65 gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_irr_pointer (gui_skin);
66 skin->setFont ((gui::IGUIFont*) scm_to_irr_pointer (font),
67 scm_to_default_font (which));
68 return SCM_UNSPECIFIED;
74 DEFINE_GSUBR ("IGUISkin_getColor", 2, 0, 0, IGUISkin_getColor);
75 DEFINE_GSUBR ("IGUISkin_getFont", 2, 0, 0, IGUISkin_getFont);
76 DEFINE_GSUBR ("IGUISkin_setColor", 3, 0, 0, IGUISkin_setColor);
77 DEFINE_GSUBR ("IGUISkin_setFont", 3, 0, 0, IGUISkin_setFont);
80 gui::EGUI_DEFAULT_COLOR
81 scm_to_default_color (SCM default_color)
83 char* color = scm_to_utf8_string (scm_symbol_to_string (default_color));
84 if (!strcmp (color, "3d-dark-shadow"))
86 return gui::EGDC_3D_DARK_SHADOW;
88 else if (!strcmp (color, "3d-shadow"))
90 return gui::EGDC_3D_SHADOW;
92 else if (!strcmp (color, "3d-face"))
94 return gui::EGDC_3D_FACE;
96 else if (!strcmp (color, "3d-high-light"))
98 return gui::EGDC_3D_HIGH_LIGHT;
100 else if (!strcmp (color, "3d-light"))
102 return gui::EGDC_3D_LIGHT;
104 else if (!strcmp (color, "active-border"))
106 return gui::EGDC_ACTIVE_BORDER;
108 else if (!strcmp (color, "active-caption"))
110 return gui::EGDC_ACTIVE_CAPTION;
112 else if (!strcmp (color, "app-workspace"))
114 return gui::EGDC_APP_WORKSPACE;
116 else if (!strcmp (color, "button-text"))
118 return gui::EGDC_BUTTON_TEXT;
120 else if (!strcmp (color, "gray-text"))
122 return gui::EGDC_GRAY_TEXT;
124 else if (!strcmp (color, "high-light"))
126 return gui::EGDC_HIGH_LIGHT;
128 else if (!strcmp (color, "high-light-text"))
130 return gui::EGDC_HIGH_LIGHT_TEXT;
132 else if (!strcmp (color, "inactive-border"))
134 return gui::EGDC_INACTIVE_BORDER;
136 else if (!strcmp (color, "inactive-caption"))
138 return gui::EGDC_INACTIVE_CAPTION;
140 else if (!strcmp (color, "tooltip"))
142 return gui::EGDC_TOOLTIP;
144 else if (!strcmp (color, "tooltip-background"))
146 return gui::EGDC_TOOLTIP_BACKGROUND;
148 else if (!strcmp (color, "scrollbar"))
150 return gui::EGDC_SCROLLBAR;
152 else if (!strcmp (color, "window"))
154 return gui::EGDC_WINDOW;
156 else if (!strcmp (color, "window-symbol"))
158 return gui::EGDC_WINDOW_SYMBOL;
160 else if (!strcmp (color, "icon"))
162 return gui::EGDC_ICON;
164 else if (!strcmp (color, "icon-high-light"))
166 return gui::EGDC_ICON_HIGH_LIGHT;
168 else if (!strcmp (color, "gray-window-symbol"))
170 return gui::EGDC_GRAY_WINDOW_SYMBOL;
172 else if (!strcmp (color, "editable"))
174 return gui::EGDC_EDITABLE;
176 else if (!strcmp (color, "gray-editable"))
178 return gui::EGDC_GRAY_EDITABLE;
180 else if (!strcmp (color, "focused-editable"))
182 return gui::EGDC_FOCUSED_EDITABLE;
186 scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S",
187 scm_list_1 (default_color), scm_list_1 (default_color));
191 gui::EGUI_DEFAULT_FONT
192 scm_to_default_font (SCM default_font)
194 char* font = scm_to_utf8_string (scm_symbol_to_string (default_font));
195 if (!strcmp (font, "default"))
197 return gui::EGDF_DEFAULT;
199 else if (!strcmp (font, "button"))
201 return gui::EGDF_BUTTON;
203 else if (!strcmp (font, "window"))
205 return gui::EGDF_WINDOW;
207 else if (!strcmp (font, "menu"))
209 return gui::EGDF_MENU;
211 else if (!strcmp (font, "tooltip"))
213 return gui::EGDF_TOOLTIP;
217 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
218 scm_list_1 (default_font), scm_list_1 (default_font));