Revert "ggroup compilable"

This reverts commit 935e949af9.
ugfx_release_2.6
Joel Bodenmann 2014-02-01 22:42:30 +01:00
parent 935e949af9
commit 84367d080f
6 changed files with 102 additions and 60 deletions

View File

@ -23,23 +23,20 @@
#if GFX_USE_GWIN || defined(__DOXYGEN__)
#include "gwin/ggroup.h"
/**
* @brief The predefined flags for a Window
* @{
*/
#define GWIN_FLG_DYNAMIC 0x00000001 // @< The GWIN structure is allocated
#define GWIN_FLG_VISIBLE 0x00000002 // @< The window is visible
#define GWIN_FLG_MINIMIZED 0x00000004 // @< The window is minimized
#define GWIN_FLG_MAXIMIZED 0x00000008 // @< The window is maximized
#define GWIN_FLG_ENABLED 0x00000010 // @< The window is enabled
#define GWIN_FLG_WIDGET 0x00000020 // @< This is a widget
#define GWIN_FLG_ALLOCTXT 0x00000040 // @< The widget text is allocated
#define GWIN_FLG_MOUSECAPTURE 0x00000080 // @< The widget has captured the mouse
#define GWIN_FLG_GROUP 0x00000100 // @< This is a group
#define GWIN_FIRST_WM_FLAG 0x00100000 // @< 4 bits free for the window manager to use
#define GWIN_FIRST_CONTROL_FLAG 0x01000000 // @< 8 bits free for Windows and Widgets to use
#define GWIN_FLG_DYNAMIC 0x0001 // @< The GWIN structure is allocated
#define GWIN_FLG_VISIBLE 0x0002 // @< The window is visible
#define GWIN_FLG_MINIMIZED 0x0004 // @< The window is minimized
#define GWIN_FLG_MAXIMIZED 0x0008 // @< The window is maximized
#define GWIN_FLG_ENABLED 0x0010 // @< The window is enabled
#define GWIN_FLG_WIDGET 0x0020 // @< This is a widget
#define GWIN_FLG_ALLOCTXT 0x0040 // @< The widget text is allocated
#define GWIN_FLG_MOUSECAPTURE 0x0080 // @< The widget has captured the mouse
#define GWIN_FIRST_WM_FLAG 0x0100 // @< 4 bits free for the window manager to use
#define GWIN_FIRST_CONTROL_FLAG 0x1000 // @< 4 bits free for Windows and Widgets to use
/* @} */
/**
@ -107,18 +104,6 @@ typedef struct gwinVMT {
/* @} */
#endif
#if GWIN_NEED_GROUPS || defined(__DOXYGEN__)
/**
* @brief The Virtual Method Table for a group
* @note A widget must have a redraw function. It must call gwinRedrawChildren() after redrawing itself
* @{
*/
typedef struct ggroupVMT {
struct gwinVMT g; // @< This is still a GWIN
} ggroupVMT;
/* @} */
#endif
// These flags are needed whether or not we are running a window manager.
/**
* @brief Flags for redrawing after a visibility change
@ -221,10 +206,6 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit
void _gwidgetRedraw(GHandle gh);
#endif
#if GWIN_NEED_GROUPS || defined(__DOXYGEN__)
GHandle _ggroupCreate(GDisplay *g, GGroupObject *go, const GWindowInit *pInit, const ggroupVMT *vmt);
#endif
#ifdef __cplusplus
}
#endif
@ -233,4 +214,3 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit
#endif /* _CLASS_GWIN_H */
/** @} */

View File

@ -31,7 +31,7 @@
#define GWIN_FRAME_MINMAX_BTN (GWIN_FIRST_CONTROL_FLAG << 2)
typedef struct GFrameObject {
GGroupObject w;
GWidgetObject w;
GListener gl; // internal listener for the buttons
// These could probably be removed... I have to think harder later
@ -60,7 +60,7 @@ typedef struct GFrameObject {
*
* @api
*/
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint32_t flags);
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint16_t flags);
#define gwinFrameCreate(fo, pInit, flags) gwinGFrameCreate(GDISP, fo, pInit, flags);
#endif /* _GWIN_FRAME_H */

View File

