1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "time_picker.h"
#include "wx_util.h"
#include "static_text.h"
#include <dcp/locale_convert.h>
#include <wx/spinctrl.h>
#include <boost/bind.hpp>
#include <iomanip>
using std::setfill;
using std::setw;
using std::min;
using std::max;
using std::string;
using std::cout;
using boost::bind;
using dcp::locale_convert;
TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
: wxPanel (parent)
{
wxClientDC dc (parent);
wxSize size = dc.GetTextExtent (wxT ("9999999"));
size.SetHeight (-1);
wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
_hours = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
sizer->Add (_hours, 1, wxEXPAND | wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
sizer->Add (new StaticText (this, wxT (":")), 0, wxALIGN_CENTER_VERTICAL);
_minutes = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
sizer->Add (_minutes, 1, wxEXPAND | wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
SetSizerAndFit (sizer);
_minutes->MoveAfterInTabOrder (_hours);
_hours->SetValue (time.GetHour ());
_hours->SetRange (0, 23);
_minutes->SetValue (time.GetMinute ());
_minutes->SetRange (0, 59);
_hours->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
_minutes->Bind (wxEVT_SPINCTRL, (bind (&TimePicker::spin_changed, this)));
}
void
TimePicker::spin_changed ()
{
Changed ();
}
int
TimePicker::hours () const
{
return _hours->GetValue();
}
int
TimePicker::minutes () const
{
return _minutes->GetValue();
}
|