aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/frame.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-02-01 22:42:30 +0100
committerJoel Bodenmann <joel@unormal.org>2014-02-01 22:42:30 +0100
commit84367d080f6e73ca2183320e768b5b3f1ce17025 (patch)
tree6ac4eae965c9097302f2f92e4a004434da6f3ceb /src/gwin/frame.c
parent935e949af94a3a80beb2c462ae425e4388fe2277 (diff)
downloaduGFX-84367d080f6e73ca2183320e768b5b3f1ce17025.tar.gz
uGFX-84367d080f6e73ca2183320e768b5b3f1ce17025.tar.bz2
uGFX-84367d080f6e73ca2183320e768b5b3f1ce17025.zip
Revert "ggroup compilable"
This reverts commit 935e949af94a3a80beb2c462ae425e4388fe2277.
Diffstat (limited to 'src/gwin/frame.c')
-rw-r--r--src/gwin/frame.c112
1 files changed, 87 insertions, 25 deletions
diff --git a/src/gwin/frame.c b/src/gwin/frame.c
index d8676449..fbef54dc 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
+#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__) */