Note: The Agar manual pages follow certain conventions, notably concerning function return values. Please read AG_Intro(3) first.
SYNOPSIS
#include <agar/core.h> #include <agar/gui.h> |
DESCRIPTION
|
The
AG_Scrollbar widget allows the user to control an integer or floating-point value within a
specified range.
AG_Scrollbar is almost always used from a widget implementation, to provide scrolling
controls (and it features a special
visible binding to faciliate this application).
For example, in a scrollable view containing a given number of "items" (e.g., the lines of a multi-line AG_Textbox(3)), the max binding would be tied to the total item count, and the visible binding would be tied to the number of items that can be displayed on-screen (based on the current widget dimensions). Finally, the value binding is tied to an index variable defining the first item that should be rendered. NOTE: For general-purpose edition of numerical values, AG_Slider(3) or AG_Numerical(3) are more suitable widgets. |
INHERITANCE HIERARCHY
| AG_Object(3)-> AG_Widget(3)-> AG_Scrollbar. |
INTERFACE
|
The AG_ScrollbarNew() function allocates, initializes, and attaches a new AG_Scrollbar widget. The type argument should be either AG_SCROLLBAR_HORIZ or AG_SCROLLBAR_VERT. Acceptable flags include:
Alternate constructor routines Fn AG_ScrollbarNew{Int,Uint,Float,Double} ,Fn AG_ScrollbarNew{Uint8,Uint16,Uint32}and Fn AG_ScrollbarNew{Sint8,Sint16,Sint32}create a new AG_Scrollbar with value, min, max, and visible bound to the variables of the specified integer or floating-point type. AG_ScrollbarSizeHint() specifies a default, preferred scrollbar length in pixels. It is not necessary to invoke this function when using the AG_SCROLLBAR_HFILL or AG_SCROLLBAR_VFILL flag. The AG_ScrollbarSetControlLength() function sets the length of the scrolling control (i.e., the center button), in pixels. This length is often computed from the ratio between the visible area of whatever is being displayed, and the total area of the content that can be displayed. AG_ScrollbarControlLength() returns the current length of the scrolling control, in pixels. AG_ScrollbarSetWidth() configures the width (i.e., thickness) of the scrollbar. AG_ScrollbarWidth() returns the effective width of a scrollbar in pixels. If the width of the scrollbar is not specified on initialization, AG_Scrollbar will use a default width. This default width can be set with AG_ScrollbarSetPrefWidth(), and retrieved with AG_ScrollbarPrefWidth() (typically from the size_request() or size_allocate() operation of a container widget). Note: Under multithreading, AG_ScrollbarControlLength(), AG_ScrollbarWidth() and AG_ScrollbarPrefWidth() should be considered safe to invoke only in widget context (e.g., event handlers, size_request(), size_allocate() or draw() operations) The AG_ScrollbarVisible() function returns 1 if the current range is such that the scrollbar is useful to display, otherwise it returns 0. The AG_ScrollbarSetDecFn() and AG_ScrollbarSetIncFn() functions configure a callback routine that will be invoked when the user presses the decrement (up/left) button and the increment (down/right) buttons. A single int argument is passed to the callback (1 = pressed, 0 = released). AG_ScrollbarSetIntIncrement() and AG_ScrollbarSetRealIncrement() define by how much the value is to be incremented/decremented as a result of the user clicking on the scrollbar buttons or using the keyboard to move the control. The former is only meaningful with integer bindings, the latter is only meaningful with floating-point bindings. |
BINDINGS
The
AG_Scrollbar widget provides the following bindings:
The scrollbar is positioned to represent value inside of the range defined by min and max. In scrolling applications, visible is typically used to conveniently represent the size of the display area (its value is simply subtracted from the range). Note that the min, max and visible bindings must be of the same type as value. The Uint64, Sint64 and long double types are only available on platforms which support these types. The Uint64, Sint64 and long double types are only available on platforms which support these types. |
EVENTS
The
AG_Scrollbar widget reacts to the following events:
The AG_Scrollbar widget generates the following events:
|
SEE ALSO
| AG_Intro(3), AG_Scrollview(3), AG_Widget(3), AG_Window(3) |
HISTORY
| The AG_Scrollbar widget first appeared in Agar 1.0. The AG_SCROLLBAR_AUTOSIZE feature was introduced in Agar 1.4.0. |
