+//---------------------------------------------------------------------------
+// Base classes. I don't expect that these will ever be used directly from
+// Python, (especially being derived from) so I own't worry about making their
+// virutals overridable. They're just defined here for their public methods.
+
+
+
+// Provides all base common scroll calculations needed for either orientation,
+// automatic scrollbar functionality, saved scroll positions, functionality
+// for changing the target window to be scrolled, as well as defining all
+// required virtual functions that need to be implemented for any orientation
+// specific work.
+
+class wxVarScrollHelperBase
+{
+public:
+
+// wxVarScrollHelperBase(wxWindow *winToScroll); *** ABC, can't instantiate
+// virtual ~wxVarScrollHelperBase();
+
+
+ // with physical scrolling on, the device origin is changed properly when
+ // a wxPaintDC is prepared, children are actually moved and laid out
+ // properly, and the contents of the window (pixels) are actually moved
+ void EnablePhysicalScrolling(bool scrolling = true);
+
+ // wxNOT_FOUND if none, i.e. if it is below the last item
+ virtual int HitTest(wxCoord coord) const;
+
+ // recalculate all our parameters and redisplay all units
+ virtual void RefreshAll();
+
+
+ // get the first currently visible unit
+ size_t GetVisibleBegin() const;
+
+ // get the last currently visible unit
+ size_t GetVisibleEnd() const;
+
+ // is this unit currently visible?
+ bool IsVisible(size_t unit) const;
+
+ // translate between scrolled and unscrolled coordinates
+ int CalcScrolledPosition(int coord) const;
+ int CalcUnscrolledPosition(int coord) const;
+
+ // update the thumb size shown by the scrollbar
+ virtual void UpdateScrollbar();
+ void RemoveScrollbar();
+
+ // Normally the wxScrolledWindow will scroll itself, but in some rare
+ // occasions you might want it to scroll [part of] another window (e.g. a
+ // 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;
+
+
+ // these functions must be overidden in the derived class to return
+ // orientation specific data (e.g. the width for vertically scrolling
+ // derivatives in the case of GetOrientationTargetSize())
+ virtual int GetOrientationTargetSize() const; // = 0;
+ virtual int GetNonOrientationTargetSize() const; // = 0;
+ virtual wxOrientation GetOrientation() const; // = 0;
+};
+
+
+
+
+
+// Provides public API functions targeted for vertical-specific scrolling,
+// wrapping the functionality of wxVarScrollHelperBase.
+
+class wxVarVScrollHelper : public wxVarScrollHelperBase
+{
+public:
+
+// wxVarVScrollHelper(wxWindow *winToScroll); *** ABC, can't instantiate
+
+ void SetRowCount(size_t rowCount);
+ bool ScrollToRow(size_t row);
+
+ virtual bool ScrollRows(int rows);
+ virtual bool ScrollRowPages(int pages);
+
+ virtual void RefreshRow(size_t row);
+ virtual void RefreshRows(size_t from, size_t to);
+
+ virtual int HitTest(wxCoord y) const;
+
+
+ size_t GetRowCount() const;
+ size_t GetVisibleRowsBegin() const;
+ size_t GetVisibleRowsEnd() const;
+ bool IsRowVisible(size_t row) const;
+
+ virtual int GetOrientationTargetSize() const;
+ virtual int GetNonOrientationTargetSize() const;
+ virtual wxOrientation GetOrientation() const;
+};
+
+
+
+
+
+// Provides public API functions targeted for horizontal-specific scrolling,
+// wrapping the functionality of wxVarScrollHelperBase.
+
+class wxVarHScrollHelper : public wxVarScrollHelperBase
+{
+public:
+
+// wxVarHScrollHelper(wxWindow *winToScroll) *** ABC, can't instantiate
+
+ void SetColumnCount(size_t columnCount);
+
+ bool ScrollToColumn(size_t column);
+ virtual bool ScrollColumns(int columns);
+ virtual bool ScrollColumnPages(int pages);
+
+ virtual void RefreshColumn(size_t column);
+ virtual void RefreshColumns(size_t from, size_t to);
+ virtual int HitTest(wxCoord x) const;
+
+
+ size_t GetColumnCount() const;
+ size_t GetVisibleColumnsBegin() const;
+ size_t GetVisibleColumnsEnd() const;
+ bool IsColumnVisible(size_t column) const;
+
+
+ virtual int GetOrientationTargetSize() const;
+ virtual int GetNonOrientationTargetSize() const;
+ virtual wxOrientation GetOrientation() const;
+
+};
+
+
+
+
+
+
+// Provides public API functions targeted at functions with similar names in
+// both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be
+// specified (since we are using multiple inheritance). It also provides
+// functions to make changing values for both orientations at the same time
+// easier.
+
+class wxVarHVScrollHelper : public wxVarVScrollHelper,
+ public wxVarHScrollHelper
+{
+public:
+
+// wxVarHVScrollHelper(wxWindow *winToScroll); *** ABC, can't instantiate
+
+
+ // set the number of units the window contains for each axis: the derived
+ // class must provide the widths and heights for all units with indices up
+ // to each of the one given here in its OnGetColumnWidth() and
+ // OnGetRowHeight()
+ void SetRowColumnCount(size_t rowCount, size_t columnCount);
+
+
+ // with physical scrolling on, the device origin is changed properly when
+ // a wxPaintDC is prepared, children are actually moved and laid out
+ // properly, and the contents of the window (pixels) are actually moved
+ void EnablePhysicalScrolling(bool vscrolling = true, bool hscrolling = true);
+
+
+ // scroll to the specified row/column: it will become the first visible
+ // cell in the window
+ //
+ // return true if we scrolled the window, false if nothing was done
+// bool ScrollToRowColumn(size_t row, size_t column);
+ bool ScrollToRowColumn(const wxPosition &pos);
+
+ // redraw the specified cell
+// virtual void RefreshRowColumn(size_t row, size_t column);
+ virtual void RefreshRowColumn(const wxPosition &pos);
+
+ // redraw the specified regions (inclusive). If the target window for
+ // both orientations is the same the rectangle of cells is refreshed; if
+ // the target windows differ the entire client size opposite the
+ // orientation direction is refreshed between the specified limits
+// virtual void RefreshRowsColumns(size_t fromRow, size_t toRow,
+// size_t fromColumn, size_t toColumn);
+ virtual void RefreshRowsColumns(const wxPosition& from,
+ const wxPosition& to);
+
+ // Override wxPanel::HitTest to use our version
+// virtual wxPosition HitTest(wxCoord x, wxCoord y) const;
+ virtual wxPosition HitTest(const wxPoint &pos) const;
+
+ // replacement implementation of wxWindow::Layout virtual method. To
+ // properly forward calls to wxWindow::Layout use
+ // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to
+ // call both base classes' ScrollLayout()
+ bool ScrollLayout();
+
+ // get the number of units this window contains (previously set by
+ // Set[Column/Row/RowColumn/Unit]Count())
+ wxSize GetRowColumnCount() const;
+
+ // get the first currently visible units
+ wxPosition GetVisibleBegin() const;
+ wxPosition GetVisibleEnd() const;
+
+ // is this cell currently visible?
+// bool IsVisible(size_t row, size_t column) const;
+ bool IsVisible(const wxPosition &pos) const;
+};