Add channel count hints to the default audio channel count preference,
[dcpomatic.git] / src / wx / wx_util.h
1 /*
2     Copyright (C) 2012-2015 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 /** @file src/wx/wx_util.h
22  *  @brief Some utility functions and classes.
23  */
24
25 #ifndef DCPOMATIC_WX_UTIL_H
26 #define DCPOMATIC_WX_UTIL_H
27
28 #include "lib/dcpomatic_time.h"
29 #include <wx/wx.h>
30 #include <wx/gbsizer.h>
31 #include <boost/function.hpp>
32 #include <boost/thread.hpp>
33 #include <boost/signals2.hpp>
34 #ifdef __WXGTK__
35 #include <gtk/gtk.h>
36 #endif
37
38 class FilePickerCtrl;
39 class wxSpinCtrl;
40 class wxSpinCtrlDouble;
41 class wxGridBagSizer;
42
43 #define DCPOMATIC_SIZER_X_GAP 8
44 #define DCPOMATIC_SIZER_Y_GAP 8
45 #define DCPOMATIC_SIZER_GAP 8
46 #define DCPOMATIC_DIALOG_BORDER 12
47
48 /** Spacing to use between buttons in a vertical line */
49 #ifdef DCPOMATIC_OSX
50 #define DCPOMATIC_BUTTON_STACK_GAP 2
51 #else
52 #define DCPOMATIC_BUTTON_STACK_GAP 0
53 #endif
54
55 /** i18n macro to support strings like Context|String
56  *  so that `String' can be translated to different things
57  *  in different contexts.
58  */
59 #define S_(x) context_translation(x)
60
61 extern void error_dialog (wxWindow *, wxString);
62 extern void message_dialog (wxWindow *, wxString);
63 extern bool confirm_dialog (wxWindow *, wxString);
64 extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, bool left, int prop = 0);
65 extern wxStaticText* add_label_to_sizer (wxGridBagSizer *, wxWindow *, wxString, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
66 extern std::string wx_to_std (wxString);
67 extern wxString std_to_wx (std::string);
68 extern void dcpomatic_setup_i18n ();
69 extern wxString context_translation (wxString);
70 extern std::string string_client_data (wxClientData* o);
71 extern wxString time_to_timecode (DCPTime t, double fps);
72 extern void setup_audio_channels_choice (wxChoice* choice, int minimum);
73
74 extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value);
75 extern void checked_set (wxSpinCtrl* widget, int value);
76 extern void checked_set (wxSpinCtrlDouble* widget, double value);
77 extern void checked_set (wxChoice* widget, int value);
78 extern void checked_set (wxChoice* widget, std::string value);
79 extern void checked_set (wxChoice* widget, std::vector<std::pair<std::string, std::string> > items);
80 extern void checked_set (wxTextCtrl* widget, std::string value);
81 extern void checked_set (wxTextCtrl* widget, wxString value);
82 extern void checked_set (wxCheckBox* widget, bool value);
83 extern void checked_set (wxRadioButton* widget, bool value);
84 extern void checked_set (wxStaticText* widget, std::string value);
85 extern void checked_set (wxStaticText* widget, wxString value);
86
87 extern int wx_get (wxChoice* widget);
88 extern int wx_get (wxSpinCtrl* widget);
89 extern double wx_get (wxSpinCtrlDouble* widget);
90
91 /* GTK 2.24.17 has a buggy GtkFileChooserButton and it was put in Ubuntu 13.04.
92    This also seems to apply to 2.24.20 in Ubuntu 13.10 and 2.24.23 in Ubuntu 14.04.
93    Use our own dir picker as this is the least bad option I can think of.
94 */
95 #if defined(__WXMSW__) || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 24 && (GTK_MICRO_VERSION == 17 || GTK_MICRO_VERSION == 20 || GTK_MICRO_VERSION == 23))
96 #define DCPOMATIC_USE_OWN_PICKER
97 #endif
98
99 #endif