Move _state_timer into VideoView.
[dcpomatic.git] / src / wx / monitor_dialog.cc
1 /*
2     Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "monitor_dialog.h"
22 #include "wx_util.h"
23 #include "lib/encode_server.h"
24 #include <dcp/locale_convert.h>
25
26 using std::string;
27 using dcp::locale_convert;
28 using boost::shared_ptr;
29 using boost::optional;
30
31 MonitorDialog::MonitorDialog (wxWindow* parent)
32         : TableDialog (parent, _("Device"), 2, 1, true)
33 {
34         add (_("Manufacturer ID"), true);
35         _manufacturer_id = add (new wxTextCtrl(this, wxID_ANY, wxT("")));
36         add (_("Manufacturer product code"), true);
37         _manufacturer_product_code = add (new wxTextCtrl(this, wxID_ANY, wxT("")));
38         add (_("Serial number"), true);
39         _serial_number = add (new wxTextCtrl(this, wxID_ANY, wxT("")));
40         add (_("Week of manufacture"), true);
41         _week_of_manufacture = add (new wxTextCtrl(this, wxID_ANY, wxT("")));
42         add (_("Year of manufacture"), true);
43         _year_of_manufacture = add (new wxTextCtrl(this, wxID_ANY, wxT("")));
44
45         layout ();
46 }
47
48 void
49 MonitorDialog::set (Monitor monitor)
50 {
51         _manufacturer_id->SetValue (std_to_wx(monitor.manufacturer_id));
52         _manufacturer_product_code->SetValue (std_to_wx(locale_convert<string>(monitor.manufacturer_product_code)));
53         _serial_number->SetValue (std_to_wx(locale_convert<string>(monitor.serial_number)));
54         _week_of_manufacture->SetValue (std_to_wx(locale_convert<string>(monitor.week_of_manufacture)));
55         _year_of_manufacture->SetValue (std_to_wx(locale_convert<string>(monitor.year_of_manufacture)));
56 }
57
58 optional<Monitor>
59 MonitorDialog::get () const
60 {
61         Monitor m;
62         m.manufacturer_id = wx_to_std (_manufacturer_id->GetValue());
63         m.manufacturer_product_code = locale_convert<uint16_t>(wx_to_std(_manufacturer_product_code->GetValue()));
64         m.serial_number = locale_convert<uint32_t>(wx_to_std(_serial_number->GetValue()));
65         m.week_of_manufacture = locale_convert<uint8_t>(wx_to_std(_week_of_manufacture->GetValue()));
66         m.year_of_manufacture = locale_convert<uint8_t>(wx_to_std (_year_of_manufacture->GetValue()));
67         return m;
68 }