ScrollBox (class)
public ScrollBox {inherits ViewportBox}
Import from: CURL.GUI.STANDARD. Defined in package CURL.GUI.CONTROL-LOGICAL.
Direct Known Subclasses: BaseTextAreaScrollBox, TextEditScrollBox

Encloses a Graphic in a box with scrollbars.

Example

The simplest use of a ScrollBox consists simply of providing the child Graphic as an argument when creating the ScrollBox:


Example
{ScrollBox
    width = 2.5in, height = 1in,
    {Frame
        width = 4in,
        {paragraph
            ScrollBoxes are pretty easy to use.  The text
            in this ScrollBox is put into a Frame with a
            specified width of 4 inches because otherwise
            all the text would spread out on a single
            line.  You can experiment with changing this
            width constraint. The ScrollBox itself has a
            specified width and height because otherwise
            it would size itself at its preferred size,
            which is the preferred size of its contents.
            The way this example is set up, you will be
            able to see scrolling actually happening, but
            if you want to see the effect of changing or
            removing the specified height and width
            constraints, you can do that too.
        }
    }
}

Notes

This object can be styled by writing style rules for "ScrollBox".

Constructors
default:Initialize a new ScrollBox.
constructor public {ScrollBox.default viewport-class:Type = Viewport, ...}

Properties
accept-focus?:Control whether a ScrollBox will accept the keyboard focus.
local option public ScrollBox.accept-focus?:bool =true
always-disable-hscroll?:Force the horizontal Scrollbar to be disabled.
local option public ScrollBox.always-disable-hscroll?:bool =false
always-disable-vscroll?:Force the vertical Scrollbar to be disabled.
local option public ScrollBox.always-disable-vscroll?:bool =false
display-context:The DisplayContext associated with this object.
nonlocal option public ScrollBox.display-context:#DisplayContext
expanded-hscroll-bounds?:Expand the scrollable region horizontally so that the contents can be scrolled just out of view.
local option public ScrollBox.expanded-hscroll-bounds?:bool =false
expanded-vscroll-bounds?:Expand the scrollable region vertically so that the contents can be scrolled just out of view.
local option public ScrollBox.expanded-vscroll-bounds?:bool =false
focus-manager:The FocusManager associated with this object.
nonlocal option public ScrollBox.focus-manager:#FocusManager
have-hscroll?:Indicates whether this ViewportBox can have its horizontal scroll position modified.
accessor public ScrollBox.have-hscroll?:bool
have-vscroll?:Indicates whether this ViewportBox can have its vertical scroll position modified.
accessor public ScrollBox.have-vscroll?:bool
hblocksize:Specifies the horizontal distance covered by block scrolling.
local option public ScrollBox.hblocksize:Distance =0m
horizontal-position:The current horizontal position.
accessor public ScrollBox.horizontal-position:Distance
setter public ScrollBox.horizontal-position:Distance
hscroll-quantized?:Control the Scrollbar.quantized? option of a ScrollBox's horizontal Scrollbar.
local option public ScrollBox.hscroll-quantized?:bool =false
hscroll?:Enables/Disables scrolling in the horizontal direction. Its default is true.
local option public ScrollBox.hscroll?:bool =true
hunitsize:Specify the horizontal distance covered by the unit scrolling gesture.
local option public ScrollBox.hunitsize:Distance =0m
max-horizontal-position:The maximum horizontal position.
accessor public ScrollBox.max-horizontal-position:Distance
max-vertical-position:The maximum vertical position.
accessor public ScrollBox.max-vertical-position:Distance
min-horizontal-position:The minimum horizontal position.
accessor public ScrollBox.min-horizontal-position:Distance
min-vertical-position:The minimum vertical position.
accessor public ScrollBox.min-vertical-position:Distance
reserve-corner?:Reserves the bottom right corner of the ScrollBox.
local option public ScrollBox.reserve-corner?:bool =false
shrink-hscroll?:Control whether a ScrollBox's horizontal Scrollbar vanishes when it is not needed.
local option public ScrollBox.shrink-hscroll?:bool =true
shrink-vscroll?:Control whether a ScrollBox's vertical Scrollbar vanishes when it is not needed.
local option public ScrollBox.shrink-vscroll?:bool =true
style-element:The "element" or "type" of this Visual, for the purpose of styling.
accessor public ScrollBox.style-element:String
take-focus?:Control whether a ScrollBox initially requests the keyboard focus.
local option public ScrollBox.take-focus?:bool =false
vblocksize:Specifies the vertical distance covered by the block scrolling gesture.
local option public ScrollBox.vblocksize:Distance =0m
vertical-position:The current vertical position.
accessor public ScrollBox.vertical-position:Distance
setter public ScrollBox.vertical-position:Distance
vscroll-quantized?:Control the Scrollbar.quantized? option of a ScrollBox's vertical Scrollbar.
local option public ScrollBox.vscroll-quantized?:bool =false
vscroll?:Enables/Disables scrolling in the vertical direction. It is by default true.
local option public ScrollBox.vscroll?:bool =true
vunitsize:Specify the vertical distance covered by the unit scrolling gesture.
local option public ScrollBox.vunitsize:Distance =0m
Properties inherited from ViewportBox: child-height, child-width, device-pixel-size, hstretch?, viewport, vstretch?
Properties inherited from Frame: clonable-class?, halign, halign-spec, hstretch?-spec, valign, valign-spec, vstretch?-spec
Properties inherited from BaseFrame: child, completely-clonable-children?, graphical-children, ordered-children, reverse-ordered-children, width-first?
Properties inherited from GetBoundsBox: layout-locally-valid?, layout-valid?
Properties inherited from Box: clip-child-shadows?
Properties inherited from Graphic: avoid-page-break?, background, border-color, border-spec, border-style, border-width, cell-border-spec, cell-border-width, cell-margin, discrete-select-in-range?, enabled?, graphic-selectable, height, horigin, is-paginating?, layout, margin, opaque-to-events?, option-parent, outside-margin, pagination-state, parent, possibly-displayed?, selection-context, shadow-color, shadow-spec, visible?, visual-parent, vorigin, width
Properties inherited from Visual: _style-element, cursor, data-source, dragee, font-size, graphical-parent, has-key-focus?, input-method-enabled?, input-method-keyboard-mode, name, options, style-class, style-manager, style-options, test-child?, test-description, test-name, test-parent?, test-type-name, test-visible?, tooltip, user-data
Properties inherited from DataBindingTarget: data-binding-context, data-bindings
Properties inherited from EventTarget: event-handlers
Properties inherited from OptionListInterface: option-register-proc, options-present-here, registered-option-keys

