diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-08-09 02:20:36 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-08-17 12:59:25 +0200 |
| commit | 9445fd4dfa58235f6f4a2badd6ba0305218b81a8 (patch) | |
| tree | 82f99504890f64bc3a5d93a61f3f1d3cc85c932d | |
| parent | f06e5720df22a46fa5d853320cea785c5b0192eb (diff) | |
Add some convenience methods to the Choice class.
| -rw-r--r-- | src/wx/dcpomatic_choice.cc | 21 | ||||
| -rw-r--r-- | src/wx/dcpomatic_choice.h | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/wx/dcpomatic_choice.cc b/src/wx/dcpomatic_choice.cc index ab7823901..52aaa4fc4 100644 --- a/src/wx/dcpomatic_choice.cc +++ b/src/wx/dcpomatic_choice.cc @@ -83,6 +83,13 @@ Choice::add_entry(wxString const& entry, wxString const& data) void +Choice::add_entry(wxString const& entry, string const& data) +{ + add_entry(entry, std_to_wx(data)); +} + + +void Choice::set_entries(wxArrayString const& entries) { if (GetStrings() == entries) { @@ -115,6 +122,13 @@ Choice::set_by_data(wxString const& data) } +void +Choice::set_by_data(string const& data) +{ + set_by_data(std_to_wx(data)); +} + + optional<int> Choice::get() const { @@ -138,3 +152,10 @@ Choice::get_data() const return dynamic_cast<wxStringClientData*>(GetClientObject(*index))->GetData(); } + +void +Choice::clear() +{ + Clear(); +} + diff --git a/src/wx/dcpomatic_choice.h b/src/wx/dcpomatic_choice.h index cc8115d20..5417c1aa2 100644 --- a/src/wx/dcpomatic_choice.h +++ b/src/wx/dcpomatic_choice.h @@ -35,11 +35,15 @@ public: void add_entry(wxString const& entry); void add_entry(wxString const& entry, wxClientData* data); void add_entry(wxString const& entry, wxString const& data); + void add_entry(wxString const& entry, std::string const& data); void add_entry(std::string const& entry); void set_entries(wxArrayString const& entries); + void clear(); + void set(int index); void set_by_data(wxString const& data); + void set_by_data(std::string const& data); boost::optional<int> get() const; boost::optional<wxString> get_data() const; |