@ -41,5 +41,6 @@ typedef struct GGroupObject {
} GGroupObject;
/** @} */
#endif /* _GGROUP_H */

View File

@ -17,7 +17,7 @@
#include "gfx.h"
#if GFX_USE_GWIN && GWIN_NEED_FRAME
#if (GFX_USE_GWIN && GWIN_NEED_FRAME) || defined(__DOXYGEN__)
/* Some values for the default render */
#define BORDER_X 5
@ -29,7 +29,7 @@
#define gh2obj ((GFrameObject *)gh)
/* Forware declarations */
void gwinFrameDraw_Std(GWindowObject *gw);
void gwinFrameDraw_Std(GWidgetObject *gw, void *param);
static void _callbackBtn(void *param, GEvent *pe);
static void _frameDestroy(GHandle gh) {
@ -41,34 +41,83 @@ static void _frameDestroy(GHandle gh) {
_gwidgetDestroy(gh);
}
static const ggroupVMT frameVMT = {
#if GINPUT_NEED_MOUSE
static void _mouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
}
static void _mouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
}
static void _mouseMove(GWidgetObject *gw, coord_t x, coord_t y) {
}
#endif
static const gwidgetVMT frameVMT = {
{
"Frame", // The classname
sizeof(GFrameObject), // The object size
_frameDestroy, // The destroy routie
gwinFrameDraw_Std, // The redraw routine
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
gwinFrameDraw_Std, // The default drawing routine
#if GINPUT_NEED_MOUSE
{
_mouseDown, // Process mouse down event
_mouseUp, // Process mouse up events
_mouseMove, // Process mouse move events
},
#endif
#if GINPUT_NEED_TOGGLE
{
0, // 1 toggle role
0, // Assign Toggles
0, // Get Toggles
0, // Process toggle off events
0, // Process toggle on events
},
#endif
#if GINPUT_NEED_DIAL
{
0, // 1 dial roles
0, // Assign Dials
0, // Get Dials
0, // Process dial move events
},
#endif
};
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint32_t flags) {
if (!(fo = (GFrameObject *)_ggroupCreate(g, &fo->w, pInit, &frameVMT)))
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint16_t flags) {
uint16_t tmp;
if (!(fo = (GFrameObject *)_gwidgetCreate(g, &fo->w, pInit, &frameVMT)))
return 0;
fo->btnClose = NULL;
fo->btnMin = NULL;
fo->btnMax = NULL;
/* Buttons require a border */
tmp = flags;
if ((tmp & GWIN_FRAME_CLOSE_BTN || tmp & GWIN_FRAME_MINMAX_BTN) && !(tmp & GWIN_FRAME_BORDER)) {
tmp |= GWIN_FRAME_BORDER;
}
/* apply flags */
fo->w.g.flags |= tmp;
/* create and initialize the listener if any button is present. */
if ((flags & GWIN_FRAME_CLOSE_BTN) || (flags & GWIN_FRAME_MINMAX_BTN)) {
flags |= GWIN_FRAME_BORDER; // Buttons require a border
if ((fo->w.g.flags & GWIN_FRAME_CLOSE_BTN) || (fo->w.g.flags & GWIN_FRAME_MINMAX_BTN)) {
geventListenerInit(&fo->gl);
gwinAttachListener(&fo->gl);
geventRegisterCallback(&fo->gl, _callbackBtn, (GHandle)fo);
}
/* create close button if necessary */
if ((flags & GWIN_FRAME_CLOSE_BTN)) {
if (fo->w.g.flags & GWIN_FRAME_CLOSE_BTN) {
GWidgetInit wi;
wi.customDraw = 0;
@ -86,7 +135,7 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint
}
/* create minimize and maximize buttons if necessary */
if ((flags & GWIN_FRAME_MINMAX_BTN)) {
if (fo->w.g.flags & GWIN_FRAME_MINMAX_BTN) {
GWidgetInit wi;
wi.customDraw = 0;
@ -111,8 +160,7 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint
gwinAddChild((GHandle)fo, fo->btnMax, FALSE);
}
fo->w.g.flags |= flags & (GWIN_FRAME_BORDER|GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN);
gwinSetVisible(&fo->w.g, pInit->show);
gwinSetVisible(&fo->w.g, pInit->g.show);
return (GHandle)fo;
}
@ -138,36 +186,47 @@ static void _callbackBtn(void *param, GEvent *pe) {
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Render routine //
// Default render routines //
///////////////////////////////////////////////////////////////////////////////////////////////////
void gwinFrameDraw_Std(GHandle gh) {
static const GColorSet* _getDrawColors(GWidgetObject *gw) {
if (!(gw->g.flags & GWIN_FLG_ENABLED))
return &gw->pstyle->disabled;
//if ((gw->g.flags & GBUTTON_FLG_PRESSED))
// return &gw->pstyle->pressed;
return &gw->pstyle->enabled;
}
void gwinFrameDraw_Std(GWidgetObject *gw, void *param) {
GColorSet *pcol;
color_t border;
color_t background;
color_t text;
(void)param;
if (gh->vmt != (gwinVMT *)&frameVMT)
if (gw->g.vmt != (gwinVMT *)&frameVMT)
return;
pcol = _getDrawColors(gw);
// do some magic to make the background lighter than the widgets. Fix this somewhen.
border = HTML2COLOR(0x2698DE);
background = HTML2COLOR(0xEEEEEE);
text = White;
#if GDISP_NEED_CLIP
gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
gdispGSetClip(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height);
#endif
// Render the actual frame (with border, if any)
if (gh->flags & GWIN_FRAME_BORDER) {
gdispGFillArea(gh->display, gh->x, gh->y, gh->width, gh->height, border);
gdispGFillArea(gh->display, gh->x + BORDER_X, gh->y + BORDER_Y, gh->width - 2*BORDER_X, gh->width - BORDER_Y - BORDER_X, background);
if (gw->g.flags & GWIN_FRAME_BORDER) {
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, border);
gdispGFillArea(gw->g.display, gw->g.x + BORDER_X, gw->g.y + BORDER_Y, gw->g.width - 2*BORDER_X, gw->g.width - BORDER_Y - BORDER_X, background);
} else {
// This ensure that the actual frame content (it's children) render at the same spot, no mather whether the frame has a border or not
gdispGFillArea(gh->display, gh->x + BORDER_X, gh->y + BORDER_Y, gh->width, gh->height, background);
gdispGFillArea(gw->g.display, gw->g.x + BORDER_X, gw->g.y + BORDER_Y, gw->g.width, gw->g.height, background);
}
/* // Render frame title - if any
// Render frame title - if any
if (gw->text != NULL) {
coord_t text_y;
@ -175,9 +234,12 @@ void gwinFrameDraw_Std(GHandle gh) {
gdispGDrawString(gw->g.display, gw->g.x + BORDER_X, gw->g.y + text_y, gw->text, gw->g.font, pcol->text);
}
*/
gwinRedrawChildren(gh);
#if GDISP_NEED_CLIP
gdispGUnsetClip(gw->g.display);
#endif
gwinRedrawChildren((GHandle)gw);
}
#endif /* (GFX_USE_GWIN && GWIN_NEED_FRAME) || defined(__DOXYGEN__) */

View File

@ -11,8 +11,8 @@
#include "gwin/class_gwin.h"
GHandle _ggroupCreate(GDisplay *g, GGroupObject *go, const GWindowInit *pInit, const ggroupVMT *vmt) {
if (!(go = (GGroupObject *)_gwindowCreate(g, &go->g, pInit, &vmt->g, GWIN_FLG_GROUP|GWIN_FLG_ENABLED)))
GHandle _ggroupCreate(GDisplay *g, GGroupObject *go, const GGroupInit *pInit) {
if (!(go = (GGroupObject *)_gwindowCreate(g, &go->g, &pInit->g, &vmt->g, GWIN_FLG_GROUP|GWIN_FLG_ENABLED)))
return NULL;
go->parent = NULL;

View File

@ -1,5 +1,4 @@
GFXSRC += $(GFXLIB)/src/gwin/gwin.c \
$(GFXLIB)/src/gwin/ggroup.c \
$(GFXLIB)/src/gwin/gwidget.c \
$(GFXLIB)/src/gwin/gwm.c \
$(GFXLIB)/src/gwin/console.c \