2 Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 TimecodeBase::TimecodeBase (wxWindow* parent)
31 wxSize const s = TimecodeBase::size (parent);
33 wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
36 wxString n (wxT ("0123456789"));
37 for (size_t i = 0; i < n.Length(); ++i) {
41 validator.SetIncludes (list);
43 _sizer = new wxBoxSizer (wxHORIZONTAL);
45 _editable = new wxPanel (this);
46 wxSizer* editable_sizer = new wxBoxSizer (wxHORIZONTAL);
47 _hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
48 _hours->SetMaxLength (2);
49 editable_sizer->Add (_hours);
50 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
51 _minutes = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
52 _minutes->SetMaxLength (2);
53 editable_sizer->Add (_minutes);
54 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
55 _seconds = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
56 _seconds->SetMaxLength (2);
57 editable_sizer->Add (_seconds);
58 add_label_to_sizer (editable_sizer, _editable, wxT (":"), false);
59 _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
60 _frames->SetMaxLength (2);
61 editable_sizer->Add (_frames);
62 _set_button = new wxButton (_editable, wxID_ANY, _("Set"));
63 editable_sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
64 _editable->SetSizerAndFit (editable_sizer);
65 _sizer->Add (_editable);
67 _fixed = add_label_to_sizer (_sizer, this, wxT ("42"), false);
69 _hours->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
70 _minutes->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
71 _seconds->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
72 _frames->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimecodeBase::changed, this));
73 _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimecodeBase::set_clicked, this));
75 _set_button->Enable (false);
79 SetSizerAndFit (_sizer);
83 TimecodeBase::clear ()
85 checked_set (_hours, wxT (""));
86 checked_set (_minutes, wxT (""));
87 checked_set (_seconds, wxT (""));
88 checked_set (_frames, wxT (""));
89 checked_set (_fixed, wxT (""));
93 TimecodeBase::changed ()
95 _set_button->Enable (true);
99 TimecodeBase::set_clicked ()
102 _set_button->Enable (false);
106 TimecodeBase::set_editable (bool e)
114 TimecodeBase::size (wxWindow* parent)
116 wxClientDC dc (parent);
117 wxSize size = dc.GetTextExtent (wxT ("9999"));