TextGrid

Extends: module:boxes/AbstractBox.AbstractBox

Source: TextGrid.js:67

This class is a special type of AbstractBox that displays a grid of single
characters.

It's used CrossWord and WordSearch activities.


Constructor

new TextGrid( parent: module:boxes/AbstractBox.AbstractBox, container: module:AWT.Container, boxBase: module:boxes/BoxBase.BoxBase, x: number, y: number, ncw: number, nch: number, cellW: number, cellH: number, border: boolean, ): TextGrid

TextGrid constructor

Parameters

  • parent (module:boxes/AbstractBox.AbstractBox) — The AbstractBox to which this text grid belongs
  • container (module:AWT.Container) — The container where this text grid is placed.
  • boxBase (module:boxes/BoxBase.BoxBase) — The object where colors, fonts, border and other graphic properties
  • x (number) — X coordinate of the upper left corner of this grid
  • y (number) — Y coordinate of the upper left corner of this grid
  • ncw (number) — Number of columns of the grid
  • nch (number) — Nomber of rows of the grid
  • cellW (number) — Width of the cells
  • cellH (number) — Height of the cells
  • border (boolean) — When true, a border must be drawn between the cells

Instance Methods

setChars(text: string)

Sets the characters to be placed in the cells of this TextGrid

Parameters

  • text (string)

randomize()

Substitutes the current content of all cells with wildcards with a randomly generated char.

  • See:
    • TextGridContent#randomChars

setCellAttributes(lockWild: boolean, clearChars: boolean)

Clears or sets global attributes to all cells

Parameters

  • lockWild (boolean) — When true, the wildcard cells will be marked with special
    attributes (used in CrossWords to mark black cells)
  • clearChars (boolean) — When true, the current content of cells will be erased.

setCellLocked(px: number, py: number, locked: boolean)

Sets or unsets the locked properties (black cell) to a specific cell.

Parameters

  • px (number) — The logical 'X' coordinate of the cell
  • py (number) — The logical 'Y' coordinate of the cell
  • locked (boolean) — When true, the locked attribute will be on.

getItemFor(rx: number, ry: number): module:AWT.Point

For a specific cell located at column rx and row ry, finds the number of words delimited
by wildchars located behind its current position and in the same row and column. Used in
CrossWord activities to find the definition for a specific cell.

The result is returned as 'x' and 'y' properties of a logical point.

Parameters

  • rx (number) — The 'X' position of the cell
  • ry (number) — The 'Y' position of the cell

Returns

setCursorEnabled(status: boolean)

Whether the blinking cursor must be enabled or disabled.

Parameters

  • status (boolean)

Starts the module:AWT.Timer that makes the cursor blink.

Stops the module:AWT.Timer that makes the cursor blink.

moveCursor(dx: number, dy: number, skipLocked: boolean)

Moves the cursor in the specified x and y directions.

Parameters

  • dx (number) — Amount to move in the 'X' axis
  • dy (number) — Amount to move in the 'Y' axis
  • skipLocked (boolean) — Skip locked cells (wildcards in CrossWord)

findFreeCell( from: module:AWT.Point, dx: number, dy: number, ): module:AWT.Point

Finds the coordinates of the nearest non-locked cell (non-wildcard) moving on the indicated
'X' and 'Y' directions.

Parameters

  • from (module:AWT.Point) — Logical coordinates of the starting point
  • dx (number) — 0 means no movement, 1 go right, -1 go left.
  • dy (number) — 0 means no movement, 1 go down, -1 go up.

Returns

findNextCellWithAttr( startX: number, startY: number, attr: number, dx: number, dy: number, attrState: boolean, ): module:AWT.Point

Finds the first cell with the specified attributes at the specified state, starting
at specified point.

