2 Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "dcpomatic_choice.h"
27 using boost::optional;
30 Choice::Choice(wxWindow* parent)
31 : wxChoice(parent, wxID_ANY)
33 /* This hack works around a problem where the height of the wxChoice would be
34 * too small on KDE. This added empty string will be removed in the first
43 Choice::add(string const& entry)
45 add(std_to_wx(entry));
50 Choice::add(wxString const& entry)
52 if (_needs_clearing) {
54 _needs_clearing = false;
62 Choice::add(wxString const& entry, wxClientData* data)
64 if (_needs_clearing) {
66 _needs_clearing = false;
74 Choice::add(wxString const& entry, wxString const& data)
76 if (_needs_clearing) {
78 _needs_clearing = false;
81 Append(entry, new wxStringClientData(data));
86 Choice::set(int index)
95 auto const sel = GetSelection();
96 if (sel == wxNOT_FOUND) {
105 Choice::get_data() const
112 return dynamic_cast<wxStringClientData*>(GetClientObject(*index))->GetData();