ScrollBar

Scrollbar widgets are typically linked to an associated window that displays a document of some sort, such as a file being edited or a drawing. A scrollbar displays a thumb in the middle portion of the scrollbar, whose position and size provides information about the portion of the document visible in the associated window. The thumb may be dragged by the user to control the visible region. Depending on the theme, two or more arrow buttons may also be present; these are used to scroll the visible region in discrete units.

Constructors

this
this(UiElement parent)

Construct the widget.

Members

Functions

getDelta
double getDelta(int deltaX, int deltaY)

Returns a real number indicating the fractional change in the scrollbar setting that corresponds to a given change in thumb position. For example, if the scrollbar is horizontal, the result indicates how much the scrollbar setting must change to move the thumb deltaX pixels to the right (deltaY is ignored in this case). If the scrollbar is vertical, the result indicates how much the scrollbar setting must change to move the thumb deltaY pixels down. The arguments and the result may be zero or negative.

getFraction
double getFraction(int x, int y)

Returns a real number between 0 and 1 indicating where the point given by x and y lies in the trough area of the scrollbar, where 0.0 corresponds to the top or left of the trough and 1.0 corresponds to the bottom or right. X and y are pixel coordinates relative to the scrollbar widget. If x and y refer to a point outside the trough, the closest point in the trough is used.

Inherited Members

From Widget

setState
auto setState(string[] state)

Set the widget's state.

getState
string[] getState()

Get the widget's state.

inState
bool inState(string[] state)

Test if a widget is in a particular state.

removeState
auto removeState(string[] state)

Remove the widget's state.

resetState
auto resetState()

Reset the widget's state to default.

setStyle
auto setStyle(string style)

Set the widget's style.

getStyle
string getStyle()

Get the widget's style.

setKeyboardFocus
auto setKeyboardFocus(string focus)

Set if the widget can recieve focus during keyboard traversal.

getKeyboardFocus
string getKeyboardFocus()

Get if the widget can recieve focus during keyboard traversal.

pack
auto pack(int outerPadding, int innerPadding, string side, string fill, string anchor, bool expand)

Geometry method for loosely placing this widget inside its parent using a web browser model. Widgets flow around each other in the available space.

grid
auto grid(int column, int row, int outerPadding, int innerPadding, int columnSpan, int rowSpan, string sticky)

Geometry method for placing this widget inside its parent using an imaginary grid. Somewhat more direct and intuitive than pack. Choose grid for tabular layouts, and when there's no good reason to choose something else.

place
auto place(int xPos, int yPos, int width, int height, string anchor, string borderMode)

Geometry method for placing this widget inside its parent using absolute positioning.

place
auto place(double relativeXPos, double relativeYPos, double relativeWidth, double relativeHeight, string anchor, string borderMode)

Geometry method for placing this widget inside its parent using relative positioning. In this case the position and size is specified as a floating-point number between 0.0 and 1.0 relative to the height of the parent. 0.5 means the widget will be half as high as the parent and 1.0 means the widget will have the same height as the parent, and so on.

Examples

auto frame = new Frame()
	.grid(0, 0);

auto canvas = new Canvas(frame);
	.setWidth(300)
	.setHeight(150)
	.setScrollRegion(-100, -150, 500, 350)

auto yscroll = new YScrollBar(frame)
	.attachWidget(canvas)
	.grid(1, 0, 0, 0, 1, 1, "nes");

auto xscroll = new XScrollBar(frame)
	.attachWidget(canvas)
	.grid(0, 1, 0, 0, 1, 1, "esw");

canvas.attachXScrollBar(xscroll)
	.attachYScrollBar(yscroll)
	.grid(0, 0, 0, 0, 1, 1, "nesw");

Additional Events

Additional events that can also be bound to using the bind method.

<<PrevWindow>>, <Alt-Key>, <B1-Motion>, <B2-Motion>, <Button-1>, <Button-2>, <ButtonRelease-1>, <ButtonRelease-2>, <Key-F10>, <Key-Tab>,

States: The scrollbar automatically sets the disabled state when the entire range is visible and clears it otherwise.

See Also

Meta