widget
Inherits |
|
Inherited By | bitmapwidget, textwidget |
Context | widgetcontainer |
The widget object defines functions generic to all widget types. There are no standalone instances of this type, this is a virtual base class.
Interface
bringToFront
function bringToFront()Bring this widget to the front in the container drawing order. The widget will be drawn last (on top). Note that if the container is located below another interface element, this function will not bring the widget on top of that element.
destroy
function destroy()Destroy the widget, removing it from the parent container.
Using the widget reference for operations after a call to destroy may produce invalid operation. Any reference to the widget object should be invalidated (set to nil).
getName
function getName()Get the name assigned to the widget.
Return values
(string)
Name of the widget
getOffset
function getOffset()Get the offset of the widget from its source object and defined anchor position.
Return values
(int)
x-offset from anchor position of the widget
(int)
y-offset from anchor position of the widget
getPosition
function getPosition()Get the final offset of the widget from its source object.
This defines the position of the center of the widget relative to its source object.
Return values
(int)
x-offset position of the widget
(int)
y-offset position of the widget
getSize
function getSize()Get the on screen dimensions of the widget. The actual values and their calculation may vary by widget type.
Return values
(int)
Width of the widget(int)
Height of the widget
getTooltipText
function getTooltipText()Get the tooltip text assigned to the widget.
Return values
(string)
Tooltip text assigned to the widget
isVisible
function isVisible()This function can be used to check if the widget has been toggled hidden.
Return values
(boolean)
Returns true if the widget is visible, false otherwise.
sendToBack
function sendToBack()Send this widget to the back in the container drawing order. The widget will be drawn first (under others). Note that if the container is located above another interface element, this finction will not cause the widget to be drawn under either that element or the widget container itself.
setColor
function setColor(color)Sets the foreground color (i.e. text color or bitmap tint) used when rendering the widget. This setting overrides the color defined in the font used (for text color). To restore the default color, specify nil as the parameter value.
The specified parameter is a color value in a HTML-style string representation, in the format "#AARRGGBB". The components are hexadecimal digits specifying the value of the alpha (transparency), red, green and blue channels, respectively, in the range 0 .. 255. If alpha is zero or not defined, FF is assumed.
Parameters
color (string)
The color to be used, or nil to reset the setting. See above for details on the string format.
setDisplayType
function setDisplayType(displaytype)Sets the display type of the widget (for token widgets only).
“floor” = always show on floor (i.e map) whether in 2D or 2.5D view modes.
”underlay” = always show behind token whether in 2D or 2.5D.
”” = always show in front of token whether in 2D or 2.5D.
Parameters
displaytype (string)
The display type of the widget. Can be “floor”, “underlay”, ““
setEnabled
function setEnabled(state)This function can be used to toggle the widget enabled state. This determines whether mouse events interact with the widget.
Parameters
state (boolean)
A value of true for enabled, false for disabled.
setFrame
function setFrame(name, [leftmargin], [topmargin], [rightmargin], [bottommargin])This function sets a bitmap frame to be used when rendering the widget on the screen. The size of the frame will equal the size of the widget, with optional margins given as parameters. A positive value for the margins will shift the edge of the frame away from the widget center, with a negative value shifting it towards the center of the widget.
Parameters
name (string)
The name of the bitmap frame resource to be used
leftmargin (number) [optional]
The left margin offset, in pixels
topmargin (number) [optional]
The top margin offset, in pixels
rightmargin (number) [optional]
The right margin offset, in pixels
bottommargin (number) [optional]
The bottom margin offset, in pixels
setName
function setName(name)Set the name assigned to the widget.
Parameters
name (string)
The name to be assigned to the widget
setPosition
function setPosition(anchor, x, y)Sets the position of the widget relative to the parent container. The widget can be placed relative to any corner of the container or its center point. The widget will be centered both horizontally and vertically on the anchor point given.
Parameters
anchor (string)
Defines the point on the parent container the widget will be centered on. This string should be a combination of the substrings "left", "top", "right" and "bottom". If either the vertical or horizontal dimension is omitted, the widget will be centered on the container in that direction. To place the widget relative to the center of the container, use the empty string "" or "center".
x (number)
Horizontal offset from the anchor point in pixels. Positive values indicate a shift to the right, negative values to the right.
y (number)
Vertical offset from the anchor point in pixels. Positive values indicate a shift down, negative values down.
setRadialPosition
function setRadialPosition(r, a)Sets the position of the widget relative to the parent container. This function can be used to place widgets radially around the center point of the container. The widget will be centered both horizontally and vertically on the anchor point given.
Parameters
r (number)
The radial distance from the center of the container to the center of the widget, in pixels.
a (number)
The angle of widget placement from the center of the container. A value of zero is directly up, and the angle is measured clockwise from that location. The value should be given as a number from 0 to 100, with the value 100 specifying a complete rotation.
setRotation
function setRotation(angle)Set the angle to be used to draw the contents of the widget. Zero is the default angle.
Parameters
angle (string)
The angle to be used when drawing the widget
setTooltipText
function setTooltipText(text)Set the tooltip assigned to the widget.
Parameters
text (string)
The tooltip to be assigned to the widget
setVisible
function setVisible(state)Set the widget visible or hidden.
Parameters
state (boolean)
If true, the widget will be visible. If false, the widget will be hidden