diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-03-01 01:23:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-03-03 01:27:53 +0100 |
| commit | 2f518094d7db4e8586eba9c741289735794c572c (patch) | |
| tree | b53aaa64dc8d6f36d12fe748b2a7a7e41a788161 | |
| parent | 1695ad102d21c601592e8895d8b402ceebf4f1b0 (diff) | |
Add Choice::get_data().
| -rw-r--r-- | src/wx/dcpomatic_choice.cc | 12 | ||||
| -rw-r--r-- | src/wx/dcpomatic_choice.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/wx/dcpomatic_choice.cc b/src/wx/dcpomatic_choice.cc index 168d76430..cf43b13ed 100644 --- a/src/wx/dcpomatic_choice.cc +++ b/src/wx/dcpomatic_choice.cc @@ -88,3 +88,15 @@ Choice::get() const return sel; } + +optional<wxString> +Choice::get_data() const +{ + auto index = get(); + if (!index) { + return {}; + } + + return dynamic_cast<wxStringClientData*>(GetClientObject(*index))->GetData(); +} + diff --git a/src/wx/dcpomatic_choice.h b/src/wx/dcpomatic_choice.h index 7c9042de9..7c1fadcc0 100644 --- a/src/wx/dcpomatic_choice.h +++ b/src/wx/dcpomatic_choice.h @@ -37,6 +37,7 @@ public: void add(std::string const& entry); void set(int index); boost::optional<int> get() const; + boost::optional<wxString> get_data() const; template <typename... Args> void bind(Args... args) { |
