2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "kdm_dialog.h"
22 #include "screens_panel.h"
23 #include "kdm_timing_panel.h"
24 #include "kdm_output_panel.h"
25 #include "kdm_cpl_panel.h"
27 #include "lib/screen.h"
28 #include <libcxml/cxml.h>
29 #include <wx/treectrl.h>
30 #include <wx/listctrl.h>
40 using boost::shared_ptr;
42 KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
43 : wxDialog (parent, wxID_ANY, _("Make KDMs"))
46 wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
48 /* Font for sub-headings */
49 wxFont subheading_font (*wxNORMAL_FONT);
50 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
52 /* Sub-heading: Screens */
53 wxStaticText* h = new wxStaticText (this, wxID_ANY, _("Screens"));
54 h->SetFont (subheading_font);
55 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL);
56 _screens = new ScreensPanel (this);
57 /* Hack to stop KDM dialogs that are taller than my laptop screen; this
58 really isn't the right way to fix it...
60 _screens->SetMaxSize (wxSize (-1, 280));
61 vertical->Add (_screens, 1, wxEXPAND);
63 /* Sub-heading: Timing */
64 /// TRANSLATORS: translate the word "Timing" here; do not include the "KDM|" prefix
65 h = new wxStaticText (this, wxID_ANY, S_("KDM|Timing"));
66 h->SetFont (subheading_font);
67 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
68 _timing = new KDMTimingPanel (this);
69 vertical->Add (_timing);
71 /* Sub-heading: CPL */
72 h = new wxStaticText (this, wxID_ANY, _("CPL"));
73 h->SetFont (subheading_font);
74 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
75 _cpl = new KDMCPLPanel (this, film->cpls ());
78 /* Sub-heading: Output */
79 h = new wxStaticText (this, wxID_ANY, _("Output"));
80 h->SetFont (subheading_font);
81 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
82 _output = new KDMOutputPanel (this, film->interop ());
83 vertical->Add (_output, 0, wxEXPAND | wxTOP, DCPOMATIC_SIZER_GAP);
86 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
88 vertical->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
91 /* Make an overall sizer to get a nice border, and put some buttons in */
93 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
94 overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
98 _screens->ScreensChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
99 _timing->TimingChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
101 setup_sensitivity ();
103 SetSizer (overall_sizer);
104 overall_sizer->Layout ();
105 overall_sizer->SetSizeHints (this);
109 KDMDialog::setup_sensitivity ()
111 _screens->setup_sensitivity ();
112 _output->setup_sensitivity ();
114 bool const sd = _cpl->has_selected ();
116 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
118 ok->Enable (!_screens->screens().empty() && _timing->valid() && sd);
122 boost::filesystem::path
123 KDMDialog::cpl () const
128 list<shared_ptr<Screen> >
129 KDMDialog::screens () const
131 return _screens->screens ();
134 boost::posix_time::ptime
135 KDMDialog::from () const
137 return _timing->from ();
140 boost::posix_time::ptime
141 KDMDialog::until () const
143 return _timing->until ();
146 boost::filesystem::path
147 KDMDialog::directory () const
149 return _output->directory ();
153 KDMDialog::write_to () const
155 return _output->write_to ();
159 KDMDialog::formulation () const
161 return _output->formulation ();