Split KDM output stuff into a separate panel.
[dcpomatic.git] / src / wx / kdm_output_panel.cc
1 /*
2     Copyright (C) 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 "kdm_output_panel.h"
21 #include "wx_util.h"
22 #include <dcp/types.h>
23 #ifdef DCPOMATIC_USE_OWN_DIR_PICKER
24 #include "dir_picker_ctrl.h"
25 #else
26 #include <wx/filepicker.h>
27 #endif
28 #include <wx/stdpaths.h>
29
30 KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop)
31         : wxPanel (parent, wxID_ANY)
32 {
33         wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, 0);
34
35         add_label_to_sizer (table, this, _("KDM type"), true);
36         _type = new wxChoice (this, wxID_ANY);
37         _type->Append ("Modified Transitional 1", ((void *) dcp::MODIFIED_TRANSITIONAL_1));
38         if (!interop) {
39                 _type->Append ("DCI Any", ((void *) dcp::DCI_ANY));
40                 _type->Append ("DCI Specific", ((void *) dcp::DCI_SPECIFIC));
41         }
42         table->Add (_type, 1, wxEXPAND);
43         _type->SetSelection (0);
44
45         _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
46         table->Add (_write_to, 1, wxEXPAND);
47
48 #ifdef DCPOMATIC_USE_OWN_DIR_PICKER
49         _folder = new DirPickerCtrl (this);
50 #else
51         _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
52 #endif
53
54         _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir());
55
56         table->Add (_folder, 1, wxEXPAND);
57
58         _email = new wxRadioButton (this, wxID_ANY, _("Send by email"));
59         table->Add (_email, 1, wxEXPAND);
60         table->AddSpacer (0);
61
62         _write_to->SetValue (true);
63
64         _write_to->Bind (wxEVT_COMMAND_RADIOBUTTON_SELECTED, boost::bind (&KDMOutputPanel::setup_sensitivity, this));
65         _email->Bind    (wxEVT_COMMAND_RADIOBUTTON_SELECTED, boost::bind (&KDMOutputPanel::setup_sensitivity, this));
66
67         SetSizer (table);
68 }
69
70 void
71 KDMOutputPanel::setup_sensitivity ()
72 {
73         _folder->Enable (_write_to->GetValue ());
74 }
75
76 boost::filesystem::path
77 KDMOutputPanel::directory () const
78 {
79         return wx_to_std (_folder->GetPath ());
80 }
81
82 bool
83 KDMOutputPanel::write_to () const
84 {
85         return _write_to->GetValue ();
86 }
87
88 dcp::Formulation
89 KDMOutputPanel::formulation () const
90 {
91         return (dcp::Formulation) reinterpret_cast<intptr_t> (_type->GetClientData (_type->GetSelection()));
92 }