Shiny Language Reference

Language Reference > User Interface > Scrollbars


setscrollbarthumbsegs

setscrollbarthumbsegs(int ID, int Top, int Middle, int Bottom);

 
 

Sets the height of the thumb segments in the source image

The SETSCROLLBARTHUMBSEGS statement tells Brass how to divide up the scrollbar thumb image for drawing. This statement is only useful for custom drawn controls. If this statement is called for a control that has not previously been set to custom draw (using for example setlistboxdrawfunc), or if the control has been reset from custom draw to standard style (for example, by calling setlistboxstyle after setlistboxdrawfunc), it will be ignored.

The scroll thumb is the moving section in a scrollbar that visually represents the current scrolled position and the overall amount of items in the parent control. As the number of items in the parent control increases or decreases, the size of the thumb increases and decreases accordingly. The more items in the parent control, the smaller the thumb is. Review the operation of a scrollbar in any Windows application for a practical example.

Brass segments the scroll thumb into 3 sections; top, middle and bottom. All segments are the same width as the scrollbar itself. The top and bottom segments are of a fixed height, the middle segment is stretched as required. Brass uses the parameters passed to SETSCROLLBARTHUMBSEGS to determine the height of each segment on the source image. The source image was drawn by your custom draw handler in response to iState == SCROLLBAR_THUMB. Brass assumes the source image begins at 0, 0. Therefore to find the fixed top segment, Brass uses (0, 0) to (ScrollbarWidth, Top). To find the scalable middle segment, Brass uses (0, Top) to (ScrollbarWidth, Top+Middle). To find the fixed bottom segment, Brass uses (0, Top+Middle) to (ScrollbarWidth, Top+Middle+Bottom).

This technique allows plugins to use nicely rounded edges for the scrollbar thumb.

 

Parameters

ID

The control ID of the parent control to set the thumb segment sizes in

Top

The height in pixels of the top segment of the thumb. This segment is never scaled.

Middle

The height in pixels of the middle segment of the thumb. This segment is scaled to match the required height of the scrollbar thumb.

Bottom

The height in pixels of the bottom segment of the thumb. This segment is never scaled.

 

Return Value

None

 

Example Code

Sample plugin code for custom drawn list boxes is available for download in the List box handler reference.