diff --git a/demos/modules/gwin/container/demo.mk b/demos/modules/gwin/container/demo.mk new file mode 100644 index 00000000..7acdf4e3 --- /dev/null +++ b/demos/modules/gwin/container/demo.mk @@ -0,0 +1,3 @@ +DEMODIR = $(GFXLIB)/demos/modules/gwin/container +GFXINC += $(DEMODIR) +GFXSRC += $(DEMODIR)/main.c diff --git a/demos/modules/gwin/container/gfxconf.h b/demos/modules/gwin/container/gfxconf.h new file mode 100644 index 00000000..fdddc3f3 --- /dev/null +++ b/demos/modules/gwin/container/gfxconf.h @@ -0,0 +1,87 @@ +/** + * This file has a different license to the rest of the uGFX system. + * You can copy, modify and distribute this file as you see fit. + * You do not need to publish your source modifications to this file. + * The only thing you are not permitted to do is to relicense it + * under a different license. + */ + +/** + * Copy this file into your project directory and rename it as gfxconf.h + * Edit your copy to turn on the uGFX features you want to use. + * The values below are the defaults. You should delete anything + * you are leaving as default. + * + * Please use spaces instead of tabs in this file. + */ + +#ifndef _GFXCONF_H +#define _GFXCONF_H + +/* The operating system to use. One of these must be defined - preferably in your Makefile */ +//#define GFX_USE_OS_CHIBIOS TRUE +//#define GFX_USE_OS_WIN32 TRUE +//#define GFX_USE_OS_LINUX TRUE +//#define GFX_USE_OS_OSX TRUE + + +/////////////////////////////////////////////////////////////////////////// +// GDISP // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GDISP TRUE + +#define GDISP_NEED_VALIDATION TRUE +#define GDISP_NEED_CLIP TRUE +#define GDISP_NEED_TEXT TRUE + #define GDISP_INCLUDE_FONT_UI2 TRUE +#define GDISP_NEED_MULTITHREAD TRUE + + +/////////////////////////////////////////////////////////////////////////// +// GWIN // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GWIN TRUE + +#define GWIN_NEED_WINDOWMANAGER TRUE + +#define GWIN_NEED_CONSOLE TRUE + #define GWIN_CONSOLE_USE_HISTORY TRUE + #define GWIN_CONSOLE_HISTORY_AVERAGING TRUE + #define GWIN_CONSOLE_HISTORY_ATCREATE TRUE + #define GWIN_CONSOLE_ESCSEQ TRUE + #define GWIN_CONSOLE_USE_BASESTREAM TRUE +#define GWIN_NEED_GRAPH TRUE + +#define GWIN_NEED_WIDGET TRUE + #define GWIN_NEED_BUTTON TRUE + #define GWIN_BUTTON_LAZY_RELEASE TRUE +#define GWIN_NEED_CONTAINERS TRUE + #define GWIN_NEED_CONTAINER TRUE + + +/////////////////////////////////////////////////////////////////////////// +// GEVENT // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GEVENT TRUE + +/////////////////////////////////////////////////////////////////////////// +// GTIMER // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GTIMER TRUE + +/////////////////////////////////////////////////////////////////////////// +// GQUEUE // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GQUEUE TRUE + +#define GQUEUE_NEED_ASYNC TRUE +#define GQUEUE_NEED_GSYNC TRUE + +/////////////////////////////////////////////////////////////////////////// +// GINPUT // +/////////////////////////////////////////////////////////////////////////// +#define GFX_USE_GINPUT TRUE + +#define GINPUT_NEED_MOUSE TRUE + +#endif /* _GFXCONF_H */ diff --git a/demos/modules/gwin/container/main.c b/demos/modules/gwin/container/main.c new file mode 100644 index 00000000..4e73b0c4 --- /dev/null +++ b/demos/modules/gwin/container/main.c @@ -0,0 +1,56 @@ +#include "gfx.h" + +static GHandle ghContainer; +static GHandle ghButton; + +static void createWidgets(void) { + GWidgetInit wi; + + // Apply some default values for GWIN + gwinWidgetClearInit(&wi); + + // Apply the container parameters + wi.g.show = FALSE; + wi.g.width = 200; + wi.g.height = 150; + wi.g.y = 10; + wi.g.x = 10; + wi.text = "Container"; + ghContainer = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); + wi.g.show = TRUE; + + // Apply the button parameters + wi.g.width = 120; + wi.g.height = 30; + wi.g.y = 10; + wi.g.x = 10; + wi.text = "Button"; + wi.g.parent = ghContainer; + ghButton = gwinButtonCreate(0, &wi); + + // Make the container become visible - therefore all its children + // become visible as well + gwinShow(ghContainer); +} + +int main(void) { + // Initialize the display + gfxInit(); + + // Attach the mouse input + gwinAttachMouse(0); + + // Set the widget defaults + gwinSetDefaultFont(gdispOpenFont("*")); + gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); + gdispClear(White); + + // Create the widget + createWidgets(); + + while(1) { + gfxSleepMilliseconds(1000); + } + + return 0; +}