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 // change the DC origin according to the scroll position. To properly
125 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
127 virtual void DoPrepareDC(wxDC
& dc
);
129 // the methods to be called from the window event handlers
130 void HandleOnScroll(wxScrollWinEvent
& event
);
131 void HandleOnSize(wxSizeEvent
& event
);
133 void HandleOnMouseWheel(wxMouseEvent
& event
);
134 #endif // wxUSE_MOUSEWHEEL
136 // these functions must be overidden in the derived class to return
137 // orientation specific data (e.g. the width for vertically scrolling
138 // derivatives in the case of GetOrientationTargetSize())
139 virtual int GetOrientationTargetSize() const = 0;
140 virtual int GetNonOrientationTargetSize() const = 0;
141 virtual wxOrientation
GetOrientation() const = 0;
144 // all *Unit* functions are protected to be exposed by
145 // wxVarScrollHelperBase implementations (with appropriate names)
147 // get the number of units this window contains (previously set by
149 size_t GetUnitCount() const { return m_unitMax
; }
151 // set the number of units the helper contains: the derived class must
152 // provide the sizes for all units with indices up to the one given here
153 // in its OnGetUnitSize()
154 void SetUnitCount(size_t count
);
156 // redraw the specified unit
157 virtual void RefreshUnit(size_t unit
);
159 // redraw all units in the specified range (inclusive)
160 virtual void RefreshUnits(size_t from
, size_t to
);
162 // scroll to the specified unit: it will become the first visible unit in
165 // return true if we scrolled the window, false if nothing was done
166 bool DoScrollToUnit(size_t unit
);
168 // scroll by the specified number of units/pages
169 virtual bool DoScrollUnits(int units
);
170 virtual bool DoScrollPages(int pages
);
172 // this function must be overridden in the derived class and it should
173 // return the size of the given unit in pixels
174 virtual wxCoord
OnGetUnitSize(size_t n
) const = 0;
176 // this function doesn't have to be overridden but it may be useful to do
177 // it if calculating the units' sizes is a relatively expensive operation
178 // as it gives the user code a possibility to calculate several of them at
181 // OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but
182 // you shouldn't rely on the latter being called for all units in the
183 // interval specified here. It is also possible that OnGetUnitHeight() will
184 // be called for the units outside of this interval, so this is really just
185 // a hint, not a promise.
187 // finally note that unitMin is inclusive, while unitMax is exclusive, as
189 virtual void OnGetUnitsSizeHint(size_t WXUNUSED(unitMin
),
190 size_t WXUNUSED(unitMax
)) const
193 // when the number of units changes, we try to estimate the total size
194 // of all units which is a rather expensive operation in terms of unit
195 // access, so if the user code may estimate the average size
196 // better/faster than we do, it should override this function to implement
199 // this function should return the best guess for the total size it may
201 virtual wxCoord
EstimateTotalSize() const { return DoEstimateTotalSize(); }
203 wxCoord
DoEstimateTotalSize() const;
205 // find the index of the unit we need to show to fit the specified unit on
206 // the opposite side either fully or partially (depending on fullyVisible)
207 size_t FindFirstVisibleFromLast(size_t last
,
208 bool fullyVisible
= false) const;
210 // get the total size of the units between unitMin (inclusive) and
211 // unitMax (exclusive)
212 wxCoord
GetUnitsSize(size_t unitMin
, size_t unitMax
) const;
214 // get the offset of the first visible unit
215 wxCoord
GetScrollOffset() const
216 { return GetUnitsSize(0, GetVisibleBegin()); }
218 // get the size of the target window
219 wxSize
GetTargetSize() const { return m_targetWindow
->GetClientSize(); }
221 void GetTargetSize(int *w
, int *h
)
223 wxSize size
= GetTargetSize();
230 // calculate the new scroll position based on scroll event type
231 size_t GetNewScrollPosition(wxScrollWinEvent
& event
) const;
233 // replacement implementation of wxWindow::Layout virtual method. To
234 // properly forward calls to wxWindow::Layout use
235 // WX_FORWARD_TO_SCROLL_HELPER() derived class
239 // queue mac window update after handling scroll event
240 virtual void UpdateMacScrollWindow() { }
243 // change the target window
244 void DoSetTargetWindow(wxWindow
*target
);
246 // delete the event handler we installed
247 void DeleteEvtHandler();
249 // helper function abstracting the orientation test: with vertical
250 // orientation, it assigns the first value to x and the second one to y,
251 // with horizontal orientation it reverses them, i.e. the first value is
252 // assigned to y and the second one to x
253 void AssignOrient(wxCoord
& x
, wxCoord
& y
, wxCoord first
, wxCoord second
);
255 // similar to "oriented assignment" above but does "oriented increment":
256 // for vertical orientation, y is incremented by the given value and x if
257 // left unchanged, for horizontal orientation x is incremented
258 void IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
);
261 // the total number of (logical) units
264 // the total (estimated) size
267 // the first currently visible unit
270 // the number of currently visible units (including the last, possibly only
271 // partly, visible one)
272 size_t m_nUnitsVisible
;
274 // accumulated mouse wheel rotation
276 int m_sumWheelRotation
;
279 // do child scrolling (used in DoPrepareDC())
280 bool m_physicalScrolling
;
282 // handler injected into target window to forward some useful events to us
283 wxVarScrollHelperEvtHandler
*m_handler
;
288 // ===========================================================================
289 // wxVarVScrollHelper
290 // ===========================================================================
292 // Provides public API functions targeted for vertical-specific scrolling,
293 // wrapping the functionality of wxVarScrollHelperBase.
295 class WXDLLIMPEXP_CORE wxVarVScrollHelper
: public wxVarScrollHelperBase
298 // constructors and such
299 // ---------------------
301 // ctor must be given the associated window
302 wxVarVScrollHelper(wxWindow
*winToScroll
)
303 : wxVarScrollHelperBase(winToScroll
)
309 void SetRowCount(size_t rowCount
) { SetUnitCount(rowCount
); }
310 bool ScrollToRow(size_t row
) { return DoScrollToUnit(row
); }
312 virtual bool ScrollRows(int rows
)
313 { return DoScrollUnits(rows
); }
314 virtual bool ScrollRowPages(int pages
)
315 { return DoScrollPages(pages
); }
317 virtual void RefreshRow(size_t row
)
318 { RefreshUnit(row
); }
319 virtual void RefreshRows(size_t from
, size_t to
)
320 { RefreshUnits(from
, to
); }
324 size_t GetRowCount() const { return GetUnitCount(); }
325 size_t GetVisibleRowsBegin() const { return GetVisibleBegin(); }
326 size_t GetVisibleRowsEnd() const { return GetVisibleEnd(); }
327 bool IsRowVisible(size_t row
) const { return IsVisible(row
); }
329 virtual int GetOrientationTargetSize() const
330 { return GetTargetWindow()->GetClientSize().y
; }
331 virtual int GetNonOrientationTargetSize() const
332 { return GetTargetWindow()->GetClientSize().x
; }
333 virtual wxOrientation
GetOrientation() const { return wxVERTICAL
; }
336 // this function must be overridden in the derived class and it should
337 // return the size of the given row in pixels
338 virtual wxCoord
OnGetRowHeight(size_t n
) const = 0;
339 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetRowHeight(n
); }
341 virtual void OnGetRowsHeightHint(size_t WXUNUSED(rowMin
),
342 size_t WXUNUSED(rowMax
)) const { }
344 // forward calls to OnGetRowsHeightHint()
345 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
346 { OnGetRowsHeightHint(unitMin
, unitMax
); }
348 // again, if not overridden, it will fall back on default method
349 virtual wxCoord
EstimateTotalHeight() const
350 { return DoEstimateTotalSize(); }
352 // forward calls to EstimateTotalHeight()
353 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalHeight(); }
355 wxCoord
GetRowsHeight(size_t rowMin
, size_t rowMax
) const
356 { return GetUnitsSize(rowMin
, rowMax
); }
361 // ===========================================================================
362 // wxVarHScrollHelper
363 // ===========================================================================
365 // Provides public API functions targeted for horizontal-specific scrolling,
366 // wrapping the functionality of wxVarScrollHelperBase.
368 class WXDLLIMPEXP_CORE wxVarHScrollHelper
: public wxVarScrollHelperBase
371 // constructors and such
372 // ---------------------
374 // ctor must be given the associated window
375 wxVarHScrollHelper(wxWindow
*winToScroll
)
376 : wxVarScrollHelperBase(winToScroll
)
382 void SetColumnCount(size_t columnCount
)
383 { SetUnitCount(columnCount
); }
385 bool ScrollToColumn(size_t column
)
386 { return DoScrollToUnit(column
); }
387 virtual bool ScrollColumns(int columns
)
388 { return DoScrollUnits(columns
); }
389 virtual bool ScrollColumnPages(int pages
)
390 { return DoScrollPages(pages
); }
392 virtual void RefreshColumn(size_t column
)
393 { RefreshUnit(column
); }
394 virtual void RefreshColumns(size_t from
, size_t to
)
395 { RefreshUnits(from
, to
); }
399 size_t GetColumnCount() const
400 { return GetUnitCount(); }
401 size_t GetVisibleColumnsBegin() const
402 { return GetVisibleBegin(); }
403 size_t GetVisibleColumnsEnd() const
404 { return GetVisibleEnd(); }
405 bool IsColumnVisible(size_t column
) const
406 { return IsVisible(column
); }
409 virtual int GetOrientationTargetSize() const
410 { return GetTargetWindow()->GetClientSize().x
; }
411 virtual int GetNonOrientationTargetSize() const
412 { return GetTargetWindow()->GetClientSize().y
; }
413 virtual wxOrientation
GetOrientation() const { return wxHORIZONTAL
; }
416 // this function must be overridden in the derived class and it should
417 // return the size of the given column in pixels
418 virtual wxCoord
OnGetColumnWidth(size_t n
) const = 0;
419 wxCoord
OnGetUnitSize(size_t n
) const { return OnGetColumnWidth(n
); }
421 virtual void OnGetColumnsWidthHint(size_t WXUNUSED(columnMin
),
422 size_t WXUNUSED(columnMax
)) const
425 // forward calls to OnGetColumnsWidthHint()
426 virtual void OnGetUnitsSizeHint(size_t unitMin
, size_t unitMax
) const
427 { OnGetColumnsWidthHint(unitMin
, unitMax
); }
429 // again, if not overridden, it will fall back on default method
430 virtual wxCoord
EstimateTotalWidth() const { return DoEstimateTotalSize(); }
432 // forward calls to EstimateTotalWidth()
433 virtual wxCoord
EstimateTotalSize() const { return EstimateTotalWidth(); }
435 wxCoord
GetColumnsWidth(size_t columnMin
, size_t columnMax
) const
436 { return GetUnitsSize(columnMin
, columnMax
); }
441 // ===========================================================================
442 // wxVarHVScrollHelper
443 // ===========================================================================
445 // Provides public API functions targeted at functions with similar names in
446 // both wxVScrollHelper and wxHScrollHelper so class scope doesn't need to be
447 // specified (since we are using multiple inheritance). It also provides
448 // functions to make changing values for both orientations at the same time
451 class WXDLLIMPEXP_CORE wxVarHVScrollHelper
: public wxVarVScrollHelper
,
452 public wxVarHScrollHelper
455 // constructors and such
456 // ---------------------
458 // ctor must be given the associated window
459 wxVarHVScrollHelper(wxWindow
*winToScroll
)
460 : wxVarVScrollHelper(winToScroll
), wxVarHScrollHelper(winToScroll
) { }
465 // set the number of units the window contains for each axis: the derived
466 // class must provide the widths and heights for all units with indices up
467 // to each of the one given here in its OnGetColumnWidth() and
469 void SetRowColumnCount(size_t rowCount
, size_t columnCount
);
472 // with physical scrolling on, the device origin is changed properly when
473 // a wxPaintDC is prepared, children are actually moved and laid out
474 // properly, and the contents of the window (pixels) are actually moved
475 void EnablePhysicalScrolling(bool vscrolling
= true, bool hscrolling
= true)
477 wxVarVScrollHelper::EnablePhysicalScrolling(vscrolling
);
478 wxVarHScrollHelper::EnablePhysicalScrolling(hscrolling
);
481 // scroll to the specified row/column: it will become the first visible
482 // cell in the window
484 // return true if we scrolled the window, false if nothing was done
485 bool ScrollToRowColumn(size_t row
, size_t column
);
486 bool ScrollToRowColumn(const wxPosition
&pos
)
487 { return ScrollToRowColumn(pos
.GetRow(), pos
.GetColumn()); }
489 // redraw the specified cell
490 virtual void RefreshRowColumn(size_t row
, size_t column
);
491 virtual void RefreshRowColumn(const wxPosition
&pos
)
492 { RefreshRowColumn(pos
.GetRow(), pos
.GetColumn()); }
494 // redraw the specified regions (inclusive). If the target window for
495 // both orientations is the same the rectangle of cells is refreshed; if
496 // the target windows differ the entire client size opposite the
497 // orientation direction is refreshed between the specified limits
498 virtual void RefreshRowsColumns(size_t fromRow
, size_t toRow
,
499 size_t fromColumn
, size_t toColumn
);
500 virtual void RefreshRowsColumns(const wxPosition
& from
,
501 const wxPosition
& to
)
503 RefreshRowsColumns(from
.GetRow(), to
.GetRow(),
504 from
.GetColumn(), to
.GetColumn());
507 // locate the virtual position from the given device coordinates
508 wxPosition
VirtualHitTest(wxCoord x
, wxCoord y
) const;
509 wxPosition
VirtualHitTest(const wxPoint
&pos
) const
510 { return VirtualHitTest(pos
.x
, pos
.y
); }
512 // change the DC origin according to the scroll position. To properly
513 // forward calls to wxWindow::Layout use WX_FORWARD_TO_SCROLL_HELPER()
514 // derived class. We use this version to call both base classes'
516 virtual void DoPrepareDC(wxDC
& dc
);
518 // replacement implementation of wxWindow::Layout virtual method. To
519 // properly forward calls to wxWindow::Layout use
520 // WX_FORWARD_TO_SCROLL_HELPER() derived class. We use this version to
521 // call both base classes' ScrollLayout()
527 // get the number of units this window contains (previously set by
528 // Set[Column/Row/RowColumn/Unit]Count())
529 wxSize
GetRowColumnCount() const;
531 // get the first currently visible units
532 wxPosition
GetVisibleBegin() const;
533 wxPosition
GetVisibleEnd() const;
535 // is this cell currently visible?
536 bool IsVisible(size_t row
, size_t column
) const;
537 bool IsVisible(const wxPosition
&pos
) const
538 { return IsVisible(pos
.GetRow(), pos
.GetColumn()); }
543 #if WXWIN_COMPATIBILITY_2_8
545 // ===========================================================================
546 // wxVarVScrollLegacyAdaptor
547 // ===========================================================================
549 // Provides backwards compatible API for applications originally built using
550 // wxVScrolledWindow in 2.6 or 2.8. Originally, wxVScrolledWindow referred
551 // to scrolling "lines". We use "units" in wxVarScrollHelperBase to avoid
552 // implying any orientation (since the functions are used for both horizontal
553 // and vertical scrolling in derived classes). And in the new
554 // wxVScrolledWindow and wxHScrolledWindow classes, we refer to them as
555 // "rows" and "columns", respectively. This is to help clear some confusion
556 // in not only those classes, but also in wxHVScrolledWindow where functions
557 // are inherited from both.
559 class WXDLLIMPEXP_CORE wxVarVScrollLegacyAdaptor
: public wxVarVScrollHelper
562 // constructors and such
563 // ---------------------
564 wxVarVScrollLegacyAdaptor(wxWindow
*winToScroll
)
565 : wxVarVScrollHelper(winToScroll
)
572 // this is the same as GetVisibleRowsBegin(), exists to match
573 // GetLastVisibleLine() and for backwards compatibility only
574 wxDEPRECATED( size_t GetFirstVisibleLine() const );
576 // get the last currently visible line
578 // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive
579 // number) if the control is empty, use GetVisibleRowsEnd() instead, this
580 // one is kept for backwards compatibility
581 wxDEPRECATED( size_t GetLastVisibleLine() const );
583 // "line" to "unit" compatibility functions
584 // ----------------------------------------
586 // get the number of lines this window contains (set by SetLineCount())
587 wxDEPRECATED( size_t GetLineCount() const );
589 // set the number of lines the helper contains: the derived class must
590 // provide the sizes for all lines with indices up to the one given here
591 // in its OnGetLineHeight()
592 wxDEPRECATED( void SetLineCount(size_t count
) );
594 // redraw the specified line
595 wxDEPRECATED( virtual void RefreshLine(size_t line
) );
597 // redraw all lines in the specified range (inclusive)
598 wxDEPRECATED( virtual void RefreshLines(size_t from
, size_t to
) );
600 // scroll to the specified line: it will become the first visible line in
603 // return true if we scrolled the window, false if nothing was done
604 wxDEPRECATED( bool ScrollToLine(size_t line
) );
606 // scroll by the specified number of lines/pages
607 wxDEPRECATED( virtual bool ScrollLines(int lines
) );
608 wxDEPRECATED( virtual bool ScrollPages(int pages
) );
611 // unless the code has been updated to override OnGetRowHeight() instead,
612 // this function must be overridden in the derived class and it should
613 // return the height of the given row in pixels
614 wxDEPRECATED_BUT_USED_INTERNALLY(
615 virtual wxCoord
OnGetLineHeight(size_t n
) const );
617 // forwards the calls from base class pure virtual function to pure virtual
618 // OnGetLineHeight instead (backwards compatible name)
619 // note that we don't need to forward OnGetUnitSize() as it is already
620 // forwarded to OnGetRowHeight() in wxVarVScrollHelper
621 virtual wxCoord
OnGetRowHeight(size_t n
) const;
623 // this function doesn't have to be overridden but it may be useful to do
624 // it if calculating the lines heights is a relatively expensive operation
625 // as it gives the user code a possibility to calculate several of them at
628 // OnGetLinesHint() is normally called just before OnGetLineHeight() but you
629 // shouldn't rely on the latter being called for all lines in the interval
630 // specified here. It is also possible that OnGetLineHeight() will be
631 // called for the lines outside of this interval, so this is really just a
632 // hint, not a promise.
634 // finally note that lineMin is inclusive, while lineMax is exclusive, as
636 wxDEPRECATED_BUT_USED_INTERNALLY( virtual void OnGetLinesHint(
637 size_t lineMin
, size_t lineMax
) const );
639 // forwards the calls from base class pure virtual function to pure virtual
640 // OnGetLinesHint instead (backwards compatible name)
641 void OnGetRowsHeightHint(size_t rowMin
, size_t rowMax
) const;
644 #else // !WXWIN_COMPATIBILITY_2_8
646 // shortcut to avoid checking compatibility modes later
647 // remove this and all references to wxVarVScrollLegacyAdaptor once
648 // wxWidgets 2.6 and 2.8 compatibility is removed
649 typedef wxVarVScrollHelper wxVarVScrollLegacyAdaptor
;
651 #endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
654 // this macro must be used in declaration of wxVarScrollHelperBase-derived
656 #define WX_FORWARD_TO_VAR_SCROLL_HELPER() \
658 virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \
659 virtual bool Layout() { return ScrollLayout(); }
663 // ===========================================================================
665 // ===========================================================================
667 // In the name of this class, "V" may stand for "variable" because it can be
668 // used for scrolling rows of variable heights; "virtual", because it is not
669 // necessary to know the heights of all rows in advance -- only those which
670 // are shown on the screen need to be measured; or even "vertical", because
671 // this class only supports scrolling vertically.
673 // In any case, this is a generalization of the wxScrolledWindow class which
674 // can be only used when all rows have the same heights. It lacks some other
675 // wxScrolledWindow features however, notably it can't scroll only a rectangle
676 // of the window and not its entire client area.
678 class WXDLLIMPEXP_CORE wxVScrolledWindow
: public wxPanel
,
679 public wxVarVScrollLegacyAdaptor
682 // constructors and such
683 // ---------------------
685 // default ctor, you must call Create() later
686 wxVScrolledWindow() : wxVarVScrollLegacyAdaptor(this) { }
688 // normal ctor, no need to call Create() after this one
690 // note that wxVSCROLL is always automatically added to our style, there is
691 // no need to specify it explicitly
692 wxVScrolledWindow(wxWindow
*parent
,
693 wxWindowID id
= wxID_ANY
,
694 const wxPoint
& pos
= wxDefaultPosition
,
695 const wxSize
& size
= wxDefaultSize
,
697 const wxString
& name
= wxPanelNameStr
)
698 : wxVarVScrollLegacyAdaptor(this)
700 (void)Create(parent
, id
, pos
, size
, style
, name
);
703 // same as the previous ctor but returns status code: true if ok
705 // just as with the ctor above, wxVSCROLL style is always used, there is no
706 // need to specify it
707 bool Create(wxWindow
*parent
,
708 wxWindowID id
= wxID_ANY
,
709 const wxPoint
& pos
= wxDefaultPosition
,
710 const wxSize
& size
= wxDefaultSize
,
712 const wxString
& name
= wxPanelNameStr
)
714 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxVSCROLL
, name
);
717 #if WXWIN_COMPATIBILITY_2_8
718 // Make sure we prefer our version of HitTest rather than wxWindow's
719 // These functions should no longer be masked in favor of VirtualHitTest()
720 int HitTest(wxCoord
WXUNUSED(x
), wxCoord y
) const
721 { return wxVarVScrollHelper::VirtualHitTest(y
); }
722 int HitTest(const wxPoint
& pt
) const
723 { return HitTest(pt
.x
, pt
.y
); }
724 #endif // WXWIN_COMPATIBILITY_2_8
726 WX_FORWARD_TO_VAR_SCROLL_HELPER()
730 virtual void UpdateMacScrollWindow() { Update(); }
734 wxDECLARE_NO_COPY_CLASS(wxVScrolledWindow
);
735 DECLARE_ABSTRACT_CLASS(wxVScrolledWindow
)
740 // ===========================================================================
742 // ===========================================================================
744 // In the name of this class, "H" stands for "horizontal" because it can be
745 // used for scrolling columns of variable widths. It is not necessary to know
746 // the widths of all columns in advance -- only those which are shown on the
747 // screen need to be measured.
749 // This is a generalization of the wxScrolledWindow class which can be only
750 // used when all columns have the same width. It lacks some other
751 // wxScrolledWindow features however, notably it can't scroll only a rectangle
752 // of the window and not its entire client area.
754 class WXDLLIMPEXP_CORE wxHScrolledWindow
: public wxPanel
,
755 public wxVarHScrollHelper
758 // constructors and such
759 // ---------------------
761 // default ctor, you must call Create() later
762 wxHScrolledWindow() : wxVarHScrollHelper(this) { }
764 // normal ctor, no need to call Create() after this one
766 // note that wxHSCROLL is always automatically added to our style, there is
767 // no need to specify it explicitly
768 wxHScrolledWindow(wxWindow
*parent
,
769 wxWindowID id
= wxID_ANY
,
770 const wxPoint
& pos
= wxDefaultPosition
,
771 const wxSize
& size
= wxDefaultSize
,
773 const wxString
& name
= wxPanelNameStr
)
774 : wxVarHScrollHelper(this)
776 (void)Create(parent
, id
, pos
, size
, style
, name
);
779 // same as the previous ctor but returns status code: true if ok
781 // just as with the ctor above, wxHSCROLL style is always used, there is no
782 // need to specify it
783 bool Create(wxWindow
*parent
,
784 wxWindowID id
= wxID_ANY
,
785 const wxPoint
& pos
= wxDefaultPosition
,
786 const wxSize
& size
= wxDefaultSize
,
788 const wxString
& name
= wxPanelNameStr
)
790 return wxPanel::Create(parent
, id
, pos
, size
, style
| wxHSCROLL
, name
);
793 WX_FORWARD_TO_VAR_SCROLL_HELPER()
797 virtual void UpdateMacScrollWindow() { Update(); }
801 wxDECLARE_NO_COPY_CLASS(wxHScrolledWindow
);
802 DECLARE_ABSTRACT_CLASS(wxHScrolledWindow
)
807 // ===========================================================================
808 // wxHVScrolledWindow
809 // ===========================================================================
811 // This window inherits all functionality of both vertical and horizontal
812 // scrolled windows automatically handling everything needed to scroll both
813 // axis simultaneously.
815 class WXDLLIMPEXP_CORE wxHVScrolledWindow
: public wxPanel
,
816 public wxVarHVScrollHelper
819 // constructors and such
820 // ---------------------
822 // default ctor, you must call Create() later
825 wxVarHVScrollHelper(this) { }
827 // normal ctor, no need to call Create() after this one
829 // note that wxVSCROLL and wxHSCROLL are always automatically added to our
830 // style, there is no need to specify them explicitly
831 wxHVScrolledWindow(wxWindow
*parent
,
832 wxWindowID id
= wxID_ANY
,
833 const wxPoint
& pos
= wxDefaultPosition
,
834 const wxSize
& size
= wxDefaultSize
,
836 const wxString
& name
= wxPanelNameStr
)
838 wxVarHVScrollHelper(this)
840 (void)Create(parent
, id
, pos
, size
, style
, name
);
843 // same as the previous ctor but returns status code: true if ok
845 // just as with the ctor above, wxVSCROLL and wxHSCROLL styles are always
846 // used, there is no need to specify them
847 bool Create(wxWindow
*parent
,
848 wxWindowID id
= wxID_ANY
,
849 const wxPoint
& pos
= wxDefaultPosition
,
850 const wxSize
& size
= wxDefaultSize
,
852 const wxString
& name
= wxPanelNameStr
)
854 return wxPanel::Create(parent
, id
, pos
, size
,
855 style
| wxVSCROLL
| wxHSCROLL
, name
);
858 WX_FORWARD_TO_VAR_SCROLL_HELPER()
862 virtual void UpdateMacScrollWindow() { Update(); }
866 wxDECLARE_NO_COPY_CLASS(wxHVScrolledWindow
);
867 DECLARE_ABSTRACT_CLASS(wxHVScrolledWindow
)
870 #endif // _WX_VSCROLL_H_