Add checked_set for wxDirPickerCtrl.
authorCarl Hetherington <cth@carlh.net>
Sun, 23 Sep 2018 00:34:15 +0000 (01:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 23 Sep 2018 00:34:15 +0000 (01:34 +0100)
src/wx/wx_util.cc
src/wx/wx_util.h

index 7edcabf40e379305d1c336f8e3702610d438d15f..91fd426247a94e40caaa82a547796864706e3c5c 100644 (file)
@@ -30,6 +30,7 @@
 #include <dcp/locale_convert.h>
 #include <wx/spinctrl.h>
 #include <wx/splash.h>
+#include <wx/filepicker.h>
 #include <boost/thread.hpp>
 
 using namespace std;
@@ -195,6 +196,20 @@ checked_set (FilePickerCtrl* widget, boost::filesystem::path value)
        }
 }
 
+void
+checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value)
+{
+       if (widget->GetPath() != std_to_wx (value.string())) {
+               if (value.empty()) {
+                       /* Hack to make wxWidgets clear the control when we are passed
+                          an empty value.
+                       */
+                       value = " ";
+               }
+               widget->SetPath (std_to_wx (value.string()));
+       }
+}
+
 void
 checked_set (wxSpinCtrl* widget, int value)
 {
index f59f5d68376cc41109981d89543a4f8582f1b30e..1acca044a6fd815445de113955f4c88e373db4fb 100644 (file)
@@ -36,6 +36,7 @@
 #endif
 
 class FilePickerCtrl;
+class wxDirPickerCtrl;
 class wxSpinCtrl;
 class wxSpinCtrlDouble;
 class wxGridBagSizer;
@@ -89,6 +90,7 @@ extern boost::filesystem::path path_from_file_dialog (wxFileDialog* dialog, std:
 extern double calculate_mark_interval (double start);
 
 extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value);
+extern void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value);
 extern void checked_set (wxSpinCtrl* widget, int value);
 extern void checked_set (wxSpinCtrlDouble* widget, double value);
 extern void checked_set (wxChoice* widget, int value);