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-skin-font!", 2, 0, 1, irr_gui_setSkinFont);
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_setSkinFont (SCM wrapped_gui_skin,
64 SCM which = scm_from_utf8_symbol ("default");
66 scm_c_bind_keyword_arguments ("get-skin-font", rest, (scm_t_keyword_arguments_flags)0,
67 scm_from_utf8_keyword ("which"), &which,
70 irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin);
71 skin->setFont (unwrap_gui_font (font),
72 scm_to_default_font (which));
73 return SCM_UNSPECIFIED;
76 irr::gui::EGUI_DEFAULT_FONT
77 scm_to_default_font (SCM default_font)
79 char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL);
80 if (!strcmp (font, "default"))
82 return irr::gui::EGDF_DEFAULT;
84 else if (!strcmp (font, "button"))
86 return irr::gui::EGDF_BUTTON;
88 else if (!strcmp (font, "window"))
90 return irr::gui::EGDF_WINDOW;
92 else if (!strcmp (font, "menu"))
94 return irr::gui::EGDF_MENU;
96 else if (!strcmp (font, "tooltip"))
98 return irr::gui::EGDF_TOOLTIP;
102 scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S",
103 scm_list_1 (default_font), scm_list_1 (default_font));