Files
love-luigi/doc/classes/Widget.html
2015-12-16 22:23:20 -05:00

878 lines
21 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Reference</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css">
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<h1>LUIGI</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Widgets</h2>
<ul class="nowrap">
<li><a href="../widgets/button.html">button</a></li>
<li><a href="../widgets/check.html">check</a></li>
<li><a href="../widgets/menu.html">menu</a></li>
<li><a href="../widgets/menu.item.html">menu.item</a></li>
<li><a href="../widgets/progress.html">progress</a></li>
<li><a href="../widgets/radio.html">radio</a></li>
<li><a href="../widgets/sash.html">sash</a></li>
<li><a href="../widgets/slider.html">slider</a></li>
<li><a href="../widgets/status.html">status</a></li>
<li><a href="../widgets/stepper.html">stepper</a></li>
<li><a href="../widgets/text.html">text</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/attribute.html">attribute</a></li>
</ul>
<h2>Classes</h2>
<ul class="nowrap">
<li><a href="../classes/Event.html">Event</a></li>
<li><a href="../classes/Layout.html">Layout</a></li>
<li><strong>Widget</strong></li>
</ul>
</div>
<div id="content">
<div id="content_top">
<h1>Class <code>Widget</code></h1>
<p>Widget class.</p>
<p>
</p>
<h2><a href="#Methods">Methods</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Widget:defineAttribute">Widget:defineAttribute (name, descriptor)</a></td>
<td class="summary">Define a custom attribute for this widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:bubbleEvent">Widget:bubbleEvent (eventName[, data])</a></td>
<td class="summary">Fire an event on this widget and each ancestor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getPreviousSibling">Widget:getPreviousSibling ()</a></td>
<td class="summary">Get widget's previous sibling.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getNextSibling">Widget:getNextSibling ()</a></td>
<td class="summary">Get widget's next sibling.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:focus">Widget:focus ()</a></td>
<td class="summary">Attempt to focus the widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getNextNeighbor">Widget:getNextNeighbor ()</a></td>
<td class="summary">Get the next widget, depth-first.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getPreviousNeighbor">Widget:getPreviousNeighbor ()</a></td>
<td class="summary">Get the previous widget, depth-first.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:addChild">Widget:addChild (data)</a></td>
<td class="summary">Add a child to this widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getX">Widget:getX ()</a></td>
<td class="summary">Get the widget's X coordinate.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getY">Widget:getY ()</a></td>
<td class="summary">Get the widget's Y coordinate.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getWidth">Widget:getWidth ()</a></td>
<td class="summary">Get the widget's calculated width.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getHeight">Widget:getHeight ()</a></td>
<td class="summary">Get the widget's calculated height.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getContentWidth">Widget:getContentWidth ()</a></td>
<td class="summary">Get the content width.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getContentHeight">Widget:getContentHeight ()</a></td>
<td class="summary">Get the content height.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:getRectangle">Widget:getRectangle (useMargin, usePadding)</a></td>
<td class="summary">Get x/y/width/height values describing a rectangle within the widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:isAt">Widget:isAt (x, y)</a></td>
<td class="summary">Determine whether a point is within a widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:eachAncestor">Widget:eachAncestor (includeSelf)</a></td>
<td class="summary">Iterate widget's ancestors.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget:reshape">Widget:reshape ()</a></td>
<td class="summary">Reshape the widget.</td>
</tr>
</table>
<h2><a href="#API_Properties">API Properties </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Widget.focused">Widget.focused</a></td>
<td class="summary">Whether this widget has keyboard focus.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.hovered">Widget.hovered</a></td>
<td class="summary">Whether the pointer is within this widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.pressed">Widget.pressed</a></td>
<td class="summary">Whether the pointer was pressed on this widget and not yet released.</td>
</tr>
</table>
<h2><a href="#Internal_Properties">Internal Properties </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Widget.isWidget">Widget.isWidget</a></td>
<td class="summary">Identifies this object as a widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.isReshaping">Widget.isReshaping</a></td>
<td class="summary">Whether the widget is currently being reshaped.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.hasType">Widget.hasType</a></td>
<td class="summary">Whether this widget has a type.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.fontData">Widget.fontData</a></td>
<td class="summary">The <code>Font</code> object associated with the widget.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Widget.textData">Widget.textData</a></td>
<td class="summary">The <code>Text</code> object associated with the widget.</td>
</tr>
</table>
<h2><a href="#Static_Functions">Static Functions </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Widget.register">Widget.register (name, decorator)</a></td>
<td class="summary">Register a custom widget type.</td>
</tr>
</table>
<h2><a href="#Constructor">Constructor</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Luigi.Widget">Luigi.Widget (layout[, data])</a></td>
<td class="summary">Widget pseudo-constructor.</td>
</tr>
</table>
</div>
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
<dl class="function">
<dt>
<a name = "Widget:defineAttribute"></a>
<strong>Widget:defineAttribute (name, descriptor)</strong>
</dt>
<dd>
Define a custom attribute for this widget.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The name of the attribute.
</li>
<li><span class="parameter">descriptor</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
A table, optionally containing <code>get</code> and <code>set</code> functions (see <code>Attribute</code>).
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a></span>
Return this widget for chaining.
</ol>
</dd>
<dt>
<a name = "Widget:bubbleEvent"></a>
<strong>Widget:bubbleEvent (eventName[, data])</strong>
</dt>
<dd>
Fire an event on this widget and each ancestor. </p>
<p>If any event handler returns non-nil, stop the event from propagating.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">eventName</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The name of the Event.
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Information about the event to send to handlers.
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mixed</span></span>
The first value returned by an event handler.
</ol>
</dd>
<dt>
<a name = "Widget:getPreviousSibling"></a>
<strong>Widget:getPreviousSibling ()</strong>
</dt>
<dd>
Get widget's previous sibling.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a> or <span class="type">nil</span></span>
The widget's previous sibling, if any.
</ol>
</dd>
<dt>
<a name = "Widget:getNextSibling"></a>
<strong>Widget:getNextSibling ()</strong>
</dt>
<dd>
Get widget's next sibling.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a> or <span class="type">nil</span></span>
The widget's next sibling, if any.
</ol>
</dd>
<dt>
<a name = "Widget:focus"></a>
<strong>Widget:focus ()</strong>
</dt>
<dd>
Attempt to focus the widget. </p>
<p>Unfocus currently focused widget, and focus this widget if it's focusable.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if this widget was focused, else false.
</ol>
</dd>
<dt>
<a name = "Widget:getNextNeighbor"></a>
<strong>Widget:getNextNeighbor ()</strong>
</dt>
<dd>
Get the next widget, depth-first. </p>
<p>If the widget has children, returns the first child.
Otherwise, returns the next sibling of the nearest possible ancestor.
Cycles back around to the layout root from the last widget in the tree.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a></span>
The next widget in the tree.
</ol>
</dd>
<dt>
<a name = "Widget:getPreviousNeighbor"></a>
<strong>Widget:getPreviousNeighbor ()</strong>
</dt>
<dd>
Get the previous widget, depth-first. </p>
<p>Uses the reverse of the traversal order used by <a href="../classes/Widget.html#Widget:getNextNeighbor">getNextNeighbor</a>.
Cycles back around to the last widget in the tree from the layout root.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a></span>
The previous widget in the tree.
</ol>
</dd>
<dt>
<a name = "Widget:addChild"></a>
<strong>Widget:addChild (data)</strong>
</dt>
<dd>
Add a child to this widget.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a> or <a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
A widget or definition table representing a widget.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a></span>
The newly added child widget.
</ol>
</dd>
<dt>
<a name = "Widget:getX"></a>
<strong>Widget:getX ()</strong>
</dt>
<dd>
Get the widget's X coordinate.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The widget's X coordinate.
</ol>
</dd>
<dt>
<a name = "Widget:getY"></a>
<strong>Widget:getY ()</strong>
</dt>
<dd>
Get the widget's Y coordinate.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The widget's Y coordinate.
</ol>
</dd>
<dt>
<a name = "Widget:getWidth"></a>
<strong>Widget:getWidth ()</strong>
</dt>
<dd>
Get the widget's calculated width.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The widget's calculated width.
</ol>
</dd>
<dt>
<a name = "Widget:getHeight"></a>
<strong>Widget:getHeight ()</strong>
</dt>
<dd>
Get the widget's calculated height.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The widget's calculated height.
</ol>
</dd>
<dt>
<a name = "Widget:getContentWidth"></a>
<strong>Widget:getContentWidth ()</strong>
</dt>
<dd>
Get the content width. </p>
<p>Gets the combined width of the widget's children.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The content width.
</ol>
</dd>
<dt>
<a name = "Widget:getContentHeight"></a>
<strong>Widget:getContentHeight ()</strong>
</dt>
<dd>
Get the content height. </p>
<p>Gets the combined height of the widget's children.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The content height.
</ol>
</dd>
<dt>
<a name = "Widget:getRectangle"></a>
<strong>Widget:getRectangle (useMargin, usePadding)</strong>
</dt>
<dd>
Get x/y/width/height values describing a rectangle within the widget.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">useMargin</span>
<span class="types"><span class="type">boolean</span></span>
Whether to adjust the rectangle based on the widget's margin.
</li>
<li><span class="parameter">usePadding</span>
<span class="types"><span class="type">boolean</span></span>
Whether to adjust the rectangle based on the widget's padding.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">number</span></span>
The upper left corner's X position.</li>
<li>
<span class="types"><span class="type">number</span></span>
The upper left corner's Y position.</li>
<li>
<span class="types"><span class="type">number</span></span>
The rectangle's width</li>
<li>
<span class="types"><span class="type">number</span></span>
The rectangle's height</li>
</ol>
</dd>
<dt>
<a name = "Widget:isAt"></a>
<strong>Widget:isAt (x, y)</strong>
</dt>
<dd>
Determine whether a point is within a widget.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">x</span>
<span class="types"><span class="type">number</span></span>
The point's X coordinate.
</li>
<li><span class="parameter">y</span>
<span class="types"><span class="type">number</span></span>
The point's Y coordinate.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
true if the point is within the widget, else false.
</ol>
</dd>
<dt>
<a name = "Widget:eachAncestor"></a>
<strong>Widget:eachAncestor (includeSelf)</strong>
</dt>
<dd>
Iterate widget's ancestors.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">includeSelf</span>
<span class="types"><span class="type">boolean</span></span>
Whether to include this widget as the first result.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">function</span></span>
Returns an iterator function that returns widgets.
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">
<span class="keyword">for</span> ancestor <span class="keyword">in</span> myWidget:eachAncestor(<span class="keyword">true</span>) <span class="keyword">do</span>
<span class="global">print</span>(widget.<span class="global">type</span> <span class="keyword">or</span> <span class="string">'generic'</span>)
<span class="keyword">end</span></pre>
</ul>
</dd>
<dt>
<a name = "Widget:reshape"></a>
<strong>Widget:reshape ()</strong>
</dt>
<dd>
Reshape the widget. </p>
<p>Clears calculated widget dimensions, allowing them to be recalculated, and
fires a Reshape event (does not bubble). Called recursively for each child.</p>
<p>When setting a widget's width or height, this function is automatically called
on the parent widget.
</dd>
</dl>
<h2 class="section-header has-description"><a name="API_Properties"></a>API Properties </h2>
<div class="section-description">
These properties may be useful when creating user interfaces,
and are a formal part of the API.
</div>
<dl class="function">
<dt>
<a name = "Widget.focused"></a>
<strong>Widget.focused</strong>
</dt>
<dd>
Whether this widget has keyboard focus. </p>
<p>Can be used by styles and themes. This value is automatically set by
the <code>Input</code> class, and should generally be treated as read-only.
</dd>
<dt>
<a name = "Widget.hovered"></a>
<strong>Widget.hovered</strong>
</dt>
<dd>
Whether the pointer is within this widget. </p>
<p>Can be used by styles and themes. This value is automatically set by
the <code>Input</code> class, and should generally be treated as read-only.
</dd>
<dt>
<a name = "Widget.pressed"></a>
<strong>Widget.pressed</strong>
</dt>
<dd>
Whether the pointer was pressed on this widget and not yet released. </p>
<p>Can be used by styles and themes. This value is automatically set by
the <code>Input</code> class, and should generally be treated as read-only.
</dd>
</dl>
<h2 class="section-header has-description"><a name="Internal_Properties"></a>Internal Properties </h2>
<div class="section-description">
These properties are used internally, but are not likely to be useful
when creating user interfaces; they are not a formal part of the API
and may change at any time.
</div>
<dl class="function">
<dt>
<a name = "Widget.isWidget"></a>
<strong>Widget.isWidget</strong>
</dt>
<dd>
Identifies this object as a widget. </p>
<p>Can be used to determine whether an unknown object is a widget.
</dd>
<dt>
<a name = "Widget.isReshaping"></a>
<strong>Widget.isReshaping</strong>
</dt>
<dd>
Whether the widget is currently being reshaped. </p>
<p>Used internally by <a href="../classes/Widget.html#Widget:reshape">reshape</a> to prevent stack overflows when handling
<code>Reshape</code> events.
</dd>
<dt>
<a name = "Widget.hasType"></a>
<strong>Widget.hasType</strong>
</dt>
<dd>
Whether this widget has a type. </p>
<p>Used by the <a href="../modules/attribute.html#type">type</a> attribute to determine whether to
run the type initializer when the widget's type is set. After a type
initializer has run, <a href="../classes/Widget.html#Widget.hasType">hasType</a> becomes <code>true</code> and no other type
initializers should run on the widget.
</dd>
<dt>
<a name = "Widget.fontData"></a>
<strong>Widget.fontData</strong>
</dt>
<dd>
The <code>Font</code> object associated with the widget.
</dd>
<dt>
<a name = "Widget.textData"></a>
<strong>Widget.textData</strong>
</dt>
<dd>
The <code>Text</code> object associated with the widget.
</dd>
</dl>
<h2 class="section-header "><a name="Static_Functions"></a>Static Functions </h2>
<dl class="function">
<dt>
<a name = "Widget.register"></a>
<strong>Widget.register (name, decorator)</strong>
</dt>
<dd>
Register a custom widget type.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
A unique name for this type of widget.
</li>
<li><span class="parameter">decorator</span>
<span class="types"><span class="type">function(Widget)</span></span>
An initialization function for this type of widget.
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Constructor"></a>Constructor</h2>
<dl class="function">
<dt>
<a name = "Luigi.Widget"></a>
<strong>Luigi.Widget (layout[, data])</strong>
</dt>
<dd>
Widget pseudo-constructor.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">layout</span>
<span class="types"><a class="type" href="../classes/Layout.html#">Layout</a></span>
The layout this widget belongs to.
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
The data definition table for this widget.
This table is identical to the constructed widget.
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../classes/Widget.html#">Widget</a></span>
A Widget instance.
</ol>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-12-16 14:12:04 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>