Widget

Undocumented in source.
class Widget {}

Constructors

this
this(string ID)

create widget, with optional id

Destructor

~this
~this()
Undocumented in source.

Members

Functions

addChild
Widget addChild(Widget item)

adds child, returns added item

animate
void animate(long interval)

animates window; interval is time left from previous draw, in hnsecs (1/10000 of second)

applyAlign
void applyAlign(Rect rc, Point sz)

Applies alignment for content of size sz - set rectangle rc to aligned value of content inside of initial value of rc.

applyMargins
void applyMargins(Rect rc)

Helper function: applies margins to rectangle

applyPadding
void applyPadding(Rect rc)

Helper function: applies padding to rectangle

child
Widget child(int index)

returns child by index

childById
Widget childById(string id, bool deepSearch)

find child by id, returns null if not found

childIndex
int childIndex(Widget item)

returns index of widget in child list, -1 if passed widget is not a child of this widget

compareId
bool compareId(string id)

compare widget id with specified value, returs true if matches

findFocusableChild
Widget findFocusableChild(bool defaultOnly)

searches children for first focusable item, returns null if not found

handleCheckChange
void handleCheckChange(bool checked)

override to handle check changes

handleClick
bool handleClick()
Undocumented in source. Be warned that the author may not have intended to support it.
handleFocusChange
void handleFocusChange(bool focused)

override to handle focus changes

invalidate
void invalidate()

request redraw

isChild
bool isChild(Widget item, bool deepSearch)

returns true if item is child of this widget (when deepSearch == true - returns true if item is this widget or one of children inside children tree).

isPointInside
bool isPointInside(int x, int y)

returns true if point is inside of this widget

layout
void layout(Rect rc)

Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).

measure
void measure(int parentWidth, int parentHeight)

Measure widget according to desired width and height constraints. (Step 1 of two phase layout).

measuredContent
void measuredContent(int parentWidth, int parentHeight, int contentWidth, int contentHeight)

helper function for implement measure() when widget's content dimensions are known

onDraw
void onDraw(DrawBuf buf)

Draw widget at its position to buffer

onKeyEvent
bool onKeyEvent(KeyEvent event)

process key event, return true if event is processed.

onMouseEvent
bool onMouseEvent(MouseEvent event)

process mouse event; return true if event is processed by widget.

removeChild
Widget removeChild(string id)

removes child by ID, returns removed item

removeChild
Widget removeChild(int index)

removes child, returns removed item

requestLayout
void requestLayout()

request relayout of widget and its children

setFocus
Widget setFocus()

sets focus to this widget or suitable focusable child, returns previously focused widget

Properties

alignment
ubyte alignment [@property getter]

returns alignment (combined vertical and horizontal)

alignment
ubyte alignment [@property setter]

sets alignment (combined vertical and horizontal)

animating
bool animating [@property getter]

returns true is widget is being animated - need to call animate() and redraw

backgroundColor
uint backgroundColor [@property getter]

returns background color

backgroundColor
uint backgroundColor [@property setter]

set background color for widget - override one from style

