aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2013-05-20 07:01:20 +0200
committerJoel Bodenmann <joel@unormal.org>2013-05-20 07:01:20 +0200
commitd4e0ce8b70d58e1e39cf58d681486b4d8657820b (patch)
tree0ba9fb4ae90fc9cf8a40cf86eaa49a1931d4c0fb /src
parent4d4a78f415214c5fb55df02ebb9747e7878fb533 (diff)
downloaduGFX-d4e0ce8b70d58e1e39cf58d681486b4d8657820b.tar.gz
uGFX-d4e0ce8b70d58e1e39cf58d681486b4d8657820b.tar.bz2
uGFX-d4e0ce8b70d58e1e39cf58d681486b4d8657820b.zip
added gwin enabled parameter and implemented button enable/disable functions
Diffstat (limited to 'src')
-rw-r--r--src/gwin/button.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gwin/button.c b/src/gwin/button.c
index 96478390..574e6330 100644
--- a/src/gwin/button.c
+++ b/src/gwin/button.c
@@ -55,6 +55,10 @@ static void gwinButtonCallback(void *param, GEvent *pe) {
#define pxe ((GEventToggle *)pe)
#define pbe ((GEventGWinButton *)pe)
+ // check if button is disabled
+ if (gh->enabled == false)
+ return;
+
switch (pe->type) {
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
case GEVENT_MOUSE:
@@ -135,6 +139,7 @@ static void gwinButtonCallback(void *param, GEvent *pe) {
GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width, coord_t height, font_t font, GButtonType type) {
if (!(gb = (GButtonObject *)_gwinInit((GWindowObject *)gb, x, y, width, height, sizeof(GButtonObject))))
return 0;
+
gb->gwin.type = GW_BUTTON;
gb->fn = 0;
gb->param = 0;
@@ -145,6 +150,10 @@ GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width,
gb->txt = "";
geventListenerInit(&gb->listener);
geventRegisterCallback(&gb->listener, gwinButtonCallback, gb);
+
+ // buttons are enabled by default
+ gb->gwin.enabled = true;
+
return (GHandle)gb;
}
@@ -225,6 +234,7 @@ void gwinButtonDraw(GHandle gh) {
#endif
gbw->fn(gh,
+ gbw->gwin.enabled,
gbw->state == GBTN_DOWN,
gh->font && gbw->txt ? gbw->txt : "",
gbw->state == GBTN_DOWN ? &gbw->dn : &gbw->up,
@@ -245,6 +255,13 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param) {
#undef gbw
}
+void gwinButtonSetEnabled(GHandle gh, bool_t enabled) {
+ if (gh->type != GW_BUTTON)
+ return;
+
+ gh->enabled = enabled;
+}
+
void gwinButtonDraw_3D(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
(void) isdown;
(void) param;