More various KDM fixes.
[dcpomatic.git] / src / wx / dci_metadata_dialog.cc
1 /*
2     Copyright (C) 2012 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 <wx/wx.h>
21 #include <wx/sizer.h>
22 #include <wx/spinctrl.h>
23 #include "lib/film.h"
24 #include "dci_metadata_dialog.h"
25 #include "wx_util.h"
26
27 using boost::shared_ptr;
28
29 DCIMetadataDialog::DCIMetadataDialog (wxWindow* parent, DCIMetadata dm)
30         : wxDialog (parent, wxID_ANY, _("DCI name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
31 {
32         wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
33         table->AddGrowableCol (1, 1);
34
35         add_label_to_sizer (table, this, _("Content version"), true);
36         _content_version = new wxSpinCtrl (this, wxID_ANY);
37         table->Add (_content_version, 1, wxEXPAND);
38
39         add_label_to_sizer (table, this, _("Audio Language (e.g. EN)"), true);
40         _audio_language = new wxTextCtrl (this, wxID_ANY);
41         table->Add (_audio_language, 1, wxEXPAND);
42
43         add_label_to_sizer (table, this, _("Subtitle Language (e.g. FR)"), true);
44         _subtitle_language = new wxTextCtrl (this, wxID_ANY);
45         table->Add (_subtitle_language, 1, wxEXPAND);
46         
47         add_label_to_sizer (table, this, _("Territory (e.g. UK)"), true);
48         _territory = new wxTextCtrl (this, wxID_ANY);
49         table->Add (_territory, 1, wxEXPAND);
50
51         add_label_to_sizer (table, this, _("Rating (e.g. 15)"), true);
52         _rating = new wxTextCtrl (this, wxID_ANY);
53         table->Add (_rating, 1, wxEXPAND);
54
55         add_label_to_sizer (table, this, _("Studio (e.g. TCF)"), true);
56         _studio = new wxTextCtrl (this, wxID_ANY);
57         table->Add (_studio, 1, wxEXPAND);
58
59         add_label_to_sizer (table, this, _("Facility (e.g. DLA)"), true);
60         _facility = new wxTextCtrl (this, wxID_ANY);
61         table->Add (_facility, 1, wxEXPAND);
62
63         add_label_to_sizer (table, this, _("Package Type (e.g. OV)"), true);
64         _package_type = new wxTextCtrl (this, wxID_ANY);
65         table->Add (_package_type, 1, wxEXPAND);
66
67         _content_version->SetRange (1, 1024);
68
69         _content_version->SetValue (dm.content_version);
70         _audio_language->SetValue (std_to_wx (dm.audio_language));
71         _subtitle_language->SetValue (std_to_wx (dm.subtitle_language));
72         _territory->SetValue (std_to_wx (dm.territory));
73         _rating->SetValue (std_to_wx (dm.rating));
74         _studio->SetValue (std_to_wx (dm.studio));
75         _facility->SetValue (std_to_wx (dm.facility));
76         _package_type->SetValue (std_to_wx (dm.package_type));
77
78         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
79         overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
80         
81         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
82         if (buttons) {
83                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
84         }
85         
86         SetSizer (overall_sizer);
87         overall_sizer->Layout ();
88         overall_sizer->SetSizeHints (this);
89 }
90
91 DCIMetadata
92 DCIMetadataDialog::dci_metadata () const
93 {
94         DCIMetadata dm;
95
96         dm.content_version = _content_version->GetValue ();
97         dm.audio_language = wx_to_std (_audio_language->GetValue ());
98         dm.subtitle_language = wx_to_std (_subtitle_language->GetValue ());
99         dm.territory = wx_to_std (_territory->GetValue ());
100         dm.rating = wx_to_std (_rating->GetValue ());
101         dm.studio = wx_to_std (_studio->GetValue ());
102         dm.facility = wx_to_std (_facility->GetValue ());
103         dm.package_type = wx_to_std (_package_type->GetValue ());
104
105         return dm;
106 }