added list widget dummy

ugfx_release_2.6
Joel Bodenmann 2013-07-17 17:49:21 +02:00
parent ceae37b7bf
commit 259f822ba7
6 changed files with 145 additions and 0 deletions

View File

@ -67,6 +67,11 @@
#define GWIN_NEED_WIDGET TRUE
#endif
#endif
#if GWIN_NEED_LIST
#if !GDISP_NEED_TEXT
#error "GWIN: GDISP_NEED_TEXT is required when GWIN_NEED_LIST is TRUE."
#endif
#endif
#if GWIN_NEED_WIDGET
#if !GDISP_NEED_TEXT
#error "GWIN: GDISP_NEED_TEXT is required if GWIN_NEED_WIDGET is TRUE."

View File

@ -825,6 +825,10 @@ extern "C" {
#include "gwin/label.h"
#endif
#if GWIN_NEED_LIST || defined(__DOXYGEN__)
#include "gwin/list.h"
#endif
#endif /* GFX_USE_GWIN */
#endif /* _GWIN_H */

View File

@ -0,0 +1,61 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/list.h
* @brief GWIN list widget header file
*
* @defgroup List List
* @ingroup GWIN
*
* @details GWIN allows it to create a list widget.
*
* @pre GFX_USE_GDISP must be set to TRUE in your gfxconf.h
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_LIST must be set to TRUE in your gfxconf.h
* @pre The font you want to use must be enabled in your gfxconf.h
*
* @{
*/
#ifndef _GWIN_LIST_H
#define _GWIN_LIST_H
// This file is included within "gwin/gwin.h"
/**
* @brief The event type for a list event
*/
#define GEVENT_GWIN_LIST (GEVENT_GWIN_FIRST+4)
/**
* @brief A list event
*/
typedef struct GEventGWinList {
GEventType type; // The type of this event (GEVENT_GWIN_LIST)
GHandle list; // THe list that has generated the event
} GEventGWinList;
// A list window
typedef struct GListObject {
GWidgetObject w;
} GListObject;
#ifdef __cplusplus
extern "C" {
#endif
GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit);
#ifdef __cplusplus
}
#endif
#endif // _GWIN_LIST_H
/** @} */

View File

@ -9,4 +9,5 @@ GFXSRC += $(GFXLIB)/src/gwin/gwin.c \
$(GFXLIB)/src/gwin/gimage.c \
$(GFXLIB)/src/gwin/label.c \
$(GFXLIB)/src/gwin/radio.c \
$(GFXLIB)/src/gwin/list.c \

View File

@ -95,6 +95,7 @@ GHandle gwinLabelCreate(GLabelObject *widget, GWidgetInit *pInit) {
// auto assign width
if (pInit->g.width <= 0) {
flags |= GLABEL_FLG_WAUTO;
pInit->g.width = getwidth(pInit->text, gwinGetDefaultFont(), gdispGetWidth() - pInit->g.x);
}

73
src/gwin/list.c 100644
View File

@ -0,0 +1,73 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/list.h
* @brief GWIN list widget header file.
*
* @defgroup List List
* @ingroup GWIN
*
* @{
*/
#include "gfx.h"
#if GFX_USE_GWIN && GWIN_NEED_LIST
#include "gwin/class_gwin.h"
static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
}
static const gwidgetVMT listVMT = {
{
"List", // The class name
sizeof(GListObject), // The object size
_gwidgetDestroy, // The destroy routine
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
gwinListDefaultDraw, // default drawing routine
#if GWINPUT_NEED_MOUSE
{
0,
0,
0,
},
#endif
#if GINPUT_NEED_TOGGLE
{
0,
0,
0,
0,
0,
},
#endif
#if GINPUT_NEED_DIAL
{
0,
0,
0,
0,
},
#endif
};
GHandle gwinListCreate(GListObject* widget, GWidgetInit* pInit) {
if (!(widget = (GListObject *)_gwidgetCreate(&widget->w, pInit, &listVMT)))
return 0;
gwinSetVisible(&widget->w.g, pInit->g.show);
return (GHandle)widget;
}
#endif // GFX_USE_GWIN && GWIN_NEED_LIST