Methods
constrain-height:Return the width preference of this Graphic when subjected to a specified height constraint.
public {ScrollBox.constrain-height
lc:LayoutContext,
ascent:Distance,
descent:Distance
}:Dimension
constrain-width:Return the height preference of this Graphic when subjected to a specified width constraint.
public {ScrollBox.constrain-width
lc:LayoutContext,
lextent:Distance,
rextent:Distance
}:Dimension
create-hscroll:Create a Scrollbar to be used for the horizontal scrolling in the ScrollBox.
protected {ScrollBox.create-hscroll}:Scrollbar
create-main-panel:Creates the user interface for the ScrollBox.
protected {ScrollBox.create-main-panel}:Graphic
create-vscroll:Create a Scrollbar to be used for the vertical scrolling in the ScrollBox.
protected {ScrollBox.create-vscroll}:Scrollbar
descendant-suggests-key-focus-request:A means by which the contents of a ScrollBox can indicate that it should request the keyboard focus.
public {ScrollBox.descendant-suggests-key-focus-request}:void
end-pagination:Ends the pagination process for this Graphic and deallocates data structures for recording the PaginationState.
public {ScrollBox.end-pagination}:void
get-height-preference:Return the height preference of this Graphic.
public {ScrollBox.get-height-preference lc:LayoutContext}:Dimension
get-hscroll:Get the horizontal Scrollbar associated with this ScrollBox.
public {ScrollBox.get-hscroll}:Scrollbar
get-vscroll:Get the vertical Scrollbar associated with this ScrollBox.
public {ScrollBox.get-vscroll}:Scrollbar
get-width-preference:Return the width preference of this Graphic.
public {ScrollBox.get-width-preference lc:LayoutContext}:Dimension
make-gui-mark:The standard way to create a GuiMark referencing this Graphic.
public {ScrollBox.make-gui-mark}:GuiMark
on-drag-over:The static event handler for DragOver events.
public {ScrollBox.on-drag-over e:DragOver}:void
on-gesture-begin:The static event handler for GestureBegin events.
public {ScrollBox.on-gesture-begin e:GestureBegin}:void
on-gesture-end:The static event handler for GestureEnd events.
public {ScrollBox.on-gesture-end e:GestureEnd}:void
on-gesture-pan:The static event handler for GesturePan events.
public {ScrollBox.on-gesture-pan e:GesturePan}:void
on-key-press:The static event handler for KeyPress events.
public {ScrollBox.on-key-press e:KeyPress}:void
on-pointer-press:The static event handler for PointerPress events.
public {ScrollBox.on-pointer-press e:PointerPress}:void
on-pointer-scroll:The static event handler for PointerScroll events.
public {ScrollBox.on-pointer-scroll e:PointerScroll}:void
paginate:Paginate the graphic.
public {ScrollBox.paginate
page-height:Distance,
next-page-height:Distance,
query-only?:bool
}:(PaginationState, PaginationQuality)
scroll-to:Positions the viewport of a ViewportBox as specified.
public {ScrollBox.scroll-to x:Distance = -1pt, y:Distance = -1pt}:void
scroll-to-include-relative-point:Set the scroll positions for this ScrollerInterfaces so that a specified point is visible.
public {ScrollBox.scroll-to-include-relative-point
relative-to:Visual,
x:Distance = 0pt,
y:Distance = 0pt,
min-window:double = 0.0,
max-window:double = 1.0
}:void
scroll-to-object:Position the viewport of a ScrollBox so that the top left corner of a given object coincides with the top left corner of the viewport.
public {ScrollBox.scroll-to-object
g:Visual,
vertical-only?:bool = false,
horizontal-only?:bool = false
}:void
set-scroll-sizes:Sets the parameters of the ScrollBox after a change in the size of its Viewport or the object in the Viewport.
public {ScrollBox.set-scroll-sizes view-bounds:GRect}:void
set-size:Assigns this object its layout width and height.
public {ScrollBox.set-size lc:LayoutContext, bounds:GRect}:void
Methods inherited from ViewportBox: add, add-adornment, clear, get-viewport-bounds, remove-child, set-viewport-x, set-viewport-y
Methods inherited from Frame: clone-appearance-helper
Methods inherited from BaseFrame: add-internal, after-reposition, allocate-layout-object, attempt-revalidate-layout, before-reposition, compute-child-bounds, compute-parent-elastic, draw, get-text, install-child-bounds, internal-remove-child, note-attached, note-detaching, notify-option-children, pick-child, propagate-request-layout, register-options
Methods inherited from BasicBox: contains-point?, find-graphic-at, handle-crossing, on-pointer-envelope-event, pointer-enter-occurred, pointer-leave-occurred
Methods inherited from GetBoundsBox: get-bounds, get-elastic-bounds-into, get-nonparent-bounds-into, request-layout, validate-layout
Methods inherited from Box: compare-children, find-test-children, get-delimited-child-text-selection, get-gui-path-to-child, get-range-as-selected-text, get-visible-rect-in-root-into, graphical-child-visible-at, search-next-here, search-prev-here
Methods inherited from Graphic: create-pagination-state, detach, draw-range-as-selected, draw-shadow, find-ancestor, find-graphical-ancestor, fire-inferior-crossing-event, get-graphical-root, get-gui-path, get-origin-in-graphical-ancestor, get-origin-in-root, get-pagination-state, get-top-left-in-ancestor, get-visible-bounds-into, on-drag-enter, on-inspection, on-pointer-enter, option-changed, paint-with-decorations, replace-with, request-draw, request-draw-rect, request-pointer-trace, search-next, search-prev, set-layout, start-pagination, xy-offset-to
Methods inherited from Visual: add-from-init-args, animate, change-cursor, clonable-appearance?, clone-appearance, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-view, maybe-fire-attach-event, maybe-fire-detach-event, non-keyword-init-arg, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, refresh-style-options, release-key-focus, request-key-focus, scroll-to-include, test-record, test-run, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-to-display-coordinates, transform-to-graphical-root-coordinates
Methods inherited from GraphicOptions: any-to-Distance, get-display-context
Methods inherited from GuiEventTarget: handle-delegate-event, handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-in, on-focus-out, on-gesture, on-gesture-magnify, on-gesture-rotate, on-gesture-swipe, on-gesture-tap, on-gesture-touch, on-grab-release, on-gui-event, on-input-method-event, on-key-event, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-release, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class
Methods inherited from DataBindingTarget: add-data-binding, get-data-binding, refresh-data-binding, remove-data-binding, unset-property, update-data-binding, validate-data-binding
Methods inherited from EventTarget: accepts-event-class?, add-event-handler, event-handler-present?, remove-event-handler, verify-event
Methods inherited from OptionListInterface: add-option, add-style-option, change-option-parent-notify, clone-options, get-option, get-option-by-name, keyword-init-arg, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-change-notify, option-lookup, option-lookup-here, option-propagate-notify, option-set?, propagate-option-change, remove-option, remove-style-option, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name
Methods inherited from BasicEventTarget: enqueue-event
Methods inherited from InitRestArgParser: process-rest-args
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize



