TabControl

A native tab control hosting one Widget per page.

Pages are positioned into the tab control's display rect (the area below the tab strip). The page widgets are expected to be children of the same parent window as the tab control.

Constructors

this
this(Widget parent)

Create a tab control as a child of parent.

Members

Functions

addPage
int addPage(string title, Widget pageContent)

Add a page captioned title showing pageContent when selected. Returns the index of the newly inserted page.

getDisplayRect
Rect getDisplayRect()

The display rect (content area below the tab strip), in client coordinates.

getPreferredSize
Size getPreferredSize()

The preferred size of the tab control.

getSelectedPage
int getSelectedPage()

The index of the currently selected page, or -1 if none.

processNotify
bool processNotify(NMHDR* header)

Translate tab-selection-change notifications into onPageChanged.

relayout
void relayout()

Re-positions all pages into the current display rect; call on window resize.

setBounds
void setBounds(Rect r)

Move/resize the tab control (bounds r, parent-relative), then re-lay out its pages.

setSelectedPage
void setSelectedPage(int index)

Select the page at index, showing its content and hiding the rest.

setTabTitle
void setTabTitle(int index, string title)

Change the label of the tab at index (e.g. when the UI language changes).

Variables

onPageChanged
Event!(int) onPageChanged;

Fired when the selected page changes, with the new page index.

Inherited Members

From Control

controlId
int controlId()

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

setText
void setText(string text)

Set the control's text.

getText
string getText()

Get the control's text.

setFont
void setFont(HFONT font)

Assign a font to the control and request a repaint.

getPreferredSize
Size getPreferredSize()

A reasonable default preferred size; override per control type.

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.

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.

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.

Meta