Class GridWidgetBase

Abstract grid widget

class GridWidgetBase
  : ScrollWidgetBase
  , GridModelAdapter
  , MenuItemActionHandler;

Constructors

NameDescription
this (ID, hscrollbarMode, vscrollbarMode)

Fields

NameTypeDescription
cellActivated Listener!(dcanvas.widgets.grid.CellActivatedHandler)Callback to handle cell double click
cellPopupMenu Signal!(dcanvas.widgets.grid.CellPopupMenuHandler)cell popup menu
cellSelected Listener!(dcanvas.widgets.grid.CellSelectedHandler)Callback to handle selection change
headerCellClicked Listener!(dcanvas.widgets.grid.HeaderCellClickHandler)Callback for handling header cell click
menuItemAction Signal!(dcanvas.widgets.menu.MenuItemActionHandler)popup menu item action
viewScrolled Listener!(dcanvas.widgets.grid.ViewScrolledHandler)Callback for handling of view scroll (top left visible cell change)
_backgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
checkChange Signal!(dcanvas.widgets.widget.OnCheckHandler)checked state change event listener (bool delegate(Widget, bool))
click Signal!(dcanvas.widgets.widget.OnClickHandler)on click event listener (bool delegate(Widget))
doubleClick Signal!(dcanvas.widgets.widget.OnDoubleClickHandler)On double click event listener (bool delegate(Widget))
focusChange Signal!(dcanvas.widgets.widget.OnFocusHandler)focus state change event listener (bool delegate(Widget, bool))
keyEvent Signal!(dcanvas.widgets.widget.OnKeyHandler)key event listener (bool delegate(Widget, KeyEvent)) - return true if event is processed by handler
keyToAction Listener!(dcanvas.widgets.widget.OnKeyActionHandler)action by key lookup handler
mouseEvent Signal!(dcanvas.widgets.widget.OnMouseHandler)mouse event listener (bool delegate(Widget, MouseEvent)) - return true if event is processed by handler
onAction Signal!(dcanvas.widgets.widget.OnActionHandler)action handlers
_allowColResizing bool
_cellBorderColor uint
_cellHeaderBackgroundColor uint
_cellHeaderBackgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
_cellHeaderBorderColor uint
_cellHeaderSelectedBackgroundColor uint
_cellHeaderSelectedBackgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
_cellRowHeaderBackgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
_cellRowHeaderSelectedBackgroundDrawable Ref!(dcanvas.graphics.resources.Drawable)
_changedSize bool
_col intselected cell column
_colCumulativeWidths int[]total width from first column to right of this
_colResizingIndex int
_colResizingStartWidth int
_colResizingStartX int
_cols intcolumn count (including header columns and fixed columns)
_colWidths int[]column widths
_customCellAdapter CustomGridCellAdapter
_defColumnWidth intdefault column width - for newly added columns
_defRowHeight intdefault row height - for newly added rows
_fixedCellBackgroundColor uint
_fixedCellBorderColor uint
_fixedCols intnumber of fixed (non-scrollable) columns
_fixedRows intnumber of fixed (non-scrollable) rows
_fullColumnOnLeft bool
_fullRowOnTop bool
_gridModelAdapter GridModelAdapter
_headerCols intnumber of header columns (e.g. like row number in excel; 0 for no header column)
_headerRows intnumber of header rows (e.g. like col name A, B, C... in excel; 0 for no header row)
_maxScrollCol int
_maxScrollRow int
_minVisibleCols int
_minVisibleRows int
_multiSelect boolwhen true, allows multi cell selection
_row intselected cell row
_rowCumulativeHeights int[]total height from first row to bottom of this
_rowHeights int[]row heights
_rows introw count (including header rows and fixed rows)
_rowSelect boolwhen true, allows to select only whole row
_scrollX intscroll X offset in pixels
_scrollY intscroll Y offset in pixels
_selection std.container.rbtree.RedBlackTree!(dcanvas.core.types.Point,"a < b",false)selected cells when multiselect is enabled
_selectionColor uint
_selectionColorRowSelect uint
_showColHeaders boolwhen true, shows col headers row
_showRowHeaders boolwhen true, shows row headers column
_smoothHScroll bool
_smoothVScroll bool
_acceleratorMap ActionMap
_action Action
_checkable bool
_checked bool
_children ObjectList!(dcanvas.widgets.widget.Widget)
_clickable bool
_clientRect Rectinner area, excluding additional controls like scrollbars
_focusable bool
_focusGroup bool
_fullScrollableArea Rect
_hscrollbar ScrollBarhorizontal scrollbar control
_hscrollbarMode ScrollBarMode
_id stringwidget id
_insideChangeScrollbarVisibility bool
_measuredHeight intheight measured by measure()
_measuredWidth intwidth measured by measure()
_needDraw booltrue to force redraw
_needLayout booltrue to force layout
_ownStyle Styleown copy of style - to override some of style properties, null of no properties overriden
_parent Widgetparent widget
_popupMenu MenuItem
_pos Rectcurrent widget position, set by layout()
_state uintwidget state (set of flags from State enum)
_styleId stringstyle id to lookup style in theme
_tabOrder ushort
_tooltipText UIString
_trackHover booldoes widget need to track mouse Hover
_visibility Visibilitywidget visibility: either Visible, Invisible, Gone
_visibleScrollableArea Rect
_vscrollbar ScrollBarvertical scrollbar control
_vscrollbarMode ScrollBarMode
_window Windowwindow (to be used for top level widgets only!)

