aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/gwin/class_gwin.h40
-rw-r--r--include/gwin/frame.h4
-rw-r--r--include/gwin/ggroup.h1
-rw-r--r--src/gwin/frame.c112
-rw-r--r--src/gwin/ggroup.c4
-rw-r--r--src/gwin/gwin.mk1
6 files changed, 60 insertions, 102 deletions
diff --git a/include/gwin/class_gwin.h b/include/gwin/class_gwin.h
index ae5ac756..e3fb74d6 100644
--- a/include/gwin/class_gwin.h
+++ b/include/gwin/class_gwin.h
@@ -23,20 +23,23 @@
#if GFX_USE_GWIN || defined(__DOXYGEN__)
+#include "gwin/ggroup.h"
+
/**
* @brief The predefined flags for a Window
* @{
*/
-#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
+#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
/* @} */
/**
@@ -104,6 +107,18 @@ 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
@@ -206,6 +221,10 @@ 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
@@ -214,3 +233,4 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit
#endif /* _CLASS_GWIN_H */
/** @} */
+
diff --git a/include/gwin/frame.h b/include/gwin/frame.h
index 2f1b93db..6c745dc8 100644
--- a/include/gwin/frame.h
+++ b/include/gwin/frame.h
@@ -31,7 +31,7 @@
#define GWIN_FRAME_MINMAX_BTN (GWIN_FIRST_CONTROL_FLAG << 2)
typedef struct GFrameObject {
- GWidgetObject w;
+ GGroupObject 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, GWidgetInit *pInit, uint16_t flags);
+GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint32_t flags);
#define gwinFrameCreate(fo, pInit, flags) gwinGFrameCreate(GDISP, fo, pInit, flags);
#endif /* _GWIN_FRAME_H */
diff --git a/include/gwin/ggroup.h b/include/gwin/ggroup.h
index b58f415b..353987f0 100644
--- a/include/gwin/ggroup.h
+++ b/include/gwin/ggroup.h
@@ -41,6 +41,5 @@ typedef struct GGroupObject {
} GGroupObject;
/** @} */
-
#endif /* _GGROUP_H */
diff --git a/src/gwin/frame.c b/src/gwin/frame.c
index fbef54dc..d8676449 100644
--- a/src/gwin/frame.c
+++ b/src/gwin/frame.c
@@ -17,7 +17,7 @@
#include "gfx.h"
-#if (GFX_USE_GWIN && GWIN_NEED_FRAME) || defined(__DOXYGEN__)
+#if GFX_USE_GWIN && GWIN_NEED_FRAME
/* Some values for the default render */
#define BORDER_X 5
@@ -29,7 +29,7 @@
#define gh2obj ((GFrameObject *)gh)
/* Forware declarations */
-void gwinFrameDraw_Std(GWidgetObject *gw, void *param);
+void gwinFrameDraw_Std(GWindowObject *gw);
static void _callbackBtn(void *param, GEvent *pe);
static void _frameDestroy(GHandle gh) {
@@ -41,83 +41,34 @@ static void _frameDestroy(GHandle gh) {
_gwidgetDestroy(gh);
}
-#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 = {
+static const ggroupVMT frameVMT = {
{
"Frame", // The classname
sizeof(GFrameObject), // The object size
_frameDestroy, // The destroy routie
- _gwidgetRedraw, // The redraw routine
+ gwinFrameDraw_Std, // 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, GWidgetInit *pInit, uint16_t flags) {
- uint16_t tmp;
-
- if (!(fo = (GFrameObject *)_gwidgetCreate(g, &fo->w, pInit, &frameVMT)))
+GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWindowInit *pInit, uint32_t flags) {
+ if (!(fo = (GFrameObject *)_ggroupCreate(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 ((fo->w.g.flags & GWIN_FRAME_CLOSE_BTN) || (fo->w.g.flags & GWIN_FRAME_MINMAX_BTN)) {
+ if ((flags & GWIN_FRAME_CLOSE_BTN) || (flags & GWIN_FRAME_MINMAX_BTN)) {
+ flags |= GWIN_FRAME_BORDER; // Buttons require a border
geventListenerInit(&fo->gl);
gwinAttachListener(&fo->gl);
geventRegisterCallback(&fo->gl, _callbackBtn, (GHandle)fo);
}
/* create close button if necessary */
- if (fo->w.g.flags & GWIN_FRAME_CLOSE_BTN) {
+ if ((flags & GWIN_FRAME_CLOSE_BTN)) {
GWidgetInit wi;
wi.customDraw = 0;
@@ -135,7 +86,7 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint
}
/* create minimize and maximize buttons if necessary */
- if (fo->w.g.flags & GWIN_FRAME_MINMAX_BTN) {
+ if ((flags & GWIN_FRAME_MINMAX_BTN)) {
GWidgetInit wi;
wi.customDraw = 0;
@@ -160,7 +111,8 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint
gwinAddChild((GHandle)fo, fo->btnMax, FALSE);
}
- gwinSetVisible(&fo->w.g, pInit->g.show);
+ fo->w.g.flags |= flags & (GWIN_FRAME_BORDER|GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN);
+ gwinSetVisible(&fo->w.g, pInit->show);
return (GHandle)fo;
}
@@ -186,47 +138,36 @@ static void _callbackBtn(void *param, GEvent *pe) {
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-// Default render routines //
+// Render routine //
///////////////////////////////////////////////////////////////////////////////////////////////////
-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;
+void gwinFrameDraw_Std(GHandle gh) {
color_t border;
color_t background;
- (void)param;
+ color_t text;
- if (gw->g.vmt != (gwinVMT *)&frameVMT)
+ if (gh->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(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height);
+ gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
#endif
// Render the actual frame (with border, if any)
- 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);
+ 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);
} 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(gw->g.display, gw->g.x + BORDER_X, gw->g.y + BORDER_Y, gw->g.width, gw->g.height, background);
+ gdispGFillArea(gh->display, gh->x + BORDER_X, gh->y + BORDER_Y, gh->width, gh->height, background);
}
- // Render frame title - if any
+/* // Render frame title - if any
if (gw->text != NULL) {
coord_t text_y;
@@ -234,12 +175,9 @@ void gwinFrameDraw_Std(GWidgetObject *gw, void *param) {
gdispGDrawString(gw->g.display, gw->g.x + BORDER_X, gw->g.y + text_y, gw->text, gw->g.font, pcol->text);
}
+*/
- #if GDISP_NEED_CLIP
- gdispGUnsetClip(gw->g.display);
- #endif
-
- gwinRedrawChildren((GHandle)gw);
+ gwinRedrawChildren(gh);
}
#endif /* (GFX_USE_GWIN && GWIN_NEED_FRAME) || defined(__DOXYGEN__) */
diff --git a/src/gwin/ggroup.c b/src/gwin/ggroup.c
index 3bfefe38..2686d204 100644
--- a/src/gwin/ggroup.c
+++ b/src/gwin/ggroup.c
@@ -11,8 +11,8 @@
#include "gwin/class_gwin.h"
-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)))
+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)))
return NULL;
go->parent = NULL;
diff --git a/src/gwin/gwin.mk b/src/gwin/gwin.mk
index dbca7fd8..bf886c9a 100644
--- a/src/gwin/gwin.mk
+++ b/src/gwin/gwin.mk
@@ -1,4 +1,5 @@
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 \