Control

Base class for all Win32 common-control wrappers.

Constructors

this
this(Widget parent, string className, DWORD style, DWORD exStyle)

Create the control as a child window.

Members

Functions

controlId
int controlId()

The control's command identifier (the hMenu child id at creation).

getPreferredSize
Size getPreferredSize()

A reasonable default preferred size; override per control type.

getText
string getText()

Get the control's text.

processCommand
bool processCommand(ushort notificationCode)

Handle a WM_COMMAND notification routed from the parent.

processNotify
bool processNotify(NMHDR* header)

Handle a WM_NOTIFY notification routed from the parent. Return true if it was handled. The default does nothing.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Intercept a message while subclassed. Set result and return true to consume the message; return false to let default processing continue.

setFont
void setFont(HFONT font)

Assign a font to the control and request a repaint.

setText
void setText(string text)

Set the control's text.

subclass
void subclass()

Install a subclass window procedure so the control can intercept its own messages (for example, swallowing the Enter key in a text field). Idempotent. Subclasses override processSubclassed to do the work.

Inherited Members

From Widget

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.

children_
Widget[] children_;

Child widgets, in z/insertion order.

visible_
bool visible_;

Cached visibility flag.

bounds_
Rect bounds_;

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

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. Read-only; see addChild.

children
Widget[] children()

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

visible
bool visible()

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

bounds
Rect bounds()

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

rawHandle
HWND rawHandle()

Raw handle accessor for subclasses and the backend.

show
void show()

Make the widget visible.

hide
void hide()

Hide the widget.

setVisible
void setVisible(bool value)

Set visibility, updating the native window if it exists.

setBounds
void setBounds(Rect r)

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

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.

setEnabled
void setEnabled(bool enabled)

Enable or disable input for the widget.

isEnabled
bool isEnabled()

Whether the widget currently accepts input.

setFocus
void setFocus()

Give the widget keyboard focus.

invalidate
void invalidate()

Request a repaint of the whole widget.

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.

addChild
void addChild(Widget child)

Append a child and set its parent to this widget.

removeChild
void removeChild(Widget child)

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

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.

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.

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

Handle a window message routed from the master window procedure.

Meta