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"
26 #include "lib/screen.h"
27 #include "lib/config.h"
28 #include <libcxml/cxml.h>
29 #ifdef DCPOMATIC_USE_OWN_PICKER
30 #include "dir_picker_ctrl.h"
32 #include <wx/filepicker.h>
34 #include <wx/treectrl.h>
35 #include <wx/listctrl.h>
36 #include <wx/stdpaths.h>
46 using boost::shared_ptr;
49 SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
50 : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic"))
53 wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
55 /* Font for sub-headings */
56 wxFont subheading_font (*wxNORMAL_FONT);
57 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
59 /* Sub-heading: CPL */
60 wxStaticText* h = new wxStaticText (this, wxID_ANY, _("CPL"));
61 h->SetFont (subheading_font);
62 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
63 _cpl = new KDMCPLPanel (this, film->cpls ());
66 /* Sub-heading: output */
67 h = new wxStaticText (this, wxID_ANY, _("Output"));
68 h->SetFont (subheading_font);
69 vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
71 _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list"));
72 vertical->Add (_internal, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP);
74 wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL);
76 _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
77 w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
79 #ifdef DCPOMATIC_USE_OWN_PICKER
80 _folder = new DirPickerCtrl (this);
82 _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
85 _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir());
87 w->Add (_folder, 1, wxEXPAND);
89 vertical->Add (w, 0, wxBOTTOM, 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);
96 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
98 overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
101 SetSizer (overall_sizer);
102 overall_sizer->Layout ();
103 overall_sizer->SetSizeHints (this);
105 switch (Config::instance()->last_dkdm_write_type().get_value_or(Config::DKDM_WRITE_INTERNAL)) {
106 case Config::DKDM_WRITE_INTERNAL:
107 _internal->SetValue (true);
109 case Config::DKDM_WRITE_FILE:
110 _write_to->SetValue (true);
113 setup_sensitivity ();
115 _internal->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
116 _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
120 SelfDKDMDialog::dkdm_write_type_changed ()
122 setup_sensitivity ();
124 if (_internal->GetValue ()) {
125 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL);
126 } else if (_write_to->GetValue ()) {
127 Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE);
132 SelfDKDMDialog::setup_sensitivity ()
134 _folder->Enable (_write_to->GetValue ());
136 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
138 ok->Enable (_cpl->has_selected ());
142 boost::filesystem::path
143 SelfDKDMDialog::cpl () const
149 SelfDKDMDialog::internal () const
151 return _internal->GetValue ();
154 boost::filesystem::path
155 SelfDKDMDialog::directory () const
157 return wx_to_std (_folder->GetPath ());