Constructor Details
default (constructor)
public {ScrollBox.default viewport-class:Type = Viewport, ...}

Initialize a new ScrollBox.

viewport-class: Indicates the type of the object that should be created to serve as the ScrollBox's viewport. If this argument is supplied, its value must be a class type that is Viewport or a subclass of Viewport.
...: Additional arguments to this constructor are the same as the arguments that can be supplied to the default Frame constructor.

Notes

The ScrollBox.create-hscroll and ScrollBox.create-vscroll will be called to get the Scrollbars to be used for the horizontal and the vertical scrolling respectively. Also ScrollBox.create-main-panel will be called to get the user interface for the ScrollBox.



Property Details
accept-focus? (local option)
public ScrollBox.accept-focus?:bool =true

Control whether a ScrollBox will accept the keyboard focus.

Description

By default, if a user clicks inside a ScrollBox and the object inside the ScrollBox does not consume the PointerPress event, the ScrollBox will request the keyboard focus and will begin to respond to Page Up, Page Down, and the keyboard arrow keys, moving the ScrollBox's Scrollbars appropriately.

This behavior can be disabled by setting the ScrollBox.accept-focus? option to false.


always-disable-hscroll? (local option)
public ScrollBox.always-disable-hscroll?:bool =false

Force the horizontal Scrollbar to be disabled.

Description

When true, the horizontal Scrollbar will act as if it were not needed, even if it is. The reason this option exists is that the ScrollBox's layout decisions are affected by the ScrollBox.hscroll? option. Typically, this is the desired effect, but there are times in which one might want the hscroll?=true layout rules but not have a Scrollbar; this can be accomplished by setting always-disable-hscroll? = true, shrink-hscroll? = true.

shrink-hscroll? always-disable-hscroll?
false false Always show the horizontal Scrollbar.
true false Show the horizontal Scrollbar only when needed.
true true Never show the horizontal Scrollbar.
false true Show a disabled horizontal Scrollbar.


See also ScrollBox.shrink-hscroll?.

Example

Try various combinations of always-disable-hscroll? and shrink-hscroll?.
Example
{ScrollBox
    width = 2in, height = 1in, background = "lime",
    shrink-hscroll? = true, always-disable-hscroll? = true, 
    {RectangleGraphic 
        width = 5in, height = 5in, background = "yellow"
    }
}


always-disable-vscroll? (local option)
public ScrollBox.always-disable-vscroll?:bool =false

Force the vertical Scrollbar to be disabled.

Description

When true, the vertical Scrollbar will act as if it were not needed, even if it is. The reason this option exists is that the ScrollBox's layout decisions are affected by the ScrollBox.vscroll? option. Typically, this is the desired effect, but there are times in which one might want the vscroll?=true layout rules but not have a Scrollbar; this can be accomplished by setting always-disable-vscroll? = true, shrink-vscroll? = true.

shrink-vscroll? always-disable-vscroll?
false false Always show the vertical Scrollbar.
true false Show the vertical Scrollbar only when needed.
true true Never show the vertical Scrollbar.
false true Show a disabled vertical Scrollbar.


See also ScrollBox.shrink-vscroll?.