Parameters

  • startX (number) — Starting X coordinate
  • startY (number) — Starting Y coordinate
  • attr (number) — Attribute to check. See module:boxes/TextGrid.TextGrid.flags.
  • dx (number) — 0 means no movement, 1 go right, -1 go left.
  • dy (number) — 0 means no movement, 1 go down, -1 go up.
  • attrState (boolean) — Desired state (enabled or disabled) of attr

Returns

setCursorAt(px: number, py: number, skipLocked: boolean)

Sets the blinking cursor at a specific point

Parameters

  • px (number) — X coordinate
  • py (number) — Y coordinate
  • skipLocked (boolean) — Skip locked (wildcard) cells

setUseCursor(value: boolean)

Sets the useCursor property of this text grid

Parameters

  • value (boolean)

getCursor(): module:AWT.Point

Gets the current position of the blinking cursor

Returns

countCharsLike(ch: string): number

Counts the number of cells of this grid with the specified character

Parameters

  • ch (string)

Returns

  • number

getNumCells(): number

Gets the number of cells of this grid

Returns

  • number

countCoincidences(checkCase: boolean): number

Counts the number of coincidences between the answers array and the current content of this grid

Parameters

  • checkCase (boolean) — Make comparisions case-sensitive

Returns

  • number

isCellOk(px: number, py: number, checkCase: boolean): boolean

Checks if a specific cell is equivalent to the content of answers at its position

Parameters

  • px (number) — X coordinate
  • py (number) — Y coordinate
  • checkCase (boolean) — Make comparisions case-sensitive

Returns

  • boolean

getLogicalCoords( devicePoint: module:AWT.Point, ): module:AWT.Point

Gets the logical coordinates (in 'cell' units) of a device point into the grid

Parameters

Returns

isValidCell(px: number, py: number): boolean

Checks if the specified logical coordinates are inside the valid bounds of the grid.

Parameters

  • px (number) — 'X' coordinate
  • py (number) — 'Y' coordinate

Returns

  • boolean

setCharAt(px: number, py: number, ch: string)

Sets the specified character as a content of the cell at specified coordinates

Parameters

  • px (number) — 'X' coordinate
  • py (number) — 'Y' coordinate
  • ch (string) — The character to set.

getCharAt(px: number, py: number): string

Gets the character of the cell at the specified coordinates

Parameters

  • px (number) — 'X' coordinate
  • py (number) — 'Y' coordinate

Returns

  • string

getStringBetween( x0: number, y0: number, x1: number, y1: number, ): string

Gets the text formed by the letters between two cells that share a straight line on the grid.
The text can be formed horizontally, vertically and diagonal, both in left-to-right or
right-to-left direction.

Parameters

  • x0 (number) — 'X' coordinate of the first cell
  • y0 (number) — 'Y' coordinate of the first cell
  • x1 (number) — 'X' coordinate of the second cell
  • y1 (number) — 'Y' coordinate of the second cell

Returns

  • string

setAttributeBetween( x0: number, y0: number, x1: number, y1: number, attribute: number, value: boolean, )

Sets a specific attribute to all cells forming a straight line between two cells on the grid.

