1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Variable scrolled windows (wx[V/H/HV]ScrolledWindow)
4 // Author: Vadim Zeitlin
5 // Modified by: Brad Anderson, Bryan Petty
7 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_VSCROLL_H_
12 #define _WX_VSCROLL_H_
15 #include "wx/position.h"
17 class WXDLLIMPEXP_FWD_CORE wxVarScrollHelperEvtHandler
;
20 // Using the same techniques as the wxScrolledWindow class |
21 // hierarchy, the wx[V/H/HV]ScrolledWindow classes are slightly |
22 // more complex (compare with the diagram outlined in |
23 // scrolwin.h) for the purpose of reducing code duplication |
24 // through the use of mix-in classes. |
26 // wxVarScrollHelperBase |
30 // wxVarHScrollHelper wxVarVScrollHelper |
34 // | wxVarHVScrollHelper | |
37 // | wxPanel | wxVarVScrollLegacyAdaptor |
39 // | / \ `-----|----------. | |
43 // wxHScrolledWindow \ | wxVScrolledWindow |
45 // wxHVScrolledWindow |
48 // Border added to suppress GCC multi-line comment warnings ->|
51 // ===========================================================================
52 // wxVarScrollHelperBase
53 // ===========================================================================
55 // Provides all base common scroll calculations needed for either orientation,
56 // automatic scrollbar functionality, saved scroll positions, functionality
57 // for changing the target window to be scrolled, as well as defining all
58 // required virtual functions that need to be implemented for any orientation
61 class WXDLLIMPEXP_CORE wxVarScrollHelperBase
64 // constructors and such
65 // ---------------------
67 wxVarScrollHelperBase(wxWindow
*winToScroll
);
68 virtual ~wxVarScrollHelperBase();
73 // with physical scrolling on, the device origin is changed properly when
74 // a wxPaintDC is prepared, children are actually moved and laid out
75 // properly, and the contents of the window (pixels) are actually moved
76 void EnablePhysicalScrolling(bool scrolling
= true)
77 { m_physicalScrolling
= scrolling
; }
79 // wxNOT_FOUND if none, i.e. if it is below the last item
80 int VirtualHitTest(wxCoord coord
) const;
82 // recalculate all our parameters and redisplay all units
83 virtual void RefreshAll();
88 // get the first currently visible unit
89 size_t GetVisibleBegin() const { return m_unitFirst
; }
91 // get the last currently visible unit
92 size_t GetVisibleEnd() const
93 { return m_unitFirst
+ m_nUnitsVisible
; }
95 // is this unit currently visible?
96 bool IsVisible(size_t unit
) const
97 { return unit
>= m_unitFirst
&& unit
< GetVisibleEnd(); }
99 // translate between scrolled and unscrolled coordinates
100 int CalcScrolledPosition(int coord
) const
101 { return DoCalcScrolledPosition(coord
); }
102 int CalcUnscrolledPosition(int coord
) const
103 { return DoCalcUnscrolledPosition(coord
); }
105 virtual int DoCalcScrolledPosition(int coord
) const;
106 virtual int DoCalcUnscrolledPosition(int coord
) const;
108 // update the thumb size shown by the scrollbar
109 virtual void UpdateScrollbar();
110 void RemoveScrollbar();
112 // Normally the wxScrolledWindow will scroll itself, but in some rare
113 // occasions you might want it to scroll [part of] another window (e.g. a
114 // child of it in order to scroll only a portion the area between the
115 // scrollbars (spreadsheet: only cell area will move).
116 virtual void SetTargetWindow(wxWindow
*target
);
117 virtual wxWindow
*GetTargetWindow() const { return m_targetWindow
; }
119 // Override this function to draw the graphic (or just process EVT_PAINT)
120 //virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
122 // change the DC origin according to the scroll position. To properly
123 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
125 virtual void DoPrepareDC(wxDC
& dc
);
127 // the methods to be called from the window event handlers
128 void HandleOnScroll(wxScrollWinEvent
& event
);
129 void HandleOnSize(wxSizeEvent
& event
);
131 void HandleOnMouseWheel(wxMouseEvent
& event
);
132 #endif // wxUSE_MOUSEWHEEL
134 // these functions must be overidden in the derived class to return
135 // orientation specific data (e.g. the width for vertically scrolling
136 // derivatives in the case of GetOrientationTargetSize())
137 virtual int GetOrientationTargetSize() const = 0;
138 virtual int GetNonOrientationTargetSize() const = 0;
139 virtual wxOrientation
GetOrientation() const = 0;
142 // all *Unit* functions are protected to be exposed by
143 // wxVarScrollHelperBase implementations (with appropriate names)
145 // get the number of units this window contains (previously set by
147 size_t GetUnitCount() const { return m_unitMax
; }
149 // set the number of units the helper contains: the derived class must
150 // provide the sizes for all units with indices up to the one given here
151 // in its OnGetUnitSize()
152 void SetUnitCount(size_t count
);
154 // redraw the specified unit
155 virtual void RefreshUnit(size_t unit
);
157 // redraw all units in the specified range (inclusive)
158 virtual void RefreshUnits(size_t from
, size_t to
);
160 // scroll to the specified unit: it will become the first visible unit in
163 // return true if we scrolled the window, false if nothing was done
164 bool DoScrollToUnit(size_t unit
);
166 // scroll by the specified number of units/pages
167 virtual bool DoScrollUnits(int units
);
168 virtual bool DoScrollPages(int pages
);
170 // this function must be overridden in the derived class and it should
171 // return the size of the given unit in pixels
172 virtual wxCoord
OnGetUnitSize(size_t n
) const = 0;
174 // this function doesn't have to be overridden but it may be useful to do
175 // it if calculating the units' sizes is a relatively expensive operation
176 // as it gives the user code a possibility to calculate several of them at
179 // OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but
180 // you shouldn't rely on the latter being called for all units in the
181 // interval specified here. It is also possible that OnGetUnitHeight() will
182 // be called for the units outside of this interval, so this is really just
183 // a hint, not a promise.
185 // finally note that unitMin is inclusive, while unitMax is exclusive, as
187 virtual void OnGetUnitsSizeHint(size_t WXUNUSED(unitMin
),
188 size_t WXUNUSED(unitMax
)) const
191 // when the number of units changes, we try to estimate the total size
192 // of all units which is a rather expensive operation in terms of unit
193 // access, so if the user code may estimate the average size
194 // better/faster than we do, it should override this function to implement
197 // this function should return the best guess for the total size it may
199 virtual wxCoord
EstimateTotalSize() const { return DoEstimateTotalSize(); }
201 wxCoord
DoEstimateTotalSize() const;
203 // find the index of the unit we need to show to fit the specified unit on
204 // the opposite side either fully or partially (depending on fullyVisible)
205 size_t FindFirstVisibleFromLast(size_t last
,
206 bool fullyVisible
= false) const;
208 // get the total size of the units between unitMin (inclusive) and
209 // unitMax (exclusive)
210 wxCoord
GetUnitsSize(size_t unitMin
, size_t unitMax
) const;
212 // get the offset of the first visible unit
213 wxCoord
GetScrollOffset() const
214 { return GetUnitsSize(0, GetVisibleBegin()); }
216 // get the size of the target window
217 wxSize
GetTargetSize() const { return m_targetWindow
->GetClientSize(); }
219 void GetTargetSize(int *w
, int *h
)
221 wxSize size
= GetTargetSize();
228 // calculate the new scroll position based on scroll event type
229 size_t GetNewScrollPosition(wxScrollWinEvent
& event
) const;
231 // replacement implementation of wxWindow::Layout virtual method. To
232 // properly forward calls to wxWindow::Layout use
233 // WX_FORWARD_TO_SCROLL_HELPER() derived class
237 // queue mac window update after handling scroll event
238 virtual void UpdateMacScrollWindow() { }
241 // change the target window
242 void DoSetTargetWindow(wxWindow
*target
);
244 // delete the event handler we installed
245 void DeleteEvtHandler();
247 // helper function abstracting the orientation test: with vertical
248 // orientation, it assigns the first value to x and the second one to y,
249 // with horizontal orientation it reverses them, i.e. the first value is
250 // assigned to y and the second one to x
251 void AssignOrient(wxCoord
& x
, wxCoord
& y
, wxCoord first
, wxCoord second
);
253 // similar to "oriented assignment" above but does "oriented increment":
254 // for vertical orientation, y is incremented by the given value and x if
255 // left unchanged, for horizontal orientation x is incremented
256 void IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
);
260 // the window that receives the scroll events and the window to actually
261 // scroll, respectively
265 // the total number of (logical) units
268 // the total (estimated) size
271 // the first currently visible unit
274 // the number of currently visible units (including the last, possibly only
275 // partly, visible one)
276 size_t m_nUnitsVisible
;
278 // accumulated mouse wheel rotation
280 int m_sumWheelRotation
;
283 // do child scrolling (used in DoPrepareDC())
284 bool m_physicalScrolling
;
286 // handler injected into target window to forward some useful events to us
287 wxVarScrollHelperEvtHandler
*m_handler
;
292 // ===========================================================================
293 // wxVarVScrollHelper
294 // ===========================================================================
296 // Provides public API functions targeted for vertical-specific scrolling,
297 // wrapping the functionality of wxVarScrollHelperBase.
299 class WXDLLIMPEXP_CORE wxVarVScrollHelper
: public wxVarScrollHelperBase
302 // constructors and such
303 // ---------------------
305 // ctor must be given the associated window
306 wxVarVScrollHelper(wxWindow
*winToScroll
)
307 : wxVarScrollHelperBase(winToScroll
)
313 void SetRowCount(size_t rowCount
) { SetUnitCount(rowCount
); }
314 bool ScrollToRow(size_t row
) { return DoScrollToUnit(row
); }
316 virtual bool ScrollRows(int rows
)
317 { return DoScrollUnits(rows
); }
318 virtual bool ScrollRowPages(int pages
)
319 { return DoScrollPages(pages
); }
321 virtual void RefreshRow(size_t row
)
322 { RefreshUnit(row
); }
323 virtual void RefreshRows(size_t from
, size_t to
)
324 { RefreshUnits(from
, to
); }
328 size_t GetRowCount() const { return GetUnitCount(); }
329 size_t GetVisibleRowsBegin() const { return GetVisibleBegin(); }
330 size_t GetVisibleRowsEnd() const { return GetVisibleEnd(); }
331 bool IsRowVisible(size_t row
) const { return IsVisible(row
); }
333 virtual int GetOrientationTargetSize() const
334 { return GetTargetWindow()->GetClientSize().y
; }
335 virtual int GetNonOrientationTargetSize() const
336 { return GetTargetWindow()->GetClientSize().x
; }
337 virtual wxOrientation
GetOrientation() const { return wxVERTICAL
; }
340 // this function must be overridden in the derived class and it should
341 // return the size of the given row in pixels
342 virtual wxCoord
OnGetRowHeight(size_t n
) const = 0;
343 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetRowHeight(n
); }
345 virtual void OnGetRowsHeightHint(size_t WXUNUSED(rowMin
),
346 size_t WXUNUSED(rowMax
)) const { }
348 // forward calls to OnGetRowsHeightHint()
349 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
350 { OnGetRowsHeightHint(unitMin
, unitMax
); }
352 // again, if not overridden, it will fall back on default method
353 virtual wxCoord
EstimateTotalHeight() const
354 { return DoEstimateTotalSize(); }
356 // forward calls to EstimateTotalHeight()
357 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalHeight(); }
359 wxCoord
GetRowsHeight(size_t rowMin
, size_t rowMax
) const
360 { return GetUnitsSize(rowMin
, rowMax
); }
365 // ===========================================================================
366 // wxVarHScrollHelper
367 // ===========================================================================
369 // Provides public API functions targeted for horizontal-specific scrolling,
370 // wrapping the functionality of wxVarScrollHelperBase.
372 class WXDLLIMPEXP_CORE wxVarHScrollHelper
: public wxVarScrollHelperBase
375 // constructors and such
376 // ---------------------
378 // ctor must be given the associated window
379 wxVarHScrollHelper(wxWindow
*winToScroll
)
380 : wxVarScrollHelperBase(winToScroll
)
386 void SetColumnCount(size_t columnCount
)
387 { SetUnitCount(columnCount
); }
389 bool ScrollToColumn(size_t column
)
390 { return DoScrollToUnit(column
); }
391 virtual bool ScrollColumns(int columns
)
392 { return DoScrollUnits(columns
); }
393 virtual bool ScrollColumnPages(int pages
)
394 { return DoScrollPages(pages
); }
396 virtual void RefreshColumn(size_t column
)
397 { RefreshUnit(column
); }
398 virtual void RefreshColumns(size_t from
, size_t to
)
399 { RefreshUnits(from
, to
); }
403 size_t GetColumnCount() const
404 { return GetUnitCount(); }
405 size_t GetVisibleColumnsBegin() const
406 { return GetVisibleBegin(); }
407 size_t GetVisibleColumnsEnd() const
408 { return GetVisibleEnd(); }
409 bool IsColumnVisible(size_t column
) const
410 { return IsVisible(column
); }
413 virtual int GetOrientationTargetSize() const
414 { return GetTargetWindow()->GetClientSize().x
; }
415 virtual int GetNonOrientationTargetSize() const
416 { return GetTargetWindow()->GetClientSize().y
; }
417 virtual wxOrientation
GetOrientation() const { return wxHORIZONTAL
; }
420 // this function must be overridden in the derived class and it should
421 // return the size of the given column in pixels
422 virtual wxCoord
OnGetColumnWidth(size_t n
) const = 0;
423 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetColumnWidth(n
); }
425 virtual void OnGetColumnsWidthHint(size_t WXUNUSED(columnMin
),
426 size_t WXUNUSED(columnMax
)) const
429 // forward calls to OnGetColumnsWidthHint()
430 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
431 { OnGetColumnsWidthHint(unitMin
, unitMax
); }
433 // again, if not overridden, it will fall back on default method
434 virtual wxCoord
EstimateTotalWidth() const { return DoEstimateTotalSize(); }
436 // forward calls to EstimateTotalWidth()
437 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalWidth(); }
439 wxCoord
GetColumnsWidth(size_t columnMin
, size_t columnMax
) const
440 { return GetUnitsSize(columnMin
, columnMax
); }
445 // ===========================================================================
446 // wxVarHVScrollHelper
447 // ===========================================================================
449 // Provides public API functions targeted at functions with similar names in
450 // both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be
451 // specified (since we are using multiple inheritance). It also provides
452 // functions to make changing values for both orientations at the same time
455 class WXDLLIMPEXP_CORE wxVarHVScrollHelper
: public wxVarVScrollHelper
,
456 public wxVarHScrollHelper
459 // constructors and such
460 // ---------------------
462 // ctor must be given the associated window
463 wxVarHVScrollHelper(wxWindow
*winToScroll
)
464 : wxVarVScrollHelper(winToScroll
), wxVarHScrollHelper(winToScroll
) { }
469 // set the number of units the window contains for each axis: the derived
470 // class must provide the widths and heights for all units with indices up
471 // to each of the one given here in its OnGetColumnWidth() and
473 void SetRowColumnCount(size_t rowCount
, size_t columnCount
);
476 // with physical scrolling on, the device origin is changed properly when
477 // a wxPaintDC is prepared, children are actually moved and laid out
478 // properly, and the contents of the window (pixels) are actually moved
479 void EnablePhysicalScrolling(bool vscrolling
= true, bool hscrolling
= true)
481 wxVarVScrollHelper::EnablePhysicalScrolling(vscrolling
);
482 wxVarHScrollHelper::EnablePhysicalScrolling(hscrolling
);
485 // scroll to the specified row/column: it will become the first visible
486 // cell in the window
488 // return true if we scrolled the window, false if nothing was done
489 bool ScrollToRowColumn(size_t row
, size_t column
);
490 bool ScrollToRowColumn(const wxPosition
&pos
)
491 { return ScrollToRowColumn(pos
.GetRow(), pos
.GetColumn()); }
493 // redraw the specified cell
494 virtual void RefreshRowColumn(size_t row
, size_t column
);
495 virtual void RefreshRowColumn(const wxPosition
&pos
)
496 { RefreshRowColumn(pos
.GetRow(), pos
.GetColumn()); }
498 // redraw the specified regions (inclusive). If the target window for
499 // both orientations is the same the rectangle of cells is refreshed; if
500 // the target windows differ the entire client size opposite the
501 // orientation direction is refreshed between the specified limits
502 virtual void RefreshRowsColumns(size_t fromRow
, size_t toRow
,
503 size_t fromColumn
, size_t toColumn
);
504 virtual void RefreshRowsColumns(const wxPosition
& from
,
505 const wxPosition
& to
)
507 RefreshRowsColumns(from
.GetRow(), to
.GetRow(),
508 from
.GetColumn(), to
.GetColumn());
511 // locate the virtual position from the given device coordinates
512 wxPosition
VirtualHitTest(wxCoord x
, wxCoord y
) const;
513 wxPosition
VirtualHitTest(const wxPoint
&pos
) const
514 { return VirtualHitTest(pos
.x
, pos
.y
); }
516 // change the DC origin according to the scroll position. To properly
517 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
518 // derived class. We use this version to call both base classes'
520 virtual void DoPrepareDC(wxDC
& dc
);
522 // replacement implementation of wxWindow::Layout virtual method. To
523 // properly forward calls to wxWindow::Layout use
524 // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to
525 // call both base classes' ScrollLayout()
531 // get the number of units this window contains (previously set by
532 // Set[Column/Row/RowColumn/Unit]Count())
533 wxSize
GetRowColumnCount() const;
535 // get the first currently visible units
536 wxPosition
GetVisibleBegin() const;
537 wxPosition
GetVisibleEnd() const;
539 // is this cell currently visible?
540 bool IsVisible(size_t row
, size_t column
) const;
541 bool IsVisible(const wxPosition
&pos
) const
542 { return IsVisible(pos
.GetRow(), pos
.GetColumn()); }
547 #if WXWIN_COMPATIBILITY_2_8
549 // ===========================================================================
550 // wxVarVScrollLegacyAdaptor
551 // ===========================================================================
553 // Provides backwards compatible API for applications originally built using
554 // wxVScrolledWindow in 2.6 or 2.8. Originally, wxVScrolledWindow referred
555 // to scrolling "lines". We use "units" in wxVarScrollHelperBase to avoid
556 // implying any orientation (since the functions are used for both horizontal
557 // and vertical scrolling in derived classes). And in the new
558 // wxVScrolledWindow and wxHScrolledWindow classes, we refer to them as
559 // "rows" and "columns", respectively. This is to help clear some confusion
560 // in not only those classes, but also in wxHVScrolledWindow where functions
561 // are inherited from both.
563 class WXDLLIMPEXP_CORE wxVarVScrollLegacyAdaptor
: public wxVarVScrollHelper
566 // constructors and such
567 // ---------------------
568 wxVarVScrollLegacyAdaptor(wxWindow
*winToScroll
)
569 : wxVarVScrollHelper(winToScroll
)
576 // this is the same as GetVisibleRowsBegin(), exists to match
577 // GetLastVisibleLine() and for backwards compatibility only
578 wxDEPRECATED( size_t GetFirstVisibleLine() const );
580 // get the last currently visible line
582 // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive
583 // number) if the control is empty, use GetVisibleRowsEnd() instead, this
584 // one is kept for backwards compatibility
585 wxDEPRECATED( size_t GetLastVisibleLine() const );
587 // "line" to "unit" compatibility functions
588 // ----------------------------------------
590 // get the number of lines this window contains (set by SetLineCount())
591 wxDEPRECATED( size_t GetLineCount() const );
593 // set the number of lines the helper contains: the derived class must
594 // provide the sizes for all lines with indices up to the one given here
595 // in its OnGetLineHeight()
596 wxDEPRECATED( void SetLineCount(size_t count
) );
598 // redraw the specified line
599 wxDEPRECATED( virtual void RefreshLine(size_t line
) );
601 // redraw all lines in the specified range (inclusive)
602 wxDEPRECATED( virtual void RefreshLines(size_t from
, size_t to
) );
604 // scroll to the specified line: it will become the first visible line in
607 // return true if we scrolled the window, false if nothing was done
608 wxDEPRECATED( bool ScrollToLine(size_t line
) );
610 // scroll by the specified number of lines/pages
611 wxDEPRECATED( virtual bool ScrollLines(int lines
) );
612 wxDEPRECATED( virtual bool ScrollPages(int pages
) );
615 // unless the code has been updated to override OnGetRowHeight() instead,
616 // this function must be overridden in the derived class and it should
617 // return the height of the given row in pixels
618 wxDEPRECATED_BUT_USED_INTERNALLY(
619 virtual wxCoord
OnGetLineHeight(size_t n
) const );
621 // forwards the calls from base class pure virtual function to pure virtual
622 // OnGetLineHeight instead (backwards compatible name)
623 // note that we don't need to forward OnGetUnitSize() as it is already
624 // forwarded to OnGetRowHeight() in wxVarVScrollHelper
625 virtual wxCoord
OnGetRowHeight(size_t n
) const;
627 // this function doesn't have to be overridden but it may be useful to do
628 // it if calculating the lines heights is a relatively expensive operation
629 // as it gives the user code a possibility to calculate several of them at
632 // OnGetLinesHint() is normally called just before OnGetLineHeight() but you
633 // shouldn't rely on the latter being called for all lines in the interval
634 // specified here. It is also possible that OnGetLineHeight() will be
635 // called for the lines outside of this interval, so this is really just a
636 // hint, not a promise.
638 // finally note that lineMin is inclusive, while lineMax is exclusive, as
640 wxDEPRECATED_BUT_USED_INTERNALLY( virtual void OnGetLinesHint(
641 size_t lineMin
, size_t lineMax
) const );
643 // forwards the calls from base class pure virtual function to pure virtual
644 // OnGetLinesHint instead (backwards compatible name)
645 void OnGetRowsHeightHint(size_t rowMin
, size_t rowMax
) const;
648 #else // !WXWIN_COMPATIBILITY_2_8
650 // shortcut to avoid checking compatibility modes later
651 // remove this and all references to wxVarVScrollLegacyAdaptor once
652 // wxWidgets 2.6 and 2.8 compatibility is removed
653 typedef wxVarVScrollHelper wxVarVScrollLegacyAdaptor
;
655 #endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
658 // this macro must be used in declaration of wxVarScrollHelperBase-derived
660 #define WX_FORWARD_TO_VAR_SCROLL_HELPER() \
662 virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \
663 virtual bool Layout() { return ScrollLayout(); }
667 // ===========================================================================
669 // ===========================================================================
671 // In the name of this class, "V" may stand for "variable" because it can be
672 // used for scrolling rows of variable heights; "virtual", because it is not
673 // necessary to know the heights of all rows in advance -- only those which
674 // are shown on the screen need to be measured; or even "vertical", because
675 // this class only supports scrolling vertically.
677 // In any case, this is a generalization of the wxScrolledWindow class which
678 // can be only used when all rows have the same heights. It lacks some other
679 // wxScrolledWindow features however, notably it can't scroll only a rectangle
680 // of the window and not its entire client area.
682 class WXDLLIMPEXP_CORE wxVScrolledWindow
: public wxPanel
,
683 public wxVarVScrollLegacyAdaptor
686 // constructors and such
687 // ---------------------
689 // default ctor, you must call Create() later
690 wxVScrolledWindow() : wxVarVScrollLegacyAdaptor(this) { }
692 // normal ctor, no need to call Create() after this one
694 // note that wxVSCROLL is always automatically added to our style, there is
695 // no need to specify it explicitly
696 wxVScrolledWindow(wxWindow
*parent
,
697 wxWindowID id
= wxID_ANY
,
698 const wxPoint
& pos
= wxDefaultPosition
,
699 const wxSize
& size
= wxDefaultSize
,
701 const wxString
& name
= wxPanelNameStr
)
702 : wxVarVScrollLegacyAdaptor(this)
704 (void)Create(parent
, id
, pos
, size
, style
, name
);
707 // same as the previous ctor but returns status code: true if ok
709 // just as with the ctor above, wxVSCROLL style is always used, there is no
710 // need to specify it
711 bool Create(wxWindow
*parent
,
712 wxWindowID id
= wxID_ANY
,
713 const wxPoint
& pos
= wxDefaultPosition
,
714 const wxSize
& size
= wxDefaultSize
,
716 const wxString
& name
= wxPanelNameStr
)
718 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxVSCROLL
, name
);
721 #if WXWIN_COMPATIBILITY_2_8
722 // Make sure we prefer our version of HitTest rather than wxWindow's
723 // These functions should no longer be masked in favor of VirtualHitTest()
724 int HitTest(wxCoord
WXUNUSED(x
), wxCoord y
) const
725 { return wxVarVScrollHelper::VirtualHitTest(y
); }
726 int HitTest(const wxPoint
& pt
) const
727 { return HitTest(pt
.x
, pt
.y
); }
728 #endif // WXWIN_COMPATIBILITY_2_8
730 WX_FORWARD_TO_VAR_SCROLL_HELPER()
734 virtual void UpdateMacScrollWindow() { Update(); }
738 wxDECLARE_NO_COPY_CLASS(wxVScrolledWindow
);
739 DECLARE_ABSTRACT_CLASS(wxVScrolledWindow
)
744 // ===========================================================================
746 // ===========================================================================
748 // In the name of this class, "H" stands for "horizontal" because it can be
749 // used for scrolling columns of variable widths. It is not necessary to know
750 // the widths of all columns in advance -- only those which are shown on the
751 // screen need to be measured.
753 // This is a generalization of the wxScrolledWindow class which can be only
754 // used when all columns have the same width. It lacks some other
755 // wxScrolledWindow features however, notably it can't scroll only a rectangle
756 // of the window and not its entire client area.
758 class WXDLLIMPEXP_CORE wxHScrolledWindow
: public wxPanel
,
759 public wxVarHScrollHelper
762 // constructors and such
763 // ---------------------
765 // default ctor, you must call Create() later
766 wxHScrolledWindow() : wxVarHScrollHelper(this) { }
768 // normal ctor, no need to call Create() after this one
770 // note that wxHSCROLL is always automatically added to our style, there is
771 // no need to specify it explicitly
772 wxHScrolledWindow(wxWindow
*parent
,
773 wxWindowID id
= wxID_ANY
,
774 const wxPoint
& pos
= wxDefaultPosition
,
775 const wxSize
& size
= wxDefaultSize
,
777 const wxString
& name
= wxPanelNameStr
)
778 : wxVarHScrollHelper(this)
780 (void)Create(parent
, id
, pos
, size
, style
, name
);
783 // same as the previous ctor but returns status code: true if ok
785 // just as with the ctor above, wxHSCROLL style is always used, there is no
786 // need to specify it
787 bool Create(wxWindow
*parent
,
788 wxWindowID id
= wxID_ANY
,
789 const wxPoint
& pos
= wxDefaultPosition
,
790 const wxSize
& size
= wxDefaultSize
,
792 const wxString
& name
= wxPanelNameStr
)
794 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxHSCROLL
, name
);
797 WX_FORWARD_TO_VAR_SCROLL_HELPER()
801 virtual void UpdateMacScrollWindow() { Update(); }
805 wxDECLARE_NO_COPY_CLASS(wxHScrolledWindow
);
806 DECLARE_ABSTRACT_CLASS(wxHScrolledWindow
)
811 // ===========================================================================
812 // wxHVScrolledWindow
813 // ===========================================================================
815 // This window inherits all functionality of both vertical and horizontal
816 // scrolled windows automatically handling everything needed to scroll both
817 // axis simultaneously.
819 class WXDLLIMPEXP_CORE wxHVScrolledWindow
: public wxPanel
,
820 public wxVarHVScrollHelper
823 // constructors and such
824 // ---------------------
826 // default ctor, you must call Create() later
829 wxVarHVScrollHelper(this) { }
831 // normal ctor, no need to call Create() after this one
833 // note that wxVSCROLL and wxHSCROLL are always automatically added to our
834 // style, there is no need to specify them explicitly
835 wxHVScrolledWindow(wxWindow
*parent
,
836 wxWindowID id
= wxID_ANY
,
837 const wxPoint
& pos
= wxDefaultPosition
,
838 const wxSize
& size
= wxDefaultSize
,
840 const wxString
& name
= wxPanelNameStr
)
842 wxVarHVScrollHelper(this)
844 (void)Create(parent
, id
, pos
, size
, style
, name
);
847 // same as the previous ctor but returns status code: true if ok
849 // just as with the ctor above, wxVSCROLL and wxHSCROLL styles are always
850 // used, there is no need to specify them
851 bool Create(wxWindow
*parent
,
852 wxWindowID id
= wxID_ANY
,
853 const wxPoint
& pos
= wxDefaultPosition
,
854 const wxSize
& size
= wxDefaultSize
,
856 const wxString
& name
= wxPanelNameStr
)
858 return wxPanel::Create(parent
, id
, pos
, size
,
859 style
| wxVSCROLL
| wxHSCROLL
, name
);
862 WX_FORWARD_TO_VAR_SCROLL_HELPER()
866 virtual void UpdateMacScrollWindow() { Update(); }
870 wxDECLARE_NO_COPY_CLASS(wxHVScrolledWindow
);
871 DECLARE_ABSTRACT_CLASS(wxHVScrolledWindow
)
874 #endif // _WX_VSCROLL_H_