aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-08-01 14:50:40 +1000
committerinmarket <andrewh@inmarket.com.au>2013-08-01 14:50:40 +1000
commit06d339456e64f6257bd72eb9343d7c899ea0b20b (patch)
tree0ada360b2157b08f6eba50f6fe38669c9f163d81
parent44f3256be382a49361b14ec8f56aa43856e1d3bb (diff)
downloaduGFX-06d339456e64f6257bd72eb9343d7c899ea0b20b.tar.gz
uGFX-06d339456e64f6257bd72eb9343d7c899ea0b20b.tar.bz2
uGFX-06d339456e64f6257bd72eb9343d7c899ea0b20b.zip
Update gwin widgets and lists demos
-rw-r--r--demos/modules/gwin/list/gfxconf.h2
-rw-r--r--demos/modules/gwin/list/main.c31
-rw-r--r--demos/modules/gwin/widgets/gfxconf.h1
-rw-r--r--demos/modules/gwin/widgets/main.c38
4 files changed, 56 insertions, 16 deletions
diff --git a/demos/modules/gwin/list/gfxconf.h b/demos/modules/gwin/list/gfxconf.h
index 895d7c49..cf5f8690 100644
--- a/demos/modules/gwin/list/gfxconf.h
+++ b/demos/modules/gwin/list/gfxconf.h
@@ -40,7 +40,7 @@
#define GDISP_NEED_CIRCLE TRUE
#define GDISP_NEED_ELLIPSE TRUE
#define GDISP_NEED_ARC FALSE
-#define GDISP_NEED_CONVEX_POLYGON FALSE
+#define GDISP_NEED_CONVEX_POLYGON TRUE
#define GDISP_NEED_SCROLL FALSE
#define GDISP_NEED_PIXELREAD FALSE
#define GDISP_NEED_CONTROL FALSE
diff --git a/demos/modules/gwin/list/main.c b/demos/modules/gwin/list/main.c
index 35847be0..a3a17250 100644
--- a/demos/modules/gwin/list/main.c
+++ b/demos/modules/gwin/list/main.c
@@ -10,11 +10,11 @@ static void createWidgets(void) {
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
- wi.g.show = TRUE;
+ wi.g.show = FALSE;
// Apply the list parameters
- wi.g.width = 300;
- wi.g.height = 200;
+ wi.g.width = 100;
+ wi.g.height = 80;
wi.g.y = 10;
wi.g.x = 10;
wi.text = "List Name";
@@ -32,7 +32,7 @@ int main(void) {
// Set the widget defaults
gwinSetDefaultFont(gdispOpenFont("UI2"));
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
- gdispClear(White);
+ gdispClear(Red);
// Attach the mouse input
gwinAttachMouse(0);
@@ -45,13 +45,22 @@ int main(void) {
gwinAttachListener(&gl);
// Add some items to the list widget
- gwinListAddItem(ghList1, "Item 0", TRUE);
- gwinListAddItem(ghList1, "Item 1", TRUE);
- gwinListAddItem(ghList1, "Item 2", TRUE);
- gwinListAddItem(ghList1, "Item 3", TRUE);
- gwinListAddItem(ghList1, "Item 4", TRUE);
-
- gwinRedraw(ghList1);
+ gwinListAddItem(ghList1, "Item 0", FALSE);
+ gwinListAddItem(ghList1, "Item 1", FALSE);
+ gwinListAddItem(ghList1, "Item 2", FALSE);
+ gwinListAddItem(ghList1, "Item 3", FALSE);
+ gwinListAddItem(ghList1, "Item 4", FALSE);
+ gwinListAddItem(ghList1, "Item 5", FALSE);
+ gwinListAddItem(ghList1, "Item 6", FALSE);
+ gwinListAddItem(ghList1, "Item 7", FALSE);
+ gwinListAddItem(ghList1, "Item 8", FALSE);
+ gwinListAddItem(ghList1, "Item 9", FALSE);
+ gwinListAddItem(ghList1, "Item 10", FALSE);
+ gwinListAddItem(ghList1, "Item 11", FALSE);
+ gwinListAddItem(ghList1, "Item 12", FALSE);
+ gwinListAddItem(ghList1, "Item 13", FALSE);
+
+ gwinSetVisible(ghList1, TRUE);
while(1) {
// Get an Event
diff --git a/demos/modules/gwin/widgets/gfxconf.h b/demos/modules/gwin/widgets/gfxconf.h
index f8d8fe5f..10db7bbc 100644
--- a/demos/modules/gwin/widgets/gfxconf.h
+++ b/demos/modules/gwin/widgets/gfxconf.h
@@ -81,6 +81,7 @@
#define GWIN_NEED_LABEL TRUE
#define GWIN_NEED_IMAGE TRUE
#define GWIN_NEED_RADIO TRUE
+#define GWIN_NEED_LIST TRUE
#define GWIN_NEED_IMAGE_ANIMATION TRUE
diff --git a/demos/modules/gwin/widgets/main.c b/demos/modules/gwin/widgets/main.c
index bff842f4..f2323b5c 100644
--- a/demos/modules/gwin/widgets/main.c
+++ b/demos/modules/gwin/widgets/main.c
@@ -69,13 +69,14 @@ static const GWidgetStyle YellowWidgetStyle = {
/* The variables we need */
static GListener gl;
static GHandle ghConsole;
-static GHandle ghTabButtons, ghTabSliders, ghTabCheckboxes, ghTabLabels, ghTabRadios, ghTabImages;
+static GHandle ghTabButtons, ghTabSliders, ghTabCheckboxes, ghTabLabels, ghTabRadios, ghTabLists, ghTabImages;
static GHandle ghButton1, ghButton2, ghButton3, ghButton4;
static GHandle ghSlider1, ghSlider2, ghSlider3, ghSlider4;
static GHandle ghCheckbox1, ghCheckbox2, ghCheckDisableAll;
static GHandle ghLabel1;
static GHandle ghRadio1, ghRadio2;
static GHandle ghRadioBlack, ghRadioWhite, ghRadioYellow;
+static GHandle ghList1;
static GHandle ghImage1;
/* Some useful macros */
@@ -86,6 +87,8 @@ static GHandle ghImage1;
#define LABEL_HEIGHT 40
#define BUTTON_WIDTH 50
#define BUTTON_HEIGHT 30
+#define LIST_WIDTH 100
+#define LIST_HEIGHT 80
#define SLIDER_WIDTH 20
#define CHECKBOX_WIDTH 80
#define CHECKBOX_HEIGHT 20
@@ -108,13 +111,14 @@ static void createWidgets(void) {
// Create the Tabs
wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab;
- wi.g.width = ScrWidth/6; wi.g.height = TAB_HEIGHT; wi.g.y = 0;
+ wi.g.width = ScrWidth/7; wi.g.height = TAB_HEIGHT; wi.g.y = 0;
wi.g.x = 0*wi.g.width; wi.text = "Buttons"; ghTabButtons = gwinRadioCreate(NULL, &wi, GROUP_TABS);
wi.g.x = 1*wi.g.width; wi.text = "Sliders"; ghTabSliders = gwinRadioCreate(NULL, &wi, GROUP_TABS);
wi.g.x = 2*wi.g.width; wi.text = "Checkbox"; ghTabCheckboxes = gwinRadioCreate(NULL, &wi, GROUP_TABS);
wi.g.x = 3*wi.g.width; wi.text = "Radios"; ghTabRadios = gwinRadioCreate(NULL, &wi, GROUP_TABS);
- wi.g.x = 4*wi.g.width; wi.text = "Labels"; ghTabLabels = gwinRadioCreate(NULL, &wi, GROUP_TABS);
- wi.g.x = 5*wi.g.width; wi.text = "Images"; ghTabImages = gwinRadioCreate(NULL, &wi, GROUP_TABS);
+ wi.g.x = 4*wi.g.width; wi.text = "Lists"; ghTabLists = gwinRadioCreate(NULL, &wi, GROUP_TABS);
+ wi.g.x = 5*wi.g.width; wi.text = "Labels"; ghTabLabels = gwinRadioCreate(NULL, &wi, GROUP_TABS);
+ wi.g.x = 6*wi.g.width; wi.text = "Images"; ghTabImages = gwinRadioCreate(NULL, &wi, GROUP_TABS);
// Buttons
wi.g.show = FALSE; wi.customDraw = 0;
@@ -156,6 +160,25 @@ static void createWidgets(void) {
wi.g.x = 2*wi.g.width; wi.text = "Yellow"; ghRadioYellow = gwinRadioCreate(NULL, &wi, GROUP_COLORS);
gwinRadioPress(ghRadioWhite);
+ // Lists
+ wi.g.show = FALSE; wi.customDraw = 0;
+ wi.g.width = LIST_WIDTH; wi.g.height = LIST_HEIGHT; wi.g.y = TAB_HEIGHT+5;
+ wi.g.x = 0+0*(LIST_WIDTH+1); wi.text = "L1"; ghList1 = gwinListCreate(NULL, &wi);
+ gwinListAddItem(ghList1, "Item 0", FALSE);
+ gwinListAddItem(ghList1, "Item 1", FALSE);
+ gwinListAddItem(ghList1, "Item 2", FALSE);
+ gwinListAddItem(ghList1, "Item 3", FALSE);
+ gwinListAddItem(ghList1, "Item 4", FALSE);
+ gwinListAddItem(ghList1, "Item 5", FALSE);
+ gwinListAddItem(ghList1, "Item 6", FALSE);
+ gwinListAddItem(ghList1, "Item 7", FALSE);
+ gwinListAddItem(ghList1, "Item 8", FALSE);
+ gwinListAddItem(ghList1, "Item 9", FALSE);
+ gwinListAddItem(ghList1, "Item 10", FALSE);
+ gwinListAddItem(ghList1, "Item 11", FALSE);
+ gwinListAddItem(ghList1, "Item 12", FALSE);
+ gwinListAddItem(ghList1, "Item 13", FALSE);
+
// Image
wi.g.x = ScrWidth-210; wi.g.y = TAB_HEIGHT + 10; wi.g.width = 200; wi.g.height = 200;
ghImage1 = gwinImageCreate(NULL, &wi.g);
@@ -183,6 +206,7 @@ static void setTab(GHandle tab) {
gwinSetVisible(ghLabel1, FALSE);
gwinSetVisible(ghRadio1, FALSE); gwinSetVisible(ghRadio2, FALSE);
gwinSetVisible(ghRadioWhite, FALSE);gwinSetVisible(ghRadioBlack, FALSE);gwinSetVisible(ghRadioYellow, FALSE);
+ gwinSetVisible(ghList1, FALSE);
gwinSetVisible(ghImage1, FALSE);
/* Turn on widgets depending on the tab selected */
@@ -199,6 +223,8 @@ static void setTab(GHandle tab) {
} else if (tab == ghTabRadios) {
gwinSetVisible(ghRadio1, TRUE); gwinSetVisible(ghRadio2, TRUE);
gwinSetVisible(ghRadioWhite, TRUE); gwinSetVisible(ghRadioBlack, TRUE); gwinSetVisible(ghRadioYellow, TRUE);
+ } else if (tab == ghTabLists) {
+ gwinSetVisible(ghList1, TRUE);
} else if (tab == ghTabImages) {
gwinSetVisible(ghImage1, TRUE);
}
@@ -282,6 +308,10 @@ int main(void) {
}
break;
+ case GEVENT_GWIN_LIST:
+ gwinPrintf(ghConsole, "List %s Item %d\n", gwinGetText(((GEventGWinList *)pe)->list), ((GEventGWinList *)pe)->item);
+ break;
+
case GEVENT_GWIN_RADIO:
gwinPrintf(ghConsole, "Radio Group %u=%s\n", ((GEventGWinRadio *)pe)->group, gwinGetText(((GEventGWinRadio *)pe)->radio));