summaryrefslogtreecommitdiff
path: root/src/wx/dcpomatic_choice.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-05 01:26:58 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-05 17:06:21 +0100
commitcb330f076f72000d028b11e88702addb0a2ab480 (patch)
treef22b8a8bff9aacdfdf84d6b42665bf38bb502ec7 /src/wx/dcpomatic_choice.cc
parent4de8ab2f8e67c50546e0bf49ab045cbdb6f0c4e2 (diff)
Add Choice::set_by_data().
Diffstat (limited to 'src/wx/dcpomatic_choice.cc')
-rw-r--r--src/wx/dcpomatic_choice.cc14
1 files changed, 14 insertions, 0 deletions
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
{