710f5e42d3c9ec17c4c731b2a6ba0e61d87fb76c
[dcpomatic.git] / src / wx / self_dkdm_dialog.cc
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include "self_dkdm_dialog.h"
21 #include "wx_util.h"
22 #include "kdm_output_panel.h"
23 #include "kdm_cpl_panel.h"
24 #include "lib/film.h"
25 #include "lib/screen.h"
26 #include <libcxml/cxml.h>
27 #include <wx/treectrl.h>
28 #include <wx/listctrl.h>
29 #include <wx/stdpaths.h>
30 #include <iostream>
31
32 using std::string;
33 using std::map;
34 using std::list;
35 using std::pair;
36 using std::cout;
37 using std::vector;
38 using std::make_pair;
39 using boost::shared_ptr;
40
41 SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
42         : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic"))
43 {
44         /* Main sizer */
45         wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
46
47         /* Font for sub-headings */
48         wxFont subheading_font (*wxNORMAL_FONT);
49         subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
50
51         /* Sub-heading: CPL */
52         wxStaticText* h = new wxStaticText (this, wxID_ANY, _("CPL"));
53         h->SetFont (subheading_font);
54         vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
55         _cpl = new KDMCPLPanel (this, film->cpls ());
56         vertical->Add (_cpl);
57
58         /* Make an overall sizer to get a nice border, and put some buttons in */
59
60         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
61         overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
62
63         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
64         if (buttons) {
65                 overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
66         }
67
68         setup_sensitivity ();
69
70         SetSizer (overall_sizer);
71         overall_sizer->Layout ();
72         overall_sizer->SetSizeHints (this);
73 }
74
75 void
76 SelfDKDMDialog::setup_sensitivity ()
77 {
78         wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
79         if (ok) {
80                 ok->Enable (_cpl->has_selected ());
81         }
82 }
83
84 boost::filesystem::path
85 SelfDKDMDialog::cpl () const
86 {
87         return _cpl->cpl ();
88 }