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 <libcxml/cxml.h>
30 #ifdef DCPOMATIC_USE_OWN_PICKER
31 #include "dir_picker_ctrl.h"
33 #include <wx/filepicker.h>
35 #include <wx/treectrl.h>
36 #include <wx/listctrl.h>
37 #include <wx/stdpaths.h>
47 using boost::shared_ptr;
50 SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
51 : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic"))
54 wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
56 /* Font for sub-headings */
57 wxFont subheading_font (*wxNORMAL_FONT);
58 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
60 /* Sub-heading: CPL */
61 wxStaticText* h = new StaticText (this, _("CPL"));
62 h->SetFont (subheading_font);
63 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
64 _cpl = new KDMCPLPanel (this, film->cpls ());
67 /* Sub-heading: output */
68 h = new StaticText (this, _("Output"));
69 h->SetFont (subheading_font);
70 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
72 _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list"));
73 vertical->Add (_internal, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP);
75 wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL);
77 _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
78 w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
80 #ifdef DCPOMATIC_USE_OWN_PICKER
81 _folder = new DirPickerCtrl (this);
83 _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
86 _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir());
88 w->Add (_folder, 1, wxEXPAND);
90 vertical->Add (w, 0, wxBOTTOM, 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);
97 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
99 overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
102 SetSizer (overall_sizer);
103 overall_sizer->Layout ();
104 overall_sizer->SetSizeHints (this);
106 switch (Config::instance()->last_dkdm_write_type().get_value_or(Config::DKDM_WRITE_INTERNAL)) {
107 case Config::DKDM_WRITE_INTERNAL:
108 _internal->SetValue (true);
110 case Config::DKDM_WRITE_FILE:
111 _write_to->SetValue (true);
114 setup_sensitivity ();
116 _internal->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
117 _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
121 SelfDKDMDialog::dkdm_write_type_changed ()
123 setup_sensitivity ();
125 if (_internal->GetValue ()) {
126 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL);
127 } else if (_write_to->GetValue ()) {
128 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE);
133 SelfDKDMDialog::setup_sensitivity ()
135 _folder->Enable (_write_to->GetValue ());
137 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
139 ok->Enable (_cpl->has_selected ());
143 boost::filesystem::path
144 SelfDKDMDialog::cpl () const
150 SelfDKDMDialog::internal () const
152 return _internal->GetValue ();
155 boost::filesystem::path
156 SelfDKDMDialog::directory () const
158 return wx_to_std (_folder->GetPath ());