1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) Markus Braun (2002)
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 ****************************************************************************/
20 #include "scrollbar.h"
21 #ifdef HAVE_LCD_BITMAP
26 void gui_scrollbar_draw(struct screen
* screen
, int x
, int y
,
27 int width
, int height
, int items
,
28 int min_shown
, int max_shown
,
31 int inner_x
, inner_y
, inner_wd
, inner_ht
, inner_len
;
38 /* min should be min */
39 if(min_shown
< max_shown
) {
48 /* limit min and max */
64 inner_ht
= height
- 2;
66 if (flags
& HORIZONTAL
)
72 while (items
> (INT_MAX
/ inner_len
)) {
77 /* calc start and end of the knob */
78 if (items
> 0 && items
> range
) {
79 size
= inner_len
* range
/ items
;
80 if (size
== 0) { /* width of knob is null */
82 start
= (inner_len
- 1) * min
/ items
;
84 start
= (inner_len
- size
) * min
/ (items
- range
);
86 } else { /* if null draw full bar */
93 /* must avoid corners if case of (flags & FOREGROUND) */
94 screen
->hline(inner_x
, x
+ inner_wd
, y
);
95 screen
->hline(inner_x
, x
+ inner_wd
, y
+ height
- 1);
96 screen
->vline(x
, inner_y
, y
+ inner_ht
);
97 screen
->vline(x
+ width
- 1, inner_y
, y
+ inner_ht
);
99 screen
->drawrect(x
, y
, width
, height
);
102 screen
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
104 #ifdef HAVE_LCD_COLOR
105 infill
= flags
& (screen
->depth
> 1 ? INNER_FILL_MASK
: INNER_FILL
);
107 if (!(flags
& FOREGROUND
))
110 /* clear corner pixels */
111 screen
->drawpixel(x
, y
);
112 screen
->drawpixel(x
+ width
- 1, y
);
113 screen
->drawpixel(x
, y
+ height
- 1);
114 screen
->drawpixel(x
+ width
- 1, y
+ height
- 1);
116 #ifdef HAVE_LCD_COLOR
117 if (infill
!= INNER_BGFILL
)
121 if (infill
== INNER_FILL
)
124 /* clear pixels in progress bar */
125 screen
->fillrect(inner_x
, inner_y
, inner_wd
, inner_ht
);
128 screen
->set_drawmode(DRMODE_SOLID
);
130 #ifdef HAVE_LCD_COLOR
131 if (infill
== INNER_BGFILL
)
133 /* fill inner area with current background color */
134 unsigned fg
= screen
->get_foreground();
135 screen
->set_foreground(screen
->get_background());
136 screen
->fillrect(inner_x
, inner_y
, inner_wd
, inner_ht
);
137 screen
->set_foreground(fg
);
141 if (flags
& HORIZONTAL
)
152 screen
->fillrect(inner_x
, inner_y
, inner_wd
, inner_ht
);
155 void gui_bitmap_scrollbar_draw(struct screen
* screen
, struct bitmap bm
, int x
, int y
,
156 int width
, int height
, int items
,
157 int min_shown
, int max_shown
,
166 screen
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
168 /* clear pixels in progress bar */
169 screen
->fillrect(x
, y
, width
, height
);
171 /* min should be min */
172 if(min_shown
< max_shown
) {
181 /* limit min and max */
192 if (flags
& HORIZONTAL
)
197 /* avoid overflows */
198 while (items
> (INT_MAX
/ inner_len
)) {
204 /* calc start and end of the knob */
205 if (items
> 0 && items
> (max
- min
)) {
206 size
= inner_len
* (max
- min
) / items
;
207 if (size
== 0) { /* width of knob is null */
209 start
= (inner_len
- 1) * min
/ items
;
211 start
= (inner_len
- size
) * min
/ (items
- (max
- min
));
213 } else { /* if null draw full bar */
218 screen
->set_drawmode(DRMODE_SOLID
);
220 if (flags
& HORIZONTAL
) {
222 if (bm
.format
== FORMAT_MONO
)
224 screen
->mono_bitmap_part(bm
.data
, 0, 0,
225 bm
.width
, x
+ start
, y
, size
, height
);
228 screen
->transparent_bitmap_part((fb_data
*)bm
.data
, 0, 0,
229 bm
.width
, x
+ start
, y
, size
, height
);
233 if (bm
.format
== FORMAT_MONO
)
235 screen
->mono_bitmap_part(bm
.data
, 0, 0,
236 bm
.width
, x
, y
+ start
, width
, size
);
239 screen
->transparent_bitmap_part((fb_data
*)bm
.data
, 0, 0,
240 bm
.width
, x
, y
+ start
, width
, size
);
245 void show_busy_slider(struct screen
*s
, int x
, int y
, int width
, int height
)
247 static int start
= 0, dir
= 1;
248 gui_scrollbar_draw(s
, x
, y
, width
, height
, 100,
249 start
, start
+20, HORIZONTAL
);
251 if (s
->screen_type
== SCREEN_MAIN
)
264 #endif /* HAVE_LCD_BITMAP */