//
// So we have
//
+// wxAnyScrollHelperBase
+// |
+// |
+// \|/
// wxScrollHelperBase
// |
// |
//
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxScrollHelperBase
+// This class allows reusing some of wxScrollHelperBase functionality in
+// wxVarScrollHelperBase in wx/vscroll.h without duplicating its code.
+class WXDLLIMPEXP_CORE wxAnyScrollHelperBase
+{
+public:
+ wxEXPLICIT wxAnyScrollHelperBase(wxWindow* win);
+
+ // Simple accessor for the window that is really being scrolled.
+ wxWindow *GetTargetWindow() const { return m_targetWindow; }
+
+protected:
+ // the window that receives the scroll events and the window to actually
+ // scroll, respectively
+ wxWindow *m_win,
+ *m_targetWindow;
+};
+
+// This is the class containing the guts of (uniform) scrolling logic.
+class WXDLLIMPEXP_CORE wxScrollHelperBase : public wxAnyScrollHelperBase
{
public:
// ctor must be given the associated window
// child of it in order to scroll only a portion the area between the
// scrollbars (spreadsheet: only cell area will move).
void SetTargetWindow(wxWindow *target);
- wxWindow *GetTargetWindow() const;
void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; }
wxRect GetTargetRect() const { return m_rectToScroll; }
double m_scaleX;
double m_scaleY;
- wxWindow *m_win,
- *m_targetWindow;
-
wxRect m_rectToScroll;
wxTimer *m_timerAutoScroll;
#include "wx/panel.h"
#include "wx/position.h"
+#include "wx/scrolwin.h"
class WXDLLIMPEXP_FWD_CORE wxVarScrollHelperEvtHandler;
// scrolwin.h) for the purpose of reducing code duplication |
// through the use of mix-in classes. |
// |
+// wxAnyScrollHelperBase |
+// | |
+// | |
+// | |
+// V |
// wxVarScrollHelperBase |
// / \ |
// / \ |
// required virtual functions that need to be implemented for any orientation
// specific work.
-class WXDLLIMPEXP_CORE wxVarScrollHelperBase
+class WXDLLIMPEXP_CORE wxVarScrollHelperBase : public wxAnyScrollHelperBase
{
public:
// constructors and such
// child of it in order to scroll only a portion the area between the
// scrollbars (spreadsheet: only cell area will move).
virtual void SetTargetWindow(wxWindow *target);
- virtual wxWindow *GetTargetWindow() const { return m_targetWindow; }
// Override this function to draw the graphic (or just process EVT_PAINT)
//virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
void IncOrient(wxCoord& x, wxCoord& y, wxCoord inc);
private:
-
- // the window that receives the scroll events and the window to actually
- // scroll, respectively
- wxWindow *m_win,
- *m_targetWindow;
-
// the total number of (logical) units
size_t m_unitMax;
}
// ============================================================================
-// wxScrollHelperBase implementation
+// wxAnyScrollHelperBase and wxScrollHelperBase implementation
// ============================================================================
// ----------------------------------------------------------------------------
-// wxScrollHelperBase construction
+// wxAnyScrollHelperBase
// ----------------------------------------------------------------------------
-wxScrollHelperBase::wxScrollHelperBase(wxWindow *win)
+wxAnyScrollHelperBase::wxAnyScrollHelperBase(wxWindow* win)
{
wxASSERT_MSG( win, wxT("associated window can't be NULL in wxScrollHelper") );
+ m_win = win;
+ m_targetWindow = NULL;
+}
+
+// ----------------------------------------------------------------------------
+// wxScrollHelperBase construction
+// ----------------------------------------------------------------------------
+
+wxScrollHelperBase::wxScrollHelperBase(wxWindow *win)
+ : wxAnyScrollHelperBase(win)
+{
m_xScrollPixelsPerLine =
m_yScrollPixelsPerLine =
m_xScrollPosition =
m_wheelRotation = 0;
#endif
- m_win =
- m_targetWindow = NULL;
-
m_timerAutoScroll = NULL;
m_handler = NULL;
- m_win = win;
-
m_win->SetScrollHelper(static_cast<wxScrollHelper *>(this));
// by default, the associated window is also the target window
DoSetTargetWindow(target);
}
-wxWindow *wxScrollHelperBase::GetTargetWindow() const
-{
- return m_targetWindow;
-}
-
// ----------------------------------------------------------------------------
// scrolling implementation itself
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow *win)
+ : wxAnyScrollHelperBase(win)
{
- wxASSERT_MSG( win, wxT("associated window can't be NULL in wxVarScrollHelperBase") );
-
#if wxUSE_MOUSEWHEEL
m_sumWheelRotation = 0;
#endif
m_sizeTotal = 0;
m_unitFirst = 0;
- m_win =
- m_targetWindow = NULL;
-
m_physicalScrolling = true;
m_handler = NULL;
- m_win = win;
-
// by default, the associated window is also the target window
DoSetTargetWindow(win);
-
}
wxVarScrollHelperBase::~wxVarScrollHelperBase()