Hand-apply 077d2abb480a883119783db3f957f175e22e543b from master; stop more flickering...
[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 <wx/wx.h>
28 #include <wx/gbsizer.h>
29 #include <boost/function.hpp>
30 #include <boost/thread.hpp>
31 #include <boost/signals2.hpp>
32 #ifdef __WXGTK__
33 #include <gtk/gtk.h>
34 #endif
35
36 class wxFilePickerCtrl;
37 class wxSpinCtrl;
38 class wxSpinCtrlDouble;
39 class wxGridBagSizer;
40
41 #define DCPOMATIC_SIZER_X_GAP 8
42 #define DCPOMATIC_SIZER_Y_GAP 8
43 #define DCPOMATIC_SIZER_GAP 8
44 #define DCPOMATIC_DIALOG_BORDER 12
45
46 /** Spacing to use between buttons in a vertical line */
47 #ifdef DCPOMATIC_OSX
48 #define DCPOMATIC_BUTTON_STACK_GAP 2
49 #else
50 #define DCPOMATIC_BUTTON_STACK_GAP 0
51 #endif
52
53 /** i18n macro to support strings like Context|String
54  *  so that `String' can be translated to different things
55  *  in different contexts.
56  */
57 #define S_(x) context_translation(x)
58
59 extern void error_dialog (wxWindow *, wxString);
60 extern bool confirm_dialog (wxWindow *, wxString);
61 extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, bool left, int prop = 0);
62 extern wxStaticText* add_label_to_grid_bag_sizer (wxGridBagSizer *, wxWindow *, wxString, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
63 extern std::string wx_to_std (wxString);
64 extern wxString std_to_wx (std::string);
65 extern void dcpomatic_setup_i18n ();
66 extern wxString context_translation (wxString);
67 extern std::string string_client_data (wxClientData* o);
68
69 extern void checked_set (wxFilePickerCtrl* widget, std::string value);
70 extern void checked_set (wxSpinCtrl* widget, int value);
71 extern void checked_set (wxSpinCtrlDouble* widget, double value);
72 extern void checked_set (wxChoice* widget, int value);
73 extern void checked_set (wxChoice* widget, std::string value);
74 extern void checked_set (wxTextCtrl* widget, std::string value);
75 extern void checked_set (wxCheckBox* widget, bool value);
76 extern void checked_set (wxRadioButton* widget, bool value);
77 extern void checked_set (wxStaticText* widget, std::string value);
78 extern void checked_set (wxStaticText* widget, wxString value);
79
80 extern int wx_get (wxChoice* widget);
81 extern int wx_get (wxSpinCtrl* widget);
82 extern double wx_get (wxSpinCtrlDouble* widget);
83
84 /* GTK 2.24.17 has a buggy GtkFileChooserButton and it was put in Ubuntu 13.04.
85    This also seems to apply to 2.24.20 in Ubuntu 13.10 and 2.24.23 in Ubuntu 14.04.
86    Use our own dir picker as this is the least bad option I can think of.
87 */
88 #if defined(__WXMSW__) || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 24 && (GTK_MICRO_VERSION == 17 || GTK_MICRO_VERSION == 20 || GTK_MICRO_VERSION == 23))
89 #define DCPOMATIC_USE_OWN_DIR_PICKER
90 #endif
91
92 #endif