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;
34 #if BOOST_VERSION >= 106100
35 using namespace boost::placeholders;
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)
47 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
48 SetSizer (overall_sizer);
50 wxGridBagSizer* sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
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));
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));
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));
68 add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition (r, 0), wxGBSpan (1, 2));
71 copy (emails.begin(), emails.end(), back_inserter (_emails));
73 vector<EditableListColumn> columns;
74 columns.push_back (EditableListColumn(_("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)
79 sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
82 overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
84 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
86 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
90 size_t sel = get_offsets (_offsets);
91 for (size_t i = 0; i < _offsets.size(); ++i) {
92 _utc_offset->Append (_offsets[i].name);
93 if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) {
98 _utc_offset->SetSelection (sel);
100 overall_sizer->Layout ();
101 overall_sizer->SetSizeHints (this);
107 CinemaDialog::name () const
109 return wx_to_std (_name->GetValue());
113 CinemaDialog::set_emails (vector<string> e)
119 CinemaDialog::get_emails () const
125 CinemaDialog::emails () const
128 copy (_emails.begin(), _emails.end(), back_inserter (e));
133 CinemaDialog::utc_offset_hour () const
135 int const sel = _utc_offset->GetSelection();
136 if (sel < 0 || sel > int (_offsets.size())) {
140 return _offsets[sel].hour;
144 CinemaDialog::utc_offset_minute () const
146 int const sel = _utc_offset->GetSelection();
147 if (sel < 0 || sel > int (_offsets.size())) {
151 return _offsets[sel].minute;
155 CinemaDialog::notes () const
157 return wx_to_std (_notes->GetValue ());