7fd73c0cf1f723896826c77fec3720c5c404d4e8 from master; tidy audio analysis dialogue...
[dcpomatic.git] / src / wx / wx_util.h
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file src/wx/wx_util.h
21  *  @brief Some utility functions and classes.
22  */
23
24 #ifndef DCPOMATIC_WX_UTIL_H
25 #define DCPOMATIC_WX_UTIL_H
26
27 #include "lib/dcpomatic_time.h"
28 #include <wx/wx.h>
29 #include <wx/gbsizer.h>
30 #include <boost/function.hpp>
31 #include <boost/thread.hpp>
32 #include <boost/signals2.hpp>
33 #ifdef __WXGTK__
34 #include <gtk/gtk.h>
35 #endif
36
37 class wxFilePickerCtrl;
38 class wxSpinCtrl;
39 class wxSpinCtrlDouble;
40 class wxGridBagSizer;
41
42 #define DCPOMATIC_SIZER_X_GAP 8
43 #define DCPOMATIC_SIZER_Y_GAP 8
44 #define DCPOMATIC_SIZER_GAP 8
45 #define DCPOMATIC_DIALOG_BORDER 12
46
47 /** Spacing to use between buttons in a vertical line */
48 #ifdef DCPOMATIC_OSX
49 #define DCPOMATIC_BUTTON_STACK_GAP 2
50 #else
51 #define DCPOMATIC_BUTTON_STACK_GAP 0
52 #endif
53
54 /** i18n macro to support strings like Context|String
55  *  so that `String' can be translated to different things
56  *  in different contexts.
57  */
58 #define S_(x) context_translation(x)
59
60 extern void error_dialog (wxWindow *, wxString);
61 extern bool confirm_dialog (wxWindow *, wxString);
62 extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, bool left, int prop = 0);
63 extern wxStaticText* add_label_to_grid_bag_sizer (wxGridBagSizer *, wxWindow *, wxString, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
64 extern std::string wx_to_std (wxString);
65 extern wxString std_to_wx (std::string);
66 extern void dcpomatic_setup_i18n ();
67 extern wxString context_translation (wxString);
68 extern std::string string_client_data (wxClientData* o);
69 extern wxString time_to_timecode (DCPTime t, float fps);
70
71 extern void checked_set (wxFilePickerCtrl* widget, std::string value);
72 extern void checked_set (wxSpinCtrl* widget, int value);
73 extern void checked_set (wxSpinCtrlDouble* widget, double value);
74 extern void checked_set (wxChoice* widget, int value);
75 extern void checked_set (wxChoice* widget, std::string value);
76 extern void checked_set (wxChoice* widget, std::vector<std::pair<std::string, std::string> > items);
77 extern void checked_set (wxTextCtrl* widget, std::string value);
78 extern void checked_set (wxTextCtrl* widget, wxString value);
79 extern void checked_set (wxCheckBox* widget, bool value);
80 extern void checked_set (wxRadioButton* widget, bool value);
81 extern void checked_set (wxStaticText* widget, std::string value);
82 extern void checked_set (wxStaticText* widget, wxString value);
83
84 extern int wx_get (wxChoice* widget);
85 extern int wx_get (wxSpinCtrl* widget);
86 extern double wx_get (wxSpinCtrlDouble* widget);
87
88 /* GTK 2.24.17 has a buggy GtkFileChooserButton and it was put in Ubuntu 13.04.
89    This also seems to apply to 2.24.20 in Ubuntu 13.10 and 2.24.23 in Ubuntu 14.04.
90    Use our own dir picker as this is the least bad option I can think of.
91 */
92 #if defined(__WXMSW__) || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 24 && (GTK_MICRO_VERSION == 17 || GTK_MICRO_VERSION == 20 || GTK_MICRO_VERSION == 23))
93 #define DCPOMATIC_USE_OWN_DIR_PICKER
94 #endif
95
96 #endif