Properties

NameTypeDescription
allowColResizing[get] boolget col resizing flag; when true, allow resizing of column with mouse
allowColResizing[set] GridWidgetBaseset col resizing flag; when true, allow resizing of column with mouse
col[get] intselected column
cols[get] intcolumn count
cols[set] GridWidgetBaseset column count
customCellAdapter[get] CustomGridCellAdapterGet adapter to override drawing of some particular cells
customCellAdapter[set] GridWidgetBaseSet adapter to override drawing of some particular cells
defColumnWidth[get] intdefault column width - for newly added columns
defColumnWidth[set] GridWidgetBase
defRowHeight[get] intdefault row height - for newly added rows
defRowHeight[set] GridWidgetBase
fixedCols[get] intfixed (non-scrollable) data column count
fixedCols[set] int
fixedRows[get] intfixed (non-scrollable) data row count
fixedRows[set] int
fullAreaPixels[get] Pointreturn all (fixed + scrollable) cells size in pixels
fullColumnOnLeft[get, set] boolExtends scroll area to show full column at left when scrolled to rightmost column
fullRowOnTop[get, set] boolExtends scroll area to show full row at top when scrolled to end row
gridModelAdapter[get] GridModelAdapterGet adapter to hold grid model data
gridModelAdapter[set] GridWidgetBaseSet adapter to hold grid model data
headerCols[get] introw header column count
headerCols[set] GridWidgetBase
headerRows[get] intcol header row count
headerRows[set] GridWidgetBase
minVisibleCols[set] intsets number of columns from 0 that are taken to measure minimum visible width
minVisibleCols[get] intreturns number of columns from 0 that are taken to measure minimum visible width
minVisibleRows[set] intsets number of rows from 0 that are taken to measure minimum visible height, if there are too little rows last row height is multiplied
minVisibleRows[get] intreturns number of rows from 0 that are taken to measure minimum visible height
multiSelect[get] boolwhen true, allows multi cell selection
multiSelect[set] GridWidgetBase
nonScrollAreaPixels[get] Pointnon-scrollable area size in pixels
nonScrollCols[get] intcount of non-scrollable columns (header + fixed)
nonScrollRows[get] intcount of non-scrollable rows (header + fixed)
row[get] intselected row
rows[get] introw count
rows[set] GridWidgetBaseset row count
rowSelect[get] boolwhen true, allows only select the whole row
rowSelect[set] GridWidgetBase
scrollAreaPixels[get] Pointscrollable area size in pixels
selection[get] std.container.rbtree.RedBlackTree!(dcanvas.core.types.Point,"a < b",false)selected cells when multiselect is enabled
showColHeaders[get] boolflag to enable column headers
showColHeaders[set] GridWidgetBase
showRowHeaders[get] boolflag to enable row headers
showRowHeaders[set] GridWidgetBase
smoothHScroll[get, set] boolGet smooth horizontal scroll flag - when true - scrolling by pixels, when false - by cells
smoothVScroll[get, set] boolGet smooth vertical scroll flag - when true - scrolling by pixels, when false - by cells
acceleratorMap[get] ActionMap
action[get, set] const(Action)action to emit on click
alignment[set] Widgetsets alignment (combined vertical and horizontal)
alignment[get] ubytereturns alignment (combined vertical and horizontal)
alpha[set] Widgetset widget drawing alpha value (0=opaque .. 255=transparent)
alpha[get] uintwidget drawing alpha value (0=opaque .. 255=transparent)
animating[get] boolreturns true is widget is being animated - need to call animate() and redraw
backgroundColor[set] Widgetset background color for widget - from string like "#5599CC" or "white"
backgroundColor[set] Widgetset background color for widget - override one from style
backgroundColor[get] uintreturns background color
backgroundDrawable[get, set] Ref!(dcanvas.graphics.resources.Drawable)background drawable
backgroundImageId[get, set] stringbackground image id
canCheck[get] bool
canClick[get] bool
canFocus[get] boolreturns true if widget is focusable and visible and enabled
checkable[set] Widget
checkable[get] boolwhen true, control supports Checked state
checked[set] Widgetset checked state
checked[get] boolget checked state
childCount[get] intreturns number of children of this widget
clickable[set] Widget
clickable[get] boolwhen true, user can click this control, and get onClick listeners called
clientRect[get] Rectreturns client area rectangle
enabled[set] Widgetchange enabled state
enabled[get] boolreturn true if state has State.Enabled flag set
focusable[set] Widget
focusable[get] boolwhether widget can be focused
focused[get] bool
focusGroup[get] boolWhen focus group is set for some parent widget, focus from one of containing widgets can be moved using keyboard only to one of other widgets containing in it and cannot bypass bounds of focusGroup.
focusGroup[set] Widgetset focus group flag for container widget
focusGroupFocused[get] bool
focusGroupFocused[set] Widget
focusRectColors[get] const(uint[])returns colors to draw focus rectangle (one for solid, two for vertical gradient) or null if no focus rect should be drawn for style
font[get] Ref!(dcanvas.graphics.fonts.Font)returns font set for widget using style or set manually
fontFace[set] Widgetset font face for widget - override one from style
fontFace[get] stringreturns font face
fontFamily[set] Widgetset font family for widget - override one from style
fontFamily[get] FontFamilyreturns font family
fontItalic[set] Widgetset font style (italic/normal) for widget - override one from style
fontItalic[get] boolreturns font style (italic/normal)
fontSize[set] Widgetset font size for widget - override one from style
fontSize[get] intreturns font size in pixels
fontWeight[set] Widgetset font weight for widget - override one from style
fontWeight[get] ushortreturns font weight
halign[get] Alignreturns vertical alignment
hasTooltip[get] boolreturns true if widget has tooltip to show
height[get] intreturns current height of widget in pixels
hscrollbar[get] ScrollBar
hscrollbar[set] ScrollBar
hscrollbarMode[get] ScrollBarModehorizontal scrollbar mode
hscrollbarMode[set] ScrollBarMode
id[get] stringreturns widget id, null if not set
id[set] Widgetset widget id
layoutHeight[set] Widgetsets layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)
layoutHeight[get] intreturns layout height options (WRAP_CONTENT, FILL_PARENT, some constant value or percent but only for one widget in layout)
layoutWeight[get] intreturns layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
layoutWeight[set] Widgetsets layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
layoutWidth[set] Widgetsets layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)
layoutWidth[get] intreturns layout width options (WRAP_CONTENT, FILL_PARENT, some constant value or percent but only for one widget in layout)
left[get] intreturns widget rectangle left position
margins[set] Widgetset margins for widget - override one from style
margins[set] Widgetset margins for widget with the same value for left, top, right, bottom - override one from style
margins[get] Rectget margins (between widget bounds and its background)
maxHeight[set] Widgetset max height constraint (SIZE_UNSPECIFIED for no constraint)
maxHeight[get] intreturns max height constraint (SIZE_UNSPECIFIED if no constraint set)
maxWidth[set] Widgetset max width constraint (SIZE_UNSPECIFIED for no constraint)
maxWidth[get] intreturns max width constraint (SIZE_UNSPECIFIED if no constraint set)
measuredHeight[get] intreturns measured height (calculated during measure() call)
measuredWidth[get] intreturns measured width (calculated during measure() call)
minHeight[set] Widgetset max height constraint (0 for no constraint)
minHeight[get] intreturns min height constraint
minWidth[set] Widgetset max width constraint (0 for no constraint)
minWidth[get] intreturns min width constraint
needDraw[get] boolreturns true if redraw is required for widget and its children
needLayout[get] boolreturns true if layout is required for widget and its children
ownStyle[get] Styleenforces widget's own style - allows override some of style properties
padding[set] Widgetset padding for widget to the same value for left, top, right, bottom - override one from style
padding[set] Widgetset padding for widget - override one from style
padding[get] Rectget padding (between background bounds and content of widget)
parent[get] Widgetreturns parent widget, null for top level widget
parent[set] Widgetsets parent for widget
popupMenu[get] MenuItem
popupMenu[set] Widget
pos[get] Rectreturns widget rectangle
resetState[set] Widgetremove state flags (set of flags from State enum)
setState[set] Widgetadd state flags (set of flags from State enum)
state[set] Widgetset new widget state (set of flags from State enum)
state[get] uintwidget state (set of flags from State enum)
styleId[set] Widgetset widget style id
styleId[get] stringreturns widget style id, null if not set
tabOrder[set] Widget
tabOrder[get] ushorttab order - hint for focus movement using Tab/Shift+Tab
text[set] Widgetsets widget content text (override to support this)
text[get] dstringreturns widget content text (override to support this)
textColor[get] uintget text color (ARGB 32 bit value)
textColor[set] Widgetset text color (ARGB 32 bit value)
textColor[set] Widgetset text color for widget - from string like "#5599CC" or "white"
textFlags[set] Widgetset text flags (bit set of TextFlag enum values)
textFlags[get] uintget text flags (bit set of TextFlag enum values)
tooltipText[get, set] dstringtooltip text - when not empty, widget will show tooltips automatically; for advanced tooltips - override hasTooltip and createTooltip
top[get] intreturns widget rectangle top position
trackHover[get] boolmouse movement processing flag (when true, widget will change Hover state while mouse is moving)
trackHover[set] Widgetset new trackHover flag value (when true, widget will change Hover state while mouse is moving)
valign[get] Alignreturns horizontal alignment
visibility[get] Visibilityreturns widget visibility (Visible, Invisible, Gone)
visibility[set] Widgetsets widget visibility (Visible, Invisible, Gone)
visible[get] boolreturns true if this widget and all its parents are visible
vscrollbar[set] ScrollBar
vscrollbar[get] ScrollBar
vscrollbarMode[set] ScrollBarMode
vscrollbarMode[get] ScrollBarModevertical scrollbar mode
wantsKeyTracking[get] booloverride and return true to track key events even when not focused
width[get] intreturns current width of widget in pixels
window[set] Windowsets window (to be used for top level widget from Window implementation). TODO: hide it from API?
window[get] Windowreturns window (if widget or its parent is attached to window)
stateStyle[get] const(Style)returns style for current widget state
style[get, set] const(Style)accessor to style - by lookup in theme by styleId (if style id is not set, theme base style will be used).

