Contents Up Previous Next

wxScrollBar: wxItem

A wxScrollBar is a panel item that represents a horizontal or vertical scroll control. It may be used on panels to give similar functionality to a scrollable wxCanvas, or it may be used as a kind of slider.

Note that the constructor arguments have changed in version 1.65.

Note also that from 1.66, SetObjectLength is now consistent under Motif and Windows, so your code under Windows may need to change. You must call SetViewLength before calling SetObjectLength. See wxGenericGrid for an example of usage.

wxScrollBar::wxScrollBar
wxScrollBar::~wxScrollBar
wxScrollBar::Create
wxScrollBar::GetValue
wxScrollBar::GetValues
wxScrollBar::SetObjectLength
wxScrollBar::SetPageLength
wxScrollBar::SetViewLength
wxScrollBar::SetValue


wxScrollBar::wxScrollBar

void wxScrollBar(wxPanel *parent, wxFunction func,
int x = -1, int y = -1, int width = -1, int height = -1,
long style = wxHORIZONTAL, char *name = "scrollBar")

Constructor, creating and showing a scrollbar. The parent must be a valid panel or dialog box pointer.

Note that the constructor arguments have changed in version 1.65: the old direction parameter is now passed in the window style.

func may be NULL; otherwise it is used as the callback for the scrollbar.

The parameters x and y are used to specify an absolute position, or a position after the previous panel item if omitted or default.

If width or height are omitted (or are less than zero), an appropriate size will be used for the scrollbar.

style may be either wxHORIZONTAL or wxVERTICAL.

The name parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual scrollbars.


wxScrollBar::~wxScrollBar

void ~wxScrollBar(void)

Destructor, destroying the scrollbar.


wxScrollBar::Create

void Create(wxPanel *parent, wxFunction func,
int x = -1, int y = -1, int width = -1, int height = -1,
long style = wxHORIZONTAL, char *name = "scrollBar")

Scrollbar creation function called by the scrollbar constructor. Call it when a derived scrollbar class uses the zero-argument wxScrollBar constructor, but can reuse the existing scrollbar creation code. See wxScrollBar::wxScrollBar for details.


wxScrollBar::GetValue

int GetValue(void)

Returns the current position of the scrollbar.


wxScrollBar::GetValues

void GetValues(int *viewStart, int *viewLength, int *objectLength, int *pageLength) Returns scrollbar settings information.


wxScrollBar::SetObjectLength

void SetObjectLength(int objectLength)

Sets the object length for the scrollbar. This is the total object size (virtual size). You must call SetViewLength before calling SetObjectLength.

Example: you are implementing scrollbars on a text window, where text lines have a maximum width of 100 characters. Your text window has a current width of 60 characters. So the view length is 60, and the object length is 100. The scrollbar will then enable you to scroll to see the other 40 characters.

You will need to call SetViewLength and SetObjectLength whenever there is a change in the size of the window (the view size) or the size of the contents (the object length).


wxScrollBar::SetPageLength

void SetPageLength(int pageLength)

Sets the page length for the scrollbar. This is the number of scroll units which are scrolled when the user pages down (clicks on the scrollbar outside the thumbtrack area).


wxScrollBar::SetViewLength

void SetViewLength(int viewLength)

Sets the view length for the scrollbar.


wxScrollBar::SetValue

void SetValue(int viewStart)

Sets the position of the scrollbar.