2 Copyright (C) 2016 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 <dcp/locale_convert.h>
24 #include <wx/spinctrl.h>
25 #include <boost/bind.hpp>
35 using dcp::locale_convert;
37 TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
40 wxClientDC dc (parent);
41 wxSize size = dc.GetTextExtent (wxT ("9999999"));
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);
51 SetSizerAndFit (sizer);
53 _minutes->MoveAfterInTabOrder (_hours);
55 _hours->SetValue (time.GetHour ());
56 _hours->SetRange (0, 23);
57 _minutes->SetValue (time.GetMinute ());
58 _minutes->SetRange (0, 59);
60 _hours->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
61 _minutes->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
65 TimePicker::spin_changed ()
71 TimePicker::hours () const
73 return _hours->GetValue();
77 TimePicker::minutes () const
79 return _minutes->GetValue();