aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2015-01-03 18:46:46 +1000
committerinmarket <andrewh@inmarket.com.au>2015-01-03 18:46:46 +1000
commit128a3b972cc50b084415b5fb69fc355fe5db9520 (patch)
tree0b619a2704bacc0020acfe15939e9c4c4365e524 /demos
parentbc9d3a1305905abe56933fb68cd9fb2062861f73 (diff)
downloaduGFX-128a3b972cc50b084415b5fb69fc355fe5db9520.tar.gz
uGFX-128a3b972cc50b084415b5fb69fc355fe5db9520.tar.bz2
uGFX-128a3b972cc50b084415b5fb69fc355fe5db9520.zip
New Tabset Widget.
Widgets demo updated to (optionally) use the new tabset.
Diffstat (limited to 'demos')
-rw-r--r--demos/modules/gwin/widgets/gfxconf.h2
-rw-r--r--demos/modules/gwin/widgets/main.c333
2 files changed, 202 insertions, 133 deletions
diff --git a/demos/modules/gwin/widgets/gfxconf.h b/demos/modules/gwin/widgets/gfxconf.h
index 346a9898..e7e2714e 100644
--- a/demos/modules/gwin/widgets/gfxconf.h
+++ b/demos/modules/gwin/widgets/gfxconf.h
@@ -75,6 +75,8 @@
#define GWIN_NEED_CONTAINERS TRUE
#define GWIN_NEED_CONTAINER TRUE
+#define GWIN_NEED_TABSET TRUE
+
///////////////////////////////////////////////////////////////////////////
// GEVENT //
///////////////////////////////////////////////////////////////////////////
diff --git a/demos/modules/gwin/widgets/main.c b/demos/modules/gwin/widgets/main.c
index d2f6882b..ea3dbfba 100644
--- a/demos/modules/gwin/widgets/main.c
+++ b/demos/modules/gwin/widgets/main.c
@@ -40,6 +40,12 @@
* The ROMFS uses the file "romfs_files.h" to describe the set of files in the ROMFS.
*/
+/**
+ * The code can either use the Tabset control or use Radio buttons set to the Tab style.
+ * Change this in your gfxconf.h file by defining GWIN_NEED_TABSET (or not). It is
+ * defined by default in this demo.
+ */
+
/* Our custom yellow style */
static const GWidgetStyle YellowWidgetStyle = {
Yellow, // window background
@@ -73,7 +79,11 @@ static const GWidgetStyle YellowWidgetStyle = {
static font_t font;
static GListener gl;
static GHandle ghConsole;
-static GHandle ghTabButtons, ghTabSliders, ghTabCheckboxes, ghTabLabels, ghTabRadios, ghTabLists, ghTabImages, ghTabProgressbar;
+#if GWIN_NEED_TABSET
+ static GHandle ghTabset;
+#else
+ static GHandle ghTabButtons, ghTabSliders, ghTabCheckboxes, ghTabLabels, ghTabRadios, ghTabLists, ghTabImages, ghTabProgressbar;
+#endif
static GHandle ghPgButtons, ghPgSliders, ghPgCheckboxes, ghPgLabels, ghPgRadios, ghPgLists, ghPgImages, ghPgProgressbars;
static GHandle ghButton1, ghButton2, ghButton3, ghButton4;
static GHandle ghSlider1, ghSlider2, ghSlider3, ghSlider4;
@@ -108,21 +118,56 @@ static gdispImage imgYesNo;
#define GROUP_YESNO 1
#define GROUP_COLORS 2
-// Wrap tabs onto the next line if they don't fit.
-static void settabtext(GWidgetInit *pwi, char *txt) {
- if (pwi->g.x >= ScrWidth) {
- pwi->g.x = 0;
- pwi->g.y += pwi->g.height;
+#if !GWIN_NEED_TABSET
+ // Wrap tabs onto the next line if they don't fit.
+ static void settabtext(GWidgetInit *pwi, char *txt) {
+ if (pwi->g.x >= ScrWidth) {
+ pwi->g.x = 0;
+ pwi->g.y += pwi->g.height;
+ }
+ pwi->text = txt;
+ pwi->g.width = gdispGetStringWidth(pwi->text, font) + BUTTON_PADDING;
+ if (pwi->g.x + pwi->g.width > ScrWidth) {
+ pwi->g.x = 0;
+ pwi->g.y += pwi->g.height;
+ }
}
- pwi->text = txt;
- pwi->g.width = gdispGetStringWidth(pwi->text, font) + BUTTON_PADDING;
- if (pwi->g.x + pwi->g.width > ScrWidth) {
- pwi->g.x = 0;
- pwi->g.y += pwi->g.height;
+
+ /**
+ * Set the visibility of widgets based on which tab is selected.
+ */
+ static void setTab(GHandle tab) {
+ /* Make sure everything is invisible first */
+ gwinHide(ghPgButtons);
+ gwinHide(ghPgSliders);
+ gwinHide(ghPgCheckboxes);
+ gwinHide(ghPgLabels);
+ gwinHide(ghPgRadios);
+ gwinHide(ghPgLists);
+ gwinHide(ghPgImages);
+ gwinHide(ghPgProgressbars);
+
+ /* Turn on widgets depending on the tab selected */
+ if (tab == ghTabButtons)
+ gwinShow(ghPgButtons);
+ else if (tab == ghTabSliders)
+ gwinShow(ghPgSliders);
+ else if (tab == ghTabCheckboxes)
+ gwinShow(ghPgCheckboxes);
+ else if (tab == ghTabLabels)
+ gwinShow(ghPgLabels);
+ else if (tab == ghTabRadios)
+ gwinShow(ghPgRadios);
+ else if (tab == ghTabLists)
+ gwinShow(ghPgLists);
+ else if (tab == ghTabImages)
+ gwinShow(ghPgImages);
+ else if (tab == ghTabProgressbar)
+ gwinShow(ghPgProgressbars);
}
-}
+#endif
-// Wrap tabs onto the next line if they don't fit.
+// Wrap buttons onto the next line if they don't fit.
static void setbtntext(GWidgetInit *pwi, coord_t maxwidth, char *txt) {
if (pwi->g.x >= maxwidth) {
pwi->g.x = 5;
@@ -146,71 +191,101 @@ static void setbtntext(GWidgetInit *pwi, coord_t maxwidth, char *txt) {
*/
static void createWidgets(void) {
GWidgetInit wi;
- coord_t border;
+ coord_t border, pagewidth;
gwinWidgetClearInit(&wi);
- // Create the Tabs
- wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab;
- wi.g.height = TAB_HEIGHT; wi.g.y = 0;
- wi.g.x = 0; setbtntext(&wi, ScrWidth, "Buttons");
- ghTabButtons = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Sliders");
- ghTabSliders = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Checkbox");
- ghTabCheckboxes = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Radios");
- ghTabRadios = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Lists");
- ghTabLists = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Labels");
- ghTabLabels = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Images");
- ghTabImages = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.x += wi.g.width; settabtext(&wi, "Progressbar");
- ghTabProgressbar = gwinRadioCreate(0, &wi, GROUP_TABS);
- wi.g.y += wi.g.height;
- wi.customDraw = 0;
-
// Calculate page borders based on screen size
border = ScrWidth < 450 ? 1 : 5;
- // Create the Pages
- wi.g.show = FALSE;
- wi.g.x = border; wi.g.y += border;
- wi.g.width = ScrWidth/2 - border; wi.g.height = ScrHeight-wi.g.y-border;
- ghPgButtons = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgSliders = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgCheckboxes = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgRadios = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgLists = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgLabels = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgImages = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- ghPgProgressbars = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
- wi.g.show = TRUE;
-
- // Console - we apply some special colors before making it visible
- wi.g.x = ScrWidth/2+border;
- wi.g.width = ScrWidth/2 - 2*border;
- ghConsole = gwinConsoleCreate(0, &wi.g);
- gwinSetColor(ghConsole, Black);
- gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0));
+ // Create the Tabs
+ #if GWIN_NEED_TABSET
+ wi.g.show = TRUE;
+ wi.g.x = border; wi.g.y = 0;
+ wi.g.width = ScrWidth - 2*border; wi.g.height = ScrHeight-wi.g.y-border;
+ ghTabset = gwinTabsetCreate(0, &wi, GWIN_TABSET_BORDER);
+ ghPgButtons = gwinTabsetAddTab(ghTabset, "Buttons", FALSE);
+ ghPgSliders = gwinTabsetAddTab(ghTabset, "Sliders", FALSE);
+ ghPgCheckboxes = gwinTabsetAddTab(ghTabset, "Checkbox", FALSE);
+ ghPgRadios = gwinTabsetAddTab(ghTabset, "Radios", FALSE);
+ ghPgLists = gwinTabsetAddTab(ghTabset, "Lists", FALSE);
+ ghPgLabels = gwinTabsetAddTab(ghTabset, "Labels", FALSE);
+ ghPgImages = gwinTabsetAddTab(ghTabset, "Images", FALSE);
+ ghPgProgressbars = gwinTabsetAddTab(ghTabset, "Progressbar", FALSE);
+
+ pagewidth = gwinGetInnerWidth(ghTabset)/2;
+
+ // Console - we apply some special colors before making it visible
+ // We put the console on the tabset itself rather than a tab-page.
+ // This makes it appear on every page :)
+ wi.g.parent = ghTabset;
+ wi.g.x = pagewidth;
+ wi.g.width = pagewidth;
+ ghConsole = gwinConsoleCreate(0, &wi.g);
+ gwinSetColor(ghConsole, Black);
+ gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0));
+
+ #else
+ wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab;
+ wi.g.height = TAB_HEIGHT; wi.g.y = 0;
+ wi.g.x = 0; setbtntext(&wi, ScrWidth, "Buttons");
+ ghTabButtons = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Sliders");
+ ghTabSliders = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Checkbox");
+ ghTabCheckboxes = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Radios");
+ ghTabRadios = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Lists");
+ ghTabLists = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Labels");
+ ghTabLabels = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Images");
+ ghTabImages = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.x += wi.g.width; settabtext(&wi, "Progressbar");
+ ghTabProgressbar = gwinRadioCreate(0, &wi, GROUP_TABS);
+ wi.g.y += wi.g.height;
+ wi.customDraw = 0;
+
+ // Create the Pages
+ wi.g.show = FALSE;
+ wi.g.x = border; wi.g.y += border;
+ wi.g.width = ScrWidth/2 - border; wi.g.height = ScrHeight-wi.g.y-border;
+ ghPgButtons = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgSliders = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgCheckboxes = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgRadios = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgLists = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgLabels = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgImages = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ ghPgProgressbars = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
+ wi.g.show = TRUE;
+
+ // Console - we apply some special colors before making it visible
+ wi.g.x = ScrWidth/2+border;
+ wi.g.width = ScrWidth/2 - 2*border;
+ ghConsole = gwinConsoleCreate(0, &wi.g);
+ gwinSetColor(ghConsole, Black);
+ gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0));
+
+ pagewidth = gwinGetInnerWidth(ghPgButtons);
+ #endif
// Buttons
wi.g.parent = ghPgButtons;
wi.g.width = BUTTON_WIDTH; wi.g.height = BUTTON_HEIGHT; wi.g.y = 5;
- wi.g.x = 5; setbtntext(&wi, gwinGetInnerWidth(ghPgButtons), "Button 1");
+ wi.g.x = 5; setbtntext(&wi, pagewidth, "Button 1");
ghButton1 = gwinButtonCreate(0, &wi);
- wi.g.x += wi.g.width+3; setbtntext(&wi, gwinGetInnerWidth(ghPgButtons), "Button 2");
+ wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 2");
ghButton2 = gwinButtonCreate(0, &wi);
- wi.g.x += wi.g.width+3; setbtntext(&wi, gwinGetInnerWidth(ghPgButtons), "Button 3");
+ wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 3");
ghButton3 = gwinButtonCreate(0, &wi);
- wi.g.x += wi.g.width+3; setbtntext(&wi, gwinGetInnerWidth(ghPgButtons), "Button 4");
+ wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 4");
ghButton4 = gwinButtonCreate(0, &wi);
// Horizontal Sliders
wi.g.parent = ghPgSliders;
- wi.g.width = gwinGetInnerWidth(ghPgSliders) - 10; wi.g.height = SLIDER_WIDTH;
+ wi.g.width = pagewidth - 10; wi.g.height = SLIDER_WIDTH;
wi.g.x = 5; wi.g.y = 5; wi.text = "S1";
ghSlider1 = gwinSliderCreate(0, &wi);
gwinSliderSetPosition(ghSlider1, 33);
@@ -242,7 +317,7 @@ static void createWidgets(void) {
// Labels
wi.g.parent = ghPgLabels;
- wi.g.width = gwinGetInnerWidth(ghPgLabels)-10; wi.g.height = LABEL_HEIGHT;
+ wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT;
wi.g.x = wi.g.y = 5; wi.text = "N/A";
ghLabelSlider1 = gwinLabelCreate(0, &wi);
gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:");
@@ -265,20 +340,20 @@ static void createWidgets(void) {
wi.g.width = RADIO_WIDTH; wi.g.height = RADIO_HEIGHT; wi.g.y = 5;
wi.g.x = 5; wi.text = "Yes";
ghRadio1 = gwinRadioCreate(0, &wi, GROUP_YESNO);
- wi.g.x += wi.g.width; wi.text = "No"; if (wi.g.x + wi.g.width > gwinGetInnerWidth(ghPgRadios)) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
+ wi.g.x += wi.g.width; wi.text = "No"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
ghRadio2 = gwinRadioCreate(0, &wi, GROUP_YESNO);
gwinRadioPress(ghRadio1);
wi.g.width = COLOR_WIDTH; wi.g.y += RADIO_HEIGHT+5;
wi.g.x = 5; wi.text = "Black";
ghRadioBlack = gwinRadioCreate(0, &wi, GROUP_COLORS);
- wi.g.x += wi.g.width; wi.text = "White"; if (wi.g.x + wi.g.width > gwinGetInnerWidth(ghPgRadios)) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
+ wi.g.x += wi.g.width; wi.text = "White"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
ghRadioWhite = gwinRadioCreate(0, &wi, GROUP_COLORS);
- wi.g.x += wi.g.width; wi.text = "Yellow"; if (wi.g.x + wi.g.width > gwinGetInnerWidth(ghPgRadios)) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
+ wi.g.x += wi.g.width; wi.text = "Yellow"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; }
ghRadioYellow = gwinRadioCreate(0, &wi, GROUP_COLORS);
gwinRadioPress(ghRadioWhite);
// Lists
- border = gwinGetInnerWidth(ghPgLists) < 10+2*LIST_WIDTH ? 2 : 5;
+ border = pagewidth < 10+2*LIST_WIDTH ? 2 : 5;
wi.g.parent = ghPgLists;
wi.g.width = LIST_WIDTH; wi.g.height = LIST_HEIGHT; wi.g.y = border;
wi.g.x = border; wi.text = "L1";
@@ -297,7 +372,7 @@ static void createWidgets(void) {
gwinListAddItem(ghList1, "Item 11", FALSE);
gwinListAddItem(ghList1, "Item 12", FALSE);
gwinListAddItem(ghList1, "Item 13", FALSE);
- wi.text = "L2"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > gwinGetInnerWidth(ghPgLists)) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
+ wi.text = "L2"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
ghList2 = gwinListCreate(0, &wi, TRUE);
gwinListAddItem(ghList2, "Item 0", FALSE);
gwinListAddItem(ghList2, "Item 1", FALSE);
@@ -313,7 +388,7 @@ static void createWidgets(void) {
gwinListAddItem(ghList2, "Item 11", FALSE);
gwinListAddItem(ghList2, "Item 12", FALSE);
gwinListAddItem(ghList2, "Item 13", FALSE);
- wi.text = "L3"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > gwinGetInnerWidth(ghPgLists)) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
+ wi.text = "L3"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
ghList3 = gwinListCreate(0, &wi, TRUE);
gwinListAddItem(ghList3, "Item 0", FALSE);
gwinListAddItem(ghList3, "Item 1", FALSE);
@@ -322,7 +397,7 @@ static void createWidgets(void) {
gdispImageOpenFile(&imgYesNo, "image_yesno.gif");
gwinListItemSetImage(ghList3, 1, &imgYesNo);
gwinListItemSetImage(ghList3, 3, &imgYesNo);
- wi.text = "L4"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > gwinGetInnerWidth(ghPgLists)) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
+ wi.text = "L4"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; }
ghList4 = gwinListCreate(0, &wi, TRUE);
gwinListAddItem(ghList4, "Item 0", FALSE);
gwinListAddItem(ghList4, "Item 1", FALSE);
@@ -342,56 +417,50 @@ static void createWidgets(void) {
// Image
wi.g.parent = ghPgImages;
- wi.g.x = wi.g.y = 0; wi.g.width = gwinGetInnerWidth(ghPgImages); wi.g.height = gwinGetInnerHeight(ghPgImages);
+ wi.g.x = wi.g.y = 0; wi.g.width = pagewidth; wi.g.height = gwinGetInnerHeight(ghPgImages);
ghImage1 = gwinImageCreate(0, &wi.g);
gwinImageOpenFile(ghImage1, "romfs_img_ugfx.gif");
// Progressbar
wi.g.parent = ghPgProgressbars;
- wi.g.width = gwinGetInnerWidth(ghPgImages)-10; wi.g.height = SLIDER_WIDTH; wi.g.y = 5;
+ wi.g.width = pagewidth-10; wi.g.height = SLIDER_WIDTH; wi.g.y = 5;
wi.g.x = 5; wi.text = "Progressbar 1";
ghProgressbar1 = gwinProgressbarCreate(0, &wi);
gwinProgressbarSetResolution(ghProgressbar1, 10);
}
/**
- * Set the visibility of widgets based on which tab is selected.
+ * Set the value of the labels
*/
-static void setTab(GHandle tab) {
- /* Make sure everything is invisible first */
- gwinHide(ghPgButtons);
- gwinHide(ghPgSliders);
- gwinHide(ghPgCheckboxes);
- gwinHide(ghPgLabels);
- gwinHide(ghPgRadios);
- gwinHide(ghPgLists);
- gwinHide(ghPgImages);
- gwinHide(ghPgProgressbars);
-
- // Stop the progress bar
- gwinProgressbarStop(ghProgressbar1);
- gwinProgressbarReset(ghProgressbar1);
-
- /* Turn on widgets depending on the tab selected */
- if (tab == ghTabButtons) {
- gwinShow(ghPgButtons);
- } else if (tab == ghTabSliders) {
- gwinShow(ghPgSliders);
- } else if (tab == ghTabCheckboxes) {
- gwinShow(ghPgCheckboxes);
- } else if (tab == ghTabLabels) {
- gwinShow(ghPgLabels);
- } else if (tab == ghTabRadios) {
- gwinShow(ghPgRadios);
- } else if (tab == ghTabLists) {
- gwinShow(ghPgLists);
- } else if (tab == ghTabImages) {
- gwinShow(ghPgImages);
- } else if (tab == ghTabProgressbar) {
- gwinShow(ghPgProgressbars);
-
- // Start the progress bar
+static void setLabels(void) {
+ char tmp[20];
+
+ // The sliders
+ snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider1));
+ gwinSetText(ghLabelSlider1, tmp, TRUE);
+ snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider2));
+ gwinSetText(ghLabelSlider2, tmp, TRUE);
+ snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider3));
+ gwinSetText(ghLabelSlider3, tmp, TRUE);
+ snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider4));
+ gwinSetText(ghLabelSlider4, tmp, TRUE);
+
+ // The radio buttons
+ if (gwinRadioIsPressed(ghRadio1))
+ gwinSetText(ghLabelRadio1, "Yes", TRUE);
+ else if (gwinRadioIsPressed(ghRadio2))
+ gwinSetText(ghLabelRadio1, "No", TRUE);
+}
+
+/**
+ * Control the progress bar auto-increment
+ */
+static void setProgressbar(bool_t onoff) {
+ if (onoff)
gwinProgressbarStart(ghProgressbar1, 500);
+ else {
+ gwinProgressbarStop(ghProgressbar1); // Stop the progress bar
+ gwinProgressbarReset(ghProgressbar1);
}
}
@@ -445,8 +514,10 @@ int main(void) {
geventListenerInit(&gl);
gwinAttachListener(&gl);
- // Press the Tab we want visible
- gwinRadioPress(ghTabButtons);
+ #if !GWIN_NEED_TABSET
+ // Press the Tab we want visible
+ gwinRadioPress(ghTabButtons);
+ #endif
while(1) {
// Get an Event
@@ -480,33 +551,18 @@ int main(void) {
gwinPrintf(ghConsole, "Radio Group %u=%s\n", ((GEventGWinRadio *)pe)->group, gwinGetText(((GEventGWinRadio *)pe)->gwin));
switch(((GEventGWinRadio *)pe)->group) {
- case GROUP_TABS:
+ #if !GWIN_NEED_TABSET
+ case GROUP_TABS:
- // Set control visibility depending on the tab selected
- setTab(((GEventGWinRadio *)pe)->gwin);
+ // Set control visibility depending on the tab selected
+ setTab(((GEventGWinRadio *)pe)->gwin);
- // We show the state of some of the GUI elements here
- if (((GEventGWinRadio *)pe)->gwin == ghTabLabels) {
- char tmp[20];
-
- // The sliders
- snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider1));
- gwinSetText(ghLabelSlider1, tmp, TRUE);
- snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider2));
- gwinSetText(ghLabelSlider2, tmp, TRUE);
- snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider3));
- gwinSetText(ghLabelSlider3, tmp, TRUE);
- snprintg(tmp, sizeof(tmp), "%d%%", gwinSliderGetPosition(ghSlider4));
- gwinSetText(ghLabelSlider4, tmp, TRUE);
-
- // The radio buttons
- if (gwinRadioIsPressed(ghRadio1)) {
- gwinSetText(ghLabelRadio1, "Yes", TRUE);
- } else if (gwinRadioIsPressed(ghRadio2)) {
- gwinSetText(ghLabelRadio1, "No", TRUE);
- }
- }
- break;
+ // We show the state of some of the GUI elements here
+ setProgressbar(((GEventGWinRadio *)pe)->gwin == ghTabProgressbar);
+ if (((GEventGWinRadio *)pe)->gwin == ghTabLabels)
+ setLabels();
+ break;
+ #endif
case GROUP_COLORS:
{
@@ -531,6 +587,17 @@ int main(void) {
}
break;
+ #if GWIN_NEED_TABSET
+ case GEVENT_GWIN_TABSET:
+ gwinPrintf(ghConsole, "TabPage %u (%s)\n", ((GEventGWinTabset *)pe)->nPage, gwinTabsetGetTitle(((GEventGWinTabset *)pe)->ghPage));
+
+ // We show the state of some of the GUI elements here
+ setProgressbar(((GEventGWinTabset *)pe)->ghPage == ghPgProgressbars);
+ if (((GEventGWinTabset *)pe)->ghPage == ghPgLabels)
+ setLabels();
+ break;
+ #endif
+
default:
gwinPrintf(ghConsole, "Unknown %d\n", pe->type);
break;