2 Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 #include "time_picker.h"
23 #include "static_text.h"
24 #include <dcp/locale_convert.h>
25 #include <wx/spinctrl.h>
26 #include <boost/bind.hpp>
36 using dcp::locale_convert;
38 TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
41 wxClientDC dc (parent);
42 wxSize size = dc.GetTextExtent (wxT ("9999999"));
45 wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
46 _hours = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
47 sizer->Add (_hours, 1, wxEXPAND | wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
48 sizer->Add (new StaticText (this, wxT (":")), 0, wxALIGN_CENTER_VERTICAL);
49 _minutes = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
50 sizer->Add (_minutes, 1, wxEXPAND | wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
52 SetSizerAndFit (sizer);
54 _minutes->MoveAfterInTabOrder (_hours);
56 _hours->SetValue (time.GetHour ());
57 _hours->SetRange (0, 23);
58 _minutes->SetValue (time.GetMinute ());
59 _minutes->SetRange (0, 59);
61 _hours->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
62 _minutes->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
66 TimePicker::spin_changed ()
72 TimePicker::hours () const
74 return _hours->GetValue();
78 TimePicker::minutes () const
80 return _minutes->GetValue();