diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-01-05 01:26:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-01-05 17:06:21 +0100 |
| commit | cb330f076f72000d028b11e88702addb0a2ab480 (patch) | |
| tree | f22b8a8bff9aacdfdf84d6b42665bf38bb502ec7 | |
| parent | 4de8ab2f8e67c50546e0bf49ab045cbdb6f0c4e2 (diff) | |
Add Choice::set_by_data().
| -rw-r--r-- | src/lib/wscript | 1 | ||||
| -rw-r--r-- | src/wx/dcpomatic_choice.cc | 14 | ||||
| -rw-r--r-- | src/wx/dcpomatic_choice.h | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/wscript b/src/lib/wscript index dad8947b1..ce36832be 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -184,6 +184,7 @@ sources = """ string_text_file_decoder.cc subtitle_analysis.cc subtitle_encoder.cc + territory_type.cc text_ring_buffers.cc text_type.cc timer.cc diff --git a/src/wx/dcpomatic_choice.cc b/src/wx/dcpomatic_choice.cc index b639dd0f9..2f1a6f0e9 100644 --- a/src/wx/dcpomatic_choice.cc +++ b/src/wx/dcpomatic_choice.cc @@ -89,6 +89,20 @@ Choice::set(int index) } +void +Choice::set_by_data(wxString const& data) +{ + for (unsigned int i = 0; i < GetCount(); ++i) { + if (auto client_data = dynamic_cast<wxStringClientData*>(GetClientObject(i))) { + if (client_data->GetData() == data) { + set(i); + return; + } + } + } +} + + optional<int> Choice::get() const { diff --git a/src/wx/dcpomatic_choice.h b/src/wx/dcpomatic_choice.h index e663c948d..dec0a3701 100644 --- a/src/wx/dcpomatic_choice.h +++ b/src/wx/dcpomatic_choice.h @@ -37,6 +37,7 @@ public: void add(wxString const& entry, wxString const& data); void add(std::string const& entry); void set(int index); + void set_by_data(wxString const& data); boost::optional<int> get() const; boost::optional<wxString> get_data() const; |
