2 Copyright (C) 2012-2018 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 "self_dkdm_dialog.h"
23 #include "kdm_output_panel.h"
24 #include "kdm_cpl_panel.h"
25 #include "static_text.h"
27 #include "lib/screen.h"
28 #include "lib/config.h"
29 #include "lib/warnings.h"
30 #include <libcxml/cxml.h>
31 #ifdef DCPOMATIC_USE_OWN_PICKER
32 #include "dir_picker_ctrl.h"
34 DCPOMATIC_DISABLE_WARNINGS
35 #include <wx/filepicker.h>
36 DCPOMATIC_ENABLE_WARNINGS
38 DCPOMATIC_DISABLE_WARNINGS
39 #include <wx/treectrl.h>
40 #include <wx/listctrl.h>
41 #include <wx/stdpaths.h>
42 DCPOMATIC_ENABLE_WARNINGS
52 using boost::shared_ptr;
55 SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
56 : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic"))
59 wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
61 /* Font for sub-headings */
62 wxFont subheading_font (*wxNORMAL_FONT);
63 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
65 /* Sub-heading: CPL */
66 wxStaticText* h = new StaticText (this, _("CPL"));
67 h->SetFont (subheading_font);
68 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
69 _cpl = new KDMCPLPanel (this, film->cpls ());
72 /* Sub-heading: output */
73 h = new StaticText (this, _("Output"));
74 h->SetFont (subheading_font);
75 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
77 _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list"));
78 vertical->Add (_internal, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP);
80 wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL);
82 _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
83 w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
85 #ifdef DCPOMATIC_USE_OWN_PICKER
86 _folder = new DirPickerCtrl (this);
88 _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
91 _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir());
93 w->Add (_folder, 1, wxEXPAND);
95 vertical->Add (w, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
97 /* Make an overall sizer to get a nice border, and put some buttons in */
99 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
100 overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
102 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
104 overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
107 SetSizer (overall_sizer);
108 overall_sizer->Layout ();
109 overall_sizer->SetSizeHints (this);
111 switch (Config::instance()->last_dkdm_write_type().get_value_or(Config::DKDM_WRITE_INTERNAL)) {
112 case Config::DKDM_WRITE_INTERNAL:
113 _internal->SetValue (true);
115 case Config::DKDM_WRITE_FILE:
116 _write_to->SetValue (true);
119 setup_sensitivity ();
121 _internal->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
122 _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
126 SelfDKDMDialog::dkdm_write_type_changed ()
128 setup_sensitivity ();
130 if (_internal->GetValue ()) {
131 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL);
132 } else if (_write_to->GetValue ()) {
133 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE);
138 SelfDKDMDialog::setup_sensitivity ()
140 _folder->Enable (_write_to->GetValue ());
142 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
144 ok->Enable (_cpl->has_selected ());
148 boost::filesystem::path
149 SelfDKDMDialog::cpl () const
155 SelfDKDMDialog::internal () const
157 return _internal->GetValue ();
160 boost::filesystem::path
161 SelfDKDMDialog::directory () const
163 return wx_to_std (_folder->GetPath ());