aboutsummaryrefslogtreecommitdiffstats
path: root/widget_icon.c
diff options
context:
space:
mode:
Diffstat (limited to 'widget_icon.c')
-rw-r--r--widget_icon.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/widget_icon.c b/widget_icon.c
index b1a811d..152343b 100644
--- a/widget_icon.c
+++ b/widget_icon.c
@@ -1,9 +1,9 @@
-/* $Id: widget_icon.c 773 2007-02-25 12:39:09Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/widget_icon.c $
+/* $Id: widget_icon.c 1106 2010-02-07 14:03:46Z mzuther $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_icon.c $
*
* icon widget handling
*
- * Copyright (C) 2003, 2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2003, 2004 Michael Reinelt <michael@reinelt.co.at>
* Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
*
*/
-/*
+/*
* exported functions:
*
* WIDGET_CLASS Widget_Icon
@@ -42,7 +42,7 @@
#include "cfg.h"
#include "qprintf.h"
#include "property.h"
-#include "timer.h"
+#include "timer_group.h"
#include "widget.h"
#include "widget_icon.h"
@@ -101,11 +101,18 @@ void widget_icon_update(void *Self)
/* evaluate properties */
property_eval(&Icon->speed);
property_eval(&Icon->visible);
-
- /* rotate icon bitmap */
- Icon->curmap++;
- if (Icon->curmap >= Icon->maxmap)
- Icon->curmap = 0;
+ property_eval(&Icon->frame);
+
+ int frame = P2N(&Icon->frame);
+ if ((frame >= 0) && (frame <= Icon->maxmap)) {
+ /* select icon bitmap by evaluated frame number */
+ Icon->curmap = frame;
+ } else {
+ /* rotate icon bitmap */
+ Icon->curmap++;
+ if (Icon->curmap >= Icon->maxmap)
+ Icon->curmap = 0;
+ }
}
/* finally, draw it! */
@@ -114,7 +121,7 @@ void widget_icon_update(void *Self)
/* add a new one-shot timer */
if (P2N(&Icon->speed) > 0) {
- timer_add(widget_icon_update, Self, P2N(&Icon->speed), 1);
+ timer_add_widget(widget_icon_update, Self, P2N(&Icon->speed), 1);
}
}
@@ -140,12 +147,15 @@ int widget_icon_init(WIDGET * Self)
/* load properties */
property_load(section, "speed", "100", &Icon->speed);
property_load(section, "visible", "1", &Icon->visible);
+ property_load(section, "frame", "-1", &Icon->frame);
/* read bitmap */
widget_icon_read_bitmap(section, Icon);
free(section);
Self->data = Icon;
+ Self->x2 = Self->col + 1;
+ Self->y2 = Self->row + 1;
/* 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(). */
@@ -178,6 +188,7 @@ int widget_icon_quit(WIDGET * Self)
WIDGET_ICON *Icon = Self->data;
property_free(&Icon->speed);
property_free(&Icon->visible);
+ property_free(&Icon->frame);
if (Icon->bitmap)
free(Icon->bitmap);
free(Self->data);