No-op; rename a whole load of wx constants to their shorter equivalents.
[dcpomatic.git] / src / wx / time_picker.cc
1 /*
2     Copyright (C) 2016 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 "time_picker.h"
22 #include "wx_util.h"
23 #include <dcp/locale_convert.h>
24 #include <wx/spinctrl.h>
25 #include <boost/bind.hpp>
26 #include <iomanip>
27
28 using std::setfill;
29 using std::setw;
30 using std::min;
31 using std::max;
32 using std::string;
33 using std::cout;
34 using boost::bind;
35 using dcp::locale_convert;
36
37 TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
38         : wxPanel (parent)
39 {
40         wxClientDC dc (parent);
41         wxSize size = dc.GetTextExtent (wxT ("9999999"));
42         size.SetHeight (-1);
43
44         wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
45         _hours = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
46         sizer->Add (_hours, 1, wxEXPAND | wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
47         sizer->Add (new wxStaticText (this, wxID_ANY, wxT (":")), 0, wxALIGN_CENTER_VERTICAL);
48         _minutes = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
49         sizer->Add (_minutes, 1, wxEXPAND | wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
50
51         SetSizerAndFit (sizer);
52
53         _minutes->MoveAfterInTabOrder (_hours);
54
55         _hours->SetValue (time.GetHour ());
56         _hours->SetRange (0, 23);
57         _minutes->SetValue (time.GetMinute ());
58         _minutes->SetRange (0, 59);
59
60         _hours->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
61         _minutes->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
62 }
63
64 void
65 TimePicker::spin_changed ()
66 {
67         Changed ();
68 }
69
70 int
71 TimePicker::hours () const
72 {
73         return _hours->GetValue();
74 }
75
76 int
77 TimePicker::minutes () const
78 {
79         return _minutes->GetValue();
80 }