Widget

Abstract base for everything that owns a native window.

Members

Functions

addChild
void addChild(Widget child)

Append a child and set its parent to this widget.

bounds
Rect bounds()

The widget's last-known bounds. Read-only; see setBounds/getBounds.

children
Widget[] children()

The child widgets, in z/insertion order. Read-only; see addChild.

dispose
void dispose()

Deterministically tear the widget down: dispose children, detach from the parent, destroy the native window, unregister it, and release the GC root. Idempotent — safe to call more than once.

getBounds
Rect getBounds()

The widget's last-known bounds.

getClientRect
Rect getClientRect()

The widget's client area (origin at 0,0). Empty if not yet created.

getPreferredSize
Size getPreferredSize()

The widget's preferred size, used by the layout engine for non-stretching (proportion 0) items. The base widget has no intrinsic size; controls override this.

handle
HWND handle()

The native window handle this widget owns (null until created).

hide
void hide()

Hide the widget.

invalidate
void invalidate()

Request a repaint of the whole widget.

isEnabled
bool isEnabled()

Whether the widget currently accepts input.

parent
Widget parent()

The widget this one is parented to, if any. Read-only; see addChild.

processMessage
LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam)

Handle a window message routed from the master window procedure.

rawHandle
HWND rawHandle()

Raw handle accessor for subclasses and the backend.

registerHandle
void registerHandle()

Associate this widget's freshly-created HWND with the dispatch machinery and pin it as a GC root. Call once, immediately after handle is set.

removeChild
void removeChild(Widget child)

Remove a child and clear its parent link. Unknown children are ignored.

setBounds
void setBounds(Rect r)

Move/resize the widget, updating the native window if it exists.

setEnabled
void setEnabled(bool enabled)

Enable or disable input for the widget.

setFocus
void setFocus()

Give the widget keyboard focus.

setVisible
void setVisible(bool value)

Set visibility, updating the native window if it exists.

show
void show()

Make the widget visible.

visible
bool visible()

Whether the widget is currently visible. Read-only; see setVisible.

Variables

bounds_
Rect bounds_;

Cached bounds (window-relative for children, screen-relative for windows).

children_
Widget[] children_;

Child widgets, in z/insertion order.

handle_
HWND handle_;

The native window handle this widget owns (null until created).

parent_
Widget parent_;

The widget this one is parented to, if any.

visible_
bool visible_;

Cached visibility flag.

Meta