Example

Try various combinations of always-disable-vscroll? and shrink-vscroll?.


Example
{ScrollBox
    width = 2in, height = 1in, background = "lime",
    shrink-vscroll? = true, always-disable-vscroll? = true, 
    {RectangleGraphic 
        width = 5in, height = 5in, background = "yellow"
    }
}


display-context (nonlocal option)
public ScrollBox.display-context:#DisplayContext

The DisplayContext associated with this object.

Programming Notes

This option is used for communication purposes within the Curl graphics system. It should not be casually set or unset by user code. It should also not usually be read directly by user code: if you want the current DisplayContext, you should fetch it by calling Visual.get-display-context.

Every graphic hierarchy that can be displayed, whether in a window on the screen or on a printed page, must have at its root an object that sets the display-context option to a DisplayContext object that is suitable for the display medium by means of which the graphic hierarchy will be seen. Thus, an object can tell that it has been attached to a displayable graphic hierarchy by watching for the display-context option's value to change from null to a non-null DisplayContext object. Accordingly, subclasses of Visual that need to take specific actions when they become connected to a displayable graphic hierarchy monitor the display-context option by including an option declaration such as

{nonlocal-option public display-context:#DisplayContext
change handler}


where the code in change handler looks at the current value of the display-context option (available within the change handler as the value of the variable display-context), watching for changes between null and non-null values, and takes any actions that are needed.

Programmers using this programming idiom should be aware, however, that it is fairly common when rearranging graphical displays to detach graphical objects temporarily from a graphic hierarchy and then reattach them to the same hierarchy, which will cause the detached objects to temporarily see the display-context object become null and then become non-null again. Code that monitors changes in the display-context option should take this possibility into account and avoid taking undesired actions in this case.


expanded-hscroll-bounds? (local option)
public ScrollBox.expanded-hscroll-bounds?:bool =false

Expand the scrollable region horizontally so that the contents can be scrolled just out of view.

Description

When false, the scroll bounds are such that the bounds of the contents define the scrolling region. When true, the scroll bounds also include the region just outside of these bounds, up to the point where the contents have just scrolled out of view.

Example


Example
{ScrollBox 
    height = 3in, width = 3in, expanded-hscroll-bounds? = true,
    {RectangleGraphic width = 1in, height = 1in}
}

Notes

By default, this is false.


expanded-vscroll-bounds? (local option)
public ScrollBox.expanded-vscroll-bounds?:bool =false

Expand the scrollable region vertically so that the contents can be scrolled just out of view.

Description

When false, the scroll bounds are such that the bounds of the contents define the scrolling region. When true, the scroll bounds also include the region just outside of these bounds, up to the point where the contents have just scrolled out of view.

Example


Example
{ScrollBox
    height = 3in, width = 3in, expanded-vscroll-bounds? = true,
    {RectangleGraphic width = 1in, height = 1in}
}

Notes

By default, this is false.


focus-manager (nonlocal option)
public ScrollBox.focus-manager:#FocusManager

The FocusManager associated with this object.

Notes

This option is used for communication purposes within the Curl graphics system. It should not be casually set or unset by user code. It should also not be read directly by user code: if you want the current FocusManager, you should fetch it by calling Visual.get-focus-manager.


have-hscroll? (accessor)
accessor public ScrollBox.have-hscroll?:bool

Indicates whether this ViewportBox can have its horizontal scroll position modified.

Description

have-hscroll? indicates that horizontal scrolling may be required; e.g., because the Viewport's contents are larger than the Viewport.

One would typically expect that have-hscroll? would always be false when hscroll? was false, but this it not a requirement.

Notes

This value differs from ScrollBox.hscroll?, which indicates whether the ScrollBox should lay out its contents such that horizontal scrolling might be required.

Overriding

The default implementation ViewportBox.have-hscroll? always returns true. Subclasses can override this method to return false in situations that call for it.


have-vscroll? (accessor)
accessor public ScrollBox.have-vscroll?:bool

Indicates whether this ViewportBox can have its vertical scroll position modified.

Description

have-vscroll? indicates that vertical scrolling may be required, for example, because the Viewport's contents are larger than the Viewport.

One would typically expect that when vscroll? is false, have-vscroll? would always be false, but this is not a requirement.

Notes

This value differs from ScrollBox.vscroll?, which indicates whether the ScrollBox should lay out its contents such that vertical scrolling might be required.

Overriding

The default implementation ViewportBox.have-vscroll? always returns true. Subclasses can override this method to return false in situations that call for it.


hblocksize (local option)
public ScrollBox.hblocksize:Distance =0m

Specifies the horizontal distance covered by block scrolling.

Description

The value of this option specifies the amount by which the contents of this ScrollBox should move horizontally when the user performs block scrolling.

When the value of this option is 0m, the block scrolling distance will be 90% of the width of the viewport inside of the ScrollBox. (In other words, by default there is a 10% overlap between the viewport contents before and after the block scrolling gesture is made.)

This default distance will be further adjusted so that it is an integer multiple of the horizontal unit scrolling distance. (If the block scrolling gesture is made at a time when the remaining available scrolling distance is less than the block scrolling distance, then the scrollbar moves by the total amount of the remaining available scrolling distance.)

It is an error to set this option to a Distance less than 0m.


horizontal-position (accessor)
accessor public ScrollBox.horizontal-position:Distance
setter public ScrollBox.horizontal-position:Distance

The current horizontal position.

Overriding

Subclasses that override the horizontal-position setter should ensure that the position is within the range [ScrollerInterface.min-horizontal-position, ScrollerInterface.max-horizontal-position] by clipping the value to be within this range.


