Containers

From uGFX Wiki
Revision as of 17:28, 1 July 2014 by Tectu (Talk | contribs)

Jump to: navigation, search

Note: Make sure you read the widget article first!

The container class is based on the widget. Containers can have children windows which they can place within their borders. Containers control the visibility and enabled state of their children. By making a container invisible you make all its children invisible. Similarly with the enabled state. A list with descriptions of the common container API can be found here.

Container Implementations

These are the currently implemented containers:

Widget creation

Each container provides a creation call with is named gwinCreateXxx() where Xxx is the name of the container. The first parameter is either a pointer to a static container object or NULL. If NULL, the object will be allocated dynamically from the heap. The second parameter is a pointer to a GWidgetInit struct. This struct contains all the attributes which are needed to create the container (position, size, font, colors...):

typedef struct GWidgetInit {
    GWindowInit                g;			// The GWIN initializer
    const char*                text;			// The initial text
    CustomWidgetDrawFunction   customDraw;		// A custom draw function - use NULL for the standard
    void*                      customParam;		// A parameter for the custom draw function (default = NULL)
    const GWidgetStyle*        customStyle;		// A custom style to use - use NULL for the default style
} GWidgetInit;

As the container class is based on the widget and therefore the window class, the widget initialization structure contains a window initialization structure. See window creation to learn more about the window initialization structure.
Examples on how to use this struct correctly can be found on each container documentation page.