Class ScrollBar |
# This class provides horizontal and vertical scroll bars. There are two ways to use a scroll bar. The first way is to set a total_size (represented by the whole bar), a page_size (represented by the draggable button) and an increment_size (being the amount added/subtracted when the top/bottom button is pressed). The value will then range from zero to (total_size - page_size) inclusive. An initial value must be set with the {set_value()} method. @example @ vb := ScrollBar() @ vb$set_pos("85%", "25%") @ vb$set_size(20, "40%") @ vb$set_total_size(130) @ vb$set_page_size(30) @ vb$set_increment_size(1) @ vb$set_value(0) @ self$add(vb) Alternatively, a scroll bar can be used as a slider which ranges over a given range of values. In this case, the range is set with {set_range()}. It is still necessary to set the increment size and the initial value, as above, but page_size and total_size should not be set. Real numbers as opposed to integers can be used for the range settings if desired. @example @ vb := ScrollBar() @ vb$set_pos("85%", "25%") @ vb$set_size(20, "40%") @ vb$set_range(2, 25) @ vb$set_value(10) @ vb$set_increment_size(1) @ self$add(vb) An Event is returned whenever the buttons are pressed or the bar dragged; the value can be retrieved by get_value(). The event code (obtainable by {get_code()}) is 1 if the bar has been dragged, and 0 if either button has been pressed or the bar released after being dragged. This fact can be used to reduce the number of events which are processed by the user's program - just ignore events with code 1.
Details |
Constructor |
Methods: |
# Get the page size.
# Return the total size.
# Get the value. @return The value
# Set the amount to increase the value by when one of the buttons is pressed. @param x The increment size.
# Make the scroll bar horizontal (default is vertical).
# Set the size which the bar in the scroll bar area represents. @param x The size.
# Set the range of the scroll bar. The values may be integer or real. @param lo The lower bound @param hi The upper bound
# Set the total size which the scroll bar area represents. @param x The total size
# Set the value representing the top of the bar in the scroll bar. The value is forced into range if it is not in range already. @param x The value.
Fields: |