From 69e46a5803c9c015f3da4153340b3d4554deea2e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 23 Sep 2018 01:34:15 +0100 Subject: [PATCH] Add checked_set for wxDirPickerCtrl. --- src/wx/wx_util.cc | 15 +++++++++++++++ src/wx/wx_util.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 7edcabf40..91fd42624 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include 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) { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index f59f5d683..1acca044a 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -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); -- 2.30.2