]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
<gui-file-open-dialog> add-file-open-dialog! get-file-name
authorJavier Sancho <jsf@jsancho.org>
Tue, 26 May 2020 10:35:52 +0000 (12:35 +0200)
committerJavier Sancho <jsf@jsancho.org>
Tue, 26 May 2020 10:35:52 +0000 (12:35 +0200)
Makefile.am
irrlicht.scm
irrlicht/gui.scm
src/gui-element.cpp
src/gui-environment.cpp
src/gui-file-open-dialog.cpp [new file with mode: 0644]
src/gui-file-open-dialog.h [new file with mode: 0644]
src/guile-irrlicht.cpp

index 1a68584eea03e98d656230501406c53a27c88c8c..5ff32e4236413237aba6b9a996c7f355960af6ce 100644 (file)
@@ -37,6 +37,7 @@ libguile_irrlicht_la_SOURCES = \
   src/file-system.cpp \
   src/gui-element.cpp \
   src/gui-environment.cpp \
   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 \
   src/gui-in-out-fader.cpp \
   src/gui-listbox.cpp \
   src/gui-scrollbar.cpp \
index 5dd508ed33c2f40f1c51dd763e71c14fe21c91a1..283e33d84ef35ac573790db0c1ad3516f10176e3 100644 (file)
@@ -44,6 +44,7 @@
                <gui-editbox>
                <gui-element>
                <gui-environment>
                <gui-editbox>
                <gui-element>
                <gui-environment>
+               <gui-file-open-dialog>
                <gui-font>
                <gui-image>
                <gui-listbox>
                <gui-font>
                <gui-image>
                <gui-listbox>
@@ -74,6 +75,7 @@
                add-custom-scene-node!
                add-editbox!
                add-file-archive!
                add-custom-scene-node!
                add-editbox!
                add-file-archive!
+               add-file-open-dialog!
                add-image!
                add-internal-point!
                add-item!
                add-image!
                add-internal-point!
                add-item!
                get-event-key
                get-event-key-pressed
                get-event-type
                get-event-key
                get-event-key-pressed
                get-event-type
+               get-file-name
                get-file-system
                get-font
                get-fps
                get-file-system
                get-font
                get-fps
index 4708d371a3c706f0ca65f439e9d33c809830235f..3430e4d3a3cfa180414f10943f3eca950271f0a2 100644 (file)
            (editbox (addEditBox gui-environment text rectangle border parent id)))
       (mem-wrapped editbox))))
 
            (editbox (addEditBox gui-environment text rectangle border parent id)))
       (mem-wrapped editbox))))
 
