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_name = scm_to_utf8_string (scm_symbol_to_string (default_color));
84 gui::EGUI_DEFAULT_COLOR color;
86 if (!strcmp (color_name, "3d-dark-shadow"))
88 color = gui::EGDC_3D_DARK_SHADOW;
90 else if (!strcmp (color_name, "3d-shadow"))
92 color = gui::EGDC_3D_SHADOW;
94 else if (!strcmp (color_name, "3d-face"))
96 color = gui::EGDC_3D_FACE;
98 else if (!strcmp (color_name, "3d-high-light"))
100 color = gui::EGDC_3D_HIGH_LIGHT;
102 else if (!strcmp (color_name, "3d-light"))
104 color = gui::EGDC_3D_LIGHT;
106 else if (!strcmp (color_name, "active-border"))
108 color = gui::EGDC_ACTIVE_BORDER;
110 else if (!strcmp (color_name, "active-caption"))
112 color = gui::EGDC_ACTIVE_CAPTION;
114 else if (!strcmp (color_name, "app-workspace"))
116 color = gui::EGDC_APP_WORKSPACE;
118 else if (!strcmp (color_name, "button-text"))
120 color = gui::EGDC_BUTTON_TEXT;
122 else if (!strcmp (color_name, "gray-text"))
124 color = gui::EGDC_GRAY_TEXT;
126 else if (!strcmp (color_name, "high-light"))
128 color = gui::EGDC_HIGH_LIGHT;
130 else if (!strcmp (color_name, "high-light-text"))
132 color = gui::EGDC_HIGH_LIGHT_TEXT;
134 else if (!strcmp (color_name, "inactive-border"))
136 color = gui::EGDC_INACTIVE_BORDER;
138 else if (!strcmp (color_name, "inactive-caption"))
140 color = gui::EGDC_INACTIVE_CAPTION;
142 else if (!strcmp (color_name, "tooltip"))
144 color = gui::EGDC_TOOLTIP;
146 else if (!strcmp (color_name, "tooltip-background"))
148 color = gui::EGDC_TOOLTIP_BACKGROUND;
150 else if (!strcmp (color_name, "scrollbar"))
152 color = gui::EGDC_SCROLLBAR;
154 else if (!strcmp (color_name, "window"))
156 color = gui::EGDC_WINDOW;
158 else if (!strcmp (color_name, "window-symbol"))
160 color = gui::EGDC_WINDOW_SYMBOL;
162 else if (!strcmp (color_name, "icon"))
164 color = gui::EGDC_ICON;
166 else if (!strcmp (color_name, "icon-high-light"))
168 color = gui::EGDC_ICON_HIGH_LIGHT;
170 else if (!strcmp (color_name, "gray-window-symbol"))
172 color = gui::EGDC_GRAY_WINDOW_SYMBOL;
174 else if (!strcmp (color_name, "editable"))
176 color = gui::EGDC_EDITABLE;
178 else if (!strcmp (color_name, "gray-editable"))
180 color = gui::EGDC_GRAY_EDITABLE;
182 else if (!strcmp (color_name, "focused-editable"))
184 color = gui::EGDC_FOCUSED_EDITABLE;
188 scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S",
189 scm_list_1 (default_color), scm_list_1 (default_color));
196 gui::EGUI_DEFAULT_FONT
197 scm_to_default_font (SCM default_font)
199 char* font_name = scm_to_utf8_string (scm_symbol_to_string (default_font));
200 gui::EGUI_DEFAULT_FONT font;
202 if (!strcmp (font_name, "default"))
204 font = gui::EGDF_DEFAULT;
206 else if (!strcmp (font_name, "button"))
208 font = gui::EGDF_BUTTON;
210 else if (!strcmp (font_name, "window"))
212 font = gui::EGDF_WINDOW;
214 else if (!strcmp (font_name, "menu"))
216 font = gui::EGDF_MENU;
218 else if (!strcmp (font_name, "tooltip"))
220 font = gui::EGDF_TOOLTIP;
224 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
225 scm_list_1 (default_font), scm_list_1 (default_font));