2 Copyright (C) 2012-2015 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 "kdm_dialog.h"
23 #include "screens_panel.h"
24 #include "kdm_timing_panel.h"
25 #include "kdm_output_panel.h"
26 #include "kdm_cpl_panel.h"
28 #include "lib/screen.h"
29 #include <libcxml/cxml.h>
30 #include <wx/treectrl.h>
31 #include <wx/listctrl.h>
41 using boost::shared_ptr;
43 KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
44 : wxDialog (parent, wxID_ANY, _("Make KDMs"))
47 wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
49 /* Font for sub-headings */
50 wxFont subheading_font (*wxNORMAL_FONT);
51 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
53 /* Sub-heading: Screens */
54 wxStaticText* h = new wxStaticText (this, wxID_ANY, _("Screens"));
55 h->SetFont (subheading_font);
56 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL);
57 _screens = new ScreensPanel (this);
58 /* Hack to stop KDM dialogs that are taller than my laptop screen; this
59 really isn't the right way to fix it...
61 _screens->SetMaxSize (wxSize (-1, 280));
62 vertical->Add (_screens, 1, wxEXPAND);
64 /* Sub-heading: Timing */
65 /// TRANSLATORS: translate the word "Timing" here; do not include the "KDM|" prefix
66 h = new wxStaticText (this, wxID_ANY, S_("KDM|Timing"));
67 h->SetFont (subheading_font);
68 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
69 _timing = new KDMTimingPanel (this);
70 vertical->Add (_timing);
72 /* Sub-heading: CPL */
73 h = new wxStaticText (this, wxID_ANY, _("CPL"));
74 h->SetFont (subheading_font);
75 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
76 _cpl = new KDMCPLPanel (this, film->cpls ());
79 /* Sub-heading: Output */
80 h = new wxStaticText (this, wxID_ANY, _("Output"));
81 h->SetFont (subheading_font);
82 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
83 _output = new KDMOutputPanel (this, film->interop ());
84 vertical->Add (_output, 0, wxEXPAND | wxTOP, DCPOMATIC_SIZER_GAP);
87 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
89 vertical->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
92 /* Make an overall sizer to get a nice border, and put some buttons in */
94 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
95 overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
99 _screens->ScreensChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
100 _timing->TimingChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
102 setup_sensitivity ();
104 SetSizer (overall_sizer);
105 overall_sizer->Layout ();
106 overall_sizer->SetSizeHints (this);
110 KDMDialog::setup_sensitivity ()
112 _screens->setup_sensitivity ();
113 _output->setup_sensitivity ();
115 bool const sd = _cpl->has_selected ();
117 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
119 ok->Enable (!_screens->screens().empty() && _timing->valid() && sd);
123 boost::filesystem::path
124 KDMDialog::cpl () const
129 list<shared_ptr<Screen> >
130 KDMDialog::screens () const
132 return _screens->screens ();
135 boost::posix_time::ptime
136 KDMDialog::from () const
138 return _timing->from ();
141 boost::posix_time::ptime
142 KDMDialog::until () const
144 return _timing->until ();
147 boost::filesystem::path
148 KDMDialog::directory () const
150 return _output->directory ();
154 KDMDialog::write_to () const
156 return _output->write_to ();
160 KDMDialog::formulation () const
162 return _output->formulation ();