Add gwinClearInit() and gwinWidgetClearInit() to clear gwin initialisation structures.

Incorporate into demo's
ugfx_release_2.6
inmarket 2014-05-09 21:25:31 +10:00
parent ca1a83abca
commit 9e8b38ba94
17 changed files with 65 additions and 20 deletions

View File

@ -152,6 +152,8 @@ int main(void) {
gwinSetDefaultFont(font);
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = swidth-SCOPE_CX;
@ -184,6 +186,8 @@ int main(void) {
/* Set up the scope window in the top right on the screen */
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE;
wi.x = swidth-SCOPE_CX;
wi.y = 0;

View File

@ -73,6 +73,7 @@ int main(void) {
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = swidth; wi.height = sheight;

View File

@ -43,6 +43,7 @@ int main(void) {
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE; wi.x = 20; wi.y = 10; wi.width = 200; wi.height = 150;
GW1 = gwinWindowCreate(0, &wi);
wi.show = TRUE; wi.x = 50; wi.y = 190; wi.width = 150; wi.height = 100;

View File

@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Apply the button parameters

View File

@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Apply the checkbox parameters

View File

@ -48,6 +48,7 @@ int main(void) {
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE;
wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2;
GW1 = gwinConsoleCreate(0, &wi);

View File

@ -69,6 +69,7 @@ int main(void) {
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = gdispGetWidth();

View File

@ -37,9 +37,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Create the label for the first list

View File

@ -5,9 +5,7 @@ GHandle ghProgressbar;
static void _createWidget(void) {
GWidgetInit wi;
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "Progress 1";

View File

@ -40,9 +40,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// create Radio11

View File

@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// create Slider1

View File

@ -113,7 +113,7 @@ static gdispImage imgYesNo;
static void createWidgets(void) {
GWidgetInit wi;
wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0;
gwinWidgetClearInit(&wi);
// Create the Tabs
wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab;

View File

@ -297,6 +297,14 @@ void _gwidgetRedraw(GHandle gh) {
gw->fnDraw(gw, gw->fnParam);
}
void gwinWidgetClearInit(GWidgetInit *pwi) {
char *p;
unsigned len;
for(p = (char *)pwi, len = sizeof(GWidgetInit); len; len--)
*p++ = 0;
}
void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll) {
if (!pstyle)
pstyle = &BlackWidgetStyle;

View File

@ -78,6 +78,10 @@ typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);
* @brief The structure to initialise a widget.
*
* @note Some widgets may have extra parameters.
* @note If you create this structure on the stack, you should always memset
* it to all zero's first in case a future version of the software
* add's extra fields. Alternatively you can use @p gwinWidgetClearInit()
* to clear it.
* @note The text element must be static string (not stack allocated). If you want to use
* a dynamic string (eg a stack allocated string) use NULL for this member and then call
* @p gwinSetText() with useAlloc set to TRUE.
@ -126,6 +130,18 @@ typedef struct GWidgetObject {
extern "C" {
#endif
/**
* @brief Clear a GWidgetInit structure to all zero's
* @note This function is provided just to prevent problems
* on operating systems where using memset() causes issues
* in the users application.
*
* @param[in] pwi The GWidgetInit structure to clear
*
* @api
*/
void gwinWidgetClearInit(GWidgetInit *pwi);
/**
* @brief Set the default style for widgets created hereafter.
*

View File

@ -149,6 +149,14 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit
* Routines that affect all windows
*-----------------------------------------------*/
void gwinClearInit(GWindowInit *pwi) {
char *p;
unsigned len;
for(p = (char *)pwi, len = sizeof(GWindowInit); len; len--)
*p++ = 0;
}
void gwinSetDefaultColor(color_t clr) {
defaultFgColor = clr;
}

View File

@ -34,7 +34,7 @@
*/
typedef struct GWindowObject {
#if GWIN_NEED_WINDOWMANAGER
// This MUST be the first member of the struct
// This MUST be the first member of the structure
gfxQueueASyncItem wmq; // @< The next window (for the window manager)
#endif
const struct gwinVMT *vmt; // @< The VMT for this GWIN
@ -54,6 +54,10 @@ typedef struct GWindowObject {
*
* @note Some gwin's will need extra parameters.
* @note The dimensions and position may be changed to fit on the real screen.
* @note If you create this structure on the stack, you should always memset
* it to all zero's first in case a future version of the software
* add's extra fields. Alternatively you can use @p gwinClearInit()
* to clear it.
*
* @{
*/
@ -102,6 +106,18 @@ extern "C" {
* Functions that affect all windows
*-------------------------------------------------*/
/**
* @brief Clear a GWindowInit structure to all zero's
* @note This function is provided just to prevent problems
* on operating systems where using memset() causes issues
* in the users application.
*
* @param[in] pwi The GWindowInit structure to clear
*
* @api
*/
void gwinClearInit(GWindowInit *pwi);
/**
* @brief Set the default foreground color for all new GWIN windows
*

View File

@ -66,6 +66,7 @@ int main(void) {
{
GWindowInit wi;
gwinClearInit(&wi);
wi.show = TRUE; wi.x = 0; wi.y = bHeight; wi.width = swidth; wi.height = sheight-bHeight;
ghc = gwinConsoleCreate(&gc, &wi);
}