
Widget is the base class for all UI widgets.
Slots
- add
-
virtual This add(Widget child)
Add a child widget. If child is null, then do nothing. If child is already parented throw ArgErr. Return this.
-
private native Void attach()
Attach to a native peer
-
private native Bool attached()
Is this widget attached to a native peer?
- bounds
-
native Rect bounds
Position and size of this widget relative to its parent. If this a window, this is the position on the screen.
- children
-
Widget[] children()
Get the children widgets.
-
private native Void detach()
Detach from native peer
- each
-
Iterate the children widgets.
- enabled
-
native Bool enabled
Enabled is used to control whether this widget can accept user input. Disabled controls are "grayed out".
-
internal Widget[] kids := Widget[,]
- onLayout
-
virtual Void onLayout()
Handle the layout event. The method is only called Pane containers. Custom panes must override this method to set the bounds on all their children.
- onPaint
-
virtual Void onPaint(Graphics g)
This callback is invoked when the widget should be repainted. The graphics context is initialized at the widget's origin with the clip bounds set to the widget's size.
- parent
-
readonly Widget parent
Get this widget's parent or null if not mounted.
- pos
-
native Point pos
Position of this widget relative to its parent. If this a window, this is the position on the screen.
- posOnDisplay
-
native Point posOnDisplay()
Get the position of this widget on the screen coordinate's system. If not on mounted on the screen then return null.
- prefSize
-
virtual native Size prefSize(Hints hints := Hints.def)
Compute the preferred size of this widget. The hints indicate constraints the widget should consider in its calculations. If no constraints are known for width, then
hints.w
will be null. If no constraints are known for height, thenhints.h
will be null. - relayout
-
Void relayout()
Relayout this widget. This method is called when something has changed and we need to recompute the layout of this widget's children.
-
static internal Str relayoutId := "relayout"
- remove
-
virtual This remove(Widget child)
Remove a child widget. If child is null, then do nothing. If this widget is not the child's current parent throw ArgErr. Return this.
- removeAll
-
virtual This removeAll()
Remove all child widgets. Return this.
- repaint
-
Void repaint(Rect dirty := null)
Repaint this widget. If the dirty rectangle is null, then the whole widget is repainted.
-
static internal Str repaintId := "repaint"
-
internal native Obj send(Str name, Obj arg)
Send the native widget peer a message
- size
-
native Size size
Size of this widget.
-
internal native Void sync(Str field)
Sync the specified field to the native widget
- visible
-
native Bool visible
Controls whether this widget is visible or hidden.
- window
-
Window window()
Get this widget's parent window or null if not mounted under a Window widget.