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