Phoenard
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PHN_WidgetContainer Class Reference

A container for storing multiple PHN_Widget instances. More...

#include <PHNWidget.h>

Inheritance diagram for PHN_WidgetContainer:
PHN_Display PHN_Widget PHN_BarGraph PHN_Button PHN_ButtonGrid PHN_Gauge PHN_ItemList PHN_Keyboard PHN_Label PHN_LineGraph PHN_NumberBox PHN_Scrollbar PHN_TextBox

Public Member Functions

 PHN_WidgetContainer (void)
 Constructor for a new widget container.
 
void updateWidgets (bool update, bool draw, bool forceRedraw)
 Updates all the widgets contained. More...
 
void addWidget (PHN_Widget &widget)
 Adds a single widget. More...
 
void removeWidget (PHN_Widget &widget)
 Removes a single widget. More...
 
void clearWidgets ()
 Removes all contained widgets. More...
 
PHN_Widgetwidget (int index)
 Gets the widget stored at an index.
 
const int widgetCount ()
 Gets how many widgets are stored.
 

Protected Member Functions

void clearSilent ()
 Removes all child widgets from this container without handling proper redrawing. More...
 
void setWidgetCapacity (int capacity)
 Resizes the internal array of widgets to a new capacity. More...
 

Protected Attributes

bool deleteAddedWidgets
 Sets whether added widgets are deleted (were added with new)
 

Detailed Description

A container for storing multiple PHN_Widget instances.

The adding and removing of widgets is handled in such a way that they are properly (re)drawn. Removing a widget fills its contents with the background color set to erase it properly. Switching between what widgets are displayed is made easier this way. It is a more efficient alternative to filling the entire screen with a color and redrawing the other widgets.

A widget itself can also hold multiple child-widgets, which are drawn and updated with the parent widget. If you, for example, need to combine multiple widgets together into a single user control, such as a keyboard, this can be done that way.

Make sure to set the bounds right after constructing a widget. It is best to set the colors afterwards (unless defaults are used) and then any other widget properties that have to be set. Please read the documentation/examples of a widget before use to find out which functions have to be called before use. Rule of thumb: widgets that have a range or dimensions require these functions to be called before it can be used properly.

Member Function Documentation

void PHN_WidgetContainer::addWidget ( PHN_Widget widget)

Adds a single widget.

The widget is not drawn until the root display is updated.

void PHN_WidgetContainer::clearSilent ( )
protected

Removes all child widgets from this container without handling proper redrawing.

Use this when the container has to be deleted from memory. After silently clearing the container is not to be used again.

void PHN_WidgetContainer::clearWidgets ( )

Removes all contained widgets.

The removed widgets are not un-drawn until the root display is updated.

void PHN_WidgetContainer::removeWidget ( PHN_Widget widget)

Removes a single widget.

The removed widget is not un-drawn until the root display is updated.

void PHN_WidgetContainer::setWidgetCapacity ( int  capacity)
protected

Resizes the internal array of widgets to a new capacity.

Widgets falling outside the range are undrawn and deleted (if specified)

void PHN_WidgetContainer::updateWidgets ( bool  update,
bool  draw,
bool  forceRedraw 
)

Updates all the widgets contained.

Parameters
[in]updateWhether to logic-update the widgets
[in]drawWhether to draw invalidated widgets
[in]forceRedrawWhether to force draw the widgets

The documentation for this class was generated from the following files: