C4 Engine
C4 Engine API Documentation

class Widget

Defined in:  C4Widgets.h
The Widget class represents a widget in a user interface.
Definition

class Widget : public Tree<Widget>, public ListElement<Widget>, public HashTableElement<Widget>,

public Transformable, public ExclusiveObservable<Widget, const WidgetEventData *>, public LinkTarget<Widget>,

public Packable, public Configurable, public Registrable<Widget, WidgetRegistration>

Member Functions
Widget::GetWidgetType Returns the widget type.
Widget::GetWidgetKey Returns the widget key.
Widget::SetWidgetKey Sets the widget key.
Widget::GetNextWidgetWithSameKey Returns the next widget having the same key.
 
Widget::GetWidgetState Returns the widget state.
Widget::SetWidgetState Sets the widget state.
Widget::GetGlobalWidgetState Returns the global widget state.
Widget::WidgetEnabled Returns a boolean value indicating whether a widget is enabled.
Widget::WidgetVisible Returns a boolean value indicating whether a widget is visible.
Widget::EnableWidget Enables a widget.
Widget::DisableWidget Disables a widget.
Widget::ShowWidget Shows a widget.
Widget::HideWidget Hides a widget.
 
Widget::GetWidgetSize Returns the widget size.
Widget::SetWidgetSize Sets the widget width and height.
Widget::GetWidgetTransform Returns a widget's transform.
Widget::SetWidgetTransform Sets a widget's transform.
Widget::SetWidgetMatrix3D Sets the upper-left 3 × 3 portion of a widget's transform.
Widget::GetWidgetPosition Returns a widget's position.
Widget::SetWidgetPosition Sets a widget's position.
 
Widget::GetWidgetColor Returns a widget color.
Widget::SetWidgetColor Sets a widget color.
Widget::SetWidgetAlpha Sets the alpha channel of a widget color.
 
Widget::GetRootWidget Returns the root widget in a tree.
Widget::GetOwningWindow Returns the window to which a widget belongs.
Widget::GetPanelController Returns the panel controller to which a widget belongs.
 
Widget::AddSprocket Adds a sprocket to a widget.
Widget::RemoveSprocket Removes a sprocket from a widget.
Widget::GetFirstSprocket Returns the first sprocket for a widget.
Widget::GetLastSprocket Returns the last sprocket for a widget.
 
Widget::GetBalloonType Returns the balloon type for a widget.
Widget::GetBalloonString Returns the balloon string for a widget.
Widget::SetBalloon Sets the balloon type and string for a widget.
 
Widget::SetBuildFlag Indicates that a widget needs to be rebuilt.
Widget::BuildWidget Builds the geometric structure of a widget.
 
Widget::TestPosition Returns the widget part corresponding to a mouse position.
Widget::HandleMouseEvent Called when the user interacts with a widget using the mouse.
Widget::HandleKeyboardEvent Called when the user interacts with a widget using the keyboard.
Widget::PostWidgetEvent Posts a widget event.
Widget::ActivateWidget Posts an activate widget event.
Widget::TrackTask Called once per frame while the mouse interacts with a widget.
Widget::FocusTask Called once per frame while a widget has the keyboard focus.
Widget::GetWidgetUsage Returns the widget usage flags.
Widget::SetWidgetUsage Sets the widget usage flags.
 
Widget::LoadPanel Loads a panel resource.
Constructor

Widget(WidgetType type, const Vector2D& size);

Widget(WidgetType type = kWidgetGeneric);

Parameters
type The widget type.
size The size of the widget, in pixels.
Description
The Widget class is the base class for all user interface widgets. It contains information about the widget's identification, the general state of the widget, the widget's transform and size, the type of help balloon attached to the widget, and the list of sprockets that may be dynamically animating the widget.

Most types of widgets are subclasses of the RenderableWidget class, which is a direct subclass of the Widget class, because it contains additional functionality needed for widgets that are actually displayed. Some kinds of widgets are only containers for other widgets, however, and they are subclassed directly from the Widget class. An instance of the Widget class can act as a group for other widgets by constructing a Widget object with the default kWidgetGeneric specified for the type parameter.

When the user interacts with a widget through the mouse or keyboard, the widget receives calls to its Widget::HandleMouseEvent and Widget::HandleKeyboardEvent functions. A widget subclass overrides these functions and handles the events appropriately. When the widget needs to inform an observer that the state of the widget has changed in some way or that the user has activated the widget, it posts a widget event using the Widget::PostWidgetEvent function. Any observer installed by the ExclusiveObservable::SetObserver function then receives the widget event and may take whatever action is necessary.
Base Classes
Tree<Widget> Widgets are organized in a tree hierarchy.
ListElement<Widget> Used internally by the Interface Manager.
HashTableElement<Widget> Widgets with nontrivial keys are organized in a hash table.
Transformable Holds the object-to-world transform for a widget.
ExclusiveObservable<Widget, const WidgetEventData *> Widgets can be observed for state changes by a single observer.
LinkTarget<Widget> Used internally by the Interface Manager.
Packable Widgets can be packed for storage in resources.
Configurable Widgets can define configurable parameters that are exposed as user interface widgets in the Panel Editor.
Registrable<Widget, WidgetRegistration> Custom widget types can be registered with the engine.
See Also

WidgetReg

PanelEffect

PanelController

Sprocket

Wiki Articles

Widgets

Panel Editor