~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to widget_bar.c

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:28:49 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: siretart@tauware.de-20110427172849-mj5cj5a0igpcc9fn
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: widget_bar.c 789 2007-04-30 04:48:10Z michael $
2
 
 * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/widget_bar.c $
 
1
/* $Id: widget_bar.c 1106 2010-02-07 14:03:46Z mzuther $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget_bar.c $
3
3
 *
4
4
 * bar widget handling
5
5
 *
6
 
 * Copyright (C) 2003, 2004 Michael Reinelt <reinelt@eunet.at>
 
6
 * Copyright (C) 2003, 2004 Michael Reinelt <michael@reinelt.co.at>
7
7
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
8
8
 *
9
9
 * This program is free software; you can redistribute it and/or modify
22
22
 *
23
23
 */
24
24
 
25
 
/* 
 
25
/*
26
26
 * exported functions:
27
27
 *
28
28
 * WIDGET_CLASS Widget_Bar
41
41
#include "debug.h"
42
42
#include "cfg.h"
43
43
#include "property.h"
44
 
#include "timer.h"
 
44
#include "timer_group.h"
45
45
#include "widget.h"
46
46
#include "widget_bar.h"
47
47
 
75
75
        min = P2N(&Bar->expr_min);
76
76
    } else {
77
77
        min = Bar->min;
78
 
        if (val1 < min)
 
78
        if (val1 < min) {
79
79
            min = val1;
80
 
        if (val2 < min)
 
80
        }
 
81
        if (val2 < min) {
81
82
            min = val2;
 
83
        }
82
84
    }
83
85
 
84
86
    /* maximum: if expression is empty, do auto-scaling */
87
89
        max = P2N(&Bar->expr_max);
88
90
    } else {
89
91
        max = Bar->max;
90
 
        if (val1 > max)
 
92
        if (val1 > max) {
91
93
            max = val1;
92
 
        if (val2 > max)
 
94
        }
 
95
        if (val2 > max) {
93
96
            max = val2;
 
97
        }
 
98
    }
 
99
 
 
100
    /* debugging */
 
101
    if (Bar->min != min || Bar->max != max) {
 
102
        debug("Bar '%s': new scale %G - %G", W->name, min, max);
94
103
    }
95
104
 
96
105
    /* calculate bar values */
145
154
    switch (toupper(*c)) {
146
155
    case 'E':
147
156
        Bar->direction = DIR_EAST;
 
157
        Self->x2 = Self->col + Bar->length - 1;
 
158
        Self->y2 = Self->row;
148
159
        break;
149
160
    case 'W':
150
161
        Bar->direction = DIR_WEST;
 
162
        Self->x2 = Self->col + Bar->length - 1;
 
163
        Self->y2 = Self->row;
151
164
        break;
152
165
    case 'N':
153
166
        Bar->direction = DIR_NORTH;
 
167
        Self->x2 = Self->col;
 
168
        Self->y2 = Self->row + Bar->length - 1;
154
169
        break;
155
170
    case 'S':
156
171
        Bar->direction = DIR_SOUTH;
 
172
        Self->x2 = Self->col;
 
173
        Self->y2 = Self->row + Bar->length - 1;
157
174
        break;
158
175
    default:
159
 
        error("widget %s has unknown direction '%s', using 'East'", Self->name, c);
 
176
        error("widget %s has unknown direction '%s'; known directions: 'E', 'W', 'N', 'S'; using 'E(ast)'", Self->name,
 
177
              c);
160
178
        Bar->direction = DIR_EAST;
161
179
    }
162
180
    free(c);
166
184
    switch (toupper(*c)) {
167
185
    case 'H':
168
186
        Bar->style = STYLE_HOLLOW;
169
 
        if (!(Bar->direction & (DIR_EAST | DIR_WEST))) {
170
 
            error("widget %s with style \"hollow\" not implemented", Self->name);
171
 
            Bar->style = 0;
172
 
        }
 
187
        break;
 
188
    case '0':
 
189
        Bar->style = 0;
173
190
        break;
174
191
    default:
 
192
        error("widget %s has unknown style '%s'; known styles: '0' or 'H'; using '0'", Self->name, c);
175
193
        Bar->style = 0;
176
194
    }
177
195
    free(c);
186
204
    free(section);
187
205
    Self->data = Bar;
188
206
 
189
 
    timer_add(widget_bar_update, Self, Bar->update, 0);
 
207
    timer_add_widget(widget_bar_update, Self, Bar->update, 0);
190
208
 
191
209
    return 0;
192
210
}