Add DCPOMATIC_SPIN_CTRL_WIDTH and use it in a few places.
[dcpomatic.git] / src / wx / wx_util.h
1 /*
2     Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 /** @file src/wx/wx_util.h
23  *  @brief Some utility functions and classes.
24  */
25
26
27 #ifndef DCPOMATIC_WX_UTIL_H
28 #define DCPOMATIC_WX_UTIL_H
29
30
31 #include "lib/dcpomatic_time.h"
32 #include "lib/warnings.h"
33 DCPOMATIC_DISABLE_WARNINGS
34 #include <wx/wx.h>
35 DCPOMATIC_ENABLE_WARNINGS
36 #include <wx/gbsizer.h>
37 #include <boost/thread.hpp>
38 #include <boost/signals2.hpp>
39
40
41 class FilePickerCtrl;
42 class wxDirPickerCtrl;
43 class wxSpinCtrl;
44 class wxSpinCtrlDouble;
45 class wxGridBagSizer;
46 class wxSplashScreen;
47 class PasswordEntry;
48
49
50 #define DCPOMATIC_SIZER_X_GAP 8
51 #define DCPOMATIC_SIZER_Y_GAP 8
52 #define DCPOMATIC_SIZER_GAP 8
53 #define DCPOMATIC_DIALOG_BORDER 12
54 #ifdef __WXGTK3__
55 #define DCPOMATIC_SPIN_CTRL_WIDTH 118
56 #else
57 #define DCPOMATIC_SPIN_CTRL_WIDTH 56
58 #endif
59
60 /** Spacing to use between buttons in a vertical/horizontal line */
61 #if defined(DCPOMATIC_OSX) || defined(__WXGTK3__)
62 #define DCPOMATIC_BUTTON_STACK_GAP 2
63 #else
64 #define DCPOMATIC_BUTTON_STACK_GAP 0
65 #endif
66
67 #ifdef DCPOMATIC_LINUX
68 #define DCPOMATIC_RTAUDIO_API RtAudio::LINUX_PULSE
69 #endif
70 #ifdef DCPOMATIC_WINDOWS
71 #define DCPOMATIC_RTAUDIO_API RtAudio::UNSPECIFIED
72 #endif
73 #ifdef DCPOMATIC_OSX
74 #define DCPOMATIC_RTAUDIO_API RtAudio::MACOSX_CORE
75 #endif
76
77
78 /** i18n macro to support strings like Context|String
79  *  so that `String' can be translated to different things
80  *  in different contexts.
81  */
82 #define S_(x) context_translation(x)
83
84
85 extern void error_dialog (wxWindow *, wxString, boost::optional<wxString> e = boost::optional<wxString>());
86 extern void message_dialog (wxWindow *, wxString);
87 extern bool confirm_dialog (wxWindow *, wxString);
88 extern wxStaticText* create_label (wxWindow* p, wxString t, bool left);
89 extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, bool left, int prop = 0, int flags = wxLEFT | wxRIGHT);
90 extern wxStaticText* add_label_to_sizer (wxSizer *, wxStaticText *, bool left, int prop = 0, int flags = wxLEFT | wxRIGHT);
91 extern wxStaticText* add_label_to_sizer (wxGridBagSizer *, wxWindow *, wxString, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
92 extern wxStaticText* add_label_to_sizer (wxGridBagSizer *, wxStaticText *, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
93 extern std::string wx_to_std (wxString);
94 extern wxString std_to_wx (std::string);
95 extern void dcpomatic_setup_i18n ();
96 extern wxString context_translation (wxString);
97 extern std::string string_client_data (wxClientData* o);
98 extern wxString time_to_timecode (dcpomatic::DCPTime t, double fps);
99 extern void setup_audio_channels_choice (wxChoice* choice, int minimum);
100 extern wxSplashScreen* maybe_show_splash ();
101 extern double calculate_mark_interval (double start);
102 extern bool display_progress (wxString title, wxString task);
103 extern bool report_errors_from_last_job (wxWindow* parent);
104 extern wxString bitmap_path (std::string name);
105 extern wxSize small_button_size (wxWindow* parent, wxString text);
106
107
108 struct Offset
109 {
110         Offset (wxString n, int h, int m)
111                 : name (n)
112                 , hour (h)
113                 , minute (m)
114         {}
115
116         wxString name;
117         int hour;
118         int minute;
119 };
120
121 extern int get_offsets (std::vector<Offset>& offsets);
122
123
124 extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value);
125 extern void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value);
126 extern void checked_set (wxSpinCtrl* widget, int value);
127 extern void checked_set (wxSpinCtrlDouble* widget, double value);
128 extern void checked_set (wxChoice* widget, int value);
129 extern void checked_set (wxChoice* widget, std::string value);
130 extern void checked_set (wxChoice* widget, std::vector<std::pair<std::string, std::string> > items);
131 extern void checked_set (wxTextCtrl* widget, std::string value);
132 extern void checked_set (wxTextCtrl* widget, wxString value);
133 extern void checked_set (PasswordEntry* widget, std::string value);
134 extern void checked_set (wxCheckBox* widget, bool value);
135 extern void checked_set (wxRadioButton* widget, bool value);
136 extern void checked_set (wxStaticText* widget, std::string value);
137 extern void checked_set (wxStaticText* widget, wxString value);
138
139 extern int wx_get (wxChoice* widget);
140 extern int wx_get (wxSpinCtrl* widget);
141 extern double wx_get (wxSpinCtrlDouble* widget);
142
143 #if defined(__WXMSW__)
144 #define DCPOMATIC_USE_OWN_PICKER
145 #endif
146
147
148 #endif