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"
16 #include "wx/scrolwin.h"
18 class WXDLLIMPEXP_FWD_CORE wxVarScrollHelperEvtHandler
;
21 // Using the same techniques as the wxScrolledWindow class |
22 // hierarchy, the wx[V/H/HV]ScrolledWindow classes are slightly |
23 // more complex (compare with the diagram outlined in |
24 // scrolwin.h) for the purpose of reducing code duplication |
25 // through the use of mix-in classes. |
27 // wxAnyScrollHelperBase |
32 // wxVarScrollHelperBase |
36 // wxVarHScrollHelper wxVarVScrollHelper |
40 // | wxVarHVScrollHelper | |
43 // | wxPanel | wxVarVScrollLegacyAdaptor |
45 // | / \ `-----|----------. | |
49 // wxHScrolledWindow \ | wxVScrolledWindow |
51 // wxHVScrolledWindow |
54 // Border added to suppress GCC multi-line comment warnings ->|
57 // ===========================================================================
58 // wxVarScrollHelperBase
59 // ===========================================================================
61 // Provides all base common scroll calculations needed for either orientation,
62 // automatic scrollbar functionality, saved scroll positions, functionality
63 // for changing the target window to be scrolled, as well as defining all
64 // required virtual functions that need to be implemented for any orientation
67 class WXDLLIMPEXP_CORE wxVarScrollHelperBase
: public wxAnyScrollHelperBase
70 // constructors and such
71 // ---------------------
73 wxVarScrollHelperBase(wxWindow
*winToScroll
);
74 virtual ~wxVarScrollHelperBase();
79 // with physical scrolling on, the device origin is changed properly when
80 // a wxPaintDC is prepared, children are actually moved and laid out
81 // properly, and the contents of the window (pixels) are actually moved
82 void EnablePhysicalScrolling(bool scrolling
= true)
83 { m_physicalScrolling
= scrolling
; }
85 // wxNOT_FOUND if none, i.e. if it is below the last item
86 int VirtualHitTest(wxCoord coord
) const;
88 // recalculate all our parameters and redisplay all units
89 virtual void RefreshAll();
94 // get the first currently visible unit
95 size_t GetVisibleBegin() const { return m_unitFirst
; }
97 // get the last currently visible unit
98 size_t GetVisibleEnd() const
99 { return m_unitFirst
+ m_nUnitsVisible
; }
101 // is this unit currently visible?
102 bool IsVisible(size_t unit
) const
103 { return unit
>= m_unitFirst
&& unit
< GetVisibleEnd(); }
105 // translate between scrolled and unscrolled coordinates
106 int CalcScrolledPosition(int coord
) const
107 { return DoCalcScrolledPosition(coord
); }
108 int CalcUnscrolledPosition(int coord
) const
109 { return DoCalcUnscrolledPosition(coord
); }
111 virtual int DoCalcScrolledPosition(int coord
) const;
112 virtual int DoCalcUnscrolledPosition(int coord
) const;
114 // update the thumb size shown by the scrollbar
115 virtual void UpdateScrollbar();
116 void RemoveScrollbar();
118 // Normally the wxScrolledWindow will scroll itself, but in some rare
119 // occasions you might want it to scroll [part of] another window (e.g. a
120 // child of it in order to scroll only a portion the area between the
121 // scrollbars (spreadsheet: only cell area will move).
122 virtual void SetTargetWindow(wxWindow
*target
);
124 // Override this function to draw the graphic (or just process EVT_PAINT)
125 //virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
127 // change the DC origin according to the scroll position. To properly
128 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
130 virtual void DoPrepareDC(wxDC
& dc
);
132 // the methods to be called from the window event handlers
133 void HandleOnScroll(wxScrollWinEvent
& event
);
134 void HandleOnSize(wxSizeEvent
& event
);
136 void HandleOnMouseWheel(wxMouseEvent
& event
);
137 #endif // wxUSE_MOUSEWHEEL
139 // these functions must be overidden in the derived class to return
140 // orientation specific data (e.g. the width for vertically scrolling
141 // derivatives in the case of GetOrientationTargetSize())
142 virtual int GetOrientationTargetSize() const = 0;
143 virtual int GetNonOrientationTargetSize() const = 0;
144 virtual wxOrientation
GetOrientation() const = 0;
147 // all *Unit* functions are protected to be exposed by
148 // wxVarScrollHelperBase implementations (with appropriate names)
150 // get the number of units this window contains (previously set by
152 size_t GetUnitCount() const { return m_unitMax
; }
154 // set the number of units the helper contains: the derived class must
155 // provide the sizes for all units with indices up to the one given here
156 // in its OnGetUnitSize()
157 void SetUnitCount(size_t count
);
159 // redraw the specified unit
160 virtual void RefreshUnit(size_t unit
);
162 // redraw all units in the specified range (inclusive)
163 virtual void RefreshUnits(size_t from
, size_t to
);
165 // scroll to the specified unit: it will become the first visible unit in
168 // return true if we scrolled the window, false if nothing was done
169 bool DoScrollToUnit(size_t unit
);
171 // scroll by the specified number of units/pages
172 virtual bool DoScrollUnits(int units
);
173 virtual bool DoScrollPages(int pages
);
175 // this function must be overridden in the derived class and it should
176 // return the size of the given unit in pixels
177 virtual wxCoord
OnGetUnitSize(size_t n
) const = 0;
179 // this function doesn't have to be overridden but it may be useful to do
180 // it if calculating the units' sizes is a relatively expensive operation
181 // as it gives the user code a possibility to calculate several of them at
184 // OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but
185 // you shouldn't rely on the latter being called for all units in the
186 // interval specified here. It is also possible that OnGetUnitHeight() will
187 // be called for the units outside of this interval, so this is really just
188 // a hint, not a promise.
190 // finally note that unitMin is inclusive, while unitMax is exclusive, as
192 virtual void OnGetUnitsSizeHint(size_t WXUNUSED(unitMin
),
193 size_t WXUNUSED(unitMax
)) const
196 // when the number of units changes, we try to estimate the total size
197 // of all units which is a rather expensive operation in terms of unit
198 // access, so if the user code may estimate the average size
199 // better/faster than we do, it should override this function to implement
202 // this function should return the best guess for the total size it may
204 virtual wxCoord
EstimateTotalSize() const { return DoEstimateTotalSize(); }
206 wxCoord
DoEstimateTotalSize() const;
208 // find the index of the unit we need to show to fit the specified unit on
209 // the opposite side either fully or partially (depending on fullyVisible)
210 size_t FindFirstVisibleFromLast(size_t last
,
211 bool fullyVisible
= false) const;
213 // get the total size of the units between unitMin (inclusive) and
214 // unitMax (exclusive)
215 wxCoord
GetUnitsSize(size_t unitMin
, size_t unitMax
) const;
217 // get the offset of the first visible unit
218 wxCoord
GetScrollOffset() const
219 { return GetUnitsSize(0, GetVisibleBegin()); }
221 // get the size of the target window
222 wxSize
GetTargetSize() const { return m_targetWindow
->GetClientSize(); }
224 void GetTargetSize(int *w
, int *h
)
226 wxSize size
= GetTargetSize();
233 // calculate the new scroll position based on scroll event type
234 size_t GetNewScrollPosition(wxScrollWinEvent
& event
) const;
236 // replacement implementation of wxWindow::Layout virtual method. To
237 // properly forward calls to wxWindow::Layout use
238 // WX_FORWARD_TO_SCROLL_HELPER() derived class
242 // queue mac window update after handling scroll event
243 virtual void UpdateMacScrollWindow() { }
246 // change the target window
247 void DoSetTargetWindow(wxWindow
*target
);
249 // delete the event handler we installed
250 void DeleteEvtHandler();
252 // helper function abstracting the orientation test: with vertical
253 // orientation, it assigns the first value to x and the second one to y,
254 // with horizontal orientation it reverses them, i.e. the first value is
255 // assigned to y and the second one to x
256 void AssignOrient(wxCoord
& x
, wxCoord
& y
, wxCoord first
, wxCoord second
);
258 // similar to "oriented assignment" above but does "oriented increment":
259 // for vertical orientation, y is incremented by the given value and x if
260 // left unchanged, for horizontal orientation x is incremented
261 void IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
);
264 // the total number of (logical) units
267 // the total (estimated) size
270 // the first currently visible unit
273 // the number of currently visible units (including the last, possibly only
274 // partly, visible one)
275 size_t m_nUnitsVisible
;
277 // accumulated mouse wheel rotation
279 int m_sumWheelRotation
;
282 // do child scrolling (used in DoPrepareDC())
283 bool m_physicalScrolling
;
285 // handler injected into target window to forward some useful events to us
286 wxVarScrollHelperEvtHandler
*m_handler
;
291 // ===========================================================================
292 // wxVarVScrollHelper
293 // ===========================================================================
295 // Provides public API functions targeted for vertical-specific scrolling,
296 // wrapping the functionality of wxVarScrollHelperBase.
298 class WXDLLIMPEXP_CORE wxVarVScrollHelper
: public wxVarScrollHelperBase
301 // constructors and such
302 // ---------------------
304 // ctor must be given the associated window
305 wxVarVScrollHelper(wxWindow
*winToScroll
)
306 : wxVarScrollHelperBase(winToScroll
)
312 void SetRowCount(size_t rowCount
) { SetUnitCount(rowCount
); }
313 bool ScrollToRow(size_t row
) { return DoScrollToUnit(row
); }
315 virtual bool ScrollRows(int rows
)
316 { return DoScrollUnits(rows
); }
317 virtual bool ScrollRowPages(int pages
)
318 { return DoScrollPages(pages
); }
320 virtual void RefreshRow(size_t row
)
321 { RefreshUnit(row
); }
322 virtual void RefreshRows(size_t from
, size_t to
)
323 { RefreshUnits(from
, to
); }
327 size_t GetRowCount() const { return GetUnitCount(); }
328 size_t GetVisibleRowsBegin() const { return GetVisibleBegin(); }
329 size_t GetVisibleRowsEnd() const { return GetVisibleEnd(); }
330 bool IsRowVisible(size_t row
) const { return IsVisible(row
); }
332 virtual int GetOrientationTargetSize() const
333 { return GetTargetWindow()->GetClientSize().y
; }
334 virtual int GetNonOrientationTargetSize() const
335 { return GetTargetWindow()->GetClientSize().x
; }
336 virtual wxOrientation
GetOrientation() const { return wxVERTICAL
; }
339 // this function must be overridden in the derived class and it should
340 // return the size of the given row in pixels
341 virtual wxCoord
OnGetRowHeight(size_t n
) const = 0;
342 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetRowHeight(n
); }
344 virtual void OnGetRowsHeightHint(size_t WXUNUSED(rowMin
),
345 size_t WXUNUSED(rowMax
)) const { }
347 // forward calls to OnGetRowsHeightHint()
348 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
349 { OnGetRowsHeightHint(unitMin
, unitMax
); }
351 // again, if not overridden, it will fall back on default method
352 virtual wxCoord
EstimateTotalHeight() const
353 { return DoEstimateTotalSize(); }
355 // forward calls to EstimateTotalHeight()
356 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalHeight(); }
358 wxCoord
GetRowsHeight(size_t rowMin
, size_t rowMax
) const
359 { return GetUnitsSize(rowMin
, rowMax
); }
364 // ===========================================================================
365 // wxVarHScrollHelper
366 // ===========================================================================
368 // Provides public API functions targeted for horizontal-specific scrolling,
369 // wrapping the functionality of wxVarScrollHelperBase.
371 class WXDLLIMPEXP_CORE wxVarHScrollHelper
: public wxVarScrollHelperBase
374 // constructors and such
375 // ---------------------
377 // ctor must be given the associated window
378 wxVarHScrollHelper(wxWindow
*winToScroll
)
379 : wxVarScrollHelperBase(winToScroll
)
385 void SetColumnCount(size_t columnCount
)
386 { SetUnitCount(columnCount
); }
388 bool ScrollToColumn(size_t column
)
389 { return DoScrollToUnit(column
); }
390 virtual bool ScrollColumns(int columns
)
391 { return DoScrollUnits(columns
); }
392 virtual bool ScrollColumnPages(int pages
)
393 { return DoScrollPages(pages
); }
395 virtual void RefreshColumn(size_t column
)
396 { RefreshUnit(column
); }
397 virtual void RefreshColumns(size_t from
, size_t to
)
398 { RefreshUnits(from
, to
); }
402 size_t GetColumnCount() const
403 { return GetUnitCount(); }
404 size_t GetVisibleColumnsBegin() const
405 { return GetVisibleBegin(); }
406 size_t GetVisibleColumnsEnd() const
407 { return GetVisibleEnd(); }
408 bool IsColumnVisible(size_t column
) const
409 { return IsVisible(column
); }
412 virtual int GetOrientationTargetSize() const
413 { return GetTargetWindow()->GetClientSize().x
; }
414 virtual int GetNonOrientationTargetSize() const
415 { return GetTargetWindow()->GetClientSize().y
; }
416 virtual wxOrientation
GetOrientation() const { return wxHORIZONTAL
; }
419 // this function must be overridden in the derived class and it should
420 // return the size of the given column in pixels
421 virtual wxCoord
OnGetColumnWidth(size_t n
) const = 0;
422 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetColumnWidth(n
); }
424 virtual void OnGetColumnsWidthHint(size_t WXUNUSED(columnMin
),
425 size_t WXUNUSED(columnMax
)) const
428 // forward calls to OnGetColumnsWidthHint()
429 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
430 { OnGetColumnsWidthHint(unitMin
, unitMax
); }
432 // again, if not overridden, it will fall back on default method
433 virtual wxCoord
EstimateTotalWidth() const { return DoEstimateTotalSize(); }
435 // forward calls to EstimateTotalWidth()
436 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalWidth(); }
438 wxCoord
GetColumnsWidth(size_t columnMin
, size_t columnMax
) const
439 { return GetUnitsSize(columnMin
, columnMax
); }
444 // ===========================================================================
445 // wxVarHVScrollHelper
446 // ===========================================================================
448 // Provides public API functions targeted at functions with similar names in
449 // both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be
450 // specified (since we are using multiple inheritance). It also provides
451 // functions to make changing values for both orientations at the same time
454 class WXDLLIMPEXP_CORE wxVarHVScrollHelper
: public wxVarVScrollHelper
,
455 public wxVarHScrollHelper
458 // constructors and such
459 // ---------------------
461 // ctor must be given the associated window
462 wxVarHVScrollHelper(wxWindow
*winToScroll
)
463 : wxVarVScrollHelper(winToScroll
), wxVarHScrollHelper(winToScroll
) { }
468 // set the number of units the window contains for each axis: the derived
469 // class must provide the widths and heights for all units with indices up
470 // to each of the one given here in its OnGetColumnWidth() and
472 void SetRowColumnCount(size_t rowCount
, size_t columnCount
);
475 // with physical scrolling on, the device origin is changed properly when
476 // a wxPaintDC is prepared, children are actually moved and laid out
477 // properly, and the contents of the window (pixels) are actually moved
478 void EnablePhysicalScrolling(bool vscrolling
= true, bool hscrolling
= true)
480 wxVarVScrollHelper::EnablePhysicalScrolling(vscrolling
);
481 wxVarHScrollHelper::EnablePhysicalScrolling(hscrolling
);
484 // scroll to the specified row/column: it will become the first visible
485 // cell in the window
487 // return true if we scrolled the window, false if nothing was done
488 bool ScrollToRowColumn(size_t row
, size_t column
);
489 bool ScrollToRowColumn(const wxPosition
&pos
)
490 { return ScrollToRowColumn(pos
.GetRow(), pos
.GetColumn()); }
492 // redraw the specified cell
493 virtual void RefreshRowColumn(size_t row
, size_t column
);
494 virtual void RefreshRowColumn(const wxPosition
&pos
)
495 { RefreshRowColumn(pos
.GetRow(), pos
.GetColumn()); }
497 // redraw the specified regions (inclusive). If the target window for
498 // both orientations is the same the rectangle of cells is refreshed; if
499 // the target windows differ the entire client size opposite the
500 // orientation direction is refreshed between the specified limits
501 virtual void RefreshRowsColumns(size_t fromRow
, size_t toRow
,
502 size_t fromColumn
, size_t toColumn
);
503 virtual void RefreshRowsColumns(const wxPosition
& from
,
504 const wxPosition
& to
)
506 RefreshRowsColumns(from
.GetRow(), to
.GetRow(),
507 from
.GetColumn(), to
.GetColumn());
510 // locate the virtual position from the given device coordinates
511 wxPosition
VirtualHitTest(wxCoord x
, wxCoord y
) const;
512 wxPosition
VirtualHitTest(const wxPoint
&pos
) const
513 { return VirtualHitTest(pos
.x
, pos
.y
); }
515 // change the DC origin according to the scroll position. To properly
516 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
517 // derived class. We use this version to call both base classes'
519 virtual void DoPrepareDC(wxDC
& dc
);
521 // replacement implementation of wxWindow::Layout virtual method. To
522 // properly forward calls to wxWindow::Layout use
523 // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to
524 // call both base classes' ScrollLayout()
530 // get the number of units this window contains (previously set by
531 // Set[Column/Row/RowColumn/Unit]Count())
532 wxSize
GetRowColumnCount() const;
534 // get the first currently visible units
535 wxPosition
GetVisibleBegin() const;
536 wxPosition
GetVisibleEnd() const;
538 // is this cell currently visible?
539 bool IsVisible(size_t row
, size_t column
) const;
540 bool IsVisible(const wxPosition
&pos
) const
541 { return IsVisible(pos
.GetRow(), pos
.GetColumn()); }
546 #if WXWIN_COMPATIBILITY_2_8
548 // ===========================================================================
549 // wxVarVScrollLegacyAdaptor
550 // ===========================================================================
552 // Provides backwards compatible API for applications originally built using
553 // wxVScrolledWindow in 2.6 or 2.8. Originally, wxVScrolledWindow referred
554 // to scrolling "lines". We use "units" in wxVarScrollHelperBase to avoid
555 // implying any orientation (since the functions are used for both horizontal
556 // and vertical scrolling in derived classes). And in the new
557 // wxVScrolledWindow and wxHScrolledWindow classes, we refer to them as
558 // "rows" and "columns", respectively. This is to help clear some confusion
559 // in not only those classes, but also in wxHVScrolledWindow where functions
560 // are inherited from both.
562 class WXDLLIMPEXP_CORE wxVarVScrollLegacyAdaptor
: public wxVarVScrollHelper
565 // constructors and such
566 // ---------------------
567 wxVarVScrollLegacyAdaptor(wxWindow
*winToScroll
)
568 : wxVarVScrollHelper(winToScroll
)
575 // this is the same as GetVisibleRowsBegin(), exists to match
576 // GetLastVisibleLine() and for backwards compatibility only
577 wxDEPRECATED( size_t GetFirstVisibleLine() const );
579 // get the last currently visible line
581 // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive
582 // number) if the control is empty, use GetVisibleRowsEnd() instead, this
583 // one is kept for backwards compatibility
584 wxDEPRECATED( size_t GetLastVisibleLine() const );
586 // "line" to "unit" compatibility functions
587 // ----------------------------------------
589 // get the number of lines this window contains (set by SetLineCount())
590 wxDEPRECATED( size_t GetLineCount() const );
592 // set the number of lines the helper contains: the derived class must
593 // provide the sizes for all lines with indices up to the one given here
594 // in its OnGetLineHeight()
595 wxDEPRECATED( void SetLineCount(size_t count
) );
597 // redraw the specified line
598 wxDEPRECATED( virtual void RefreshLine(size_t line
) );
600 // redraw all lines in the specified range (inclusive)
601 wxDEPRECATED( virtual void RefreshLines(size_t from
, size_t to
) );
603 // scroll to the specified line: it will become the first visible line in
606 // return true if we scrolled the window, false if nothing was done
607 wxDEPRECATED( bool ScrollToLine(size_t line
) );
609 // scroll by the specified number of lines/pages
610 wxDEPRECATED( virtual bool ScrollLines(int lines
) );
611 wxDEPRECATED( virtual bool ScrollPages(int pages
) );
614 // unless the code has been updated to override OnGetRowHeight() instead,
615 // this function must be overridden in the derived class and it should
616 // return the height of the given row in pixels
617 wxDEPRECATED_BUT_USED_INTERNALLY(
618 virtual wxCoord
OnGetLineHeight(size_t n
) const );
620 // forwards the calls from base class pure virtual function to pure virtual
621 // OnGetLineHeight instead (backwards compatible name)
622 // note that we don't need to forward OnGetUnitSize() as it is already
623 // forwarded to OnGetRowHeight() in wxVarVScrollHelper
624 virtual wxCoord
OnGetRowHeight(size_t n
) const;
626 // this function doesn't have to be overridden but it may be useful to do
627 // it if calculating the lines heights is a relatively expensive operation
628 // as it gives the user code a possibility to calculate several of them at
631 // OnGetLinesHint() is normally called just before OnGetLineHeight() but you
632 // shouldn't rely on the latter being called for all lines in the interval
633 // specified here. It is also possible that OnGetLineHeight() will be
634 // called for the lines outside of this interval, so this is really just a
635 // hint, not a promise.
637 // finally note that lineMin is inclusive, while lineMax is exclusive, as
639 wxDEPRECATED_BUT_USED_INTERNALLY( virtual void OnGetLinesHint(
640 size_t lineMin
, size_t lineMax
) const );
642 // forwards the calls from base class pure virtual function to pure virtual
643 // OnGetLinesHint instead (backwards compatible name)
644 void OnGetRowsHeightHint(size_t rowMin
, size_t rowMax
) const;
647 #else // !WXWIN_COMPATIBILITY_2_8
649 // shortcut to avoid checking compatibility modes later
650 // remove this and all references to wxVarVScrollLegacyAdaptor once
651 // wxWidgets 2.6 and 2.8 compatibility is removed
652 typedef wxVarVScrollHelper wxVarVScrollLegacyAdaptor
;
654 #endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
657 // this macro must be used in declaration of wxVarScrollHelperBase-derived
659 #define WX_FORWARD_TO_VAR_SCROLL_HELPER() \
661 virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \
662 virtual bool Layout() { return ScrollLayout(); }
666 // ===========================================================================
668 // ===========================================================================
670 // In the name of this class, "V" may stand for "variable" because it can be
671 // used for scrolling rows of variable heights; "virtual", because it is not
672 // necessary to know the heights of all rows in advance -- only those which
673 // are shown on the screen need to be measured; or even "vertical", because
674 // this class only supports scrolling vertically.
676 // In any case, this is a generalization of the wxScrolledWindow class which
677 // can be only used when all rows have the same heights. It lacks some other
678 // wxScrolledWindow features however, notably it can't scroll only a rectangle
679 // of the window and not its entire client area.
681 class WXDLLIMPEXP_CORE wxVScrolledWindow
: public wxPanel
,
682 public wxVarVScrollLegacyAdaptor
685 // constructors and such
686 // ---------------------
688 // default ctor, you must call Create() later
689 wxVScrolledWindow() : wxVarVScrollLegacyAdaptor(this) { }
691 // normal ctor, no need to call Create() after this one
693 // note that wxVSCROLL is always automatically added to our style, there is
694 // no need to specify it explicitly
695 wxVScrolledWindow(wxWindow
*parent
,
696 wxWindowID id
= wxID_ANY
,
697 const wxPoint
& pos
= wxDefaultPosition
,
698 const wxSize
& size
= wxDefaultSize
,
700 const wxString
& name
= wxPanelNameStr
)
701 : wxVarVScrollLegacyAdaptor(this)
703 (void)Create(parent
, id
, pos
, size
, style
, name
);
706 // same as the previous ctor but returns status code: true if ok
708 // just as with the ctor above, wxVSCROLL style is always used, there is no
709 // need to specify it
710 bool Create(wxWindow
*parent
,
711 wxWindowID id
= wxID_ANY
,
712 const wxPoint
& pos
= wxDefaultPosition
,
713 const wxSize
& size
= wxDefaultSize
,
715 const wxString
& name
= wxPanelNameStr
)
717 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxVSCROLL
, name
);
720 #if WXWIN_COMPATIBILITY_2_8
721 // Make sure we prefer our version of HitTest rather than wxWindow's
722 // These functions should no longer be masked in favor of VirtualHitTest()
723 int HitTest(wxCoord
WXUNUSED(x
), wxCoord y
) const
724 { return wxVarVScrollHelper::VirtualHitTest(y
); }
725 int HitTest(const wxPoint
& pt
) const
726 { return HitTest(pt
.x
, pt
.y
); }
727 #endif // WXWIN_COMPATIBILITY_2_8
729 WX_FORWARD_TO_VAR_SCROLL_HELPER()
733 virtual void UpdateMacScrollWindow() { Update(); }
737 wxDECLARE_NO_COPY_CLASS(wxVScrolledWindow
);
738 DECLARE_ABSTRACT_CLASS(wxVScrolledWindow
)
743 // ===========================================================================
745 // ===========================================================================
747 // In the name of this class, "H" stands for "horizontal" because it can be
748 // used for scrolling columns of variable widths. It is not necessary to know
749 // the widths of all columns in advance -- only those which are shown on the
750 // screen need to be measured.
752 // This is a generalization of the wxScrolledWindow class which can be only
753 // used when all columns have the same width. It lacks some other
754 // wxScrolledWindow features however, notably it can't scroll only a rectangle
755 // of the window and not its entire client area.
757 class WXDLLIMPEXP_CORE wxHScrolledWindow
: public wxPanel
,
758 public wxVarHScrollHelper
761 // constructors and such
762 // ---------------------
764 // default ctor, you must call Create() later
765 wxHScrolledWindow() : wxVarHScrollHelper(this) { }
767 // normal ctor, no need to call Create() after this one
769 // note that wxHSCROLL is always automatically added to our style, there is
770 // no need to specify it explicitly
771 wxHScrolledWindow(wxWindow
*parent
,
772 wxWindowID id
= wxID_ANY
,
773 const wxPoint
& pos
= wxDefaultPosition
,
774 const wxSize
& size
= wxDefaultSize
,
776 const wxString
& name
= wxPanelNameStr
)
777 : wxVarHScrollHelper(this)
779 (void)Create(parent
, id
, pos
, size
, style
, name
);
782 // same as the previous ctor but returns status code: true if ok
784 // just as with the ctor above, wxHSCROLL style is always used, there is no
785 // need to specify it
786 bool Create(wxWindow
*parent
,
787 wxWindowID id
= wxID_ANY
,
788 const wxPoint
& pos
= wxDefaultPosition
,
789 const wxSize
& size
= wxDefaultSize
,
791 const wxString
& name
= wxPanelNameStr
)
793 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxHSCROLL
, name
);
796 WX_FORWARD_TO_VAR_SCROLL_HELPER()
800 virtual void UpdateMacScrollWindow() { Update(); }
804 wxDECLARE_NO_COPY_CLASS(wxHScrolledWindow
);
805 DECLARE_ABSTRACT_CLASS(wxHScrolledWindow
)
810 // ===========================================================================
811 // wxHVScrolledWindow
812 // ===========================================================================
814 // This window inherits all functionality of both vertical and horizontal
815 // scrolled windows automatically handling everything needed to scroll both
816 // axis simultaneously.
818 class WXDLLIMPEXP_CORE wxHVScrolledWindow
: public wxPanel
,
819 public wxVarHVScrollHelper
822 // constructors and such
823 // ---------------------
825 // default ctor, you must call Create() later
828 wxVarHVScrollHelper(this) { }
830 // normal ctor, no need to call Create() after this one
832 // note that wxVSCROLL and wxHSCROLL are always automatically added to our
833 // style, there is no need to specify them explicitly
834 wxHVScrolledWindow(wxWindow
*parent
,
835 wxWindowID id
= wxID_ANY
,
836 const wxPoint
& pos
= wxDefaultPosition
,
837 const wxSize
& size
= wxDefaultSize
,
839 const wxString
& name
= wxPanelNameStr
)
841 wxVarHVScrollHelper(this)
843 (void)Create(parent
, id
, pos
, size
, style
, name
);
846 // same as the previous ctor but returns status code: true if ok
848 // just as with the ctor above, wxVSCROLL and wxHSCROLL styles are always
849 // used, there is no need to specify them
850 bool Create(wxWindow
*parent
,
851 wxWindowID id
= wxID_ANY
,
852 const wxPoint
& pos
= wxDefaultPosition
,
853 const wxSize
& size
= wxDefaultSize
,
855 const wxString
& name
= wxPanelNameStr
)
857 return wxPanel::Create(parent
, id
, pos
, size
,
858 style
| wxVSCROLL
| wxHSCROLL
, name
);
861 WX_FORWARD_TO_VAR_SCROLL_HELPER()
865 virtual void UpdateMacScrollWindow() { Update(); }
869 wxDECLARE_NO_COPY_CLASS(wxHVScrolledWindow
);
870 DECLARE_ABSTRACT_CLASS(wxHVScrolledWindow
)
873 #endif // _WX_VSCROLL_H_