hscroll-quantized? (local option)
public ScrollBox.hscroll-quantized?:bool =false

Control the Scrollbar.quantized? option of a ScrollBox's horizontal Scrollbar.

Description

Setting this option forces the horizontal Scrollbar's value to always be constrained to integer multiples of its unit scrolling distance.


hscroll? (local option)
public ScrollBox.hscroll?:bool =true

Enables/Disables scrolling in the horizontal direction. Its default is true.

Description

Setting hscroll? option to false does not merely hide the horizontal Scrollbar. The Scrollbar is actually eliminated and no scrolling occurs in the horizontal direction. This results in the contents of the ScrollBox getting squished in the horizontal direction if there is not enough space for the contents in this direction.


hunitsize (local option)
public ScrollBox.hunitsize:Distance =0m

Specify the horizontal distance covered by the unit scrolling gesture.

Description

The value of this option specifies the amount by which the contents of this ScrollBox should move horizontally when the user performs unit scrolling.

When the value of this option is 0m, the unit scrolling distance will be calculated dynamically. In particular, it will be one-tenth of the block scrolling distance. (Note that the block scrolling distance may also be calculated dynamically.)

It is an error to set this option to a Distance less than 0m.


max-horizontal-position (accessor)
accessor public ScrollBox.max-horizontal-position:Distance

The maximum horizontal position.

Description

ScrollerInterface.horizontal-position must be equal to or less than this value.


max-vertical-position (accessor)
accessor public ScrollBox.max-vertical-position:Distance

The maximum vertical position.

Description

ScrollerInterface.vertical-position must be equal to or less than this value.


min-horizontal-position (accessor)
accessor public ScrollBox.min-horizontal-position:Distance

The minimum horizontal position.

Description

ScrollerInterface.horizontal-position must be equal to or greater than this value.


min-vertical-position (accessor)
accessor public ScrollBox.min-vertical-position:Distance

The minimum vertical position.

Description

ScrollerInterface.vertical-position must be equal to or greater than this value.


reserve-corner? (local option)
public ScrollBox.reserve-corner?:bool =false

Reserves the bottom right corner of the ScrollBox.

Notes

If true, the bottom right corner of the ScrollBox will have a Graphic if one or more Scrollbars of this object is showing.

Notes

This is generally used on the Mac OS X™ platform by ScrollBoxs that are used as containers by a View. Not making a ScrollBox reserve the corner space will have an annoying problem of not been able to use the buttons of the Scrollbox as that space is used by the operating system for resizing the View's window.
Introduced in: version 6.0


shrink-hscroll? (local option)
public ScrollBox.shrink-hscroll?:bool =true

Control whether a ScrollBox's horizontal Scrollbar vanishes when it is not needed.

Description

If this option is set to true (the default), the horizontal Scrollbar vanishes when it is not needed. If the option is set to false, the Scrollbar continues to occupy the same amount of space but is drawn as disabled when it is not needed.

See also ScrollBox.always-disable-hscroll?.


shrink-vscroll? (local option)
public ScrollBox.shrink-vscroll?:bool =true

Control whether a ScrollBox's vertical Scrollbar vanishes when it is not needed.

Description

If this option is set to true (the default), the vertical Scrollbar vanishes when it is not needed. If the option is set to false, the Scrollbar continues to occupy the same amount of space but is drawn as disabled when it is not needed.

See also ScrollBox.always-disable-vscroll?.


style-element (accessor)
accessor public ScrollBox.style-element:String

The "element" or "type" of this Visual, for the purpose of styling.

Description

This implementation returns the value of Visual._style-element but is normally overridden to return a constant value.

Overriding

If a subclass of Visual should be stylable separately from other types of objects, this getter should be overridden to return an appropriate string. By convention, this string is the name of the class or the name of the markup that produces the object.

An override must return self._style-element if it is not the empty string.
Introduced in: version 6.0


take-focus? (local option)
public ScrollBox.take-focus?:bool =false

Control whether a ScrollBox initially requests the keyboard focus.

Description

If the value of this option is true, then this ScrollBox will request the keyboard focus whenever it is attached to a FocusManager. Otherwise, the ScrollBox will request the keyboard focus only when the user clicks on one of the scrollbars or clicks inside the ScrollBox on some object that does not consume the pointer-click event. See also ScrollBox.accept-focus?.


vblocksize (local option)
public ScrollBox.vblocksize:Distance =0m

Specifies the vertical distance covered by the block scrolling gesture.

Description

The value of this option specifies the amount by which the contents of this ScrollBox should move vertically when the user performs block scrolling.

When the value of this option is 0m, the block scrolling distance will be 90% of the height of the viewport inside of the ScrollBox. (In other words, by default there is a 10% overlap between the viewport contents before and after the block scrolling gesture is made.)

This default distance will be further adjusted so that it is an integer multiple of the vertical unit scrolling distance. (If the block scrolling gesture is made at a time when the remaining available scrolling distance is less than the block scrolling distance, then the scrollbar moves by the total amount of the remaining available scrolling distance.)

It is an error to set this option to a Distance less than 0m.


vertical-position (accessor)
accessor public ScrollBox.vertical-position:Distance
setter public ScrollBox.vertical-position:Distance

The current vertical position.

Overriding

Subclasses that override the vertical-position setter should ensure that the position is within the range [ScrollerInterface.min-vertical-position, ScrollerInterface.max-vertical-position] by clipping the value to be within this range.


vscroll-quantized? (local option)
public ScrollBox.vscroll-quantized?:bool =false

Control the Scrollbar.quantized? option of a ScrollBox's vertical Scrollbar.

Description

Setting this option forces the vertical Scrollbar's value to always be constrained to integer multiples of its unit scrolling distance.


vscroll? (local option)
public ScrollBox.vscroll?:bool =true

Enables/Disables scrolling in the vertical direction. It is by default true.

Description

Setting vscroll? option to false does not merely hide the vertical Scrollbar. The Scrollbar is actually eliminated and no scrolling occurs in the vertical direction. This results in the contents of the ScrollBox getting squished in the vertical direction if there is not enough space for the contents in this direction.


vunitsize (local option)
public ScrollBox.vunitsize:Distance =0m

Specify the vertical distance covered by the unit scrolling gesture.

Description

The value of this option specifies the amount by which the contents of this ScrollBox should move vertically when the user performs unit scrolling.

When the value of this option is 0m, the unit scrolling distance will be calculated dynamically. In particular, it will be one-tenth of the block scrolling distance. (Note that the block scrolling distance may also be calculated dynamically.)

It is an error to set this option to a Distance less than 0m.





Method Details
constrain-height (method)
public {ScrollBox.constrain-height
lc:LayoutContext,
ascent:Distance,
descent:Distance
}:Dimension

Return the width preference of this Graphic when subjected to a specified height constraint.

lc: the LayoutContext in effect for this layout negotiation.
ascent, descent: the height constraint, expressed as ascent and descent distances relative to the origin of this Graphic.

Returns

a Dimension expressing this object's width preference. This Dimension will be converted to an OriginElastic during subsequent layout processing.

Overriding

The default method Graphic.constrain-height simply invokes Graphic.get-width-preference. This method need not be overridden unless an object needs to take the height constraint into account in computing its width preference.

Classes overriding this method should take care to return a Dimension which represents the space along the horizontal axis which is required, including how it relates to their object's origin. In practice, this means that this method should return either an appropriate OriginElastic, or a Dimension which will be converted to an appropriate OriginElastic via the conversion rules described in Converting Dimensions to OriginElastics.

Important note: Any overriding implementation of this method must include a call to the superclass implementation in order to insure that the layout negotiation is propagated appropriately throughout the entire graphical hierarchy.


constrain-width (method)
public {ScrollBox.constrain-width
lc:LayoutContext,
lextent:Distance,
rextent:Distance
}:Dimension

Return the height preference of this Graphic when subjected to a specified width constraint.

lc: the LayoutContext in effect for this layout negotiation.
lextent, rextent: the width constraint, expressed as distances to the left and right relative to the origin.

Returns

a Dimension expressing this object's height preference. This Dimension will be converted to an OriginElastic during subsequent layout operations.

Overriding

The default method Graphic.constrain-width simply invokes Graphic.get-height-preference. This method need not be overridden unless an object needs to take the width constraint into account in computing its height preference.

Classes overriding this method should take care to return a Dimension which represents the space along the vertical axis which is required, including how it relates to their object's origin. In practice, this means that this method should return either an appropriate OriginElastic, or a Dimension which will be converted to an appropriate OriginElastic via the conversion rules described in Converting Dimensions to OriginElastics.

Important note: Any overriding implementation of this method must include a call to the superclass implementation in order to insure that the layout negotiation is propagated appropriately throughout the entire graphical hierarchy.


create-hscroll (method)
protected {ScrollBox.create-hscroll}:Scrollbar

Create a Scrollbar to be used for the horizontal scrolling in the ScrollBox.

Notes

This is called by the constructor of the ScrollBox.

Various properties and event handlers will be set to this Scrollbar to make it suitable for horizontal scrolling.
Introduced in: version 6.0


create-main-panel (method)
protected {ScrollBox.create-main-panel}:Graphic

Creates the user interface for the ScrollBox.

Returns

The Graphic that will be used for the user interface of the ScrollBox.

Description

This is called by the constructor of the ScrollBox after setting and initializing the vertical and the horizontal Scrollbar's.

By default, this method arranges the vertical and the horizontal Scrollbar's and the Viewport to provide the user interface for the ScrollBox.
Introduced in: version 6.0


create-vscroll (method)
protected {ScrollBox.create-vscroll}:Scrollbar

Create a Scrollbar to be used for the vertical scrolling in the ScrollBox.

Notes

This is called by the constructor if a Scrollbox.

Various properties and event handlers will be set to this Scrollbar to make it suitable for vertical scrolling.
Introduced in: version 6.0


descendant-suggests-key-focus-request (method)
public {ScrollBox.descendant-suggests-key-focus-request}:void

A means by which the contents of a ScrollBox can indicate that it should request the keyboard focus.

Notes

This is provided so that ScrollBox can differentiate between this sort of request and other key focus requests. The default implementation calls ScrollBox.request-key-focus when ScrollBox.accept-focus? is true.


end-pagination (method)
public {ScrollBox.end-pagination}:void

Ends the pagination process for this Graphic and deallocates data structures for recording the PaginationState.

Programming Notes

This method must be called for all the Graphics for which Graphic.start-pagination was called.

Notes

This is called when a call to Layout.end-pagination is made.


get-height-preference (method)
public {ScrollBox.get-height-preference lc:LayoutContext}:Dimension

Return the height preference of this Graphic.

lc: the LayoutContext in effect for this layout negotiation.

Returns

a Dimension expressing this object's height preference. This Dimension will be converted to an OriginElastic during subsequent layout operations.

Overriding

This method must be defined in a subclass of Graphic.

Classes overriding this method should take care to return a Dimension which represents the space along the vertical axis which is desired, including how it relates to their object's origin. In practice, this means that this method should return either an appropriate OriginElastic, or a Dimension which will be converted to an appropriate OriginElastic via the conversion rules described in Converting Dimensions to OriginElastics.


get-hscroll (method)
public {ScrollBox.get-hscroll}:Scrollbar

Get the horizontal Scrollbar associated with this ScrollBox.

Returns

The horizontal Scrollbar.

Notes

When used as part of a ScrollBox, certain aspects of the Scrollbar are under the ScrollBoxes control. For example, the following options may be set by the ScrollBox at any time: In addition, the ScrollBox assumes that the value for these and other options (direction, in particular) will not otherwise be modified on the Scrollbar.

These lists of sensitive options may change in the future. In general, one should not manipulate a Scrollbar directly if it came from a ScrollBox.


get-vscroll (method)
public {ScrollBox.get-vscroll}:Scrollbar

Get the vertical Scrollbar associated with this ScrollBox.

Returns

The vertical Scrollbar.

Notes

When used as part of a ScrollBox, certain aspects of the Scrollbar are under the ScrollBoxes control. For example, the following options may be set by the ScrollBox at any time: In addition, the ScrollBox assumes that the value for these and other options (direction, in particular) will not otherwise be modified on the Scrollbar.

These lists of sensitive options may change in the future. In general, one should not manipulate a Scrollbar directly if it came from a ScrollBox.


get-width-preference (method)
public {ScrollBox.get-width-preference lc:LayoutContext}:Dimension

Return the width preference of this Graphic.

lc: the LayoutContext in effect for this layout negotiation.

Returns

a Dimension expressing this object's width preference. This Dimension will be converted to an OriginElastic during subsequent layout operations.

Overriding

This method must be defined in a subclass of Graphic.

Classes overriding this method should take care to return a Dimension which represents the space along the horizontal axis which is desired, including how it relates to their object's origin. In practice, this means that this method should return either an appropriate OriginElastic, or a Dimension which will be converted to an appropriate OriginElastic via the conversion rules described in Converting Dimensions to OriginElastics


make-gui-mark (method)
public {ScrollBox.make-gui-mark}:GuiMark

The standard way to create a GuiMark referencing this Graphic.

Returns

A newly allocated GuiMark initialized to the leading edge of the Graphic.

Overriding

Subclasses of Graphics which require custom subclasses of GuiMark to refer to their contents should override this method.


on-drag-over (method)
public {ScrollBox.on-drag-over e:DragOver}:void

The static event handler for DragOver events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.


on-gesture-begin (method)
public {ScrollBox.on-gesture-begin e:GestureBegin}:void

The static event handler for GestureBegin events.

Description

A ScrollBox can scroll via GestureEvents on systems with appropriate hardware and operating system support. To enable this for any given ScrollBox, have that ScrollBox grab the pointer before this method is called; e.g. either by overriding this method or adding a dynamic event handler calling GestureBegin.continue-implicit-pointer-grab with the ScrollBox as the target. The GestureBegin will be consumed if this method causes the ScrollBox to accept future GesturePan events for scrolling.

See GuiEventTarget.on-pointer-event for general information about static event handlers.
Introduced in: version 8.0


on-gesture-end (method)
public {ScrollBox.on-gesture-end e:GestureEnd}:void

The static event handler for GestureEnd events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.
Introduced in: version 8.0


on-gesture-pan (method)
public {ScrollBox.on-gesture-pan e:GesturePan}:void

The static event handler for GesturePan events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.
Introduced in: version 8.0


on-key-press (method)
public {ScrollBox.on-key-press e:KeyPress}:void

The static event handler for KeyPress events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.


on-pointer-press (method)
public {ScrollBox.on-pointer-press e:PointerPress}:void

The static event handler for PointerPress events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.


on-pointer-scroll (method)
public {ScrollBox.on-pointer-scroll e:PointerScroll}:void

The static event handler for PointerScroll events.

Description

See GuiEventTarget.on-pointer-event for general information about static event handlers.


paginate (method)
public {ScrollBox.paginate
page-height:Distance,
next-page-height:Distance,
query-only?:bool
}:(PaginationState, PaginationQuality)

Paginate the graphic.

page-height: The height available to render the graphic on the page. This does not include the space taken up by border and margin.
next-page-height: The height that would be available to paginate this graphic if this graphic was moved to the next page.
query-only?: If true, then the state of the PaginationState for this Graphic does not change. See Graphic.get-pagination-state and the notes for details.

Returns

The returned PaginationState is the pagination state of the Graphic after this method is called.

The returned PaginationQuality value describes the quality of the page split that will be achieved using the given page-height.

Programming Notes

Before paginating a Graphic one may call this function with query-only? set to true. In this way the caller can determine what PaginationQuality can be achieved with the given page-height. Depending on the PaginationQuality, the caller can decide to paginate a portion on an object in the current page or push it entirely to the next page by setting the PaginationState.end-offset of the PaginationState associated to the Graphic to point to the top of this object.

Overriding

Override this method if you want a Graphic to paginate itself across pages in some specific way.

You should follow these rules when overriding this method:

Call Graphic.get-pagination-state with query-only? to get the current pagination state of this Graphic. When query-only? is true, the method acts on a clone of the PaginationState of this Graphic.

If this methods is called on a Graphic that previously returned PaginationQuality.complete then make sure that the PaginationState.start-offset is set to PaginationState.end-offset and the returned pagination quality is PaginationQuality.complete.

If the page-height is negative or negligible then the returned pagination state should be the current pagination state of the object and the returned pagination quality must be PaginationQuality.clipped-outside.

Otherwise, given the available page-height now compute and set the PaginationState.start-offset, PaginationState.end-offset, and PaginationState.min-end-offset for the new page and return the appropriate PaginationQuality for this pagination sequence.

