diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2006-02-08 04:55:05 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2006-02-08 04:55:05 +0000 |
commit | 68b4e0616ab80a32903d0c6ede232e47d4d88382 (patch) | |
tree | d71f4054e5a360af26940acfe16053068206cedb | |
parent | 5c71af9339a592ef3759b40614685c83537d3ac3 (diff) | |
download | lcd4linux-68b4e0616ab80a32903d0c6ede232e47d4d88382.tar.gz |
[lcd4linux @ 2006-02-08 04:55:03 by reinelt]
moved widget registration to drv_generic_graphic
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@635 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r-- | drv_G15.c | 38 | ||||
-rw-r--r-- | drv_Image.c | 37 | ||||
-rw-r--r-- | drv_LPH7508.c | 38 | ||||
-rw-r--r-- | drv_LUIse.c | 36 | ||||
-rw-r--r-- | drv_Sample.c | 24 | ||||
-rw-r--r-- | drv_T6963.c | 37 | ||||
-rw-r--r-- | drv_X11.c | 44 | ||||
-rw-r--r-- | drv_generic_graphic.c | 70 | ||||
-rw-r--r-- | drv_serdisplib.c | 37 | ||||
-rw-r--r-- | layout.c | 19 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 16 | ||||
-rw-r--r-- | widget_image.c | 60 | ||||
-rw-r--r-- | widget_image.h | 13 |
13 files changed, 206 insertions, 263 deletions
@@ -1,4 +1,4 @@ -/* $Id: drv_G15.c,v 1.4 2006/01/30 06:25:49 reinelt Exp $ +/* $Id: drv_G15.c,v 1.5 2006/02/08 04:55:03 reinelt Exp $ * * Driver for Logitech G-15 keyboard LCD screen * @@ -24,6 +24,9 @@ * * * $Log: drv_G15.c,v $ + * Revision 1.5 2006/02/08 04:55:03 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.4 2006/01/30 06:25:49 reinelt * added CVS Revision * @@ -60,10 +63,6 @@ #include "qprintf.h" #include "udelay.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -273,17 +272,6 @@ static int drv_G15_start(const char *section) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_text_draw(W) */ -/* using drv_generic_text_icon_draw(W) */ -/* using drv_generic_text_bar_draw(W) */ -/* using drv_generic_gpio_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -299,10 +287,9 @@ int drv_G15_list(void) /* initialize driver & display */ int drv_G15_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.4 $"); + info("%s: %s", Name, "$Revision: 1.5 $"); DEBUG("entered"); @@ -327,20 +314,9 @@ int drv_G15_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); + /* register plugins */ + /* none at the moment... */ - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); DEBUG("left"); diff --git a/drv_Image.c b/drv_Image.c index 8d68e18..0ee912b 100644 --- a/drv_Image.c +++ b/drv_Image.c @@ -1,4 +1,4 @@ -/* $Id: drv_Image.c,v 1.16 2006/02/06 06:29:30 reinelt Exp $ +/* $Id: drv_Image.c,v 1.17 2006/02/08 04:55:04 reinelt Exp $ * * new style Image (PPM/PNG) Driver for LCD4Linux * @@ -23,6 +23,9 @@ * * * $Log: drv_Image.c,v $ + * Revision 1.17 2006/02/08 04:55:04 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.16 2006/02/06 06:29:30 reinelt * Image driver uses RGBA * @@ -124,10 +127,6 @@ #include "timer.h" #include "qprintf.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -461,16 +460,6 @@ static int drv_IMG_start(const char *section) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_graphic_draw(W) */ -/* using drv_generic_graphic_icon_draw(W) */ -/* using drv_generic_graphic_bar_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -487,10 +476,9 @@ int drv_IMG_list(void) int drv_IMG_init(const char *section, const __attribute__ ((unused)) int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.16 $"); + info("%s: %s", Name, "$Revision: 1.17 $"); /* real worker functions */ drv_generic_graphic_real_blit = drv_IMG_blit; @@ -503,21 +491,6 @@ int drv_IMG_init(const char *section, const __attribute__ ((unused)) if ((ret = drv_generic_graphic_init(section, Name)) != 0) return ret; - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ /* none at the moment... */ diff --git a/drv_LPH7508.c b/drv_LPH7508.c index f49b9a5..cd53c8e 100644 --- a/drv_LPH7508.c +++ b/drv_LPH7508.c @@ -1,4 +1,4 @@ -/* $Id: drv_LPH7508.c,v 1.8 2006/01/30 06:25:53 reinelt Exp $ +/* $Id: drv_LPH7508.c,v 1.9 2006/02/08 04:55:04 reinelt Exp $ * * driver for Pollin LPH7508 * @@ -23,6 +23,9 @@ * * * $Log: drv_LPH7508.c,v $ + * Revision 1.9 2006/02/08 04:55:04 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.8 2006/01/30 06:25:53 reinelt * added CVS Revision * @@ -73,10 +76,6 @@ #include "qprintf.h" #include "udelay.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" #include "drv_generic_gpio.h" @@ -466,17 +465,6 @@ static void plugin_contrast(RESULT * result, RESULT * arg1) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_graphic_draw(W) */ -/* using drv_generic_graphic_icon_draw(W) */ -/* using drv_generic_graphic_bar_draw(W) */ -/* using drv_generic_gpio_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -492,10 +480,9 @@ int drv_L7_list(void) /* initialize driver & display */ int drv_L7_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.8 $"); + info("%s: %s", Name, "$Revision: 1.9 $"); /* real worker functions */ drv_generic_graphic_real_blit = drv_L7_blit; @@ -522,21 +509,6 @@ int drv_L7_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ AddFunction("LCD::contrast", 1, plugin_contrast); diff --git a/drv_LUIse.c b/drv_LUIse.c index 7814791..5548de9 100644 --- a/drv_LUIse.c +++ b/drv_LUIse.c @@ -1,4 +1,4 @@ -/* $Id: drv_LUIse.c,v 1.3 2006/01/30 06:25:53 reinelt Exp $ +/* $Id: drv_LUIse.c,v 1.4 2006/02/08 04:55:05 reinelt Exp $ * * LUIse lcd4linux driver * @@ -23,6 +23,9 @@ * * * $Log: drv_LUIse.c,v $ + * Revision 1.4 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.3 2006/01/30 06:25:53 reinelt * added CVS Revision * @@ -57,10 +60,6 @@ #include "qprintf.h" #include "udelay.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -266,15 +265,6 @@ static void plugin_backlight(RESULT * result, RESULT * arg1) SetResult(&result, R_NUMBER, &backlight); } -/****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_text_draw(W) */ -/* using drv_generic_text_icon_draw(W) */ -/* using drv_generic_text_bar_draw(W) */ - /****************************************/ /*** exported functions ***/ @@ -291,10 +281,9 @@ int drv_LUIse_list(void) /* initialize driver & display */ int drv_LUIse_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.3 $"); + info("%s: %s", Name, "$Revision: 1.4 $"); /* real worker functions */ drv_generic_graphic_real_blit = drv_LUIse_blit; @@ -316,21 +305,6 @@ int drv_LUIse_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ AddFunction("LCD::contrast", 1, plugin_contrast); AddFunction("LCD::backlight", 1, plugin_backlight); diff --git a/drv_Sample.c b/drv_Sample.c index 23e7332..c57cdf3 100644 --- a/drv_Sample.c +++ b/drv_Sample.c @@ -1,4 +1,4 @@ -/* $Id: drv_Sample.c,v 1.5 2006/01/30 06:25:53 reinelt Exp $ +/* $Id: drv_Sample.c,v 1.6 2006/02/08 04:55:05 reinelt Exp $ * * sample lcd4linux driver * @@ -23,6 +23,9 @@ * * * $Log: drv_Sample.c,v $ + * Revision 1.6 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.5 2006/01/30 06:25:53 reinelt * added CVS Revision * @@ -436,7 +439,7 @@ int drv_Sample_init(const char *section, const int quiet) WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.5 $"); + info("%s: %s", Name, "$Revision: 1.6 $"); /* display preferences */ XRES = 5; /* pixel width of one char */ @@ -513,7 +516,6 @@ int drv_Sample_init(const char *section, const int quiet) /* use this function for a graphic display */ int drv_Sample_init2(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; /* real worker functions */ @@ -539,25 +541,9 @@ int drv_Sample_init2(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ AddFunction("LCD::contrast", 1, plugin_contrast); - return 0; } diff --git a/drv_T6963.c b/drv_T6963.c index 9cc64dd..eab3a30 100644 --- a/drv_T6963.c +++ b/drv_T6963.c @@ -1,4 +1,4 @@ -/* $Id: drv_T6963.c,v 1.18 2006/01/30 06:25:54 reinelt Exp $ +/* $Id: drv_T6963.c,v 1.19 2006/02/08 04:55:05 reinelt Exp $ * * new style driver for T6963-based displays * @@ -23,6 +23,9 @@ * * * $Log: drv_T6963.c,v $ + * Revision 1.19 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.18 2006/01/30 06:25:54 reinelt * added CVS Revision * @@ -119,10 +122,6 @@ #include "qprintf.h" #include "udelay.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" #include "drv_generic_parport.h" @@ -568,16 +567,6 @@ static int drv_T6_start(const char *section) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_graphic_draw(W) */ -/* using drv_generic_graphic_icon_draw(W) */ -/* using drv_generic_graphic_bar_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -597,10 +586,9 @@ int drv_T6_list(void) /* initialize driver & display */ int drv_T6_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.18 $"); + info("%s: %s", Name, "$Revision: 1.19 $"); /* real worker functions */ drv_generic_graphic_real_blit = drv_T6_blit; @@ -622,21 +610,6 @@ int drv_T6_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ /* none at the moment... */ @@ -1,4 +1,4 @@ -/* $Id: drv_X11.c,v 1.15 2006/01/30 06:25:54 reinelt Exp $ +/* $Id: drv_X11.c,v 1.16 2006/02/08 04:55:05 reinelt Exp $ * * new style X11 Driver for LCD4Linux * @@ -26,6 +26,9 @@ * * * $Log: drv_X11.c,v $ + * Revision 1.16 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.15 2006/01/30 06:25:54 reinelt * added CVS Revision * @@ -111,11 +114,6 @@ #include "qprintf.h" #include "timer.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_image.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -360,17 +358,6 @@ static int drv_X11_start(const char *section) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_graphic_draw(W) */ -/* using drv_generic_graphic_icon_draw(W) */ -/* using drv_generic_graphic_image_draw(W) */ -/* using drv_generic_graphic_bar_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -386,10 +373,9 @@ int drv_X11_list(void) /* initialize driver & display */ int drv_X11_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.15 $"); + info("%s: %s", Name, "$Revision: 1.16 $"); /* start display */ if ((ret = drv_X11_start(section)) != 0) @@ -416,26 +402,6 @@ int drv_X11_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register image widget */ - wc = Widget_Image; - /* Fixme: wc.draw = drv_generic_graphic_image_draw; */ - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ /* none at the moment... */ diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c index 6a4bdeb..92b5a45 100644 --- a/drv_generic_graphic.c +++ b/drv_generic_graphic.c @@ -23,6 +23,9 @@ * * * $Log: drv_generic_graphic.c,v $ + * Revision 1.20 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.19 2006/02/07 05:36:13 reinelt * Layers added to Layout * @@ -144,6 +147,7 @@ #include "widget_text.h" #include "widget_icon.h" #include "widget_bar.h" +#include "widget_image.h" #include "rgb.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -518,6 +522,51 @@ int drv_generic_graphic_bar_draw(WIDGET * W) /****************************************/ +/*** generic image handling ***/ +/****************************************/ + +int drv_generic_graphic_image_draw(WIDGET * W) +{ + WIDGET_IMAGE *Image = W->data; + int layer, row, col, width, height; + int x, y; + + layer = W->layer; + row = W->row; + col = W->col; + width = Image->width; + height = Image->height; + + /* sanity check */ + if (layer < 0 || layer >= LAYERS) { + error("%s: layer %d out of bounds (0..%d)", Driver, layer, LAYERS - 1); + return -1; + } + + /* maybe grow layout framebuffer */ + drv_generic_graphic_resizeFB(row + height, col + width); + + /* render image */ + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int i = (row + y) * LCOLS + col + x; + if (Image->visible && Image->bitmap) { + drv_generic_graphic_FB[layer][i] = Image->bitmap[y*width+x]; + } else { + drv_generic_graphic_FB[layer][i] = BG_COL; + } + } + } + + /* flush area */ + drv_generic_graphic_blit(row, col, height, width); + + return 0; + +} + + +/****************************************/ /*** generic init/quit ***/ /****************************************/ @@ -525,6 +574,7 @@ int drv_generic_graphic_init(const char *section, const char *driver) { int l; char *color; + WIDGET_CLASS wc; Section = (char *) section; Driver = (char *) driver; @@ -568,6 +618,26 @@ int drv_generic_graphic_init(const char *section, const char *driver) if (color) free(color); + /* register text widget */ + wc = Widget_Text; + wc.draw = drv_generic_graphic_draw; + widget_register(&wc); + + /* register icon widget */ + wc = Widget_Icon; + wc.draw = drv_generic_graphic_icon_draw; + widget_register(&wc); + + /* register bar widget */ + wc = Widget_Bar; + wc.draw = drv_generic_graphic_bar_draw; + widget_register(&wc); + + /* register image widget */ + wc = Widget_Image; + wc.draw = drv_generic_graphic_image_draw; + widget_register(&wc); + return 0; } diff --git a/drv_serdisplib.c b/drv_serdisplib.c index d8e98f8..d6b003c 100644 --- a/drv_serdisplib.c +++ b/drv_serdisplib.c @@ -1,4 +1,4 @@ -/* $Id: drv_serdisplib.c,v 1.7 2006/01/30 06:25:54 reinelt Exp $ +/* $Id: drv_serdisplib.c,v 1.8 2006/02/08 04:55:05 reinelt Exp $ * * driver for serdisplib displays * @@ -23,6 +23,9 @@ * * * $Log: drv_serdisplib.c,v $ + * Revision 1.8 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.7 2006/01/30 06:25:54 reinelt * added CVS Revision * @@ -76,10 +79,6 @@ #include "cfg.h" #include "qprintf.h" #include "plugin.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" #include "drv_generic_graphic.h" @@ -294,16 +293,6 @@ static void plugin_rotate(RESULT * result, RESULT * arg1) /****************************************/ -/*** widget callbacks ***/ -/****************************************/ - - -/* using drv_generic_graphic_draw(W) */ -/* using drv_generic_graphic_icon_draw(W) */ -/* using drv_generic_graphic_bar_draw(W) */ - - -/****************************************/ /*** exported functions ***/ /****************************************/ @@ -319,10 +308,9 @@ int drv_SD_list(void) /* initialize driver & display */ int drv_SD_init(const char *section, const int quiet) { - WIDGET_CLASS wc; int ret; - info("%s: %s", Name, "$Revision: 1.7 $"); + info("%s: %s", Name, "$Revision: 1.8 $"); /* real worker functions */ drv_generic_graphic_real_blit = drv_SD_blit; @@ -344,21 +332,6 @@ int drv_SD_init(const char *section, const int quiet) } } - /* register text widget */ - wc = Widget_Text; - wc.draw = drv_generic_graphic_draw; - widget_register(&wc); - - /* register icon widget */ - wc = Widget_Icon; - wc.draw = drv_generic_graphic_icon_draw; - widget_register(&wc); - - /* register bar widget */ - wc = Widget_Bar; - wc.draw = drv_generic_graphic_bar_draw; - widget_register(&wc); - /* register plugins */ AddFunction("LCD::contrast", 1, plugin_contrast); AddFunction("LCD::backlight", 1, plugin_backlight); @@ -1,4 +1,4 @@ -/* $Id: layout.c,v 1.20 2006/02/07 05:36:13 reinelt Exp $ +/* $Id: layout.c,v 1.21 2006/02/08 04:55:05 reinelt Exp $ * * new layouter framework * @@ -23,6 +23,9 @@ * * * $Log: layout.c,v $ + * Revision 1.21 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.20 2006/02/07 05:36:13 reinelt * Layers added to Layout * @@ -162,6 +165,20 @@ int layout_init(const char *layout) if ((p = strchr(l, '|')) != NULL) *p = '\0'; + /* layer/x/y widgets */ + i = sscanf(l, "layer:%d.x%d.y%d%n", &lay, &row, &col, &n); + if (i == 3 && l[n] == '\0') { + if (lay < 0 || lay >= LAYERS) { + error ("%s: layer %d out of bounds (0..%d)", section, lay, LAYERS-1); + } else { + widget = cfg_get(section, l, NULL); + if (widget != NULL && *widget != '\0') { + widget_add(widget, WIDGET_TYPE_XY, lay, row - 1, col - 1); + } + free(widget); + } + } + /* layer/row/col widgets */ i = sscanf(l, "layer:%d.row%d.col%d%n", &lay, &row, &col, &n); if (i == 3 && l[n] == '\0') { diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 7e4d8c5..ba334b9 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -806,6 +806,12 @@ Widget GPO_Test255 { update 100 } +Widget ImageTest { + class 'Image' + update 1000 + visible 1 +} + Layout Default { Row1 { Col1 'OS' @@ -858,10 +864,8 @@ Layout TestLayer { Col1 'Eth0' Col11 'Eth0Bar' } - Layer 0 { - Row3 { - Col1 'Test' - } + Layer 2 { + X0.Y0 'ImageTest' } } @@ -976,8 +980,8 @@ Layout testMySQL { #Display 'SimpleLCD' #Display 'BA63' #Display 'CT20x4' -#Display 'T6963-240x64' -Display 'XWindow' +Display 'T6963-240x64' +#Display 'XWindow' #Display 'USBLCD' #Display 'BWCT' #Display 'Image' diff --git a/widget_image.c b/widget_image.c index 7281271..6c510e7 100644 --- a/widget_image.c +++ b/widget_image.c @@ -1,4 +1,4 @@ -/* $Id: widget_image.c,v 1.2 2006/01/23 06:17:18 reinelt Exp $ +/* $Id: widget_image.c,v 1.3 2006/02/08 04:55:05 reinelt Exp $ * * image widget handling * @@ -21,6 +21,9 @@ * * * $Log: widget_image.c,v $ + * Revision 1.3 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.2 2006/01/23 06:17:18 reinelt * timer widget added * @@ -53,11 +56,29 @@ #include "widget.h" #include "widget_image.h" +#ifdef HAVE_GD_GD_H +#include <gd/gd.h> +#define WITH_GD +#else +#ifdef HAVE_GD_H +#include <gd.h> +#define WITH_GD +#endif +#endif + #ifdef WITH_DMALLOC #include <dmalloc.h> #endif -void widget_image_update(void *Self) +static void widget_image_render (WIDGET_IMAGE *Image) +{ + /* try to open file */ + + if (Image->file == NULL || Image->file[0] == '\0') { + } +} + +static void widget_image_update(void *Self) { WIDGET *W = (WIDGET *) Self; WIDGET_IMAGE *Image = W->data; @@ -67,6 +88,16 @@ void widget_image_update(void *Self) if (W->parent == NULL) { /* evaluate expressions */ + if (Image->file) { + free (Image->file); + Image->file = NULL; + } + if (Image->file_tree != NULL) { + Eval(Image->file_tree, &result); + Image->file = strdup(R2S(&result)); + DelResult(&result); + } + Image->update = 0; if (Image->update_tree != NULL) { Eval(Image->update_tree, &result); @@ -84,8 +115,13 @@ void widget_image_update(void *Self) Image->visible = 0; DelResult(&result); } + + /* render image into bitmap */ + widget_image_render(Image); } + error ("Fixme: We are at image_update"); + /* finally, draw it! */ if (W->class->draw) W->class->draw(W); @@ -114,17 +150,28 @@ int widget_image_init(WIDGET * Self) Image = malloc(sizeof(WIDGET_IMAGE)); memset(Image, 0, sizeof(WIDGET_IMAGE)); + /* initial size */ + Image->width = 0; + Image->height = 0; + Image->bitmap = NULL; + Image->file = NULL; + /* get raw expressions (we evaluate them ourselves) */ + Image->file_expr = cfg_get_raw(section, "file", NULL); Image->update_expr = cfg_get_raw(section, "update", NULL); Image->visible_expr = cfg_get_raw(section, "visible", NULL); - /* sanity check */ + /* sanity checks */ + if (Image->file_expr == NULL || *Image->file_expr == '\0') { + error("Warning: Image %s has no file", Self->name); + } if (Image->update_expr == NULL || *Image->update_expr == '\0') { error("Image %s has no update, using '100'", Self->name); Image->update_expr = "100"; } /* compile'em */ + Compile(Image->file_expr, &Image->file_tree); Compile(Image->update_expr, &Image->update_tree); Compile(Image->visible_expr, &Image->visible_tree); @@ -152,10 +199,13 @@ int widget_image_quit(WIDGET * Self) if (Self->parent == NULL) { if (Self->data) { WIDGET_IMAGE *Image = Self->data; - DelTree(Image->update_tree); - DelTree(Image->visible_tree); + if (Image->bitmap) + free(Image->bitmap); if (Image->file) free(Image->file); + DelTree(Image->file_tree); + DelTree(Image->update_tree); + DelTree(Image->visible_tree); free(Self->data); Self->data = NULL; } diff --git a/widget_image.h b/widget_image.h index 1f89753..c55b190 100644 --- a/widget_image.h +++ b/widget_image.h @@ -1,4 +1,4 @@ -/* $Id: widget_image.h,v 1.1 2006/01/22 09:16:11 reinelt Exp $ +/* $Id: widget_image.h,v 1.2 2006/02/08 04:55:05 reinelt Exp $ * * image widget handling * @@ -23,6 +23,9 @@ * * * $Log: widget_image.h,v $ + * Revision 1.2 2006/02/08 04:55:05 reinelt + * moved widget registration to drv_generic_graphic + * * Revision 1.1 2006/01/22 09:16:11 reinelt * Image Widget framework added * @@ -32,14 +35,20 @@ #ifndef _WIDGET_IMAGE_H_ #define _WIDGET_IMAGE_H_ +#include "rgb.h" + typedef struct WIDGET_IMAGE { + RGBA *bitmap; /* image bitmap */ + int width, height; /* size of the image */ + char *file_expr; /* expression for image filename */ + void *file_tree; /* pre-compiled expression for image filename */ + char *file; /* evaluated filename */ char *update_expr; /* expression for update interval */ void *update_tree; /* pre-compiled expression for update interval */ int update; /* update interval (msec) */ char *visible_expr; /* expression for visibility */ void *visible_tree; /* pre-compiled expression for visibility */ int visible; /* icon visible? */ - char *file; /* file containing the image */ } WIDGET_IMAGE; extern WIDGET_CLASS Widget_Image; |