Tabset: Difference between revisions
Appearance
No edit summary |
|||
| Line 14: | Line 14: | ||
GHandle ghLabel1, ghLabel2, ghLabel3; | GHandle ghLabel1, ghLabel2, ghLabel3; | ||
static void createWidgets(void) { | static void createWidgets(void) | ||
{ | |||
GWidgetInit wi; | GWidgetInit wi; | ||
| Line 47: | Line 48: | ||
} | } | ||
int main(void) { | int main(void) | ||
{ | |||
GEvent* pe; | GEvent* pe; | ||
Revision as of 18:00, 27 June 2015
The tabset is a special container widget that manages different tabs. It is pretty much like the tabs in your web browser.
API Reference
The API reference of the Tabset can be found here.
Example
The following example shows how to create a tabset with three pages and adding different widgets to each page.
#include "gfx.h"
GListener gl;
GHandle ghTabset;
GHandle ghPage1, ghPage2, ghPage3;
GHandle ghLabel1, ghLabel2, ghLabel3;
static void createWidgets(void)
{
GWidgetInit wi;
// Apply some default values for GWIN
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Create the Tabset
wi.g.width = 200; wi.g.height = 200; wi.g.x = 10, wi.g.y = 10;
ghTabset = gwinTabsetCreate(0, &wi, GWIN_TABSET_BORDER);
ghPage1 = gwinTabsetAddTab(ghTabset, "Page 1", FALSE);
ghPage2 = gwinTabsetAddTab(ghTabset, "Page 2", FALSE);
ghPage3 = gwinTabsetAddTab(ghTabset, "Page 3", FALSE);
// Add some widgets to Page 1
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 10;
wi.g.parent = ghPage1;
wi.text = "This is page Nr. 1";
ghLabel1 = gwinLabelCreate(0, &wi);
// Add some widgets to Page 2
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 50;
wi.g.parent = ghPage2;
wi.text = "This is page Nr. 2";
ghLabel2 = gwinLabelCreate(0, &wi);
// Add some widgets to Page 3
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 90;
wi.g.parent = ghPage3;
wi.text = "This is page Nr. 3";
ghLabel3 = gwinLabelCreate(0, &wi);
}
int main(void)
{
GEvent* pe;
// Initialize the display
gfxInit();
// Set the widget defaults
gwinSetDefaultFont(gdispOpenFont("UI2"));
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
gdispClear(White);
// create the widget
createWidgets();
// We want to listen for widget events
geventListenerInit(&gl);
gwinAttachListener(&gl);
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
(void)pe;
}
return 0;
}