WidgetScrollBox Class
This class creates a scroll box.
WidgetScrollBox Class
This class inherits from WidgetMembers
WidgetScrollBox (Gui gui, int space_x = 0, int space_y = 0)
Constructor. Creates a box with scrolling based on given parameters.Arguments
- Gui gui - GUI, to which the new box will belong.
- int space_x = 0 - Horizontal space between the widgets in the box and between them and the box border. This is an optional parameter.
- int space_y = 0 - Vertical space between the widgets in the box and between them and the box border. This is an optional parameter.
int getBorder ()
Returns a flag indicating if a one-pixel border is rendered around the widget content (in a shape of a box). The default is 1 (use a border).Return value
Positive number if a border is enabled; otherwise, 0.int getHScrollFrameSize ()
Returns the width of the currently visible area.Return value
Width of the visible area in pixels.int getHScrollObjectSize ()
Returns the width of the whole object that should be scrolled.Return value
Width of the object being scrolled in pixels.int getHScrollStepSize ()
Returns the step of the horizontal scroller. This step is used to increment the scroll position.Return value
Step of the horizontal scroller in pixels.int getHScrollValue ()
Returns the current position (and also the size) of the horizontal scroller. That is, it returns the width of the currently invisible area that determines the size of the slider.Return value
Position of the horizontal scroller.int getPaddingBottom ()
Returns the current bottom padding for the widget content.Return value
Bottom padding in pixels.int getPaddingLeft ()
Returns the current left-side padding for the widget content.Return value
Left-side padding in pixels.int getPaddingRight ()
Returns the current right-side padding for the widget content.Return value
Right-side padding in pixels.int getPaddingTop ()
Returns the current top padding for the widget content.Return value
Top padding in pixels.int getScrollScale ()
Returns the divisor used to convert integer values into floating point values.Return value
Divisor used to scale integers.int getSpaceX ()
Returns the horizontal space between the widgets in the box and between them and the box border.Return value
Horizontal space.int getSpaceY ()
Returns the vertical space between the widgets in the box and between them and the box border.Return value
Vertical space.int getVScrollFrameSize ()
Returns the height of the currently visible area.Return value
Height of the visible area in pixels.int getVScrollObjectSize ()
Returns the height of the whole object that should be scrolled.Return value
Height of the object being scrolled in pixels.int getVScrollStepSize ()
Returns the step of the vertical scroller. This step is used to increment the scroll position.Return value
Step of the vertical scroller in pixels.int getVScrollValue ()
Returns the current position (and also the size) of the vertical scroller. That is, it returns the width of the currently invisible area that determines the size of the slider.Return value
Position of the vertical scroller.int isHScrollEnabled ()
Returns a value indicating if horizontal scrolling is enabled.Return value
Positive number if scrolling is enabled; otherwise, 0.int isHScrollHidden ()
Returns a flag indicating if a horizontal scroll bar is hidden, disabled or always rendered.Return value
Hide flag:- 0 if a scroll bar is always rendered.
- 1 if a scroll bar is automatically hidden when necessary. For example, if the container area is big enough to show all elements, the scroll bar is not rendered. And vice versa, if not all elements can be shown at once, a scroll bar is rendered.
- 2 if a scroll bar is always hidden. In this mode, scroll bar bounds, though a bar itself is not rendered, are still taken into account when the widget bounds are calculated.
- 3 if a scroll bar is always hidden and its size is not added to widget bounds.
int isVScrollEnabled ()
Returns a value indicating if vertical scrolling is enabled.Return value
Positive number if scrolling is enabled; otherwise, 0.int isVScrollHidden ()
Returns a flag indicating if a vertical scroll bar is hidden, disabled or always rendered.Return value
Hide flag:- 0 if a scroll bar is always rendered.
- 1 if a scroll bar is automatically hidden when necessary. For example, if the container area is big enough to show all elements, the scroll bar is not rendered. And vice versa, if not all elements can be shown at once, a scroll bar is rendered.
- 2 if a scroll bar is always hidden. In this mode, scroll bar bounds, though a bar itself is not rendered, are still taken into account when the widget bounds are calculated.
- 3 if a scroll bar is always hidden and its size is not added to widget bounds.
void setBorder (int border)
Sets a flag indicating if a one-pixel border is rendered around the widget content (in a shape of a box). The default is 1 (use a border).Arguments
- int border - Positive number to enable a border, 0 to disable it.
void setHScrollEnabled (int mode)
Sets a value indicating if horizontal scrolling is enabled.Arguments
- int mode - Positive number to enable horizontal scrolling, 0 to disable it.
void setHScrollHidden (int hide)
Sets a flag for hiding, disabling or always rendering a horizontal scroll bar.Arguments
- int hide - Hide mode:
- 0 to always render a scroll bar.
- 1 to automatically hide a scroll bar, if necessary. If the container area is big enough to show all elements, the scroll bar is not rendered. And vice versa, if not all elements can be shown at once, a scroll bar is rendered.
- 2 to always hide a scroll bar. In this mode, scroll bar bounds, though a bar itself is not rendered, are still taken into account when the widget bounds are calculated.
- 3 to always hide a scroll bar and not to add scroll bar size when calculating widget bounds.
void setHScrollValue (int position)
Sets a position (and also the size) of the horizontal scroller. That is, it sets the width of the currently invisible area that determines the size of the slider.Arguments
- int position - Position of the scroller. The minimum value is 0, the maximum value is the difference between the object width and the frame width.
Examples
For example, if you need to scroll to the right side of the widget:
scroll = new WidgetScrollBox(gui);
widget.addChild(scroll);
// Scroll to the right side
scroll.setHScrollValue(scroll.getHScrollObjectSize() - scroll.getHScrollFrameSize());
void setPadding (int left, int right, int top, int bottom)
Sets widget paddings for all sides. Padding clears an area around the content of a widget (inside of it).Arguments
- int left - Left-side padding in pixels.
- int right - Right-side padding in pixels.
- int top - Top padding in pixels.
- int bottom - Bottom padding in pixels.
void setSpace (int space_x, int space_y)
Sets a space between the widgets in the box and between them and the box border.Arguments
- int space_x - Horizontal space. If a negative value is specified, 0 will be used instead.
- int space_y - Vertical space. If a negative value is specified, 0 will be used instead.
void setVScrollEnabled (int mode)
Sets a value indicating if vertical scrolling is enabled.Arguments
- int mode - Positive number to enable vertical scrolling, 0 to disable it.
void setVScrollHidden (int hide)
Sets a flag indicating if a vertical scroll bar is hidden, disabled or always rendered.Arguments
- int hide - Hide mode:
- 0 to always render a scroll bar.
- 1 to automatically hide a scroll bar, if necessary. If the container area is big enough to show all elements, the scroll bar is not rendered. And vice versa, if not all elements can be shown at once, a scroll bar is rendered.
- 2 to always hide a scroll bar. In this mode, scroll bar bounds, though a bar itself is not rendered, are still taken into account when the widget bounds are calculated.
- 3 to always hide a scroll bar and not to add scroll bar size when calculating widget bounds.
void setVScrollValue (int position)
Sets the position (and also the size) of the vertical scroller. That is, it sets the width of the currently invisible area that determines the size of the slider.Arguments
- int position - Position of the scroller. The minimum value is 0, the maximum value is the difference between the object height and the frame height.
Examples
//For example, if you need to scroll to the bottom of the widget:
scroll = new WidgetScrollBox(gui);
widget.addChild(scroll);
// Scroll down to the bottom
scroll.setVScrollValue(scroll.getVScrollObjectSize() - scroll.getVScrollFrameSize());
Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter