RegionShape (class)
public RegionShape {inherits RegionShapeMixin}
Package: CURL.GUI.SHAPES

An implementation of Shape that draws a Region.

Description

This is the most general of the solid shape classes, as Region can represent virtually any shape.

Notes

This class uses the following shape options:

Example


Example
{import * from CURL.GUI.SHAPES}

{let shape:RegionShape =
    {RegionShape
        {Region.from-vertices
            {Distance2d 0cm, -1cm},
            {Distance2d 1cm, -1cm},
            {Distance2d 1cm, -.8cm},
            {Distance2d .2cm, -.8cm},
            {Distance2d .2cm, -.6cm},
            {Distance2d .7cm, -.6cm},
            {Distance2d .7cm, -.4cm},
            {Distance2d .2cm, -.4cm},
            {Distance2d .2cm, -.2cm},
            {Distance2d 1cm, -.2cm},
            {Distance2d 1cm, 0cm},
            {Distance2d 0cm, 0cm}
        },
        border-width = 0m,
        color = FillPattern.silver,
        border-color = FillPattern.navy,
        translation = {Distance2d 1cm, 1.5cm}
    }
}

{HBox
    "border-width (in pixels): ",
    {TextField
        width = .5in,
        value = "0",
        {on ValueFinished at field:TextField do
            let p-s:Distance = {shape.get-display-context}.pixel-size
            set shape.border-width = {field.value.to-double} * p-s
        }
    }
}

{Canvas
    width = 3cm,
    height = 2cm,
    shape
}

Constructors
default:Construct a new RegionShape.
constructor public {RegionShape.default region:Region, ...}
Properties
region:The region that defines this RegionShape.
accessor public final RegionShape.region:Region
setter public final RegionShape.region:Region
style-element:The "element" or "type" of this Visual, for the purpose of styling.
accessor public RegionShape.style-element:String
Properties inherited from RegionShapeMixin: border-color, border-line-style, border-width, color, display-context
Properties inherited from Shape: as-Shape, draw-operation, option-parent, selection-context, shape-parent, shape-selectable, stroke-thickness, transformation, visible?
Properties inherited from ShapeContainerBase: as-ShapeRoot, shape-children
Properties inherited from Visual: _style-element, clonable-class?, completely-clonable-children?, cursor, data-source, dragee, font-size, input-method-enabled?, input-method-keyboard-mode, name, options, options-present-here, style-class, style-manager, style-options, 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, registered-option-keys
Methods
get-own-bounds:Calculate the rectangular rendering bounds of this Shape, in its local coordinate system.
public {RegionShape.get-own-bounds dest:GRect = {GRect.empty}}:GRect
get-own-bounds-in-shape-root:Calculate the rectangular rendering bounds of this shape in the coordinate system of its shape root ancestor.
public {RegionShape.get-own-bounds-in-shape-root
    dest:GRect = {GRect.empty}
}:GRect
get-own-layout-bounds:Calculate the rectangular layout bounds of this Shape, in its local coordinate system.
public {RegionShape.get-own-layout-bounds
    lc:LayoutContext,
    width-first?:bool = true,
    dest:GRect = {GRect.empty}
}:GRect
self-contains-point?:Determine whether or not a point lies within this Shape.
public {RegionShape.self-contains-point? x:Distance, y:Distance}:bool
transformation-changed:Notification that Shape.transformation has changed.
public {RegionShape.transformation-changed}:void
Methods inherited from RegionShapeMixin: draw, overdraw-for-selection, self-intersects-polygon?
Methods inherited from Shape: apply-rotation, apply-scale, apply-transformation, apply-translation, apply-translation-in-parent, constrain-own-layout-bounds, constrain-shape-layout-bounds, contains-point?, detach, find-graphical-ancestor, fire-crossing-event, fire-in-child, get-display-context, get-down-orientation-in-shape-parent, get-graphical-root, get-local-device-pixel-size, get-origin-in-graphical-ancestor, get-origin-in-root, get-origin-in-shape-parent, get-origin-in-shape-root, get-right-orientation-in-shape-parent, get-shape-bounds, get-shape-bounds-in-shape-root, get-shape-layout-bounds, get-top-left-in-ancestor, get-transformation-to-shape-root, keyword-init-arg, option-change-notify, quantize-line-thickness, request-draw, request-draw-self, reset-transformation, set-rotation, set-scale, set-transformation, set-translation-in-parent, to-Graphic, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-point-from-shape-root, transform-point-to-shape-root, transform-to-display-coordinates, transform-to-graphical-root-coordinates, transform-vector-from-shape-root, transform-vector-to-shape-root, transformation-changing
Methods inherited from ShapeContainerBase: add, clear, draw-shape-child, draw-shape-children, get-all-children-at-point, get-child-at-point, get-leaf-at-point, get-shape-root, note-attached, note-detaching, notify-option-children, on-drag-enter, on-pointer-enter, on-pointer-envelope-event, register-options, remove, set-shape-index, set-shape-index-after, set-shape-index-before, shape-container-fire-inferior-crossing-event, shape-container-handle-crossing, shape-container-pick-child, shape-container-pointer-enter-occurred, shape-container-pointer-leave-occurred
Methods inherited from Visual: add-from-init-args, add-option, add-style-option, animate, change-cursor, clonable-appearance?, clone-appearance, clone-appearance-helper, find-test-children, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-text, 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, release-key-focus, remove-option, remove-style-option, request-key-focus, scroll-to-include, test-record, test-run, xy-offset-to
Methods inherited from GraphicOptions: any-to-Distance
Methods inherited from GuiEventTarget: 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-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-in, on-focus-out, on-grab-release, on-gui-event, on-input-method-event, on-inspection, on-key-event, on-key-press, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-press, on-pointer-release, on-pointer-scroll, 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: change-option-parent-notify, clone-options, get-option, get-option-by-name, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-changed, option-lookup, option-lookup-here, option-propagate-notify, option-set?, propagate-option-change, 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 {RegionShape.default region:Region, ...}

Construct a new RegionShape.

region: The region that defines this RegionShape.
...: Any normal Shape construction arguments may be passed, including option initializers, transformations, or child Shapes. See Shape.default for details.


Property Details
region (accessor)
accessor public final RegionShape.region:Region
setter public final RegionShape.region:Region

The region that defines this RegionShape.



style-element (accessor)
accessor public RegionShape.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


Method Details
get-own-bounds (method)
public {RegionShape.get-own-bounds dest:GRect = {GRect.empty}}:GRect

Calculate the rectangular rendering bounds of this Shape, in its local coordinate system.

dest: An optional GRect object to be used to return the data.

Returns

A GRect object containing the bounds. This will always be the same object as dest. This GRect must be well-formed; that is, the following must be true: -dest.lextent <= dest.rextent and -dest.ascent <= dest.descent

Description

The bounds returned should cover all pixels that will be painted by this object but do not include all of the children of this object.

Notes

Rendering bounds (get-own-bounds) and layout bounds (get-own-layout-bounds) are typically similar, but may differ. In particular, the rendering bounds may be generously inclusive, but the layout bounds must describe the Shape precisely in order for adjacent items to abut properly.

Overriding

When subclassing Shape, this method must be overridden. The dest parameter must be used to return the data.


get-own-bounds-in-shape-root (method)
public {RegionShape.get-own-bounds-in-shape-root
    dest:GRect = {GRect.empty}
}:GRect

Calculate the rectangular rendering bounds of this shape in the coordinate system of its shape root ancestor.

dest: An optional GRect object to be used to return the data.

Returns

A GRect object containing the bounds. This will always be the same object as dest. This GRect must be well-formed; that is, the following must be true: -dest.lextent <= dest.rextent and -dest.ascent <= dest.descent

Description

The bounds returned should cover all pixels that will be painted by this object but do not include all of the children of this object.

This method is implemented to call Shape.get-own-bounds and transform the bounds into the correct coordinate system.

Notes

It is illegal to call this method on a shape that does not have a shape root, and an exception will result when this occurs.

Overriding

You are encouraged to override this method in your own Shape implementation if it is possible to transform the bounds of your object in a tighter fashion than using an axis-aligned rectangle.


get-own-layout-bounds (method)
public {RegionShape.get-own-layout-bounds
    lc:LayoutContext,
    width-first?:bool = true,
    dest:GRect = {GRect.empty}
}:GRect

Calculate the rectangular layout bounds of this Shape, in its local coordinate system.

lc: The LayoutContext in effect for this layout negotiation.
width-first?: For GraphicShapes, indicates whether the bounds should be calculated using using width-first layout negotation. This parameter is not typically used by other subclasses.
dest: An optional GRect object to be used to return the data.

Returns

A GRect object containing the bounds. This will always be the same object as dest. This GRect must be well-formed; that is, the following must be true: -dest.lextent <= dest.rextent and -dest.ascent <= dest.descent

Description

The bounds returned are those that best describe the object for layout purposes but do not include all of the children of this object.

Notes

Rendering bounds (get-own-bounds) and layout bounds (get-own-layout-bounds) are typically similar, but may differ. In particular, the rendering bounds may be generously inclusive, but the layout bounds must describe the Shape precisely in order for adjacent items to abut properly.

Overriding

The default implementation merely calls get-own-bounds. The dest parameter must be used to return the data.


self-contains-point? (method)
public {RegionShape.self-contains-point? x:Distance, y:Distance}:bool

Determine whether or not a point lies within this Shape.

x: The X coordinate of the point.
y: The Y coordinate of the point.

Returns

true if this Shape contains (x, y).

Description

The point is in this object's local coordinate system. This method does not consider its children.

Overriding

When subclassing Shape, this method must be overridden. This method determines when mouse events (such as PointerMotion) will be delivered to this object, among other things.

Generally, you should implement this method to determine whether or not the point lies within any of the rendered primitives of the shape, not simply whether or not it is within the bounds of the shape. However, you are free to implement it using whatever metric you desire.


transformation-changed (method)
public {RegionShape.transformation-changed}:void

Notification that Shape.transformation has changed.

Overriding

Important note: Any overriding implementation of this method should include a call to the superclass implementation in order to ensure that the new area of the object is invalidated.