aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/frame.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-01-07 01:24:54 +0100
committerJoel Bodenmann <joel@unormal.org>2014-01-07 01:24:54 +0100
commitda13d31c6910a12fb6cb56717b24ffeb82ed2d68 (patch)
treeab7fa6c0b3a6fbfb9d95ac7cfb58d108d4b24e20 /src/gwin/frame.c
parentf3cbb02c3a9a199acfb04d543a8e160e83e00d49 (diff)
downloaduGFX-da13d31c6910a12fb6cb56717b24ffeb82ed2d68.tar.gz
uGFX-da13d31c6910a12fb6cb56717b24ffeb82ed2d68.tar.bz2
uGFX-da13d31c6910a12fb6cb56717b24ffeb82ed2d68.zip
implemented button callback in frame widget
Diffstat (limited to 'src/gwin/frame.c')
-rw-r--r--src/gwin/frame.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/gwin/frame.c b/src/gwin/frame.c
index 6472663c..a6b957f7 100644
--- a/src/gwin/frame.c
+++ b/src/gwin/frame.c
@@ -30,6 +30,16 @@
/* Forware declarations */
void gwinFrameDraw_Std(GWidgetObject *gw, void *param);
+static void _callbackBtn(void *param, GEvent *pe);
+
+static void _frameDestroy(GHandle gh) {
+ /* Detach all button sources */
+ // ToDo
+ //geventDetachSource(&gh2obj->gl, NULL);
+
+ /* call the gwidget standard destroy routine */
+ _gwidgetDestroy(gh);
+}
#if GINPUT_NEED_MOUSE
static void _mouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
@@ -49,7 +59,7 @@ static const gwidgetVMT frameVMT = {
{
"Frame", // The classname
sizeof(GFrameObject), // The object size
- _gwidgetDestroy, // The destroy routine
+ _frameDestroy, // The destroy routie
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
@@ -99,6 +109,13 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint
/* 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)) {
+ 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) {
GWidgetInit wi;
@@ -148,6 +165,26 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint
return (GHandle)fo;
}
+/* Process a button event */
+static void _callbackBtn(void *param, GEvent *pe) {
+ switch (pe->type) {
+ case GEVENT_GWIN_BUTTON:
+ if (((GEventGWinButton *)pe)->button == ((GFrameObject*)(GHandle)param)->btnClose)
+ gwinDestroy((GHandle)param);
+
+ else if (((GEventGWinButton *)pe)->button == ((GFrameObject*)(GHandle)param)->btnMin)
+ ;/* ToDo */
+
+ else if (((GEventGWinButton *)pe)->button == ((GFrameObject*)(GHandle)param)->btnMax)
+ ;/* ToDo */
+
+ break;
+
+ default:
+ break;
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// Default render routines //
///////////////////////////////////////////////////////////////////////////////////////////////////