+class WXDLLEXPORT wxVarScrollHelperEvtHandler : public wxEvtHandler
+{
+public:
+ wxVarScrollHelperEvtHandler(wxVarScrollHelperBase *scrollHelper)
+ {
+ m_scrollHelper = scrollHelper;
+ }
+
+ virtual bool ProcessEvent(wxEvent& event);
+
+private:
+ wxVarScrollHelperBase *m_scrollHelper;
+
+ wxDECLARE_NO_COPY_CLASS(wxVarScrollHelperEvtHandler);
+};
+
+// ============================================================================
+// wxVarScrollHelperEvtHandler implementation
+// ============================================================================
+
+// FIXME: This method totally duplicates a method with the same name in
+// wxScrollHelperEvtHandler, we really should merge them by reusing the
+// common parts in wxAnyScrollHelperBase.
+bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
+{
+ wxEventType evType = event.GetEventType();
+
+ // Pass it on to the real handler: notice that we must not call
+ // ProcessEvent() on this object itself as it wouldn't pass it to the next
+ // handler (i.e. the real window) if we're called from a previous handler
+ // (as indicated by "process here only" flag being set) and we do want to
+ // execute the handler defined in the window we're associated with right
+ // now, without waiting until TryAfter() is called from wxEvtHandler.
+ bool processed = m_nextHandler->ProcessEvent(event);
+
+ // always process the size events ourselves, even if the user code handles
+ // them as well, as we need to AdjustScrollbars()
+ //
+ // NB: it is important to do it after processing the event in the normal
+ // way as HandleOnSize() may generate a wxEVT_SIZE itself if the
+ // scrollbar[s] (dis)appear and it should be seen by the user code
+ // after this one
+ if ( evType == wxEVT_SIZE )
+ {
+ m_scrollHelper->HandleOnSize((wxSizeEvent &)event);
+ return true;
+ }
+
+ if ( processed && event.IsCommandEvent())
+ return true;
+
+ // For wxEVT_PAINT the user code can either handle this event as usual or
+ // override virtual OnDraw(), so if the event hasn't been handled we need
+ // to call this virtual function ourselves.
+ if (
+#ifndef __WXUNIVERSAL__
+ // in wxUniversal "processed" will always be true, because
+ // all windows use the paint event to draw themselves.
+ // In this case we can't use this flag to determine if a custom
+ // paint event handler already drew our window and we just
+ // call OnDraw() anyway.
+ !processed &&
+#endif // !__WXUNIVERSAL__
+ evType == wxEVT_PAINT )
+ {
+ m_scrollHelper->HandleOnPaint((wxPaintEvent &)event);
+ return true;
+ }
+
+ // reset the skipped flag (which might have been set to true in
+ // ProcessEvent() above) to be able to test it below
+ bool wasSkipped = event.GetSkipped();
+ if ( wasSkipped )
+ event.Skip(false);
+
+ if ( evType == wxEVT_SCROLLWIN_TOP ||
+ evType == wxEVT_SCROLLWIN_BOTTOM ||
+ evType == wxEVT_SCROLLWIN_LINEUP ||
+ evType == wxEVT_SCROLLWIN_LINEDOWN ||
+ evType == wxEVT_SCROLLWIN_PAGEUP ||
+ evType == wxEVT_SCROLLWIN_PAGEDOWN ||
+ evType == wxEVT_SCROLLWIN_THUMBTRACK ||
+ evType == wxEVT_SCROLLWIN_THUMBRELEASE )
+ {
+ m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event);
+ if ( !event.GetSkipped() )
+ {
+ // it makes sense to indicate that we processed the message as we
+ // did scroll the window (and also notice that wxAutoScrollTimer
+ // relies on our return value to stop scrolling when we are at top
+ // or bottom already)
+ processed = true;
+ wasSkipped = false;
+ }
+ }