2 Copyright (C) 2013-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/>.
29 TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button)
33 wxSize const s = TimecodeBase::size (parent);
35 wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
38 wxString n (wxT ("0123456789"));
39 for (size_t i = 0; i < n.Length(); ++i) {
43 validator.SetIncludes (list);
45 _sizer = new wxBoxSizer (wxHORIZONTAL);
47 _editable = new wxPanel (this);
48 wxSizer* editable_sizer = new wxBoxSizer (wxHORIZONTAL);
49 _hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
50 _hours->SetMaxLength (2);
51 editable_sizer->Add (_hours);
52 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
53 _minutes = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
54 _minutes->SetMaxLength (2);
55 editable_sizer->Add (_minutes);
56 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
57 _seconds = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
58 _seconds->SetMaxLength (2);
59 editable_sizer->Add (_seconds);
60 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
61 _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
62 _frames->SetMaxLength (2);
63 editable_sizer->Add (_frames);
65 _set_button = new wxButton (_editable, wxID_ANY, _("Set"));
66 editable_sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
68 _editable->SetSizerAndFit (editable_sizer);
69 _sizer->Add (_editable);
71 _fixed = add_label_to_sizer (_sizer, this, wxT ("42"), false);
73 _hours->Bind (wxEVT_TEXT, boost::bind (&TimecodeBase::changed, this));
74 _minutes->Bind (wxEVT_TEXT, boost::bind (&TimecodeBase::changed, this));
75 _seconds->Bind (wxEVT_TEXT, boost::bind (&TimecodeBase::changed, this));
76 _frames->Bind (wxEVT_TEXT, boost::bind (&TimecodeBase::changed, this));
78 _set_button->Bind (wxEVT_BUTTON, boost::bind (&TimecodeBase::set_clicked, this));
79 _set_button->Enable (false);
84 SetSizerAndFit (_sizer);
88 TimecodeBase::set_focus ()
94 TimecodeBase::clear ()
96 checked_set (_hours, wxT (""));
97 checked_set (_minutes, wxT (""));
98 checked_set (_seconds, wxT (""));
99 checked_set (_frames, wxT (""));
100 checked_set (_fixed, wxT (""));
104 TimecodeBase::changed ()
107 _set_button->Enable (true);
112 TimecodeBase::set_clicked ()
116 _set_button->Enable (false);
121 TimecodeBase::set_editable (bool e)
129 TimecodeBase::size (wxWindow* parent)
131 wxClientDC dc (parent);
132 wxSize size = dc.GetTextExtent (wxT ("9999"));