aboutsummaryrefslogtreecommitdiffstats
path: root/widget_icon.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-05-08 04:32:45 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-05-08 04:32:45 +0000
commitdbf5d92605a9db10e3e3cb154d03a515c5d5c5af (patch)
tree501d5dda3ce90fe924b893e487d9ef9f0683382b /widget_icon.c
parenta1c471e9fb7cadb68bb182ab2e9715a0aa092386 (diff)
downloadlcd4linux-dbf5d92605a9db10e3e3cb154d03a515c5d5c5af.tar.gz
[lcd4linux @ 2005-05-08 04:32:43 by reinelt]
CodingStyle added and applied git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@547 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'widget_icon.c')
-rw-r--r--widget_icon.c264
1 files changed, 135 insertions, 129 deletions
diff --git a/widget_icon.c b/widget_icon.c
index 4b3008b..0b7a330 100644
--- a/widget_icon.c
+++ b/widget_icon.c
@@ -1,4 +1,4 @@
-/* $Id: widget_icon.c,v 1.16 2005/01/18 06:30:24 reinelt Exp $
+/* $Id: widget_icon.c,v 1.17 2005/05/08 04:32:45 reinelt Exp $
*
* icon widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_icon.c,v $
+ * Revision 1.17 2005/05/08 04:32:45 reinelt
+ * CodingStyle added and applied
+ *
* Revision 1.16 2005/01/18 06:30:24 reinelt
* added (C) to all copyright statements
*
@@ -124,153 +127,156 @@
/* icons always are 8 pixels high */
#define YRES 8
-static void widget_icon_read_bitmap (const char *section, WIDGET_ICON *Icon)
+static void widget_icon_read_bitmap(const char *section, WIDGET_ICON * Icon)
{
- int row, n;
- char key[15];
- char *val, *v;
- unsigned char *map;
-
- for (row=0; row<YRES; row++) {
- qprintf(key, sizeof(key), "Bitmap.Row%d", row+1);
- val=cfg_get(section, key, "");
- map=Icon->bitmap+row;
- n=0;
- for (v=val; *v!='\0'; v++) {
- if (n>=Icon->maxmap) {
- Icon->maxmap++;
- Icon->bitmap=realloc(Icon->bitmap, Icon->maxmap*YRES*sizeof(char));
- memset (Icon->bitmap+n*YRES, 0, YRES*sizeof(char));
- map=Icon->bitmap+n*YRES+row;
- }
- switch (*v) {
- case '|':
- n++;
- map+=YRES;
- break;
- case '*':
- (*map)<<=1;
- (*map)|=1;
- break;
- default:
- (*map)<<=1;
- }
+ int row, n;
+ char key[15];
+ char *val, *v;
+ unsigned char *map;
+
+ for (row = 0; row < YRES; row++) {
+ qprintf(key, sizeof(key), "Bitmap.Row%d", row + 1);
+ val = cfg_get(section, key, "");
+ map = Icon->bitmap + row;
+ n = 0;
+ for (v = val; *v != '\0'; v++) {
+ if (n >= Icon->maxmap) {
+ Icon->maxmap++;
+ Icon->bitmap = realloc(Icon->bitmap, Icon->maxmap * YRES * sizeof(char));
+ memset(Icon->bitmap + n * YRES, 0, YRES * sizeof(char));
+ map = Icon->bitmap + n * YRES + row;
+ }
+ switch (*v) {
+ case '|':
+ n++;
+ map += YRES;
+ break;
+ case '*':
+ (*map) <<= 1;
+ (*map) |= 1;
+ break;
+ default:
+ (*map) <<= 1;
+ }
+ }
+ free(val);
}
- free(val);
- }
}
-void widget_icon_update (void *Self)
+void widget_icon_update(void *Self)
{
- WIDGET *W = (WIDGET*)Self;
- WIDGET_ICON *Icon = W->data;
- RESULT result = {0, 0, 0, NULL};
-
- /* evaluate expressions */
- Icon->speed = 100;
- if (Icon->speed_tree!=NULL) {
- Eval(Icon->speed_tree, &result);
- Icon->speed = R2N(&result);
- if (Icon->speed<10) Icon->speed=10;
- DelResult(&result);
- }
-
- Icon->visible = 1;
- if (Icon->visible_tree!=NULL) {
- Eval(Icon->visible_tree, &result);
- Icon->visible = R2N(&result);
- if (Icon->visible<1) Icon->visible=0;
- DelResult(&result);
- }
-
- /* rotate icon bitmap */
- Icon->curmap++;
- if (Icon->curmap >= Icon->maxmap)
- Icon->curmap = 0;
-
- /* finally, draw it! */
- if (W->class->draw)
- W->class->draw(W);
-
- /* add a new one-shot timer */
- timer_add (widget_icon_update, Self, Icon->speed, 1);
-
+ WIDGET *W = (WIDGET *) Self;
+ WIDGET_ICON *Icon = W->data;
+ RESULT result = { 0, 0, 0, NULL };
+
+ /* evaluate expressions */
+ Icon->speed = 100;
+ if (Icon->speed_tree != NULL) {
+ Eval(Icon->speed_tree, &result);
+ Icon->speed = R2N(&result);
+ if (Icon->speed < 10)
+ Icon->speed = 10;
+ DelResult(&result);
+ }
+
+ Icon->visible = 1;
+ if (Icon->visible_tree != NULL) {
+ Eval(Icon->visible_tree, &result);
+ Icon->visible = R2N(&result);
+ if (Icon->visible < 1)
+ Icon->visible = 0;
+ DelResult(&result);
+ }
+
+ /* rotate icon bitmap */
+ Icon->curmap++;
+ if (Icon->curmap >= Icon->maxmap)
+ Icon->curmap = 0;
+
+ /* finally, draw it! */
+ if (W->class->draw)
+ W->class->draw(W);
+
+ /* add a new one-shot timer */
+ timer_add(widget_icon_update, Self, Icon->speed, 1);
+
}
-int widget_icon_init (WIDGET *Self)
+int widget_icon_init(WIDGET * Self)
{
- char *section;
- WIDGET_ICON *Icon;
-
- /* prepare config section */
- /* strlen("Widget:")=7 */
- section=malloc(strlen(Self->name)+8);
- strcpy(section, "Widget:");
- strcat(section, Self->name);
-
- Icon=malloc(sizeof(WIDGET_ICON));
- memset (Icon, 0, sizeof(WIDGET_ICON));
-
- /* get raw expressions (we evaluate them ourselves) */
- Icon->speed_expr = cfg_get_raw (section, "speed", NULL);
- Icon->visible_expr = cfg_get_raw (section, "visible", NULL);
-
- /* compile'em */
- Compile (Icon->speed_expr, &Icon->speed_tree);
- Compile (Icon->visible_expr, &Icon->visible_tree);
-
- /* sanity check */
- if (Icon->speed_expr==NULL || *Icon->speed_expr=='\0') {
- error ("Icon %s has no speed, using '100'", Self->name);
- Icon->speed_expr="100";
- }
-
- /* read bitmap */
- widget_icon_read_bitmap (section, Icon);
-
- free (section);
- Self->data=Icon;
-
- /* as the speed is evaluatod on every call, we use 'one-shot'-timers. */
- /* The timer will be reactivated on every call to widget_icon_update(). */
- /* We do the initial call here... */
- Icon->prvmap=-1;
-
- /* reset ascii */
- Icon->ascii=-1;
-
- /* just do it! */
- widget_icon_update(Self);
-
- return 0;
+ char *section;
+ WIDGET_ICON *Icon;
+
+ /* prepare config section */
+ /* strlen("Widget:")=7 */
+ section = malloc(strlen(Self->name) + 8);
+ strcpy(section, "Widget:");
+ strcat(section, Self->name);
+
+ Icon = malloc(sizeof(WIDGET_ICON));
+ memset(Icon, 0, sizeof(WIDGET_ICON));
+
+ /* get raw expressions (we evaluate them ourselves) */
+ Icon->speed_expr = cfg_get_raw(section, "speed", NULL);
+ Icon->visible_expr = cfg_get_raw(section, "visible", NULL);
+
+ /* compile'em */
+ Compile(Icon->speed_expr, &Icon->speed_tree);
+ Compile(Icon->visible_expr, &Icon->visible_tree);
+
+ /* sanity check */
+ if (Icon->speed_expr == NULL || *Icon->speed_expr == '\0') {
+ error("Icon %s has no speed, using '100'", Self->name);
+ Icon->speed_expr = "100";
+ }
+
+ /* read bitmap */
+ widget_icon_read_bitmap(section, Icon);
+
+ free(section);
+ Self->data = Icon;
+
+ /* as the speed is evaluatod on every call, we use 'one-shot'-timers. */
+ /* The timer will be reactivated on every call to widget_icon_update(). */
+ /* We do the initial call here... */
+ Icon->prvmap = -1;
+
+ /* reset ascii */
+ Icon->ascii = -1;
+
+ /* just do it! */
+ widget_icon_update(Self);
+
+ return 0;
}
-int widget_icon_quit (WIDGET *Self)
+int widget_icon_quit(WIDGET * Self)
{
- if (Self) {
- if (Self->data) {
- WIDGET_ICON *Icon = Self->data;
- DelTree(Icon->speed_tree);
- DelTree(Icon->visible_tree);
- if (Icon->bitmap) free (Icon->bitmap);
- free(Self->data);
- Self->data=NULL;
+ if (Self) {
+ if (Self->data) {
+ WIDGET_ICON *Icon = Self->data;
+ DelTree(Icon->speed_tree);
+ DelTree(Icon->visible_tree);
+ if (Icon->bitmap)
+ free(Icon->bitmap);
+ free(Self->data);
+ Self->data = NULL;
+ }
}
- }
-
- return 0;
-
+
+ return 0;
+
}
WIDGET_CLASS Widget_Icon = {
- name: "icon",
- init: widget_icon_init,
- draw: NULL,
- quit: widget_icon_quit,
+ name:"icon",
+ init:widget_icon_init,
+ draw:NULL,
+ quit:widget_icon_quit,
};