+(define-method (add-file-open-dialog! (gui-environment <gui-environment>) . rest)
+  (let-keywords rest #f
+        ((title "")
+         (modal #t)
+         (parent (make <gui-element>))
+         (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 <gui-environment>) image pos . rest)
   (let-keywords rest #f
         ((use-alpha-channel #t)
 (define-method (add-image! (gui-environment <gui-environment>) image pos . rest)
   (let-keywords rest #f
         ((use-alpha-channel #t)
   (let ((getSkin (get-irrlicht-proc "getSkin" gui-environment)))
     (getSkin gui-environment)))
 
   (let ((getSkin (get-irrlicht-proc "getSkin" gui-environment)))
     (getSkin gui-environment)))
 
-(export <gui-environment> 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 <gui-environment> 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
 
 
 ;; IGUIStaticText
   (irr-class #:init-value "IGUIWindow"))
 
 (export <gui-window>)
   (irr-class #:init-value "IGUIWindow"))
 
 (export <gui-window>)
+
+
+;; IGUIFileOpenDialog
+(define-class <gui-file-open-dialog> (<gui-element>)
+  (irr-class #:init-value "IGUIFileOpenDialog"))
+
+(define-method (get-file-name (dialog <gui-file-open-dialog>))
+  (let ((getFileName (get-irrlicht-proc "getFileName" dialog)))
+    (getFileName dialog)))
+
+(export <gui-file-open-dialog> get-file-name)
index af02ea6e499aaab4e13b0e399b3b9a939aaa4350..896554d40ab2502cb7aedf55667e2a5dc8af8c77 100644 (file)
@@ -41,6 +41,7 @@ init_gui_element (void)
   DEFINE_GSUBR ("IGUIButton_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIButton*>);
   DEFINE_GSUBR ("IGUIEditBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIEditBox*>);
   DEFINE_GSUBR ("IGUIElement_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIElement*>);
   DEFINE_GSUBR ("IGUIButton_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIButton*>);
   DEFINE_GSUBR ("IGUIEditBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIEditBox*>);
   DEFINE_GSUBR ("IGUIElement_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIElement*>);
+  DEFINE_GSUBR ("IGUIFileOpenDialog_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIFileOpenDialog*>);
   DEFINE_GSUBR ("IGUIImage_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIImage*>);
   DEFINE_GSUBR ("IGUIListBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIListBox*>);
   DEFINE_GSUBR ("IGUIScrollBar_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIScrollBar*>);
   DEFINE_GSUBR ("IGUIImage_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIImage*>);
   DEFINE_GSUBR ("IGUIListBox_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIListBox*>);
   DEFINE_GSUBR ("IGUIScrollBar_getID", 1, 0, 0, IGUIElement_getID<gui::IGUIScrollBar*>);
index 33a03e4dfb8d276e3e0046aa0342f1a763141ecd..c2e52726d5d516c589d45bcb6fb65d6375512690 100644 (file)
@@ -78,6 +78,33 @@ IGUIEnvironment_addEditBox (SCM gui_environment,
   return scm_from_irr_pointer ("<gui-editbox>", (void*) editbox);
 }
 
   return scm_from_irr_pointer ("<gui-editbox>", (void*) editbox);
 }
 
+template <typename TParent>
+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 ("<gui-file-open-dialog>", (void*) dialog);
+}
+
 template <typename TParent>
 SCM
 IGUIEnvironment_addImage (SCM gui_environment,
 template <typename TParent>
 SCM
 IGUIEnvironment_addImage (SCM gui_environment,
@@ -228,6 +255,8 @@ init_gui_environment (void)
                 IGUIEnvironment_addButton<gui::IGUIElement*>);
   DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
                 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
                 IGUIEnvironment_addButton<gui::IGUIElement*>);
   DEFINE_GSUBR ("IGUIEnvironment_addEditBox_IGUIElement", 6, 0, 0,
                 IGUIEnvironment_addEditBox<gui::IGUIElement*>);
+  DEFINE_GSUBR ("IGUIEnvironment_addFileOpenDialog_IGUIElement", 7, 0, 0,
+                IGUIEnvironment_addFileOpenDialog<gui::IGUIElement*>);
   DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
                 IGUIEnvironment_addImage<gui::IGUIElement*>);
   DEFINE_GSUBR ("IGUIEnvironment_addListBox_IGUIElement", 5, 0, 0,
   DEFINE_GSUBR ("IGUIEnvironment_addImage_IGUIElement", 7, 0, 0,
                 IGUIEnvironment_addImage<gui::IGUIElement*>);
   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 (file)
index 0000000..c706a6f
--- /dev/null
@@ -0,0 +1,42 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   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
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#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 (file)
index 0000000..717b51d
--- /dev/null
@@ -0,0 +1,28 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   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
+   <http://www.gnu.org/licenses/>.
+*/
+
+#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
index 6223aac5cc99f5cb9fb74b9a172f3bd3860f53c0..8f04ce335edf444467684a552d3f75eeb755b87c 100644 (file)
@@ -29,6 +29,7 @@
 #include "file-system.h"
 #include "gui-element.h"
 #include "gui-environment.h"
 #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"
 #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_file_system ();
     init_gui_element ();
     init_gui_environment ();
+    init_gui_file_open_dialog ();
     init_gui_in_out_fader ();
     init_gui_listbox ();
     init_gui_scrollbar ();
     init_gui_in_out_fader ();
     init_gui_listbox ();
     init_gui_scrollbar ();