A container, like a Box, if paginating should try not to split its children across pages. If the container cannot fit a child in the current page then it should follow the following two steps.

1. It should see if its child has requested to avoid page breaks (see Graphic.avoid-page-break?). If it did, then it should push it to the next page,if the height available for this graphic in the current page is lesser than next-page-height. To push the child to the next page the container has to set the PaginationState.end-offset of its current PaginationState to the top of the child which is -{child.get-cell-bounds}.ascent.

2. Ask the child to paginate and if the returned PaginationQuality is PaginationQuality.good or better then start the child's pagination in the current page. Otherwise the container should try to determine if the child's pagination would be at least PaginationQuality.good if it pushes it to the next page by calling the Graphic.paginate method with query-only? passed as true and page-height and next-page-height passed as next-page-height that was passed to its own Graphic.paginate method. If yes, then it should push it to the next page otherwise make the child paginate from the current page.

Note that a container should ask the Layout of its child graphic to paginate, instead of the child graphic to paginate directly.

Here is some code that shows how a Graphic.paginate is implemented.

{method public open {paginate
                              page-height:Distance,
                              next-page-height:Distance,
                              query-only?:bool
                          }:(PaginationState, PaginationQuality)
          let pstate:PaginationState = 
              {self.get-pagination-state query-only?}
          let bounds:GRect = pstate.bounds
          let constant epsilon:Distance = epsilon-float * 1m

          || All done.
          {if {abs bounds.descent - pstate.end-offset} < epsilon then
              set pstate.start-offset = pstate.end-offset
              {return pstate, PaginationQuality.complete}
          }

          || No space left for the graphic.
          {if page-height < epsilon then
              {return pstate, PaginationQuality.clipped-outside}
          }

          let new-start-offset:Distance = pstate.min-end-offset
          let new-end-offset:Distance = 
              {min new-start-offset + page-height, bounds.descent}

          {return
              {pstate.advance-pagination
                  new-start-offset,
                  new-end-offset,
                  quality-if-not-complete = PaginationQuality.poor
              }
          }
      }
  

Notes

This is called when a call to Layout.paginate is made.


scroll-to (method)
public {ScrollBox.scroll-to x:Distance = -1pt, y:Distance = -1pt}:void

Positions the viewport of a ViewportBox as specified.

x: the horizontal offset to apply (as interpreted by ViewportBox.horizontal-position).
y: the vertical offset to apply (as interpreted by ViewportBox.vertical-position).

Notes

Invocation of this method will result in positioning the viewport, if possible, so that ViewportBox.horizontal-position returns the value x and ViewportBox.vertical-position returns the value y. If either x or y is not specified, then the current position of the viewport in that dimension is preserved.

Overriding

This abstract method of ViewportBox must be overridden by concrete subclasses.


scroll-to-include-relative-point (method)
public {ScrollBox.scroll-to-include-relative-point
relative-to:Visual,
x:Distance = 0pt,
y:Distance = 0pt,
min-window:double = 0.0,
max-window:double = 1.0
}:void

Set the scroll positions for this ScrollerInterfaces so that a specified point is visible.

relative-to: A Visual defining the coordinate system in which x and y are based.
x, y: The point to be scrolled into view.

If either argument is not supplied, then no scrolling is performed in that direction.
min-window: Specifies the top and the left-hand bound of the region in the ScrollerInterface's viewport where the specified point should appear. min-window is a number between 0 and 1, specifying the fraction of the viewport's vertical extent that is above (and to the left of) the specified position. The default value is 0.
max-window: Specifies the bottom and the right-hand bound of the region in the ScrollerInterface's viewport where the specified point should appear. Like min-window, max-window is a number between 0 and 1. Its default value is 1.

Overriding

Subclasses should comply with the description of this method as given in the documentation. If this is not possible, such as when a ScrollerInterface is used to represent a positioning mechanism that doesn't involve Visuals, then it is acceptable for subclasses to ignore the request.


scroll-to-object (method)
public {ScrollBox.scroll-to-object
g:Visual,
vertical-only?:bool = false,
horizontal-only?:bool = false
}:void

Position the viewport of a ScrollBox so that the top left corner of a given object coincides with the top left corner of the viewport.

g: The object of interest.
vertical-only?: Supply true for this argument to inhibit horizontal scrolling.
horizontal-only?: Supply true for this argument to inhibit vertical scrolling.

Notes

An error will be signaled if g is not a graphical descendant of this ScrollBox.


set-scroll-sizes (method)
public {ScrollBox.set-scroll-sizes view-bounds:GRect}:void

Sets the parameters of the ScrollBox after a change in the size of its Viewport or the object in the Viewport.

view-bounds: The new bounds of the Viewport.

Description

Performs the actions that a ScrollBox needs to perform when there is a change in object sizes, such as adjusting the thumb length and range of values for any Scrollbars.

Expected Events

Action: Fired by the Scrollbox at itself after adjusting the parameters.


set-size (method)
public {ScrollBox.set-size lc:LayoutContext, bounds:GRect}:void

Assigns this object its layout width and height.

Description

When set-size is called on this object, it is assigned its layout size, and layout negotiation for it ends. Layout negotiation for a graphical hierarchy terminates after all graphic objects in the hierarchy have been assigned their layout size.
lc: the LayoutContext in effect for this layout negotiation.
bounds: a GRect indicating the left/right and up/down extents of this object's bounding box, relative to this object's origin.

Programming Notes

This method is invoked by the object's graphical parent.

Overriding

The default method Graphic.set-size does nothing. Subclasses of Graphic may override this method in order to intercept the information provided here.