Add mouse wheel handlign to wxGenericCalendarCtrl
Mimics the scrolling behaviour of native MSW and GTK calendars by allowing to increment/decrement the month by scrolling anywhere on the generic calendar. Additionally, use horizontal scrolling to increment/decrement the year. Closes https://github.com/wxWidgets/wxWidgets/pull/88
This commit is contained in:
committed by
Vadim Zeitlin
parent
4d911fb059
commit
50daf1feab
@@ -179,6 +179,7 @@ private:
|
|||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
void OnClick(wxMouseEvent& event);
|
void OnClick(wxMouseEvent& event);
|
||||||
void OnDClick(wxMouseEvent& event);
|
void OnDClick(wxMouseEvent& event);
|
||||||
|
void OnWheel(wxMouseEvent& event);
|
||||||
void OnChar(wxKeyEvent& event);
|
void OnChar(wxKeyEvent& event);
|
||||||
void OnMonthChange(wxCommandEvent& event);
|
void OnMonthChange(wxCommandEvent& event);
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ wxBEGIN_EVENT_TABLE(wxGenericCalendarCtrl, wxControl)
|
|||||||
|
|
||||||
EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick)
|
EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick)
|
||||||
EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick)
|
EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick)
|
||||||
|
EVT_MOUSEWHEEL(wxGenericCalendarCtrl::OnWheel)
|
||||||
|
|
||||||
EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged)
|
EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
@@ -1512,6 +1513,28 @@ wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGenericCalendarCtrl::OnWheel(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
wxDateSpan span;
|
||||||
|
switch ( event.GetWheelAxis() )
|
||||||
|
{
|
||||||
|
case wxMOUSE_WHEEL_VERTICAL:
|
||||||
|
span = wxDateSpan::Month();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxMOUSE_WHEEL_HORIZONTAL:
|
||||||
|
span = wxDateSpan::Year();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Currently we only take into account the rotation direction, not its
|
||||||
|
// magnitude.
|
||||||
|
if ( event.GetWheelRotation() < 0 )
|
||||||
|
span = -span;
|
||||||
|
|
||||||
|
SetDateAndNotify(m_date + span);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// subcontrols events handling
|
// subcontrols events handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user