lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] (no subject)


From: Greg Chicares
Subject: [lmi-commits] (no subject)
Date: Sun, 5 Jun 2016 22:32:33 +0000 (UTC)

branch: master
commit 5230e2cb67d352c0aee4f4ed22a4e888e6c59fba
Author: Vadim Zeitlin <address@hidden>
Date:   Sat Jun 4 16:48:12 2016 +0200

    Use wxFilePickerCtrl for preferences dialog default input field
    
    This is more convenient as it allows the user to easily select an existing
    file without having to laboriously type in its name.
---
 preferences_view.xrc |    6 +++---
 transferor.cpp       |   18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/preferences_view.xrc b/preferences_view.xrc
index e7b6697..e2c9af5 100644
--- a/preferences_view.xrc
+++ b/preferences_view.xrc
@@ -252,10 +252,10 @@
                 </object>
                 <object class="sizeritem">
                     <flag>wxGROW</flag>
-                    <object class="wxTextCtrl" name="DefaultInputFilename">
-<!-- change soon to:
                     <object class="wxFilePickerCtrl" 
name="DefaultInputFilename">
--->
+                        
<style>wxFLP_OPEN|wxFLP_FILE_MUST_EXIST|wxFLP_USE_TEXTCTRL|wxFLP_SMALL</style>
+                        <message>Choose default file for new illustrations and 
censuses</message>
+                        <wildcard>Illustrations (*.ill)|*.ill|All 
files|*.*</wildcard>
                         <help>Name of file with customized input values that 
are used as defaults for new illustrations and censuses</help>
                         <size>180,-1</size>
                     </object>
diff --git a/transferor.cpp b/transferor.cpp
index 00ba9a3..4a5b3d3 100644
--- a/transferor.cpp
+++ b/transferor.cpp
@@ -47,6 +47,7 @@
 #include <wx/combobox.h>
 #include <wx/datectrl.h>
 #include <wx/dynarray.h>
+#include <wx/filepicker.h>
 #include <wx/gauge.h>
 #include <wx/intl.h>
 #include <wx/listbox.h>
@@ -70,6 +71,7 @@ namespace
     bool Transfer(transfer_direction, std::string&, wxChoice&         );
     bool Transfer(transfer_direction, std::string&, wxComboBox&       );
     bool Transfer(transfer_direction, std::string&, wxDatePickerCtrl& );
+    bool Transfer(transfer_direction, std::string&, wxFilePickerCtrl& );
     bool Transfer(transfer_direction, std::string&, wxGauge&          );
     bool Transfer(transfer_direction, std::string&, wxListBox&        );
     bool Transfer(transfer_direction, std::string&, wxRadioBox&       );
@@ -148,6 +150,7 @@ bool Transferor::PerformTransfer(transfer_direction td)
     wxComboBox       * combobox     ;
     wxChoice         * choice       ;
     wxDatePickerCtrl * datepicker   ;
+    wxFilePickerCtrl * filepicker   ;
     wxGauge          * gauge        ;
     wxListBox        * listbox      ;
     wxRadioBox       * radiobox     ;
@@ -173,6 +176,8 @@ bool Transferor::PerformTransfer(transfer_direction td)
         return Transfer(td, data_,             *choice      );
     else if(nullptr != (datepicker   = dynamic_cast<wxDatePickerCtrl 
*>(control)))
         return Transfer(td, data_,             *datepicker  );
+    else if(nullptr != (filepicker   = dynamic_cast<wxFilePickerCtrl 
*>(control)))
+        return Transfer(td, data_,             *filepicker  );
     else if(nullptr != (gauge        = dynamic_cast<wxGauge          
*>(control)))
         return Transfer(td, data_,             *gauge       );
     else if(nullptr != (listbox      = dynamic_cast<wxListBox        
*>(control)))
@@ -380,6 +385,19 @@ namespace
         return true;
     }
 
+    bool Transfer(transfer_direction td, std::string& data, wxFilePickerCtrl& 
control)
+    {
+        if(td == from_string_to_control)
+            {
+            control.SetPath(data);
+            }
+        else
+            {
+            data = control.GetPath().ToStdString();
+            }
+        return true;
+    }
+
     bool Transfer(transfer_direction td, std::string& data, wxGauge& control)
     {
         return TransferInt(td, data, control);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]