Revert overwrite changes; remove our replacement of file extension (#1383).
[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 wxDirPickerCtrl;
40 class wxSpinCtrl;
41 class wxSpinCtrlDouble;
42 class wxGridBagSizer;
43 class wxSplashScreen;
44
45 #define DCPOMATIC_SIZER_X_GAP 8
46 #define DCPOMATIC_SIZER_Y_GAP 8
47 #define DCPOMATIC_SIZER_GAP 8
48 #define DCPOMATIC_DIALOG_BORDER 12
49
50 /** Spacing to use between buttons in a vertical line */
51 #ifdef DCPOMATIC_OSX
52 #define DCPOMATIC_BUTTON_STACK_GAP 2
53 #else
54 #define DCPOMATIC_BUTTON_STACK_GAP 0
55 #endif
56
57 #ifdef DCPOMATIC_LINUX
58 #define DCPOMATIC_RTAUDIO_API RtAudio::LINUX_PULSE
59 #endif
60 #ifdef DCPOMATIC_WINDOWS
61 #define DCPOMATIC_RTAUDIO_API RtAudio::WINDOWS_DS
62 #endif
63 #ifdef DCPOMATIC_OSX
64 #define DCPOMATIC_RTAUDIO_API RtAudio::MACOSX_CORE
65 #endif
66
67 /** i18n macro to support strings like Context|String
68  *  so that `String' can be translated to different things
69  *  in different contexts.
70  */
71 #define S_(x) context_translation(x)
72
73 extern void error_dialog (wxWindow *, wxString, boost::optional<wxString> e = boost::optional<wxString>());
74 extern void message_dialog (wxWindow *, wxString);
75 extern bool confirm_dialog (wxWindow *, wxString);
76 extern wxStaticText* create_label (wxWindow* p, wxString t, bool left);
77 extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, bool left, int prop = 0, int flags = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT);
78 extern wxStaticText* add_label_to_sizer (wxSizer *, wxStaticText *, bool left, int prop = 0, int flags = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT);
79 extern wxStaticText* add_label_to_sizer (wxGridBagSizer *, wxWindow *, wxString, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
80 extern wxStaticText* add_label_to_sizer (wxGridBagSizer *, wxStaticText *, bool, wxGBPosition, wxGBSpan span = wxDefaultSpan);
81 extern std::string wx_to_std (wxString);
82 extern wxString std_to_wx (std::string);
83 extern void dcpomatic_setup_i18n ();
84 extern wxString context_translation (wxString);
85 extern std::string string_client_data (wxClientData* o);
86 extern wxString time_to_timecode (DCPTime t, double fps);
87 extern void setup_audio_channels_choice (wxChoice* choice, int minimum);
88 extern wxSplashScreen* maybe_show_splash ();
89 extern double calculate_mark_interval (double start);
90
91 extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value);
92 extern void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value);
93 extern void checked_set (wxSpinCtrl* widget, int value);
94 extern void checked_set (wxSpinCtrlDouble* widget, double value);
95 extern void checked_set (wxChoice* widget, int value);
96 extern void checked_set (wxChoice* widget, std::string value);
97 extern void checked_set (wxChoice* widget, std::vector<std::pair<std::string, std::string> > items);
98 extern void checked_set (wxTextCtrl* widget, std::string value);
99 extern void checked_set (wxTextCtrl* widget, wxString value);
100 extern void checked_set (wxCheckBox* widget, bool value);
101 extern void checked_set (wxRadioButton* widget, bool value);
102 extern void checked_set (wxStaticText* widget, std::string value);
103 extern void checked_set (wxStaticText* widget, wxString value);
104
105 extern int wx_get (wxChoice* widget);
106 extern int wx_get (wxSpinCtrl* widget);
107 extern double wx_get (wxSpinCtrlDouble* widget);
108
109 /* GTK 2.24.17 has a buggy GtkFileChooserButton and it was put in Ubuntu 13.04.
110    This also seems to apply to 2.24.20 in Ubuntu 13.10 and 2.24.23 in Ubuntu 14.04.
111    Use our own dir picker as this is the least bad option I can think of.
112 */
113 #if defined(__WXMSW__) || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 24 && (GTK_MICRO_VERSION == 17 || GTK_MICRO_VERSION == 20 || GTK_MICRO_VERSION == 23))
114 #define DCPOMATIC_USE_OWN_PICKER
115 #endif
116
117 #endif