aboutsummaryrefslogtreecommitdiffstats
path: root/widget_bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'widget_bar.c')
-rw-r--r--widget_bar.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/widget_bar.c b/widget_bar.c
index 7421205..3399a04 100644
--- a/widget_bar.c
+++ b/widget_bar.c
@@ -1,9 +1,9 @@
-/* $Id: widget_bar.c 789 2007-04-30 04:48:10Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/widget_bar.c $
+/* $Id: widget_bar.c 1106 2010-02-07 14:03:46Z mzuther $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_bar.c $
*
* bar 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_Bar
@@ -41,7 +41,7 @@
#include "debug.h"
#include "cfg.h"
#include "property.h"
-#include "timer.h"
+#include "timer_group.h"
#include "widget.h"
#include "widget_bar.h"
@@ -75,10 +75,12 @@ void widget_bar_update(void *Self)
min = P2N(&Bar->expr_min);
} else {
min = Bar->min;
- if (val1 < min)
+ if (val1 < min) {
min = val1;
- if (val2 < min)
+ }
+ if (val2 < min) {
min = val2;
+ }
}
/* maximum: if expression is empty, do auto-scaling */
@@ -87,10 +89,17 @@ void widget_bar_update(void *Self)
max = P2N(&Bar->expr_max);
} else {
max = Bar->max;
- if (val1 > max)
+ if (val1 > max) {
max = val1;
- if (val2 > max)
+ }
+ if (val2 > max) {
max = val2;
+ }
+ }
+
+ /* debugging */
+ if (Bar->min != min || Bar->max != max) {
+ debug("Bar '%s': new scale %G - %G", W->name, min, max);
}
/* calculate bar values */
@@ -145,18 +154,27 @@ int widget_bar_init(WIDGET * Self)
switch (toupper(*c)) {
case 'E':
Bar->direction = DIR_EAST;
+ Self->x2 = Self->col + Bar->length - 1;
+ Self->y2 = Self->row;
break;
case 'W':
Bar->direction = DIR_WEST;
+ Self->x2 = Self->col + Bar->length - 1;
+ Self->y2 = Self->row;
break;
case 'N':
Bar->direction = DIR_NORTH;
+ Self->x2 = Self->col;
+ Self->y2 = Self->row + Bar->length - 1;
break;
case 'S':
Bar->direction = DIR_SOUTH;
+ Self->x2 = Self->col;
+ Self->y2 = Self->row + Bar->length - 1;
break;
default:
- error("widget %s has unknown direction '%s', using 'East'", Self->name, c);
+ error("widget %s has unknown direction '%s'; known directions: 'E', 'W', 'N', 'S'; using 'E(ast)'", Self->name,
+ c);
Bar->direction = DIR_EAST;
}
free(c);
@@ -166,12 +184,12 @@ int widget_bar_init(WIDGET * Self)
switch (toupper(*c)) {
case 'H':
Bar->style = STYLE_HOLLOW;
- if (!(Bar->direction & (DIR_EAST | DIR_WEST))) {
- error("widget %s with style \"hollow\" not implemented", Self->name);
- Bar->style = 0;
- }
+ break;
+ case '0':
+ Bar->style = 0;
break;
default:
+ error("widget %s has unknown style '%s'; known styles: '0' or 'H'; using '0'", Self->name, c);
Bar->style = 0;
}
free(c);
@@ -186,7 +204,7 @@ int widget_bar_init(WIDGET * Self)
free(section);
Self->data = Bar;
- timer_add(widget_bar_update, Self, Bar->update, 0);
+ timer_add_widget(widget_bar_update, Self, Bar->update, 0);
return 0;
}