Methods

NameDescription
activateCell (col, row) Select cell and call onCellActivated handler
autoFit ()
autoFitColumnWidth (i)
autoFitColumnWidths ()
autoFitRowHeight (i)
autoFitRowHeights ()
canShowPopupMenu (x, y) returns true if widget can show popup menu (e.g. by mouse right click at point x,y)
cellRect (x, y) returns cell rectangle relative to client area; row 0 is col headers row; col 0 is row headers column
cellRectNoScroll (x, y) get cell rectangle (relative to client area) not counting scroll position
cellRectScroll (x, y) get cell rectangle moved by scroll pixels (may overlap non-scroll cols!)
colVisible (x) returns true if column is inside client area and not overlapped outside scroll area
colWidth (col) get column width, 0 is header column
fillColumnWidth (colIndex) extend specified column width to fit client area if grid width
fullContentSize () calculate full content size in pixels
getCursorType (x, y) returns mouse cursor type for widget
isColumnResizingPoint (x, y) return column index to resize if point is in column resize area in header row, -1 if outside resize area
makeCellVisible (col, row) ensure that cell is visible (scroll if necessary)
minimumVisibleContentSize () calculate minimum size of widget
multiSelectCell (col, row, expandExisting)
onHScroll (event) process horizontal scrollbar event
onMouseEvent (event) handle mouse wheel events
onVScroll (event) process vertical scrollbar event
pointToCell (x, y, col, row, cellRect) converts client rect relative coordinates to cell coordinates
resize (c, r) set new size
rowHeight (row) get row height, 0 is header row
rowVisible (y) returns true if row is inside client area and not overlapped outside scroll area
scrollBy (dx, dy) move scroll position horizontally by dx, and vertically by dy; returns true if scrolled
scrollTo (x, y, source, doNotify) set scroll position to show specified cell as top left in scrollable area; col or row -1 value means no change
selectCell (col, row, makeVisible, source, needNotification) move selection to specified cell
setBoolProperty (name, value) set string property value, for ML loaders
setColWidth (x, w)
setIntProperty (name, value) set int property value, for ML loaders
setRowHeight (y, w)
showPopupMenu (xx, yy) shows popup menu at (x,y)
addChild (item) adds child, returns added item
addChildren (items) adds child, returns added item
addOnCheckChangeListener (listener) helper function to add onCheckChangeListener in method chain
addOnClickListener (listener) helper function to add onClickListener in method chain
addOnFocusChangeListener (listener) helper function to add onFocusChangeListener in method chain
animate (interval) animates window; interval is time left from previous draw, in hnsecs (1/10000000 of second)
applyAlign (rc, sz, ha, va) Applies alignment for content of size sz - set rectangle rc to aligned value of content inside of initial value of rc.
applyMargins (rc) Helper function: applies margins to rectangle
applyPadding (rc) Helper function: applies padding to rectangle
cancelLayout ()
cancelTimer (timerId) cancel timer - pass value returned from setTimer() as timerId parameter
child (index) returns child by index
childById (id, deepSearch) find child of specified type T by id, returns null if not found or cannot be converted to type T
childIndex (item) returns index of widget in child list, -1 if passed widget is not a child of this widget
compareId (id) compare widget id with specified value, returs true if matches
createTooltip (mouseX, mouseY, alignment, x, y) will be called from window once tooltip request timer expired; if null is returned, popup will not be shown; you can change alignment and position of popup here
dispatchAction (a) call to dispatch action
drawFocusRect (buf, rc) draws focus rectangle, if enabled in styles
executeInUiThread (runnable) execute delegate later in UI thread if this widget will be still available (can be used to modify UI from background thread, or just to postpone execution of action)
fillHorizontal () sets layoutWidth=FILL_PARENT
fillParent () sets layoutWidth=FILL_PARENT and layoutHeight=FILL_PARENT
fillVertical () sets layoutHeight=FILL_PARENT
findFocusableChild (defaultOnly) searches children for first focusable item, returns null if not found
findKeyAction (keyCode, flags) map key to action
focusGroupWidget () find nearest parent of this widget with focusGroup flag, returns topmost parent if no focusGroup flag set to any of parents.
fullContentSizeWithBorders () calculate full content size in pixels including widget borders / margins
handleActionStateChanged () called when state of action assigned on widget is changed
handleActionStateRequest (a) override to handle specific actions state (e.g. change enabled state for supported actions)
handleMoveFocusUsingKeys (event)
insertChild (item, index) inserts child at given index, returns inserted item
invalidate () request redraw
isActionEnabled (action) override to change popup menu items state
isChild (item, 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 (x, y) returns true if point is inside of this widget
isPointInside (pt)
layout (rc) Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
makeRectVisible (rc, alignHorizontally, alignVertically)
measure (parentWidth, parentHeight) Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
onDraw (buf) Draw widget at its position to buffer
onEvent (event) handle custom event
onKeyEvent (event) process key event, return true if event is processed.
onScrollEvent (source, event) handle scroll event
onThemeChanged () handle theme change: e.g. reload some themed resources
onTimer (id) handle timer; return true to repeat timer event after next interval, false cancel timer
removeAllChildren (destroyObj)
removeChild (index) removes child, returns removed item
removeChild (ID) removes child by ID, returns removed item
removeChild (child) removes child, returns removed item
replaceChild (newChild, oldChild) replace child with other child
requestActionsUpdate (immediateUpdate) set action update request flag, will be cleared after redraw
requestLayout () request relayout of widget and its children
scheduleTooltip (delay, alignment, x, y) schedule tooltip
setDoubleProperty (name, value) set double property value, for ML loaders
setDstringProperty (name, value) set string property value, for ML loaders
setFocus (reason) sets focus to this widget or suitable focusable child, returns previously focused widget
setRectProperty (name, value) set Rect property value, for ML loaders
setStringListValueListProperty (propName, values) StringListValue list values
setStringProperty (name, value) set string property value, for ML loaders
setTimer (intervalMillis) set new timer to call onTimer() after specified interval (for recurred notifications, return true from onTimer)
setUIStringListProperty (propName, values) UIString list values
setUistringProperty (name, value) set string property value, for ML loaders
updateActionState (a, force, allowDefault) ask for update state of some action (unles force=true, checks window flag actionsUpdateRequested), returns true if action state is changed
updateActionState (force) call to update state for action (if action is assigned for widget)
updateStateFromAction (a) apply enabled, visibile and checked state for this widget from action's state
calcScrollableAreaPos () calculate scrollable area info
colByAbsoluteX (x) column by X, ignoring scroll position
correctScrollPos ()
drawCell (buf, rc, col, row) draw data cell content
drawCellBackground (buf, rc, col, row) draw data cell background
drawClient (buf)
drawHeaderCell (buf, rc, col, row) draw header cell content
drawHeaderCellBackground (buf, rc, col, row) draw header cell background
endColResize ()
findPosIndex (cumulativeSizes, pos) search for index of position inside cumulative sizes array
getCellPopupMenu (col, row)
handleAction (a) override to handle specific actions
handleClientRectLayout (rc) override to support modification of client rect after change, e.g. apply offset
lastScrollCol () returns last fully visible column in scroll area
lastScrollRow () returns last fully visible row in scroll area
measureCell (x, y)
measureColWidth (x)
measureRowHeight (y)
onMenuItemAction (action) handle popup menu action
processColResize (x)
rowByAbsoluteY (y) row by Y, ignoring scroll position
scrollCol () returns first fully visible column in scroll area
scrollRow () returns first fully visible row in scroll area
startColResize (col, x)
updateCumulativeSizes () recalculate colCumulativeWidths, rowCumulativeHeights after resizes
updateScrollBars () update scrollbar positions
checkIfNeededToChangeScrollbarVisibility ()
checkIfScrollbarsNeeded (needHScroll, needVScroll) override to determine if scrollbars are needed or not
drawExtendedArea (buf)
handleCheckChange (checked) override to handle check changes
handleClick ()
handleDoubleClick ()
handleFocusChange (focused, receivedFocusFromKeyboard) override to handle focus changes
handleFontChanged () override to handle font changes
measuredContent (parentWidth, parentHeight, contentWidth, contentHeight) helper function for implement measure() when widget's content dimensions are known
setWindowFocusedFlag (flg)
updateHScrollBar () update horizontal scrollbar widget position
updateVScrollBar () update verticat scrollbar widget position

Aliases

NameDescription
~this