| Version: 3.2.8

Public Member Functions | Protected Member Functions | List of all members
wxVarScrollHelperBase Class Referenceabstract
Class List by Category » Miscellaneous Windows

`#include <wx/vscroll.h>`

Inheritance diagram for wxVarScrollHelperBase:
[legend]

## Detailed Description

This class provides all common base functionality for scroll calculations shared among all variable scrolled window implementations as well as automatic scrollbar functionality, saved scroll positions, controlling target windows to be scrolled, as well as defining all required virtual functions that need to be implemented for any orientation specific work.

Documentation of this class is provided specifically for referencing use of the functions provided by this class for use with the variable scrolled windows that derive from here. You will likely want to derive your window from one of the already implemented variable scrolled windows rather than from wxVarScrollHelperBase directly.

##

Library: wxCore
Category: Miscellaneous Windows

See also
  wxHScrolledWindow, wxHVScrolledWindow, wxVScrolledWindow

## Public Member Functions
| wxVarScrollHelperBase (wxWindow *winToScroll)
| Constructor taking the target window to be scrolled by this helper class. More...
virtual | ~wxVarScrollHelperBase ()
| Virtual destructor for detaching scroll event handlers attached with this helper class. More...
int | CalcScrolledPosition (int coord) const
| Translates the logical coordinate given to the current device coordinate. More...
int | CalcUnscrolledPosition (int coord) const
| Translates the device coordinate given to the corresponding logical coordinate. More...
void | EnablePhysicalScrolling (bool scrolling=true)
| With physical scrolling on (when this is true), 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. More...
virtual int | GetNonOrientationTargetSize () const =0
| This function needs to be overridden in the in the derived class to return the window size with respect to the opposing orientation. More...
virtual wxOrientation | GetOrientation () const =0
| This function need to be overridden to return the orientation that this helper is working with, either `wxHORIZONTAL` or `wxVERTICAL`. More...
virtual int | GetOrientationTargetSize () const =0
| This function needs to be overridden in the in the derived class to return the window size with respect to the orientation this helper is working with. More...
virtual wxWindow * | GetTargetWindow () const
| This function will return the target window this helper class is currently scrolling. More...
size_t | GetVisibleBegin () const
| Returns the index of the first visible unit based on the scroll position. More...
size_t | GetVisibleEnd () const
| Returns the index of the last visible unit based on the scroll position. More...
bool | IsVisible (size_t unit) const
| Returns true if the given scroll unit is currently visible (even if only partially visible) or false otherwise. More...
virtual void | RefreshAll ()
| Recalculate all parameters and repaint all units. More...
virtual void | SetTargetWindow (wxWindow *target)
| Normally the window will scroll itself, but in some rare occasions you might want it to scroll (part of) another window (e.g. More...
virtual void | UpdateScrollbar ()
| Update the thumb size shown by the scrollbar. More...
int | VirtualHitTest (wxCoord coord) const
| Returns the virtual scroll unit under the device unit given accounting for scroll position or `wxNOT_FOUND` if none (i.e. More...

## Protected Member Functions
virtual void | OnGetUnitsSizeHint (size_t unitMin, size_t unitMax) const
| This function doesn't have to be overridden but it may be useful to do so if calculating the units' sizes is a relatively expensive operation as it gives your code a chance to calculate several of them at once and cache the result if necessary. More...
virtual wxCoord | EstimateTotalSize () const
| When the number of scroll units change, we try to estimate the total size of all units when the full window size is needed (i.e. More...
virtual wxCoord | OnGetUnitSize (size_t unit) const =0
| This function must be overridden in the derived class, and should return the size of the given unit in pixels. More...

## Constructor & Destructor Documentation

## ◆ wxVarScrollHelperBase()

wxVarScrollHelperBase::wxVarScrollHelperBase | ( | wxWindow * | winToScroll | ) |

Constructor taking the target window to be scrolled by this helper class.

This will attach scroll event handlers to the target window to catch and handle scroll events appropriately.

## ◆ ~wxVarScrollHelperBase()

virtual wxVarScrollHelperBase::~wxVarScrollHelperBase | ( |  | ) |
| virtual

Virtual destructor for detaching scroll event handlers attached with this helper class.

## Member Function Documentation

## ◆ CalcScrolledPosition()

int wxVarScrollHelperBase::CalcScrolledPosition | ( | int | coord | ) | const

Translates the logical coordinate given to the current device coordinate.

For example, if the window is scrolled 10 units and each scroll unit represents 10 device units (which may not be the case since this class allows for variable scroll unit sizes), a call to this function with a coordinate of 15 will return -85.

See also
  CalcUnscrolledPosition()

## ◆ CalcUnscrolledPosition()

int wxVarScrollHelperBase::CalcUnscrolledPosition | ( | int | coord | ) | const

Translates the device coordinate given to the corresponding logical coordinate.

For example, if the window is scrolled 10 units and each scroll unit represents 10 device units (which may not be the case since this class allows for variable scroll unit sizes), a call to this function with a coordinate of 15 will return 115.

See also
  CalcScrolledPosition()

## ◆ EnablePhysicalScrolling()

void wxVarScrollHelperBase::EnablePhysicalScrolling | ( | bool | scrolling = `true` | ) |

With physical scrolling on (when this is true), 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.

When this is false, you are responsible for repainting any invalidated areas of the window yourself to account for the new scroll position.

## ◆ EstimateTotalSize()

virtual wxCoord wxVarScrollHelperBase::EstimateTotalSize | ( |  | ) | const
| protected virtual

When the number of scroll units change, we try to estimate the total size of all units when the full window size is needed (i.e.

to calculate the scrollbar thumb size). This is a rather expensive operation in terms of unit access, so if the user code may estimate the average size better or faster than we do, it should override this function to implement its own logic. This function should return the best guess for the total virtual window size.

Note
  Although returning a totally wrong value would still work, it risks resulting in very strange scrollbar behaviour so this function should really try to make the best guess possible.

## ◆ GetNonOrientationTargetSize()

virtual int wxVarScrollHelperBase::GetNonOrientationTargetSize | ( |  | ) | const
| pure virtual

This function needs to be overridden in the in the derived class to return the window size with respect to the opposing orientation.

If this is a vertical scrolled window, it should return the height.

See also
  GetOrientationTargetSize()

## ◆ GetOrientation()

virtual wxOrientation wxVarScrollHelperBase::GetOrientation | ( |  | ) | const
| pure virtual

This function need to be overridden to return the orientation that this helper is working with, either `wxHORIZONTAL` or `wxVERTICAL`.

## ◆ GetOrientationTargetSize()

virtual int wxVarScrollHelperBase::GetOrientationTargetSize | ( |  | ) | const
| pure virtual

This function needs to be overridden in the in the derived class to return the window size with respect to the orientation this helper is working with.

If this is a vertical scrolled window, it should return the width.

See also
  GetNonOrientationTargetSize()

## ◆ GetTargetWindow()

virtual wxWindow* wxVarScrollHelperBase::GetTargetWindow | ( |  | ) | const
| virtual

This function will return the target window this helper class is currently scrolling.

See also
  SetTargetWindow()

## ◆ GetVisibleBegin()

size_t wxVarScrollHelperBase::GetVisibleBegin | ( |  | ) | const

Returns the index of the first visible unit based on the scroll position.

## ◆ GetVisibleEnd()

size_t wxVarScrollHelperBase::GetVisibleEnd | ( |  | ) | const

Returns the index of the last visible unit based on the scroll position.

This includes the last unit even if it is only partially visible.

## ◆ IsVisible()

bool wxVarScrollHelperBase::IsVisible | ( | size_t | unit | ) | const

Returns true if the given scroll unit is currently visible (even if only partially visible) or false otherwise.

## ◆ OnGetUnitSize()

virtual wxCoord wxVarScrollHelperBase::OnGetUnitSize | ( | size_t | unit | ) | const
| protected pure virtual

This function must be overridden in the derived class, and should return the size of the given unit in pixels.

## ◆ OnGetUnitsSizeHint()

virtual void wxVarScrollHelperBase::OnGetUnitsSizeHint | ( | size_t | unitMin,
|  | size_t | unitMax
| ) |  | const
| protected virtual

This function doesn't have to be overridden but it may be useful to do so if calculating the units' sizes is a relatively expensive operation as it gives your code a chance to calculate several of them at once and cache the result if necessary.

OnGetUnitsSizeHint() is normally called just before OnGetUnitSize() but you shouldn't rely on the latter being called for all units in the interval specified here. It is also possible that OnGetUnitSize() will be called for units outside of this interval, so this is really just a hint, not a promise.

Finally, note that unitMin is inclusive, while unitMax is exclusive.

## ◆ RefreshAll()

virtual void wxVarScrollHelperBase::RefreshAll | ( |  | ) |
| virtual

Recalculate all parameters and repaint all units.

## ◆ SetTargetWindow()

virtual void wxVarScrollHelperBase::SetTargetWindow | ( | wxWindow * | target | ) |
| virtual

Normally the window 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 like a spreadsheet where only the cell area will move).

See also
  GetTargetWindow()

## ◆ UpdateScrollbar()

virtual void wxVarScrollHelperBase::UpdateScrollbar | ( |  | ) |
| virtual

Update the thumb size shown by the scrollbar.

## ◆ VirtualHitTest()

int wxVarScrollHelperBase::VirtualHitTest | ( | wxCoord | coord | ) | const

Returns the virtual scroll unit under the device unit given accounting for scroll position or `wxNOT_FOUND` if none (i.e.

if it is below the last item).