{
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+#ifdef __WXGTK3__
+ /* wxDatePickerCtrl is too small with the GTK3 backend so we need to make it bigger with some fudge factors */
+ wxClientDC dc (parent);
+ wxSize size = dc.GetTextExtent (wxT("99/99/9999"));
+ size.SetWidth (size.GetWidth() * 1.75);
+ size.SetHeight (-1);
+#else
+ wxSize size = wxDefaultSize;
+#endif
+
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);
+ _from_date = new wxDatePickerCtrl (this, wxID_ANY, from, wxDefaultPosition, size);
table->Add (_from_date, 0, wxALIGN_CENTER_VERTICAL);
- _from_time = new TimePicker (this, from);
+
+#ifdef __WXGTK3__
+ _from_time = new TimePickerText (this, from);
+#else
+ _from_time = new TimePickerSpin (this, from);
+#endif
+
#ifdef DCPOMATIC_OSX
/* Hack to tweak alignment, which I can't get right by "proper" means for some reason */
table->Add (_from_time, 0, wxALIGN_CENTER_VERTICAL | wxTOP, 4);
wxDateTime to = from;
/* 1 week from now */
to.Add (wxDateSpan (0, 0, 1, 0));
- _until_date = new wxDatePickerCtrl (this, wxID_ANY, to);
+ _until_date = new wxDatePickerCtrl (this, wxID_ANY, to, wxDefaultPosition, size);
table->Add (_until_date, 0, wxALIGN_CENTER_VERTICAL);
- _until_time = new TimePicker (this, to);
+
+#ifdef __WXGTK3__
+ _until_time = new TimePickerText (this, to);
+#else
+ _until_time = new TimePickerSpin (this, to);
+#endif
+
#ifdef DCPOMATIC_OSX
table->Add (_until_time, 0, wxALIGN_CENTER_VERTICAL | wxTOP, 4);
#else
{
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
- _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (200, -1));
+#ifdef __WXGTK3__
+ int const height = 30;
+#else
+ int const height = -1;
+#endif
+
+ _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (200, height));
+#ifndef __WXGTK3__
+ /* The cancel button seems to be strangely broken in GTK3; clicking on it twice sometimes works */
_search->ShowCancelButton (true);
+#endif
sizer->Add (_search, 0, wxBOTTOM, DCPOMATIC_SIZER_GAP);
wxBoxSizer* targets = new wxBoxSizer (wxHORIZONTAL);
{
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
- _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (200, -1));
+#ifdef __WXGTK3__
+ int const height = 30;
+#else
+ int const height = -1;
+#endif
+
+ _search = new wxSearchCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, height));
+#ifndef __WXGTK3__
+ /* The cancel button seems to be strangely broken in GTK3; clicking on it twice sometimes works */
_search->ShowCancelButton (true);
+#endif
sizer->Add (_search, 0, wxBOTTOM, DCPOMATIC_SIZER_GAP);
wxBoxSizer* targets = new wxBoxSizer (wxHORIZONTAL);
/*
- Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using boost::bind;
using dcp::locale_convert;
-TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
+
+TimePicker::TimePicker (wxWindow* parent)
: wxPanel (parent)
{
+
+}
+
+
+TimePickerSpin::TimePickerSpin (wxWindow* parent, wxDateTime time)
+ : TimePicker (parent)
+{
wxClientDC dc (parent);
wxSize size = dc.GetTextExtent (wxT ("9999999"));
size.SetHeight (-1);
_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)));
+ _hours->Bind (wxEVT_SPINCTRL, (bind (&TimePickerSpin::changed, this)));
+ _minutes->Bind (wxEVT_SPINCTRL, (bind (&TimePickerSpin::changed, this)));
}
+
void
-TimePicker::spin_changed ()
+TimePickerSpin::changed ()
{
Changed ();
}
+
int
-TimePicker::hours () const
+TimePickerSpin::hours () const
{
return _hours->GetValue();
}
+
int
-TimePicker::minutes () const
+TimePickerSpin::minutes () const
{
return _minutes->GetValue();
}
+
+
+TimePickerText::TimePickerText (wxWindow* parent, wxDateTime time)
+ : TimePicker (parent)
+{
+ wxClientDC dc (parent);
+ wxSize size = dc.GetTextExtent (wxT("99999"));
+ size.SetHeight (-1);
+
+ wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
+ _hours = new wxTextCtrl (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, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 4);
+ _minutes = new wxTextCtrl (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 (wxString::Format("%d", time.GetHour()));
+ _minutes->SetValue (wxString::Format("%d", time.GetMinute()));
+
+ _hours->Bind (wxEVT_TEXT, (bind(&TimePickerText::changed, this)));
+ _minutes->Bind (wxEVT_TEXT, (bind(&TimePickerText::changed, this)));
+}
+
+
+void
+TimePickerText::changed ()
+{
+ Changed ();
+}
+
+
+int
+TimePickerText::hours () const
+{
+ return max(0, min(23, wxAtoi(_hours->GetValue())));
+}
+
+
+int
+TimePickerText::minutes () const
+{
+ return max(0, min(59, wxAtoi(_minutes->GetValue())));
+}
+
+
+
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
class wxSpinCtrl;
+
class TimePicker : public wxPanel
{
public:
- TimePicker (wxWindow* parent, wxDateTime time);
+ TimePicker (wxWindow* parent);
- int hours () const;
- int minutes () const;
+ virtual int hours () const = 0;
+ virtual int minutes () const = 0;
boost::signals2::signal<void ()> Changed;
+};
+
+
+class TimePickerSpin : public TimePicker
+{
+public:
+ TimePickerSpin (wxWindow* parent, wxDateTime time);
+
+ int hours () const;
+ int minutes () const;
private:
- void spin_changed ();
+ void changed ();
wxSpinCtrl* _hours;
wxSpinCtrl* _minutes;
};
+
+
+class TimePickerText : public TimePicker
+{
+public:
+ TimePickerText (wxWindow* parent, wxDateTime time);
+
+ int hours () const;
+ int minutes () const;
+
+private:
+ void changed ();
+
+ wxTextCtrl* _hours;
+ wxTextCtrl* _minutes;
+};