2 Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 #include "cinema_dialog.h"
23 #include "lib/dcpomatic_assert.h"
25 #include <boost/foreach.hpp>
30 using std::back_inserter;
41 CinemaDialog::CinemaDialog (wxWindow* parent, wxString title, string name, list<string> emails, string notes, int utc_offset_hour, int utc_offset_minute)
42 : wxDialog (parent, wxID_ANY, title)
44 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
45 SetSizer (overall_sizer);
47 wxGridBagSizer* sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
50 add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition (r, 0));
51 _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (500, -1));
52 sizer->Add (_name, wxGBPosition (r, 1));
55 add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition (r, 0));
56 _utc_offset = new wxChoice (this, wxID_ANY);
57 sizer->Add (_utc_offset, wxGBPosition (r, 1));
60 add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition (r, 0));
61 _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx (notes), wxDefaultPosition, wxSize (500, -1));
62 sizer->Add (_notes, wxGBPosition (r, 1));
65 add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition (r, 0), wxGBSpan (1, 2));
68 copy (emails.begin(), emails.end(), back_inserter (_emails));
70 vector<string> columns;
71 columns.push_back (wx_to_std (_("Address")));
72 _email_list = new EditableList<string, EmailDialog> (
73 this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&column, _1)
76 sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
79 overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
81 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
83 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
86 _offsets.push_back (Offset (_("UTC-11"), -11, 0));
87 _offsets.push_back (Offset (_("UTC-10"), -10, 0));
88 _offsets.push_back (Offset (_("UTC-9"), -9, 0));
89 _offsets.push_back (Offset (_("UTC-8"), -8, 0));
90 _offsets.push_back (Offset (_("UTC-7"), -7, 0));
91 _offsets.push_back (Offset (_("UTC-6"), -6, 0));
92 _offsets.push_back (Offset (_("UTC-5"), -5, 0));
93 _offsets.push_back (Offset (_("UTC-4:30"), -4, 30));
94 _offsets.push_back (Offset (_("UTC-4"), -4, 0));
95 _offsets.push_back (Offset (_("UTC-3:30"), -3, 30));
96 _offsets.push_back (Offset (_("UTC-3"), -3, 0));
97 _offsets.push_back (Offset (_("UTC-2"), -2, 0));
98 _offsets.push_back (Offset (_("UTC-1"), -1, 0));
99 _offsets.push_back (Offset (_("UTC") , 0, 0));
100 _offsets.push_back (Offset (_("UTC+1"), 1, 0));
101 _offsets.push_back (Offset (_("UTC+2"), 2, 0));
102 _offsets.push_back (Offset (_("UTC+3"), 3, 0));
103 _offsets.push_back (Offset (_("UTC+4"), 4, 0));
104 _offsets.push_back (Offset (_("UTC+5"), 5, 0));
105 _offsets.push_back (Offset (_("UTC+5:30"), 5, 30));
106 _offsets.push_back (Offset (_("UTC+6"), 6, 0));
107 _offsets.push_back (Offset (_("UTC+7"), 7, 0));
108 _offsets.push_back (Offset (_("UTC+8"), 8, 0));
109 _offsets.push_back (Offset (_("UTC+9"), 9, 0));
110 _offsets.push_back (Offset (_("UTC+9:30"), 9, 30));
111 _offsets.push_back (Offset (_("UTC+10"), 10, 0));
112 _offsets.push_back (Offset (_("UTC+11"), 11, 0));
113 _offsets.push_back (Offset (_("UTC+12"), 12, 0));
117 for (size_t i = 0; i < _offsets.size(); ++i) {
118 _utc_offset->Append (_offsets[i].name);
119 if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) {
124 _utc_offset->SetSelection (sel);
126 overall_sizer->Layout ();
127 overall_sizer->SetSizeHints (this);
131 CinemaDialog::name () const
133 return wx_to_std (_name->GetValue());
137 CinemaDialog::set_emails (vector<string> e)
143 CinemaDialog::get_emails () const
149 CinemaDialog::emails () const
152 copy (_emails.begin(), _emails.end(), back_inserter (e));
157 CinemaDialog::utc_offset_hour () const
159 int const sel = _utc_offset->GetSelection();
160 if (sel < 0 || sel > int (_offsets.size())) {
164 return _offsets[sel].hour;
168 CinemaDialog::utc_offset_minute () const
170 int const sel = _utc_offset->GetSelection();
171 if (sel < 0 || sel > int (_offsets.size())) {
175 return _offsets[sel].minute;
179 CinemaDialog::notes () const
181 return wx_to_std (_notes->GetValue ());