MAUI::Widget Class Reference
#include <MAUI/Widget.h>
Inheritance diagram for MAUI::Widget:
List of all members.
Detailed Description
A Widget is an object that has a graphical representation and can perform (or be subjected to) (inter)actions by the user. It is abstract, since there is no default implementation of the drawWidget() function.
Examples of components are the images, labels and listboxes you would usually find in a user interface.
The Widget class is the abstract superclass of all MAUI Widgets. It can also be directly inherited to create new Widgets. For simple widgets, all you need to do is to implement the drawWidget() function.
Widgets are rectangular and may not overlap each other. Overlapping widgets lead to undefined rendering behaviour. A widget is clipped by its parent.
Widget constructors take a "parent" argument which, if not NULL, causes the widget being constructed to be added as a child of the parent.
When a Widget is deleted, it deletes all its children as well.
The position of a widget is always expressed relatively to the top left corner of the parent widget.
Widgets have padding parameters, which specify a margin from each side of the widget by which the widgets' content is offset. This applies both to the widgets' own content (such as a the caption of a Label) and its children.
Since mobile devices have different input mechanisms, MAUI Widgets are designed not to depend on any specific form of input. They do not deal with mouse, stylus or key events. Instead, widgets provide logical actions that they can perform. For instance, a listbox does not receive MAK_UP or MAK_DOWN key events - instead, it has the functions selectNextItem() and selectPreviousItem() to move one up or down among the items it contains.
Constructor & Destructor Documentation
MAUI::Widget::Widget |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
width, |
|
|
int |
height, |
|
|
Widget * |
parent |
|
) |
|
|
|
Constructor for Widget. 'x' and 'y' are the relative position of the top left corner of the widget, and 'width' and 'height' is the dimensions of the widget. 'parent' is the parent to the widget and the widget will be automatically added as a child to the parent. If parent equals NULL no parent will be set. |
virtual MAUI::Widget::~Widget |
( |
|
) |
[virtual] |
|
Member Function Documentation
virtual void MAUI::Widget::add |
( |
Widget * |
w |
) |
[virtual] |
|
|
Function used to add childs to a widget. The parent of the children will automatically be set. The widget cannot have a parent already.
Reimplemented in MAUI::Layout, and MAUI::ListBox. |
void MAUI::Widget::setParent |
( |
Widget * |
w |
) |
|
|
|
Function used to set the parent of a widget. The widget will not be added to the parent as a child. The widget cannot have a parent already. |
Widget* MAUI::Widget::getParent |
( |
|
) |
|
|
|
Function to retrieve the parent of a widget. |
|
Function to retrieve a reference to the list of childrens for a widget. |
virtual void MAUI::Widget::draw |
( |
bool |
forceDraw = false |
) |
[virtual] |
|
virtual void MAUI::Widget::update |
( |
|
) |
[virtual] |
|
void MAUI::Widget::requestRepaint |
( |
|
) |
|
|
|
Registers an idle listener with the current environment that will redraw the widget and anything else that may be made dirty by doing so. For instance, if the widget is transparent its parent also has to be repainted, and so on recursively. |
virtual bool MAUI::Widget::isTransparent |
( |
|
) |
const [virtual] |
|
|
Returns whether or not the widget is transparent. A widget is transparent if it has a skin that is transparent in the current selection state (selected/unselected) or if it has no solid background color. |
virtual void MAUI::Widget::setSkin |
( |
WidgetSkin * |
widgetSkin |
) |
[virtual] |
|
|
Assigns a widget skin to be used during the rendering of the widget. What The skin applies to varies depending on the widget. Labels extend the skin over their entire area, while listboxes apply the skin to each individual item they contain. |
void MAUI::Widget::setDrawBackground |
( |
bool |
b = true |
) |
|
|
|
Sets the background drawing state. If b is true, the Widget's background will be drawn - otherwise not. In most cases, the background is either a constant color or a skin. |
void MAUI::Widget::setBackgroundColor |
( |
int |
col |
) |
|
|
|
Returns a pointer to the first child widget or deeper descendant, surrounding the point. Returns NULL if no widget is found. |
Widget* MAUI::Widget::widgetAt |
( |
int |
x, |
|
|
int |
y |
|
) |
|
|
virtual void MAUI::Widget::setPosition |
( |
int |
x, |
|
|
int |
y |
|
) |
[virtual] |
|
|
Sets the widget's position relative to its parent.
Reimplemented in MAUI::Layout. |
const Point& MAUI::Widget::getPosition |
( |
|
) |
const |
|
|
Gets the widget's position relative to its parent. |
const Point& MAUI::Widget::getPaddedPosition |
( |
|
) |
const |
|
|
Gets the widget's padded position relative to its parent. |
virtual void MAUI::Widget::setWidth |
( |
int |
width |
) |
[virtual] |
|
int MAUI::Widget::getWidth |
( |
|
) |
const |
|
|
Returns the width of the widget |
virtual void MAUI::Widget::setHeight |
( |
int |
height |
) |
[virtual] |
|
int MAUI::Widget::getHeight |
( |
|
) |
const |
|
|
Returns the height of the widget |
virtual const Rect& MAUI::Widget::getBounds |
( |
|
) |
[virtual] |
|
|
Returns a Rect containing the absolute screen position of the widget together with its dimensions. |
virtual bool MAUI::Widget::contains |
( |
const Point & |
p |
) |
[virtual] |
|
|
Check if widget surrounds position 'p'. |
virtual bool MAUI::Widget::contains |
( |
int |
x, |
|
|
int |
y |
|
) |
[virtual] |
|
|
Check if widget surrounds position 'x' and 'y'. |
virtual void MAUI::Widget::setSelected |
( |
bool |
selected = true |
) |
[virtual] |
|
|
Set widget selected state (default: true).
Reimplemented in MAUI::EditBox. |
bool MAUI::Widget::isSelected |
( |
|
) |
const |
|
virtual void MAUI::Widget::setEnabled |
( |
bool |
enabled = true |
) |
[virtual] |
|
bool MAUI::Widget::isEnabled |
( |
|
) |
const |
|
virtual void MAUI::Widget::trigger |
( |
|
) |
[virtual] |
|
|
This function is called whenever the widget is "triggered", which is roughly equivalent to having been "clicked" on. However, sice MAUI is independant of input facilities, the more input-neutral concept of triggering is used.
Reimplemented in MAUI::Layout. |
|
returns a reference the the vector of Widget listeners |
void MAUI::Widget::setInputManager |
( |
InputManager * |
inputManager |
) |
|
|
|
Sets the input manager to use for this widget |
virtual void MAUI::Widget::setPaddingLeft |
( |
int |
l |
) |
[virtual] |
|
virtual void MAUI::Widget::setPaddingTop |
( |
int |
t |
) |
[virtual] |
|
virtual void MAUI::Widget::setPaddingRight |
( |
int |
r |
) |
[virtual] |
|
virtual void MAUI::Widget::setPaddingBottom |
( |
int |
b |
) |
[virtual] |
|
|
Set bottom padding height.
Reimplemented in MAUI::Label. |
int MAUI::Widget::getPaddingLeft |
( |
|
) |
const |
|
int MAUI::Widget::getPaddingTop |
( |
|
) |
const |
|
int MAUI::Widget::getPaddingRight |
( |
|
) |
const |
|
int MAUI::Widget::getPaddingBottom |
( |
|
) |
const |
|
|
Get bottom padding height. |
const Rect& MAUI::Widget::getPaddedBounds |
( |
|
) |
const |
|
virtual void MAUI::Widget::setParameter |
( |
const String & |
name, |
|
|
const String & |
value |
|
) |
[virtual] |
|
virtual void MAUI::Widget::drawWidget |
( |
|
) |
[protected, pure virtual] |
|
|
This is the only function that is absolutely neccesary to implement when inheriting Widget to create a custom widget. It is responsible for painting the widget. When it is called, the widget must respect its own padded bounds and not extend rendering beyond that area.
Implemented in MAUI::Image, MAUI::Label, MAUI::Layout, MAUI::ListBox, and MAP::MapWidget. |
void MAUI::Widget::drawBackground |
( |
|
) |
[protected] |
|
void MAUI::Widget::updateAbsolutePosition |
( |
|
) |
[protected] |
|
|
This function is used to regenerate the absolute positions of each widget in the tree. This is done in a depth first manner where each widget takes the parent absolute position and adds it to their own relative position to calculate their absolute position. |
void MAUI::Widget::updateAbsolutePositionChildren |
( |
int |
x, |
|
|
int |
y |
|
) |
[protected] |
|
void MAUI::Widget::updatePaddedBounds |
( |
|
) |
[protected] |
|
|
Used to recalculate the padded bounds from the global bounds. |
bool MAUI::Widget::isDirty |
( |
|
) |
const [protected] |
|
|
Returns the dirty state of the widget, indicating whether it requires to be redrawn or not. When a widget calls requestRepaint(), it's dirty state is set to true. Normally, you shouldn't have to use isDirty() or setDirty() unless possibly when implementing your own widgets. |
void MAUI::Widget::setDirty |
( |
bool |
d = true |
) |
[protected] |
|
|
Sets the dirty state of the widget. |
Friends And Related Function Documentation
Member Data Documentation
Generated on Sat Feb 13 00:15:39 2010 for MoSync 2 beta 1 by
1.4.6-NO