Parameters

  • x0 (number) — 'X' coordinate of the first cell
  • y0 (number) — 'Y' coordinate of the first cell
  • x1 (number) — 'X' coordinate of the second cell
  • y1 (number) — 'Y' coordinate of the second cell
  • attribute (number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.
  • value (boolean) — Whether to set or unset the attribute.

setAttribute( px: number, py: number, attribute: number, state: boolean, )

Sets or unsets a specifi attrobut to a cell.

Parameters

  • px (number) — The 'X' coordinate of the cell
  • py (number) — The 'Y' coordinate of the cell
  • attribute (number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.
  • state (boolean) — Whether to set or unset the attribute.

setAllCellsAttribute(attribute: number, state: boolean)

Sets the specified attribute to all cells.

Parameters

getCellAttribute( px: number, py: number, attribute: number, ): boolean

Gets the specified attribute of a cell

Parameters

  • px (number) — The 'X' coordinate of the cell
  • py (number) — The 'Y' coordinate of the cell
  • attribute (number) — The binary flag representing this attribute. See module:boxes/TextGrid.TextGrid.flags.

Returns

  • boolean

getCellRect(px: number, py: number): module:AWT.Rectangle

Gets the rectangle enclosing a specific cell

Parameters

  • px (number) — The 'X' coordinate of the cell
  • py (number) — The 'Y' coordinate of the cell

Returns

getCellBorderBounds( px: number, py: number, ): module:AWT.Rectangle

Gets the rectangle enclosing a specific cell, including the border thick.

Parameters

  • px (number) — The 'X' coordinate of the cell
  • py (number) — The 'Y' coordinate of the cell

Returns

repaintCell(px: number, py: number)

Repaints a cell

Parameters

  • px (number) — The 'X' coordinate of the cell
  • py (number) — The 'Y' coordinate of the cell

getPreferredSize(): module:AWT.Dimension

Gets the preferred size of this grid

Returns

getMinimumSize(): module:AWT.Dimension

Gets the minimum size of this grid

Returns

getScaledSize(scale: number): module:AWT.Dimension

Scales the grid to a new size

Parameters

  • scale (number) — The factor used to multiply all coordinates and sizes

Returns

setBounds( rect: AWT.Rectangle | number, y?: number, w?: number, h?: number, )

Overrides module:boxes/AbstractBox.AbstractBox#setBounds

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

updateContent( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, )

Overrides module:boxes/AbstractBox.AbstractBox#updateContent

Parameters

Makes the cursor blink, alternating between two states. This method should be called only by
module:boxes/TextGrid.TextGrid#cursorTimer

Parameters

  • status (boolean)

end()

Overrides: module:boxes/AbstractBox.AbstractBox#end

Stops the cursor timer if not null and active

setParent(parent: module:boxes/AbstractBox.AbstractBox)

Inherited from module:boxes/AbstractBox.AbstractBox#setParent

Overrides: module:boxes/AbstractBox.AbstractBox#setParent

Setter method for parent

Parameters

getParent(): module:boxes/AbstractBox.AbstractBox

Inherited from module:boxes/AbstractBox.AbstractBox#getParent

Overrides: module:boxes/AbstractBox.AbstractBox#getParent

Gets the current parent of this box

Returns

setContainer(newContainer: module:AWT.Container)

Inherited from module:boxes/AbstractBox.AbstractBox#setContainer

Overrides: module:boxes/AbstractBox.AbstractBox#setContainer

Setter method for container

Parameters

getContainerX(): module:AWT.Container

Inherited from module:boxes/AbstractBox.AbstractBox#getContainerX

Overrides: module:boxes/AbstractBox.AbstractBox#getContainerX

Gets the container attribute of this box, without checking its parent

Returns

getContainerResolve(): module:AWT.Container

Inherited from module:boxes/AbstractBox.AbstractBox#getContainerResolve

Overrides: module:boxes/AbstractBox.AbstractBox#getContainerResolve

Gets the container associated to this box, asking its parents when null.

Returns

invalidate(rect: module:AWT.Rectangle)

Inherited from module:boxes/AbstractBox.AbstractBox#invalidate

Overrides: module:boxes/AbstractBox.AbstractBox#invalidate

Invalidates the zone corresponding to this box in the associated module:AWT.Container, if any.

Parameters

  • rect (module:AWT.Rectangle) — The rectangle to be invalidated. When null, it's the full
    container area.

setBoxBase(boxBase: module:boxes/BoxBase.BoxBase)

Inherited from module:boxes/AbstractBox.AbstractBox#setBoxBase

Overrides: module:boxes/AbstractBox.AbstractBox#setBoxBase

Sets the BoxBase of this box

Parameters

getBoxBaseResolve(): module:boxes/BoxBase.BoxBase

Inherited from module:boxes/AbstractBox.AbstractBox#getBoxBaseResolve

Overrides: module:boxes/AbstractBox.AbstractBox#getBoxBaseResolve

Gets the real BoxBase associated to this box, scanning down parent relationships.

Returns

setShape(sh: module:AWT.Shape)

Inherited from module:boxes/AbstractBox.AbstractBox#setShape

Overrides: module:boxes/AbstractBox.AbstractBox#setShape

Sets the shape used to draw the content of this box

Parameters

getShape(): module:AWT.Shape

Inherited from module:boxes/AbstractBox.AbstractBox#getShape

Overrides: module:boxes/AbstractBox.AbstractBox#getShape

Gets the current shape used in this box

Returns

contains(p: module:AWT.Point): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#contains

Check if this box contains the specified point

Parameters

Returns

  • boolean

setBounds( rect: AWT.Rectangle | number, y?: number, w?: number, h?: number, ): module:AWT.Rectangle

Inherited from module:boxes/TextGrid.TextGrid#setBounds

Overrides: module:boxes/AbstractBox.AbstractBox#setBounds

Overrides module:boxes/AbstractBox.AbstractBox#setBounds

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

Returns

moveTo(newPos: AWT.Point | number, y?: number)

Inherited from module:boxes/AbstractBox.AbstractBox#moveTo

Overrides: module:boxes/AbstractBox.AbstractBox#moveTo

Sets a new location for this box. In JClic this method was named setLocation

Parameters

  • newPos (AWT.Point | number) — A point or the x coordinate of a new point.
  • y (number, optional) — The y coordinate of a new point.

moveBy(dx: number, dy: number)

Inherited from module:boxes/AbstractBox.AbstractBox#moveBy

Overrides: module:boxes/AbstractBox.AbstractBox#moveBy

Sets a new location to this box. In JClic this method was named translate.

Parameters

  • dx (number) — The displacement on the X axis
  • dy (number) — The displacement on the Y axis

setSize(width: number, height: number)

Inherited from module:boxes/AbstractBox.AbstractBox#setSize

Overrides: module:boxes/AbstractBox.AbstractBox#setSize

Changes the size of this box

Parameters

  • width (number)
  • height (number)

hasBorder(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#hasBorder

Overrides: module:boxes/AbstractBox.AbstractBox#hasBorder

Checks if this box has border

Returns

  • boolean

setBorder(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setBorder

Overrides: module:boxes/AbstractBox.AbstractBox#setBorder

Sets/unsets a border to this box

Parameters

  • newVal (boolean) — true to set a border.

isVisible(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isVisible

Overrides: module:boxes/AbstractBox.AbstractBox#isVisible

Checks if this box is fully visible

Returns

  • boolean

setVisible(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setVisible

Overrides: module:boxes/AbstractBox.AbstractBox#setVisible

Sets this box visible or invisible

Parameters

  • newVal (boolean) — true for visible

setHostedComponentVisible()

Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentVisible

Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentVisible

Makes module:boxes/AbstractBox.AbstractBox#$hostedComponent visible or invisible, based on the value of
the AbstractBox visible flag.

isTemporaryHidden(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isTemporaryHidden

Overrides: module:boxes/AbstractBox.AbstractBox#isTemporaryHidden

Checks if this box is temporary hidden

Returns

  • boolean

setTemporaryHidden(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setTemporaryHidden

Overrides: module:boxes/AbstractBox.AbstractBox#setTemporaryHidden

Makes this box temporary hidden (newVal true) or resets its original state (newVal false)

Parameters

  • newVal (boolean)

isInactive(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isInactive

Overrides: module:boxes/AbstractBox.AbstractBox#isInactive

Checks if this box is currently inactive.

Returns

  • boolean

setInactive(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setInactive

Overrides: module:boxes/AbstractBox.AbstractBox#setInactive

Makes this box active (false) or inactive (true)

Parameters

  • newVal (boolean)

isInverted(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isInverted

Overrides: module:boxes/AbstractBox.AbstractBox#isInverted

Checks if this box is in inverted state.

Returns

  • boolean

setInverted(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setInverted

Overrides: module:boxes/AbstractBox.AbstractBox#setInverted

Puts this box in inverted mode or restores its original state.

Parameters

  • newVal (boolean)

isMarked(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isMarked

Overrides: module:boxes/AbstractBox.AbstractBox#isMarked

Checks if this box is marked

Returns

  • boolean

setMarked(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setMarked

Overrides: module:boxes/AbstractBox.AbstractBox#setMarked

Sets this box in marked mode, or restores its original state.

Parameters

  • newVal (boolean)

isFocused(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isFocused

Overrides: module:boxes/AbstractBox.AbstractBox#isFocused

Checks if this box has the input focus

Returns

  • boolean

setFocused(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setFocused

Overrides: module:boxes/AbstractBox.AbstractBox#setFocused

Sets or unsets the input focus to this box.

Parameters

  • newVal (boolean)

isAlternative(): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#isAlternative

Overrides: module:boxes/AbstractBox.AbstractBox#isAlternative

Checks if this box is in alternative state.

Returns

  • boolean

setAlternative(newVal: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setAlternative

Overrides: module:boxes/AbstractBox.AbstractBox#setAlternative

Sets this box in alternative mode, or restores its original state.

Parameters

  • newVal (boolean)

update( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, )

Inherited from module:boxes/AbstractBox.AbstractBox#update

Overrides: module:boxes/AbstractBox.AbstractBox#update

Draws the content of this box on an HTML canvas element. At this level, only background
and border are painted/stroked. Derived classes should implement specific drawing tasks in
module:boxes/AbstractBox.AbstractBox#updateContent.

Parameters

updateContent( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, )

Inherited from module:boxes/TextGrid.TextGrid#updateContent

Overrides: module:boxes/AbstractBox.AbstractBox#updateContent

Overrides module:boxes/AbstractBox.AbstractBox#updateContent

Parameters

drawBorder(ctx: external:CanvasRenderingContext2D)

Inherited from module:boxes/AbstractBox.AbstractBox#drawBorder

Overrides: module:boxes/AbstractBox.AbstractBox#drawBorder

Draws the box border

Parameters

getBorderBounds(): module:AWT.Rectangle

Inherited from module:boxes/AbstractBox.AbstractBox#getBorderBounds

Overrides: module:boxes/AbstractBox.AbstractBox#getBorderBounds

Returns the enclosing Rectangle of this box including its border (if any)

Returns

setHostedComponent($hc: external:jQuery)

Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponent

Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponent

Sets the $hostedComponent member.

Parameters

getHostedComponent(): external:jQuery

Inherited from module:boxes/AbstractBox.AbstractBox#getHostedComponent

Overrides: module:boxes/AbstractBox.AbstractBox#getHostedComponent

Gets the current $hostedComponent member

Returns

setHostedComponentColors()

Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentColors

Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentColors

Sets $hostedComponent colors and other css properties
based on the current BoxBase of this box.

setHostedComponentBorder()

Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentBorder

Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentBorder

Sets the $hostedComponent border, based on the current
BoxBase of this box.

setHostedComponentBounds(_sizeChanged: boolean)

Inherited from module:boxes/AbstractBox.AbstractBox#setHostedComponentBounds

Overrides: module:boxes/AbstractBox.AbstractBox#setHostedComponentBounds

Places and resizes $hostedComponent, based on the size
and position of this box.

Parameters

  • _sizeChanged (boolean) — true when this ActiveBox has changed its size

getBounds(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#getBounds

Overrides: module:boxes/AbstractBox.AbstractBox#getBounds

Gets the enclosing Rectangle of this Shape.

Returns

equals(r: module:AWT.Shape): boolean

Inherited from module:AWT.Rectangle#equals

Overrides: module:boxes/AbstractBox.AbstractBox#equals

Checks if two shapes are equivalent.

Parameters

Returns

  • boolean

clone(): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#clone

Overrides: module:boxes/AbstractBox.AbstractBox#clone

Clones this Rectangle

Returns

scaleBy(delta: Point | Dimension): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#scaleBy

Overrides: module:boxes/AbstractBox.AbstractBox#scaleBy

Multiplies the dimension of the Shape by the specified delta amount.

Parameters

  • delta (Point | Dimension) — Object containing the X and Y ratio to be scaled.

Returns

grow(dx: number, dy: number): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#grow

Overrides: module:boxes/AbstractBox.AbstractBox#grow

Expands the boundaries of this shape. This affects the current position and dimension.

Parameters

  • dx (number) — The amount to grow (or decrease) in horizontal direction
  • dy (number) — The amount to grow (or decrease) in vertical direction

Returns

getOppositeVertex(): module:AWT.Point

Inherited from module:AWT.Rectangle#getOppositeVertex

Overrides: module:boxes/AbstractBox.AbstractBox#getOppositeVertex

Gets the module:AWT.Point corresponding to the lower-right vertex of the Rectangle.

Returns

add(shape: module:AWT.Shape): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#add

Overrides: module:boxes/AbstractBox.AbstractBox#add

Adds the boundaries of another shape to the current one

Parameters

Returns

getCoords(): string

Inherited from module:AWT.Rectangle#getCoords

Overrides: module:boxes/AbstractBox.AbstractBox#getCoords

Gets a string with the co-ordinates of the upper-left and lower-right vertexs of this rectangle,
(with values rounded to int)

Returns

  • string

getAttributes(): object

Inherited from module:AWT.Rectangle#getAttributes

Overrides: module:boxes/AbstractBox.AbstractBox#getAttributes

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns

  • object

setAttributes(data: object): module:AWT.Rectangle

Inherited from module:AWT.Rectangle#setAttributes

Overrides: module:boxes/AbstractBox.AbstractBox#setAttributes

Reads the properties of this Rectangle from a data object

Parameters

  • data (object) — The data object to be parsed

Returns

intersects(_r: module:AWT.Rectangle): boolean

Inherited from module:AWT.Shape#intersects

Overrides: module:boxes/AbstractBox.AbstractBox#intersects

Checks if the provided Rectangle r intersects with this shape.

Parameters

Returns

  • boolean

fill( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#fill

Overrides: module:boxes/AbstractBox.AbstractBox#fill

Fills the Shape with the current style in the provided HTML canvas context

Parameters

Returns

stroke( ctx: external:CanvasRenderingContext2D, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#stroke

Overrides: module:boxes/AbstractBox.AbstractBox#stroke

Draws this shape in the provided HTML canvas 2D rendering context.

Parameters

Returns

preparePath( ctx: external:CanvasRenderingContext2D, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#preparePath

Overrides: module:boxes/AbstractBox.AbstractBox#preparePath

Prepares an HTML canvas 2D rendering context with a path that can be used to stroke a line,
to fill a surface or to define a clipping region.

Parameters

Returns

clip( ctx: external:CanvasRenderingContext2D, fillRule?: string, ): external:CanvasRenderingContext2D

Inherited from module:AWT.Shape#clip

Overrides: module:boxes/AbstractBox.AbstractBox#clip

Creates a clipping region on the specified HTML canvas 2D rendering context

Parameters

  • ctx (external:CanvasRenderingContext2D) — The rendering context
  • fillRule (string, optional, default: "'nonzero'") — Can be 'nonzero' (default when not set) or 'evenodd'

Returns

isRect(): boolean

Inherited from module:AWT.Shape#isRect

Overrides: module:boxes/AbstractBox.AbstractBox#isRect

Shorthand method for determining if a Shape is an Rectangle

Returns

  • boolean

toString(): string

Inherited from module:AWT.Shape#toString

Overrides: module:boxes/AbstractBox.AbstractBox#toString

Overwrites the original 'Object.toString' method with a more descriptive text

Returns

  • string

contains(p: module:AWT.Point): boolean

Inherited from module:boxes/AbstractBox.AbstractBox#contains

Check if this box contains the specified point

Parameters

Returns

  • boolean

setBounds( rect: AWT.Rectangle | number, y?: number, w?: number, h?: number, ): module:AWT.Rectangle

Inherited from module:boxes/TextGrid.TextGrid#setBounds

Overrides: module:boxes/AbstractBox.AbstractBox#setBounds

Overrides module:boxes/AbstractBox.AbstractBox#setBounds

Parameters

  • rect (AWT.Rectangle | number) — An AWT.Rectangle object, or the x coordinate of the
    upper-left corner of a new rectangle.
  • y (number, optional) — y coordinate of the upper-left corner of the new rectangle.
  • w (number, optional) — Width of the new rectangle.
  • h (number, optional) — Height of the new rectangle.

Returns

updateContent( ctx: external:CanvasRenderingContext2D, dirtyRegion?: module:AWT.Rectangle, )

Inherited from module:boxes/TextGrid.TextGrid#updateContent

Overrides: module:boxes/AbstractBox.AbstractBox#updateContent

Overrides module:boxes/AbstractBox.AbstractBox#updateContent

Parameters

Static Methods

createEmptyGrid( parent: module:boxes/AbstractBox.AbstractBox, container: module:AWT.Container, x: number, y: number, tgc: module:boxes/TextGridContent.TextGridContent, wildTransparent: boolean, ): module:boxes/TextGrid.TextGrid

Factory constructor that creates an empty grid based on a TextGridContent

Parameters

  • parent (module:boxes/AbstractBox.AbstractBox) — The AbstractBox to which the text grid belongs
  • container (module:AWT.Container) — The container where the text grid will be placed.
  • x (number) — X coordinate of the upper left corner of the grid
  • y (number) — Y coordinate of the upper left corner of the grid
  • tgc (module:boxes/TextGridContent.TextGridContent) — Object with the content and other settings of the grid
  • wildTransparent (boolean) — When true, the wildcard character will be transparent

Returns

buildShape(data: object): module:AWT.Shape

Inherited from module:AWT.Shape

Builds a shape based on the provided data object.
Data should contain a 'type' member, specifying the type of shape requested ('rect', 'ellipse', 'rectangle' or 'path')

Parameters

  • data (object) — Specific data for this shape

Returns

Instance Fields

nRows: number

Number of rows

nCols: number

Number of columns

chars: Array.<Array.<string>>

Two-dimension array of characters

answers: Array.<Array.<string>>

Two-dimension array with the expected characters, used to check user's answers.

attributes: Array.<Array.<number>>

Two-dimension array of bytes used as containers of boolean attributes

  • See:
    • TextGrid.flags

cellWidth: number

The cell width, in pixels

cellHeight: number

The cell height, in pixels

preferredBounds: module:AWT.Rectangle

The preferred bounds of this grid

wild: string

The character to be used as wildcard

randomChars: string

Characters that can be used when randomizing the content of this grid

  • See:
    • TextGridContent#randomChars

cursorEnabled: boolean

Whether the blinking cursor is enabled or disabled

useCursor: boolean

Whether this grid uses a blinking cursor or not

cursor: module:AWT.Point

The current position of the cursor

true when the cursor is "blinking" (cell drawn with BoxBase inverse attributes)

cursorTimer: module:AWT.Timer

Controls the blinking of the cursor

wildTransparent: boolean

Whether the wildcard character is transparent or opaque

parent: module:boxes/AbstractBox.AbstractBox

Inherited from module:boxes/AbstractBox.AbstractBox#parent

Overrides: module:boxes/AbstractBox.AbstractBox#parent

The parent AbstractBox (can be null)

container: module:AWT.Container

Inherited from module:boxes/AbstractBox.AbstractBox#container

Overrides: module:boxes/AbstractBox.AbstractBox#container

The Container to which this AbstractBox belongs

boxBase: module:boxes/BoxBase.BoxBase

Inherited from module:boxes/AbstractBox.AbstractBox#boxBase

Overrides: module:boxes/AbstractBox.AbstractBox#boxBase

The BoxBase related to this AbstractBox. When null, the parent can provide an
alternative one.

border: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#border

Overrides: module:boxes/AbstractBox.AbstractBox#border

Whether this box has a border or not

shape: module:AWT.Shape

Inherited from module:boxes/AbstractBox.AbstractBox#shape

Overrides: module:boxes/AbstractBox.AbstractBox#shape

The shape of this box (the box Rectangle or a special Shape, if set)

specialShape: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#specialShape

Overrides: module:boxes/AbstractBox.AbstractBox#specialShape

Whether this box has a shape that is not a rectangle

visible: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#visible

Overrides: module:boxes/AbstractBox.AbstractBox#visible

Whether this box is visible or not

temporaryHidden: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#temporaryHidden

Overrides: module:boxes/AbstractBox.AbstractBox#temporaryHidden

Used to temporary hide a box while other drawing operations are done

tmpTrans: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#tmpTrans

Overrides: module:boxes/AbstractBox.AbstractBox#tmpTrans

Cells with this attribute will be transparent but with painted border

inactive: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#inactive

Overrides: module:boxes/AbstractBox.AbstractBox#inactive

Whether this box is active or inactive

inverted: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#inverted

Overrides: module:boxes/AbstractBox.AbstractBox#inverted

Whether this box must be displayed with inverted or regular colors

alternative: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#alternative

Overrides: module:boxes/AbstractBox.AbstractBox#alternative

Whether this box must be displayed with alternative or regular color and font settings

marked: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#marked

Overrides: module:boxes/AbstractBox.AbstractBox#marked

Whether this box is marked (selected) or not

focused: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#focused

Overrides: module:boxes/AbstractBox.AbstractBox#focused

Whether this box holds the input focus

accessibleText: string

Inherited from module:boxes/AbstractBox.AbstractBox#accessibleText

Overrides: module:boxes/AbstractBox.AbstractBox#accessibleText

Text to be used in accessible contexts

role: string

Inherited from module:boxes/AbstractBox.AbstractBox#role

Overrides: module:boxes/AbstractBox.AbstractBox#role

Describes the main role of this box on the activity. Useful in wai-aria descriptions.

$accessibleElement: external:jQuery

Inherited from module:boxes/AbstractBox.AbstractBox#$accessibleElement

Overrides: module:boxes/AbstractBox.AbstractBox#$accessibleElement

DOM element used to display this cell content in wai-aria contexts

accessibleAlwaysActive: boolean

Inherited from module:boxes/AbstractBox.AbstractBox#accessibleAlwaysActive

Overrides: module:boxes/AbstractBox.AbstractBox#accessibleAlwaysActive

Flag indicating that $accessibleElement should be always active

$hostedComponent: external:jQuery

Inherited from module:boxes/AbstractBox.AbstractBox#$hostedComponent

Overrides: module:boxes/AbstractBox.AbstractBox#$hostedComponent

An external JQuery DOM element hosted by this box

type: string

Inherited from module:AWT.Rectangle#type

Overrides: module:boxes/AbstractBox.AbstractBox#type

Shape type id

dim: module:AWT.Dimension

Inherited from module:AWT.Rectangle#dim

Overrides: module:boxes/AbstractBox.AbstractBox#dim

The Dimension of the Rectangle

pos: module:AWT.Point

Inherited from module:AWT.Shape#pos

Overrides: module:boxes/AbstractBox.AbstractBox#pos

The current position of the shape

Other

defaults: object

TextGrid default values

flags: object

Binary flags used to mark status