summaryrefslogtreecommitdiff
path: root/src/wx/dcpomatic_choice.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-10-10 01:12:29 +0200
committerCarl Hetherington <cth@carlh.net>2022-10-11 00:28:57 +0200
commitd9b398b33716d5f28fd8d6e22cb723c2fbb635a0 (patch)
treeb68ae47772dd1132c35dcdb3a6927dc4059cde84 /src/wx/dcpomatic_choice.cc
parenta4d0c85dba60e2837814bd100547189b9a193fff (diff)
Hack to fix wxChoice heights on KDE (#2343).
Diffstat (limited to 'src/wx/dcpomatic_choice.cc')
-rw-r--r--src/wx/dcpomatic_choice.cc90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/wx/dcpomatic_choice.cc b/src/wx/dcpomatic_choice.cc
new file mode 100644
index 000000000..168d76430
--- /dev/null
+++ b/src/wx/dcpomatic_choice.cc
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "dcpomatic_choice.h"
+#include "wx_util.h"
+
+
+using std::string;
+using boost::optional;
+
+
+Choice::Choice(wxWindow* parent)
+ : wxChoice(parent, wxID_ANY)
+{
+ /* This hack works around a problem where the height of the wxChoice would be
+ * too small on KDE. This added empty string will be removed in the first
+ * call to add().
+ */
+ Append("");
+ set(0);
+}
+
+
+void
+Choice::add(string const& entry)
+{
+ add(std_to_wx(entry));
+}
+
+
+void
+Choice::add(wxString const& entry)
+{
+ if (_needs_clearing) {
+ Clear();
+ _needs_clearing = false;
+ }
+
+ Append(entry);
+}
+
+
+void
+Choice::add(wxString const& entry, wxClientData* data)
+{
+ if (_needs_clearing) {
+ Clear();
+ _needs_clearing = false;
+ }
+
+ Append(entry, data);
+}
+
+
+void
+Choice::set(int index)
+{
+ SetSelection(index);
+}
+
+
+optional<int>
+Choice::get() const
+{
+ auto const sel = GetSelection();
+ if (sel == wxNOT_FOUND) {
+ return {};
+ }
+
+ return sel;
+}
+