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>
35 init_gui_skin_type ();
36 DEFINE_GSUBR ("get-skin-font", 1, 0, 1, irr_gui_getSkinFont);
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_getSkinFont (SCM wrapped_gui_skin,
48 SCM which = scm_from_utf8_symbol ("default");
50 scm_c_bind_keyword_arguments ("get-skin-font", rest, (scm_t_keyword_arguments_flags)0,
51 scm_from_utf8_keyword ("which"), &which,
54 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
55 irr::gui::IGUIFont* font = skin->getFont (scm_to_default_font (which));
56 return wrap_gui_font (font);
60 irr_gui_IGUISkin_getFont (SCM wrapped_gui_skin,
63 SCM which = scm_from_utf8_symbol ("default");
65 scm_c_bind_keyword_arguments ("get-font", rest, (scm_t_keyword_arguments_flags)0,
66 scm_from_utf8_keyword ("which"), &which,
69 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
70 irr::gui::IGUIFont* font = skin->getFont (scm_to_default_font (which));
71 return wrap_gui_font (font);
75 irr_gui_setFont (SCM wrapped_gui_skin,
79 SCM which = scm_from_utf8_symbol ("default");
81 scm_c_bind_keyword_arguments ("set-font!", rest, (scm_t_keyword_arguments_flags)0,
82 scm_from_utf8_keyword ("which"), &which,
85 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
86 skin->setFont (unwrap_gui_font (font),
87 scm_to_default_font (which));
88 return SCM_UNSPECIFIED;
91 irr::gui::EGUI_DEFAULT_FONT
92 scm_to_default_font (SCM default_font)
94 char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL);
95 if (!strcmp (font, "default"))
97 return irr::gui::EGDF_DEFAULT;
99 else if (!strcmp (font, "button"))
101 return irr::gui::EGDF_BUTTON;
103 else if (!strcmp (font, "window"))
105 return irr::gui::EGDF_WINDOW;
107 else if (!strcmp (font, "menu"))
109 return irr::gui::EGDF_MENU;
111 else if (!strcmp (font, "tooltip"))
113 return irr::gui::EGDF_TOOLTIP;
117 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
118 scm_list_1 (default_font), scm_list_1 (default_font));