aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2013-07-02 19:26:48 +0200
committerJoel Bodenmann <joel@unormal.org>2013-07-02 19:26:48 +0200
commit3f80e1f89dbeec06dd97a914d6851ad4596b1743 (patch)
treebe9087bf08cb186f521aa5a68a7f32a484f1f7e0 /src
parentad57ab7967d0e0ee3cfce8746b0c4969cfe970fd (diff)
downloaduGFX-3f80e1f89dbeec06dd97a914d6851ad4596b1743.tar.gz
uGFX-3f80e1f89dbeec06dd97a914d6851ad4596b1743.tar.bz2
uGFX-3f80e1f89dbeec06dd97a914d6851ad4596b1743.zip
label work in progress - not working anymore
Diffstat (limited to 'src')
-rw-r--r--src/gwin/gwin.c4
-rw-r--r--src/gwin/label.c120
2 files changed, 67 insertions, 57 deletions
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 75f1b2d3..f080ac64 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -143,6 +143,10 @@ void gwinSetDefaultBgColor(color_t bgclr) {
void gwinSetDefaultFont(font_t font) {
defaultFont = font;
}
+
+ font_t gwinGetDefaultFont(void) {
+ return defaultFont;
+ }
#endif
/*-----------------------------------------------
diff --git a/src/gwin/label.c b/src/gwin/label.c
index 8c892217..7f8ab814 100644
--- a/src/gwin/label.c
+++ b/src/gwin/label.c
@@ -21,74 +21,80 @@
#include "gwin/class_gwin.h"
-#define widget(gh) ((GLabelWidget*)gh)
-
-static void _destroy(GWindowObject *gh) {
- (void)gh;
-
- return;
-}
-
-static void _redraw(GWindowObject *gh) {
- (void)gh;
-
- return;
-}
+#define widget(gh) ((GLabelWidget*)gh)
+#define GLABEL_FLG_WAUTO (GWIN_FIRST_CONTROL_FLAG<<0)
+#define GLABEL_FLG_HAUTO (GWIN_FIRST_CONTROL_FLAG<<1)
+
+static void gwinLabelDefaultDraw(GHandle gh) {
+ // if( check if auto flag is set )
+ // if( call current size != font size )
+ // gwinResize();
+
+ gdispFillString( widget(gh)->w.g.x,
+ widget(gh)->w.g.y,
+ widget(gh)->w.txt,
+ widget(gh)->w.g.font,
+ widget(gh)->w.g.color,
+ widget(gh)->w.g.bgcolor
+ );
-static void _afterClear(GWindowObject *gh) {
- (void)gh;
+ gdispFillArea( widget(gh)->w.g.x, widget(gh)->w.g.y, widget(gh)->w.g.width, widget(gh)->w.g.height, Green);
- return;
+ printf("Text: %s\r\n", widget(gh)->w.txt);
}
-static const gwinVMT labelVMT = {
- "Label", // The class name
- sizeof(GLabelWidget), // The object size
- _destroy, // The destroy routine
- 0, // The redraw routine
- _afterClear // The after-clear routine
+static const gwidgetVMT labelVMT = {
+ {
+ "Label", // The class name
+ sizeof(GLabelWidget), // The object size
+ _gwidgetDestroy, // The destroy routine
+ _gwidgetRedraw, // The redraw routine
+ 0, // The after-clear routine
+ },
+ gwinLabelDefaultDraw, // default drawing routine
+ {
+ 0, // Process mose down events (NOT USED)
+ 0, // Process mouse up events (NOT USED)
+ 0, // Process mouse move events (NOT USED)
+ },
+ {
+ 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)
+ },
+ {
+ 0, // No dial roles
+ 0, // Assign Dials (NOT USED)
+ 0, // Get Dials (NOT USED)
+ 0, // Procees dial move events (NOT USED)
+ }
};
-GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit) {
- if (!(widget = (GLabelWidget *)_gwindowCreate(&widget->g, pInit, &labelVMT, 0)))
+GHandle gwinLabelCreate(GLabelWidget *widget, GWidgetInit *pInit) {
+ uint16_t flags = 0;
+
+ // auto assign width
+ if (pInit->g.width <= 0) {
+ flags |= GLABEL_FLG_WAUTO;
+ pInit->g.width = gdispGetStringWidth(pInit->text, gwinGetDefaultFont());
+ }
+
+ // auto assign height
+ if (pInit->g.height <= 0) {
+ flags |= GLABEL_FLG_HAUTO;
+ pInit->g.height = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight);
+ }
+
+ if (!(widget = (GLabelWidget *)_gwidgetCreate(&widget->w, pInit, &labelVMT)))
return 0;
- widget->g.x = pInit->x;
- widget->g.y = pInit->y;
- widget->g.width = pInit->width;
- widget->g.height = pInit->height;
- gwinSetVisible((GHandle)widget, pInit->show);
+ gwinLabelDefaultDraw((GHandle)widget);
+ widget->w.g.flags |= flags;
return (GHandle)widget;
}
-void gwinLabelSetColor(GHandle gh, color_t color) {
- widget(gh)->g.color = color;
-}
-
-void gwinLabelSetBgColor(GHandle gh, color_t bgColor) {
- widget(gh)->g.bgcolor = bgColor;
-}
-
-void gwinLabelSetFont(GHandle gh, font_t font) {
- widget(gh)->g.font = font;
-}
-
-void gwinLabelSetText(GHandle gh, const char* text) {
- widget(gh)->text = text;
-
- gwinLabelDraw(gh);
-}
-
-void gwinLabelDraw(GHandle gh) {
- gdispFillString( widget(gh)->g.x,
- widget(gh)->g.y,
- widget(gh)->text,
- widget(gh)->g.font,
- widget(gh)->g.color,
- widget(gh)->g.bgcolor
- );
-}
-
#endif // GFX_USE_GWIN && GFX_NEED_LABEL