aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwin_textedit.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 19:36:14 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 19:36:14 +0200
commit46ba0420c342eaed1e4365c7e4cb65c0263bc7eb (patch)
treed33b8e13e3f06fb4ed838851f9c2c6d4043542eb /src/gwin/gwin_textedit.c
parent213013e68e64a655e0c6cb56875ea9a7977fe2f6 (diff)
downloaduGFX-46ba0420c342eaed1e4365c7e4cb65c0263bc7eb.tar.gz
uGFX-46ba0420c342eaed1e4365c7e4cb65c0263bc7eb.tar.bz2
uGFX-46ba0420c342eaed1e4365c7e4cb65c0263bc7eb.zip
Adding TextEdit dummy widget (not implemented yet)
Diffstat (limited to 'src/gwin/gwin_textedit.c')
-rw-r--r--src/gwin/gwin_textedit.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c
new file mode 100644
index 00000000..4aa41d61
--- /dev/null
+++ b/src/gwin/gwin_textedit.c
@@ -0,0 +1,113 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/**
+ * @file src/gwin/gwin_textedit.c
+ * @brief GWIN TextEdit widget header file
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GWIN && GWIN_NEED_TEXTEDIT
+
+#include "gwin_class.h"
+
+// Text padding (between edge and text) in pixels
+const int TEXT_PADDING = 3;
+
+// macros to assist in data type conversions
+#define gh2obj ((GTexteditObject *)gh)
+#define gw2obj ((GTexteditObject *)gw)
+
+#if GINPUT_NEED_KEYBOARD
+ static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke)
+ {
+ if (pke->bytecount = 1) {
+ //gw->text = pke->c[0];
+ gwinSetText((GHandle)gw, &(pke->c[0]), TRUE);
+ }
+
+ _gwinUpdate(&gw);
+ }
+#endif
+
+static void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param);
+
+static const gwidgetVMT texteditVMT = {
+ {
+ "TextEdit", // The class name
+ sizeof(GTexteditObject), // The object size
+ _gwidgetDestroy, // The destroy routine
+ _gwidgetRedraw, // The redraw routine
+ 0, // The after-clear routine
+ },
+ gwinTexteditDefaultDraw, // default drawing routine
+ #if GINPUT_NEED_MOUSE
+ {
+ 0, // Process mose down events (NOT USED)
+ 0, // Process mouse up events (NOT USED)
+ 0, // Process mouse move events (NOT USED)
+ },
+ #endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ _keyboardEvent, // Process keyboard key down events
+ },
+ #endif
+ #if GINPUT_NEED_TOGGLE
+ {
+ 0, // No toggle role
+ 0, // Assign Toggles (NOT USED)
+ 0, // Get Toggles (NOT USED)
+ 0, // Process toggle off event (NOT USED)
+ 0, // Process toggle on event (NOT USED)
+ },
+ #endif
+ #if GINPUT_NEED_DIAL
+ {
+ 0, // No dial roles
+ 0, // Assign Dials (NOT USED)
+ 0, // Get Dials (NOT USED)
+ 0, // Procees dial move events (NOT USED)
+ },
+ #endif
+};
+
+GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* widget, GWidgetInit* pInit)
+{
+ uint16_t flags = 0;
+
+ if (!(widget = (GTexteditObject*)_gwidgetCreate(g, &widget->w, pInit, &texteditVMT))) {
+ return 0;
+ }
+
+ widget->w.g.flags |= flags;
+ gwinSetVisible(&widget->w.g, pInit->g.show);
+
+ return (GHandle)widget;
+}
+
+static void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
+{
+ color_t textColor;
+ (void) param;
+
+ // Is it a valid handle?
+ if (gw->g.vmt != (gwinVMT*)&texteditVMT) {
+ return;
+ }
+
+ textColor = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
+
+
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, textColor, gw->pstyle->background, justifyLeft);
+}
+
+#undef gh2obj
+#undef gw2obj
+
+#endif // GFX_USE_GWIN && GWIN_NEED_TEXTEDIT