From: Javier Sancho Date: Tue, 26 May 2020 10:35:52 +0000 (+0200) Subject: add-file-open-dialog! get-file-name X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=7409d2166e97b930d76f32d0a78979df03be7119;p=guile-irrlicht.git add-file-open-dialog! get-file-name --- diff --git a/Makefile.am b/Makefile.am index 1a68584..5ff32e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,6 +37,7 @@ libguile_irrlicht_la_SOURCES = \ src/file-system.cpp \ src/gui-element.cpp \ src/gui-environment.cpp \ + src/gui-file-open-dialog.cpp \ src/gui-in-out-fader.cpp \ src/gui-listbox.cpp \ src/gui-scrollbar.cpp \ diff --git a/irrlicht.scm b/irrlicht.scm index 5dd508e..283e33d 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -44,6 +44,7 @@ + @@ -74,6 +75,7 @@ add-custom-scene-node! add-editbox! add-file-archive! + add-file-open-dialog! add-image! add-internal-point! add-item! @@ -101,6 +103,7 @@ get-event-key get-event-key-pressed get-event-type + get-file-name get-file-system get-font get-fps diff --git a/irrlicht/gui.scm b/irrlicht/gui.scm index 4708d37..3430e4d 100644 --- a/irrlicht/gui.scm +++ b/irrlicht/gui.scm @@ -72,6 +72,18 @@ (editbox (addEditBox gui-environment text rectangle border parent id))) (mem-wrapped editbox)))) +(define-method (add-file-open-dialog! (gui-environment ) . rest) + (let-keywords rest #f + ((title "") + (modal #t) + (parent (make )) + (id -1) + (restore-cwd #f) + (start-dir "")) + (let* ((addFileOpenDialog (get-irrlicht-proc "addFileOpenDialog" gui-environment parent)) + (dialog (addFileOpenDialog gui-environment title modal parent id restore-cwd start-dir))) + (mem-wrapped dialog)))) + (define-method (add-image! (gui-environment ) image pos . rest) (let-keywords rest #f ((use-alpha-channel #t) @@ -140,8 +152,8 @@ (let ((getSkin (get-irrlicht-proc "getSkin" gui-environment))) (getSkin gui-environment))) -(export add-button! add-editbox! add-image! add-listbox! add-scrollbar! - add-static-text! add-window! draw-all get-built-in-font get-font get-skin) +(export add-button! add-editbox! add-file-open-dialog! add-image! add-listbox! + add-scrollbar! add-static-text! add-window! draw-all get-built-in-font get-font get-skin) ;; IGUIStaticText @@ -239,3 +251,14 @@ (irr-class #:init-value "IGUIWindow")) (export ) + + +;; IGUIFileOpenDialog +(define-class () + (irr-class #:init-value "IGUIFileOpenDialog")) + +(define-method (get-file-name (dialog )) + (let ((getFileName (get-irrlicht-proc "getFileName" dialog))) + (getFileName dialog))) + +(export get-file-name) diff --git a/src/gui-element.cpp b/src/gui-element.cpp index af02ea6..896554d 100644 --- a/src/gui-element.cpp +++ b/src/gui-element.cpp @@ -41,6 +41,7 @@ init_gui_element (void) DEFINE_GSUBR ("IGUIButton_getID", 1, 0, 0, IGUIElement_getID); DEFINE_GSUBR ("IGUIEditBox_getID", 1, 0, 0, IGUIElement_getID); DEFINE_GSUBR ("IGUIElement_getID", 1, 0, 0, IGUIElement_getID); + DEFINE_GSUBR ("IGUIFileOpenDialog_getID", 1, 0, 0, IGUIElement_getID); DEFINE_GSUBR ("IGUIImage_getID", 1, 0, 0, IGUIElement_getID); DEFINE_GSUBR ("IGUIListBox_getID", 1, 0, 0, IGUIElement_getID); DEFINE_GSUBR ("IGUIScrollBar_getID", 1, 0, 0, IGUIElement_getID); diff --git a/src/gui-environment.cpp b/src/gui-environment.cpp index 33a03e4..c2e5272 100644 --- a/src/gui-environment.cpp +++ b/src/gui-environment.cpp @@ -78,6 +78,33 @@ IGUIEnvironment_addEditBox (SCM gui_environment, return scm_from_irr_pointer ("", (void*) editbox); } +template +SCM +IGUIEnvironment_addFileOpenDialog (SCM gui_environment, + SCM title, + SCM modal, + SCM parent, + SCM id, + SCM restore_cwd, + SCM start_dir) +{ + gui::IGUIEnvironment* guienv = (gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment); + wchar_t* wtitle = (wchar_t*) scm_to_utf32_string (title); + io::path::char_type* cstartDir = scm_to_utf8_string (start_dir); + + gui::IGUIFileOpenDialog* dialog = + guienv->addFileOpenDialog (wtitle, + scm_to_bool (modal), + (TParent)scm_to_irr_pointer (parent), + scm_to_int32 (id), + scm_to_bool (restore_cwd), + cstartDir); + + free (wtitle); + free (cstartDir); + return scm_from_irr_pointer ("", (void*) dialog); +} + template SCM IGUIEnvironment_addImage (SCM gui_environment, @@ -228,6 +255,8 @@ init_gui_environment (void) IGUIEnvironment_addButton); DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0, IGUIEnvironment_addEditBox); + DEFINE_GSUBR ("IGUIEnvironment_addFileOpenDialog_IGUIElement", 7, 0, 0, + IGUIEnvironment_addFileOpenDialog); DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0, IGUIEnvironment_addImage); DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0, diff --git a/src/gui-file-open-dialog.cpp b/src/gui-file-open-dialog.cpp new file mode 100644 index 0000000..c706a6f --- /dev/null +++ b/src/gui-file-open-dialog.cpp @@ -0,0 +1,42 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#include +#include +#include "gui-file-open-dialog.h" +#include "gsubr.h" +#include "wrapped.h" + +using namespace irr; + +SCM +IGUIFileOpenDialog_getFileName (SCM gui_file_open_dialog) +{ + gui::IGUIFileOpenDialog* dialog = + (gui::IGUIFileOpenDialog*)scm_to_irr_pointer (gui_file_open_dialog); + return scm_from_utf32_string ((scm_t_wchar*) dialog->getFileName ()); +} + +void +init_gui_file_open_dialog (void) +{ + DEFINE_GSUBR ("IGUIFileOpenDialog_getFileName", 1, 0, 0, IGUIFileOpenDialog_getFileName); +} diff --git a/src/gui-file-open-dialog.h b/src/gui-file-open-dialog.h new file mode 100644 index 0000000..717b51d --- /dev/null +++ b/src/gui-file-open-dialog.h @@ -0,0 +1,28 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#ifndef __GUILE_IRRLICHT_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ +#define __GUILE_IRRLICHT_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ + +void +init_gui_file_open_dialog (void); + +#endif diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index 6223aac..8f04ce3 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -29,6 +29,7 @@ #include "file-system.h" #include "gui-element.h" #include "gui-environment.h" +#include "gui-file-open-dialog.h" #include "gui-in-out-fader.h" #include "gui-listbox.h" #include "gui-scrollbar.h" @@ -59,6 +60,7 @@ extern "C" { init_file_system (); init_gui_element (); init_gui_environment (); + init_gui_file_open_dialog (); init_gui_in_out_fader (); init_gui_listbox (); init_gui_scrollbar ();