1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Markus Braun
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
23 #ifdef HAVE_LCD_BITMAP
25 /* Valid dimensions return true, invalid false */
26 bool valid_dimensions(int x
, int y
, int width
, int height
)
28 if((x
< 0) || (x
+ width
> LCD_WIDTH
) ||
29 (y
< 0) || (y
+ height
> LCD_HEIGHT
))
37 void init_bar(int x
, int y
, int width
, int height
)
40 lcd_drawrect(x
, y
, width
, height
);
42 /* clear edge pixels */
44 lcd_clearpixel((x
+ width
- 1), y
);
45 lcd_clearpixel(x
, (y
+ height
- 1));
46 lcd_clearpixel((x
+ width
- 1), (y
+ height
- 1));
48 /* clear pixels in progress bar */
49 lcd_clearrect(x
+ 1, y
+ 1, width
- 2, height
- 2);
53 * Print a progress bar
55 void progressbar(int x
, int y
, int width
, int height
, int percent
,
60 /* check position and dimensions */
61 if (!valid_dimensions(x
, y
, width
, height
))
64 init_bar(x
, y
, width
, height
);
76 pos
=(width
- 2) * pos
/ 100;
77 lcd_fillrect(x
+ 1, y
+ 1, pos
, height
- 2);
80 pos
=(width
- 2) * (100 - pos
) / 100;
81 lcd_fillrect(x
+ pos
, y
+ 1, width
- 1 - pos
, height
- 2);
84 pos
=(height
- 2) * pos
/ 100;
85 lcd_fillrect(x
+ 1, y
+ 1, width
- 2, pos
);
88 pos
=(height
- 2) * (100 - pos
) / 100;
89 lcd_fillrect(x
+ 1, y
+ pos
, width
- 2, height
- 1 - pos
);
96 * Print a slidebar bar
98 void slidebar(int x
, int y
, int width
, int height
, int percent
, int direction
)
102 /* check position and dimensions */
103 if (!valid_dimensions(x
, y
, width
, height
))
106 init_bar(x
, y
, width
, height
);
118 pos
= (width
- height
) * pos
/ 100;
121 pos
=(width
- height
) * (100 - pos
) / 100;
124 pos
=(height
- width
) * pos
/ 100;
127 pos
=(height
- width
) * (100 - pos
) / 100;
131 if(direction
== Grow_Left
|| direction
== Grow_Right
)
132 lcd_fillrect(x
+ pos
+ 1, y
+ 1, height
- 2, height
- 2);
134 lcd_fillrect(x
+ 1, y
+ pos
+ 1, width
- 2, width
- 2);
141 void scrollbar(int x
, int y
, int width
, int height
, int items
, int min_shown
,
142 int max_shown
, int orientation
)
149 /* check position and dimensions */
150 if (!valid_dimensions(x
, y
, width
, height
))
153 init_bar(x
, y
, width
, height
);
155 /* min should be min */
156 if(min_shown
< max_shown
) {
165 /* limit min and max */
176 /* calc start and end of the knob */
177 if(items
> 0 && items
> (max
- min
)) {
178 if(orientation
== VERTICAL
) {
179 size
= (height
- 2) * (max
- min
) / items
;
180 start
= (height
- 2 - size
) * min
/ (items
- (max
- min
));
183 size
= (width
- 2) * (max
- min
) / items
;
184 start
= (width
- 2 - size
) * min
/ (items
- (max
- min
));
187 else { /* if null draw a full bar */
189 if(orientation
== VERTICAL
)
195 /* knob has a width */
197 if(orientation
== VERTICAL
)
198 lcd_fillrect(x
+ 1, y
+ start
+ 1, width
- 2, size
);
200 lcd_fillrect(x
+ start
+ 1, y
+ 1, size
, height
- 2);
202 else { /* width of knob is null */
203 if(orientation
== VERTICAL
) {
204 start
= (height
- 2 - 1) * min
/ items
;
205 lcd_fillrect(x
+ 1, y
+ start
+ 1, width
- 2, 1);
208 start
= (width
- 2 - 1) * min
/ items
;
209 lcd_fillrect(x
+ start
+ 1, y
+ 1, 1, height
- 2);
217 void checkbox(int x
, int y
, int width
, int height
, bool checked
)
219 /* check position and dimensions */
220 if((x
< 0) || (x
+ width
> LCD_WIDTH
) ||
221 (y
< 0) || (y
+ height
> LCD_HEIGHT
) ||
222 (width
< 4 ) || (height
< 4 ))
227 lcd_drawrect(x
, y
, width
, height
);
230 lcd_drawline(x
+ 2, y
+ 2, x
+ width
- 2 - 1 , y
+ height
- 2 - 1);
231 lcd_drawline(x
+ 2, y
+ height
- 2 - 1, x
+ width
- 2 - 1, y
+ 2);
233 /* be sure to clear box */
234 lcd_clearrect(x
+ 1, y
+ 1, width
- 2, height
- 2);