canCheck
bool canCheck [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
canClick
bool canClick [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
canFocus
bool canFocus [@property getter]

returns true if widget is focusable and visible

checkable
bool checkable [@property getter]

when true, control supports Checked state

checkable
bool checkable [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
checked
bool checked [@property getter]

get checked state

checked
bool checked [@property setter]

set checked state

childCount
int childCount [@property getter]

returns number of children of this widget

clickable
bool clickable [@property getter]

when true, user can click this control, and get onClick listeners called

clickable
bool clickable [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
enabled
bool enabled [@property getter]

return true if state has State.Enabled flag set

enabled
bool enabled [@property setter]

change enabled state

focusable
bool focusable [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
focusable
bool focusable [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
focused
bool focused [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
font
FontRef font [@property getter]

returns font set for widget using style or set manually

fontFace
string fontFace [@property getter]

returns font face

fontFace
string fontFace [@property setter]

set font face for widget - override one from style

fontFamily
FontFamily fontFamily [@property getter]

returns font family

fontFamily
FontFamily fontFamily [@property setter]

set font family for widget - override one from style

fontItalic
bool fontItalic [@property getter]

returns font style (italic/normal)

fontItalic
bool fontItalic [@property setter]

set font style (italic/normal) for widget - override one from style

fontSize
ushort fontSize [@property getter]

returns font size in pixels

fontSize
ushort fontSize [@property setter]

set font size for widget - override one from style

fontWeight
ushort fontWeight [@property getter]

returns font weight

fontWeight
ushort fontWeight [@property setter]

set font weight for widget - override one from style

halign
Align halign [@property getter]

returns vertical alignment

height
int height [@property getter]

returns current height of widget in pixels

id
string id [@property getter]

returns widget id, null if not set

id
string id [@property setter]

set widget id

layoutHeight
int layoutHeight [@property getter]

returns layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)

layoutHeight
int layoutHeight [@property setter]

sets layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)

layoutWeight
int layoutWeight [@property getter]

returns layout weight (while resizing to fill parent, widget will be resized proportionally to this value)

layoutWeight
int layoutWeight [@property setter]

sets layout weight (while resizing to fill parent, widget will be resized proportionally to this value)

layoutWidth
int layoutWidth [@property getter]

returns layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)

layoutWidth
int layoutWidth [@property setter]

sets layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)

left
int left [@property getter]

returns widget rectangle left position

margins
Rect margins [@property getter]

get margins (between widget bounds and its background)

margins
Rect margins [@property setter]

set margins for widget - override one from style

maxHeight
int maxHeight [@property getter]

returns max height constraint (SIZE_UNSPECIFIED if no constraint set)

maxHeight
int maxHeight [@property setter]

set max height constraint (SIZE_UNSPECIFIED for no constraint)

maxWidth
int maxWidth [@property getter]

returns max width constraint (SIZE_UNSPECIFIED if no constraint set)

maxWidth
int maxWidth [@property setter]

set max width constraint (SIZE_UNSPECIFIED for no constraint)

measuredHeight
measuredHeight [@property getter]

returns measured height (calculated during measure() call)

measuredWidth
measuredWidth [@property getter]

returns measured width (calculated during measure() call)

minHeight
int minHeight [@property getter]

returns min height constraint

minHeight
int minHeight [@property setter]

set max height constraint (0 for no constraint)

minWidth
int minWidth [@property getter]

returns min width constraint

minWidth
int minWidth [@property setter]

set max width constraint (0 for no constraint)

needDraw
bool needDraw [@property getter]

returns true if redraw is required for widget and its children

needLayout
bool needLayout [@property getter]

returns true if layout is required for widget and its children

ownStyle
Style ownStyle [@property getter]

enforces widget's own style - allows override some of style properties

padding
Rect padding [@property getter]

get padding (between background bounds and content of widget)

padding
Rect padding [@property setter]

set padding for widget - override one from style

parent
Widget parent [@property setter]

sets parent for widget

parent
Widget parent [@property getter]

returns parent widget, null for top level widget

pos
Rect pos [@property getter]

returns widget rectangle

resetState
uint resetState [@property setter]

remove state flags (set of flags from State enum)

setState
uint setState [@property setter]

add state flags (set of flags from State enum)

state
uint state [@property getter]

widget state (set of flags from State enum)

state
uint state [@property setter]

set new widget state (set of flags from State enum)

stateStyle
const(Style) stateStyle [@property getter]

returns style for current widget state

style
const(Style) style [@property getter]

accessor to style - by lookup in theme by styleId (if style id is not set, theme base style will be used).

style
uint style [@property setter]

accessor to style - by lookup in theme by styleId (if style id is not set, theme base style will be used).

styleId
string styleId [@property getter]

returns widget style id, null if not set

styleId
string styleId [@property setter]

set widget style id

text
dstring text [@property getter]

returns widget content text (override to support this)

text
dstring text [@property setter]

sets widget content text (override to support this)

text
UIString text [@property setter]

sets widget content text (override to support this)

textColor
uint textColor [@property getter]

get text color (ARGB 32 bit value)

textColor
uint textColor [@property setter]

set text color (ARGB 32 bit value)

top
int top [@property getter]

returns widget rectangle top position

trackHover
bool trackHover [@property getter]

mouse movement processing flag (when true, widget will change Hover state while mouse is moving)

trackHover
bool trackHover [@property setter]

set new trackHover flag value (when true, widget will change Hover state while mouse is moving)

valign
Align valign [@property getter]

returns horizontal alignment

visibility
Visibility visibility [@property getter]

returns widget visibility (Visible, Invisible, Gone)

visibility
Visibility visibility [@property setter]

sets widget visibility (Visible, Invisible, Gone)

visible
bool visible [@property getter]

returns true if this widget and all its parents are visible

width
int width [@property getter]

returns current width of widget in pixels

window
Window window [@property getter]

returns window (if widget or its parent is attached to window)

window
Window window [@property setter]

sets window (to be used for top level widget from Window implementation). TODO: hide it from API?

Variables

_checkable
bool _checkable;
Undocumented in source.
_checked
bool _checked;
Undocumented in source.
_clickable
bool _clickable;
Undocumented in source.
_focusable
bool _focusable;
Undocumented in source.
_id
string _id;

widget id

_measuredHeight
int _measuredHeight;

height measured by measure()

_measuredWidth
int _measuredWidth;

width measured by measure()

_needDraw
bool _needDraw;

true to force redraw

_needLayout
bool _needLayout;

true to force layout

_ownStyle
Style _ownStyle;

own copy of style - to override some of style properties, null of no properties overriden

_parent
Widget _parent;

parent widget

_pos
Rect _pos;

current widget position, set by layout()

_state
uint _state;

widget state (set of flags from State enum)

_styleId
string _styleId;

style id to lookup style in theme

_trackHover
bool _trackHover;

does widget need to track mouse Hover

_visibility
Visibility _visibility;

widget visibility: either Visible, Invisible, Gone

_window
Window _window;

window (to be used for top level widgets only!)

onCheckChangeListener
Signal!OnCheckHandler onCheckChangeListener;

checked state change event listener (bool delegate(Widget, bool))

onClickListener
Signal!OnClickHandler onClickListener;

on click event listener (bool delegate(Widget))

onFocusChangeListener
Signal!OnFocusHandler onFocusChangeListener;

focus state change event listener (bool delegate(Widget, bool))

Meta