Build fixes for Boost >= 1.73
[dcpomatic.git] / src / wx / cinema_dialog.cc
1 /*
2     Copyright (C) 2012-2016 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 #include "cinema_dialog.h"
22 #include "wx_util.h"
23 #include "lib/dcpomatic_assert.h"
24 #include "lib/util.h"
25 #include <boost/foreach.hpp>
26
27 using std::string;
28 using std::vector;
29 using std::copy;
30 using std::back_inserter;
31 using std::list;
32 using std::cout;
33 using boost::bind;
34 #if BOOST_VERSION >= 106100
35 using namespace boost::placeholders;
36 #endif
37
38 static string
39 column (string s)
40 {
41         return s;
42 }
43
44 CinemaDialog::CinemaDialog (wxWindow* parent, wxString title, string name, list<string> emails, string notes, int utc_offset_hour, int utc_offset_minute)
45         : wxDialog (parent, wxID_ANY, title)
46 {
47         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
48         SetSizer (overall_sizer);
49
50         wxGridBagSizer* sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
51         int r = 0;
52
53         add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition (r, 0));
54         _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (500, -1));
55         sizer->Add (_name, wxGBPosition (r, 1));
56         ++r;
57
58         add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition (r, 0));
59         _utc_offset = new wxChoice (this, wxID_ANY);
60         sizer->Add (_utc_offset, wxGBPosition (r, 1));
61         ++r;
62
63         add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition (r, 0));
64         _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx (notes), wxDefaultPosition, wxSize (500, -1));
65         sizer->Add (_notes, wxGBPosition (r, 1));
66         ++r;
67
68         add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition (r, 0), wxGBSpan (1, 2));
69         ++r;
70
71         copy (emails.begin(), emails.end(), back_inserter (_emails));
72
73         vector<string> columns;
74         columns.push_back (wx_to_std (_("Address")));
75         _email_list = new EditableList<string, EmailDialog> (
76                 this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&column, _1)
77                 );
78
79         sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
80         ++r;
81
82         overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
83
84         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
85         if (buttons) {
86                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
87         }
88
89         _offsets.push_back (Offset (_("UTC-11"),  -11,  0));
90         _offsets.push_back (Offset (_("UTC-10"),  -10,  0));
91         _offsets.push_back (Offset (_("UTC-9"),    -9,  0));
92         _offsets.push_back (Offset (_("UTC-8"),    -8,  0));
93         _offsets.push_back (Offset (_("UTC-7"),    -7,  0));
94         _offsets.push_back (Offset (_("UTC-6"),    -6,  0));
95         _offsets.push_back (Offset (_("UTC-5"),    -5,  0));
96         _offsets.push_back (Offset (_("UTC-4:30"), -4, 30));
97         _offsets.push_back (Offset (_("UTC-4"),    -4,  0));
98         _offsets.push_back (Offset (_("UTC-3:30"), -3, 30));
99         _offsets.push_back (Offset (_("UTC-3"),    -3,  0));
100         _offsets.push_back (Offset (_("UTC-2"),    -2,  0));
101         _offsets.push_back (Offset (_("UTC-1"),    -1,  0));
102         _offsets.push_back (Offset (_("UTC")  ,     0,  0));
103         _offsets.push_back (Offset (_("UTC+1"),     1,  0));
104         _offsets.push_back (Offset (_("UTC+2"),     2,  0));
105         _offsets.push_back (Offset (_("UTC+3"),     3,  0));
106         _offsets.push_back (Offset (_("UTC+4"),     4,  0));
107         _offsets.push_back (Offset (_("UTC+5"),     5,  0));
108         _offsets.push_back (Offset (_("UTC+5:30"),  5, 30));
109         _offsets.push_back (Offset (_("UTC+6"),     6,  0));
110         _offsets.push_back (Offset (_("UTC+7"),     7,  0));
111         _offsets.push_back (Offset (_("UTC+8"),     8,  0));
112         _offsets.push_back (Offset (_("UTC+9"),     9,  0));
113         _offsets.push_back (Offset (_("UTC+9:30"),  9, 30));
114         _offsets.push_back (Offset (_("UTC+10"),   10,  0));
115         _offsets.push_back (Offset (_("UTC+11"),   11,  0));
116         _offsets.push_back (Offset (_("UTC+12"),   12,  0));
117
118         /* Default to UTC */
119         size_t sel = 13;
120         for (size_t i = 0; i < _offsets.size(); ++i) {
121                 _utc_offset->Append (_offsets[i].name);
122                 if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) {
123                         sel = i;
124                 }
125         }
126
127         _utc_offset->SetSelection (sel);
128
129         overall_sizer->Layout ();
130         overall_sizer->SetSizeHints (this);
131 }
132
133 string
134 CinemaDialog::name () const
135 {
136         return wx_to_std (_name->GetValue());
137 }
138
139 void
140 CinemaDialog::set_emails (vector<string> e)
141 {
142         _emails = e;
143 }
144
145 vector<string>
146 CinemaDialog::get_emails () const
147 {
148         return _emails;
149 }
150
151 list<string>
152 CinemaDialog::emails () const
153 {
154         list<string> e;
155         copy (_emails.begin(), _emails.end(), back_inserter (e));
156         return e;
157 }
158
159 int
160 CinemaDialog::utc_offset_hour () const
161 {
162         int const sel = _utc_offset->GetSelection();
163         if (sel < 0 || sel > int (_offsets.size())) {
164                 return 0;
165         }
166
167         return _offsets[sel].hour;
168 }
169
170 int
171 CinemaDialog::utc_offset_minute () const
172 {
173         int const sel = _utc_offset->GetSelection();
174         if (sel < 0 || sel > int (_offsets.size())) {
175                 return 0;
176         }
177
178         return _offsets[sel].minute;
179 }
180
181 string
182 CinemaDialog::notes () const
183 {
184         return wx_to_std (_notes->GetValue ());
185 }