summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-10-28 22:56:23 +0100
committerCarl Hetherington <cth@carlh.net>2016-10-28 22:56:23 +0100
commitc27d6f3a7e6c79c60ffac7c616dd3a3431819862 (patch)
tree65dbc097882c052eee7e1021dc9ea35fed68956d /src
parent1b6cc1e8aa8abd05dfc9a108b35ddd7cbf50dedf (diff)
Attempt to tidy up layout of KDM window.
Diffstat (limited to 'src')
-rw-r--r--src/wx/kdm_timing_panel.cc10
-rw-r--r--src/wx/time_picker.cc65
-rw-r--r--src/wx/time_picker.h14
3 files changed, 23 insertions, 66 deletions
diff --git a/src/wx/kdm_timing_panel.cc b/src/wx/kdm_timing_panel.cc
index a07929b99..613b62cbf 100644
--- a/src/wx/kdm_timing_panel.cc
+++ b/src/wx/kdm_timing_panel.cc
@@ -32,23 +32,23 @@ KDMTimingPanel::KDMTimingPanel (wxWindow* parent)
{
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
- wxFlexGridSizer* table = new wxFlexGridSizer (6, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ wxSizer* table = new wxBoxSizer (wxHORIZONTAL);
add_label_to_sizer (table, this, _("From"), true);
wxDateTime from;
from.SetToCurrent ();
_from_date = new wxDatePickerCtrl (this, wxID_ANY, from);
- table->Add (_from_date, 1, wxEXPAND);
+ table->Add (_from_date);
_from_time = new TimePicker (this, from);
- table->Add (_from_time, 0);
+ table->Add (_from_time);
add_label_to_sizer (table, this, _("until"), true);
wxDateTime to = from;
/* 1 week from now */
to.Add (wxDateSpan (0, 0, 1, 0));
_until_date = new wxDatePickerCtrl (this, wxID_ANY, to);
- table->Add (_until_date, 1, wxEXPAND);
+ table->Add (_until_date);
_until_time = new TimePicker (this, to);
- table->Add (_until_time, 0);
+ table->Add (_until_time);
overall_sizer->Add (table);
diff --git a/src/wx/time_picker.cc b/src/wx/time_picker.cc
index 309e5c713..ee591023b 100644
--- a/src/wx/time_picker.cc
+++ b/src/wx/time_picker.cc
@@ -36,82 +36,45 @@ using dcp::locale_convert;
TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
: wxPanel (parent)
- , _block_update (false)
{
wxClientDC dc (parent);
- wxSize size = dc.GetTextExtent (wxT ("9999"));
+ wxSize size = dc.GetTextExtent (wxT ("9999999"));
size.SetHeight (-1);
wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
- _hours = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
- _hours->SetMaxLength (2);
- sizer->Add (_hours, 0);
- _hours_spin = new wxSpinButton (this, wxID_ANY);
- sizer->Add (_hours_spin, 0, wxLEFT | wxRIGHT, 2);
+ _hours = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
+ sizer->Add (_hours, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP);
sizer->Add (new wxStaticText (this, wxID_ANY, wxT (":")), 0, wxALIGN_CENTER_VERTICAL);
- _minutes = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
- _minutes->SetMaxLength (2);
- sizer->Add (_minutes, 0);
- _minutes_spin = new wxSpinButton (this, wxID_ANY);
- sizer->Add (_minutes_spin, 0, wxLEFT | wxRIGHT, 2);
+ _minutes = new wxSpinCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
+ sizer->Add (_minutes, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_GAP);
SetSizerAndFit (sizer);
_minutes->MoveAfterInTabOrder (_hours);
- _hours_spin->SetValue (time.GetHour ());
- _hours_spin->SetRange (0, 23);
- _minutes_spin->SetValue (time.GetMinute ());
- _minutes_spin->SetRange (0, 59);
+ _hours->SetValue (time.GetHour ());
+ _hours->SetRange (0, 23);
+ _minutes->SetValue (time.GetMinute ());
+ _minutes->SetRange (0, 59);
- update_text ();
-
- _hours->Bind (wxEVT_COMMAND_TEXT_UPDATED, (bind (&TimePicker::update_spin, this)));
- _minutes->Bind (wxEVT_COMMAND_TEXT_UPDATED, (bind (&TimePicker::update_spin, this)));
- _hours_spin->Bind (wxEVT_SPIN, bind (&TimePicker::update_text, this));
- _minutes_spin->Bind (wxEVT_SPIN, bind (&TimePicker::update_text, this));
-}
-
-void
-TimePicker::update_text ()
-{
- if (_block_update) {
- return;
- }
-
- _block_update = true;
-
- _hours->SetValue (wxString::Format ("%d", _hours_spin->GetValue ()));
- _minutes->SetValue (wxString::Format ("%02d", _minutes_spin->GetValue ()));
-
- _block_update = false;
-
- Changed ();
+ _hours->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, (bind (&TimePicker::spin_changed, this)));
+ _minutes->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, (bind (&TimePicker::spin_changed, this)));
}
void
-TimePicker::update_spin ()
+TimePicker::spin_changed ()
{
- if (_block_update) {
- return;
- }
-
- _block_update = true;
- _hours_spin->SetValue (locale_convert<int> (wx_to_std (_hours->GetValue())));
- _minutes_spin->SetValue (locale_convert<int> (wx_to_std (_minutes->GetValue())));
- _block_update = false;
-
Changed ();
}
int
TimePicker::hours () const
{
- return _hours_spin->GetValue();
+ return _hours->GetValue();
}
int
TimePicker::minutes () const
{
- return _minutes_spin->GetValue();
+ return _minutes->GetValue();
}
diff --git a/src/wx/time_picker.h b/src/wx/time_picker.h
index 808883010..53e31a06a 100644
--- a/src/wx/time_picker.h
+++ b/src/wx/time_picker.h
@@ -21,8 +21,7 @@
#include <wx/wx.h>
#include <boost/signals2.hpp>
-class wxTextCtrl;
-class wxSpinButton;
+class wxSpinCtrl;
class TimePicker : public wxPanel
{
@@ -35,13 +34,8 @@ public:
boost::signals2::signal<void ()> Changed;
private:
- void update_spin ();
- void update_text ();
+ void spin_changed ();
- wxTextCtrl* _hours;
- wxSpinButton* _hours_spin;
- wxTextCtrl* _minutes;
- wxSpinButton* _minutes_spin;
-
- bool _block_update;
+ wxSpinCtrl* _hours;
+ wxSpinCtrl* _minutes;
};