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