From: Javier Sancho Date: Sat, 9 May 2020 12:13:23 +0000 (+0200) Subject: gui-scrollbar X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=490e119e587a59ec16dbad027580e882f0fc0abc;p=guile-irrlicht.git gui-scrollbar --- diff --git a/src/gui-scrollbar.cpp b/src/gui-scrollbar.cpp index 39dfa36..b67413e 100644 --- a/src/gui-scrollbar.cpp +++ b/src/gui-scrollbar.cpp @@ -21,76 +21,47 @@ #include #include - -#include "gui-element.h" #include "gui-scrollbar.h" #include "gsubr.h" -#include "wrapped.h" -extern "C" { - void - init_gui_scrollbar (void) - { - init_gui_scrollbar_type (); - DEFINE_GSUBR ("get-pos", 1, 0, 0, irr_gui_getPos); - DEFINE_GSUBR ("set-pos!", 2, 0, 0, irr_gui_setPos); - } +using namespace irr; - DEFINE_WRAPPED_TYPE (irr::gui::IGUIScrollBar*, "gui-scrollbar", - init_gui_scrollbar_type, gui_scrollbar_p, - wrap_gui_scrollbar, unwrap_gui_scrollbar); - SCM - irr_gui_setMax (SCM wrapped_obj, - SCM max) - { -#define SET_MAX(OBJ) OBJ->setMax (scm_to_int32 (max)); - - if (gui_editbox_p (wrapped_obj)) - { - SET_MAX (unwrap_gui_editbox (wrapped_obj)); - } - else if (gui_scrollbar_p (wrapped_obj)) - { - SET_MAX (unwrap_gui_scrollbar (wrapped_obj)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set max to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return SCM_UNSPECIFIED; - } +SCM +gui_IGUIScrollBar_getPos (SCM gui_scrollbar) +{ + return scm_from_int32 + (((gui::IGUIScrollBar*)scm_to_pointer (gui_scrollbar))->getPos ()); +} - SCM - irr_gui_getPos (SCM wrapped_scrollbar) - { - irr::gui::IGUIScrollBar* scrollbar; - if (gui_element_p (wrapped_scrollbar)) - { - scrollbar = (irr::gui::IGUIScrollBar*)unwrap_gui_element (wrapped_scrollbar); - } - else { - scrollbar = unwrap_gui_scrollbar (wrapped_scrollbar); - } - return scm_from_int32 (scrollbar->getPos ()); - } - SCM - irr_gui_setPos (SCM wrapped_scrollbar, - SCM pos) +SCM +gui_IGUIScrollBar_setMax (SCM gui_scrollbar, + SCM max) +{ + ((gui::IGUIScrollBar*) scm_to_pointer (gui_scrollbar))->setMax (scm_to_int32 (max)); + return SCM_UNSPECIFIED; +} + + +SCM +gui_IGUIScrollBar_setPos (SCM gui_scrollbar, + SCM pos) +{ + ((gui::IGUIScrollBar*) scm_to_pointer (gui_scrollbar))->setPos (scm_to_int32 (pos)); + return SCM_UNSPECIFIED; +} + + +extern "C" { + + void + init_gui_scrollbar (void) { - irr::gui::IGUIScrollBar* scrollbar; - if (gui_element_p (wrapped_scrollbar)) - { - scrollbar = (irr::gui::IGUIScrollBar*)unwrap_gui_element (wrapped_scrollbar); - } - else { - scrollbar = unwrap_gui_scrollbar (wrapped_scrollbar); - } - scrollbar->setPos (scm_to_int32 (pos)); - return SCM_UNSPECIFIED; + DEFINE_GSUBR ("gui_IGUIScrollBar_getPos", 1, 0, 0, gui_IGUIScrollBar_getPos); + DEFINE_GSUBR ("gui_IGUIScrollBar_setMax", 2, 0, 0, gui_IGUIScrollBar_setMax); + DEFINE_GSUBR ("gui_IGUIScrollBar_setPos", 2, 0, 0, gui_IGUIScrollBar_setPos); } } diff --git a/src/gui-scrollbar.h b/src/gui-scrollbar.h index 8dcf7d7..5d49a83 100644 --- a/src/gui-scrollbar.h +++ b/src/gui-scrollbar.h @@ -24,23 +24,10 @@ #include #include -#include "wrapped.h" extern "C" { - void init_gui_scrollbar (void); - - DECLARE_WRAPPED_TYPE (irr::gui::IGUIScrollBar*, init_gui_scrollbar_type, - gui_scrollbar_p, wrap_gui_scrollbar, unwrap_gui_scrollbar); - - SCM - irr_gui_getPos (SCM wrapped_scrollbar); - - SCM - irr_gui_setPos (SCM wrapped_scrollbar, - SCM pos); - } #endif