FS#10406 - split the statusbar setting into one for each display, and allow the bar...
[kugel-rb.git] / apps / screen_access.c
blob2f928b73605b0a62159b7a5ad3ebfc9022e247d1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Kevin Ferrare
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <lcd.h>
23 #include <lcd-remote.h>
24 #include <scroll_engine.h>
25 #include "backlight.h"
26 #include <font.h>
27 #include <button.h>
28 #include <sprintf.h>
29 #include <settings.h>
30 #include <kernel.h>
31 #include <icons.h>
33 #include "screen_access.h"
35 /* some helper functions to calculate metrics on the fly */
36 static int screen_helper_getcharwidth(void)
38 #ifdef HAVE_LCD_BITMAP
39 return font_get(lcd_getfont())->maxwidth;
40 #else
41 return 1;
42 #endif
45 static int screen_helper_getcharheight(void)
47 #ifdef HAVE_LCD_BITMAP
48 return font_get(lcd_getfont())->height;
49 #else
50 return 1;
51 #endif
54 static int screen_helper_getnblines(void)
56 int height=screens[0].lcdheight;
57 #ifdef HAVE_LCD_BITMAP
58 if(global_settings.statusbar)
59 height -= STATUSBAR_HEIGHT;
60 #ifdef HAVE_BUTTONBAR
61 if(global_settings.buttonbar && screens[0].has_buttonbar)
62 height -= BUTTONBAR_HEIGHT;
63 #endif
64 #endif
65 return height / screens[0].getcharheight();
68 #if NB_SCREENS == 2
69 static int screen_helper_remote_getcharwidth(void)
71 #ifdef HAVE_LCD_BITMAP
72 return font_get(lcd_remote_getfont())->maxwidth;
73 #else
74 return 1;
75 #endif
78 static int screen_helper_remote_getcharheight(void)
80 #ifdef HAVE_LCD_BITMAP
81 return font_get(lcd_remote_getfont())->height;
82 #else
83 return 1;
84 #endif
87 static int screen_helper_remote_getnblines(void)
89 int height=screens[1].lcdheight;
90 #ifdef HAVE_LCD_BITMAP
91 if(global_settings.statusbar)
92 height -= STATUSBAR_HEIGHT;
93 #ifdef HAVE_BUTTONBAR
94 if(global_settings.buttonbar && screens[0].has_buttonbar)
95 height -= BUTTONBAR_HEIGHT;
96 #endif
97 #endif
98 return height / screens[1].getcharheight();
100 #endif
102 struct screen screens[NB_SCREENS] =
105 .screen_type=SCREEN_MAIN,
106 .lcdwidth=LCD_WIDTH,
107 .lcdheight=LCD_HEIGHT,
108 .depth=LCD_DEPTH,
109 .getnblines=&screen_helper_getnblines,
110 #if defined(HAVE_LCD_COLOR)
111 .is_color=true,
112 #else
113 .is_color=false,
114 #endif
115 #ifdef HAVE_LCD_BITMAP
116 .pixel_format=LCD_PIXELFORMAT,
117 #endif
118 .getcharwidth=screen_helper_getcharwidth,
119 .getcharheight=screen_helper_getcharheight,
120 #if (CONFIG_LED == LED_VIRTUAL)
121 .has_disk_led=false,
122 #elif defined(HAVE_REMOTE_LCD)
123 .has_disk_led=true,
124 #endif
125 .set_viewport=&lcd_set_viewport,
126 .getwidth=&lcd_getwidth,
127 .getheight=&lcd_getheight,
128 .getstringsize=&lcd_getstringsize,
129 #ifdef HAVE_LCD_BITMAP
130 .setfont=&lcd_setfont,
131 .getfont=&lcd_getfont,
132 .mono_bitmap=&lcd_mono_bitmap,
133 .mono_bitmap_part=&lcd_mono_bitmap_part,
134 .set_drawmode=&lcd_set_drawmode,
135 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
136 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
137 #if LCD_DEPTH <= 2
138 /* No transparency yet for grayscale and mono lcd */
139 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
140 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
141 #else
142 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
143 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
144 #endif
145 #if LCD_DEPTH > 1
146 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
147 .color_to_native=&lcd_color_to_native,
148 #endif
149 .get_background=&lcd_get_background,
150 .get_foreground=&lcd_get_foreground,
151 .set_background=&lcd_set_background,
152 .set_foreground=&lcd_set_foreground,
153 #ifdef HAVE_LCD_COLOR
154 .set_selector_start=&lcd_set_selector_start,
155 .set_selector_end=&lcd_set_selector_end,
156 .set_selector_text=&lcd_set_selector_text,
157 #endif
158 #endif /* LCD_DEPTH > 1 */
159 .update_rect=&lcd_update_rect,
160 .update_viewport_rect=&lcd_update_viewport_rect,
161 .fillrect=&lcd_fillrect,
162 .drawrect=&lcd_drawrect,
163 .drawpixel=&lcd_drawpixel,
164 .drawline=&lcd_drawline,
165 .vline=&lcd_vline,
166 .hline=&lcd_hline,
167 .scroll_step=&lcd_scroll_step,
168 .puts_style_offset=&lcd_puts_style_offset,
169 .puts_scroll_style=&lcd_puts_scroll_style,
170 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
171 #endif /* HAVE_LCD_BITMAP */
173 #ifdef HAVE_LCD_CHARCELLS
174 .double_height=&lcd_double_height,
175 .putc=&lcd_putc,
176 .get_locked_pattern=&lcd_get_locked_pattern,
177 .define_pattern=&lcd_define_pattern,
178 .unlock_pattern=&lcd_unlock_pattern,
179 .icon=&lcd_icon,
180 #endif /* HAVE_LCD_CHARCELLS */
182 .putsxy=&lcd_putsxy,
183 .puts=&lcd_puts,
184 .puts_offset=&lcd_puts_offset,
185 .puts_scroll=&lcd_puts_scroll,
186 .puts_scroll_offset=&lcd_puts_scroll_offset,
187 .scroll_speed=&lcd_scroll_speed,
188 .scroll_delay=&lcd_scroll_delay,
189 .stop_scroll=&lcd_stop_scroll,
190 .clear_display=&lcd_clear_display,
191 .clear_viewport=&lcd_clear_viewport,
192 .scroll_stop=&lcd_scroll_stop,
193 .scroll_stop_line=&lcd_scroll_stop_line,
194 .update=&lcd_update,
195 .update_viewport=&lcd_update_viewport,
196 .backlight_on=&backlight_on,
197 .backlight_off=&backlight_off,
198 .is_backlight_on=&is_backlight_on,
199 .backlight_set_timeout=&backlight_set_timeout,
200 #ifdef HAVE_BUTTONBAR
201 .has_buttonbar=false
202 #endif
204 #if NB_SCREENS == 2
206 .screen_type=SCREEN_REMOTE,
207 .lcdwidth=LCD_REMOTE_WIDTH,
208 .lcdheight=LCD_REMOTE_HEIGHT,
209 .depth=LCD_REMOTE_DEPTH,
210 .getnblines=&screen_helper_remote_getnblines,
211 .is_color=false,/* No color remotes yet */
212 .pixel_format=LCD_REMOTE_PIXELFORMAT,
213 .getcharwidth=screen_helper_remote_getcharwidth,
214 .getcharheight=screen_helper_remote_getcharheight,
215 .has_disk_led=false,
216 .set_viewport=&lcd_remote_set_viewport,
217 .getwidth=&lcd_remote_getwidth,
218 .getheight=&lcd_remote_getheight,
219 .getstringsize=&lcd_remote_getstringsize,
220 #if 1 /* all remote LCDs are bitmapped so far */
221 .setfont=&lcd_remote_setfont,
222 .getfont=&lcd_remote_getfont,
223 .mono_bitmap=&lcd_remote_mono_bitmap,
224 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
225 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
226 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
227 .set_drawmode=&lcd_remote_set_drawmode,
228 #if LCD_REMOTE_DEPTH <= 2
229 /* No transparency yet for grayscale and mono lcd */
230 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
231 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
232 /* No colour remotes yet */
233 #endif
234 #if LCD_REMOTE_DEPTH > 1
235 #if defined(HAVE_LCD_COLOR)
236 .color_to_native=&lcd_remote_color_to_native,
237 #endif
238 .get_background=&lcd_remote_get_background,
239 .get_foreground=&lcd_remote_get_foreground,
240 .set_background=&lcd_remote_set_background,
241 .set_foreground=&lcd_remote_set_foreground,
242 #endif /* LCD_REMOTE_DEPTH > 1 */
243 .update_rect=&lcd_remote_update_rect,
244 .update_viewport_rect=&lcd_remote_update_viewport_rect,
245 .fillrect=&lcd_remote_fillrect,
246 .drawrect=&lcd_remote_drawrect,
247 .drawpixel=&lcd_remote_drawpixel,
248 .drawline=&lcd_remote_drawline,
249 .vline=&lcd_remote_vline,
250 .hline=&lcd_remote_hline,
251 .scroll_step=&lcd_remote_scroll_step,
252 .puts_style_offset=&lcd_remote_puts_style_offset,
253 .puts_scroll_style=&lcd_remote_puts_scroll_style,
254 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
255 #endif /* 1 */
257 #if 0 /* no charcell remote LCDs so far */
258 .double_height=&lcd_remote_double_height,
259 .putc=&lcd_remote_putc,
260 .get_locked_pattern=&lcd_remote_get_locked_pattern,
261 .define_pattern=&lcd_remote_define_pattern,
262 .icon=&lcd_remote_icon,
263 #endif /* 0 */
264 .putsxy=&lcd_remote_putsxy,
265 .puts=&lcd_remote_puts,
266 .puts_offset=&lcd_remote_puts_offset,
267 .puts_scroll=&lcd_remote_puts_scroll,
268 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
269 .scroll_speed=&lcd_remote_scroll_speed,
270 .scroll_delay=&lcd_remote_scroll_delay,
271 .stop_scroll=&lcd_remote_stop_scroll,
272 .clear_display=&lcd_remote_clear_display,
273 .clear_viewport=&lcd_remote_clear_viewport,
274 .scroll_stop=&lcd_remote_scroll_stop,
275 .scroll_stop_line=&lcd_remote_scroll_stop_line,
276 .update=&lcd_remote_update,
277 .update_viewport=&lcd_remote_update_viewport,
278 .backlight_on=&remote_backlight_on,
279 .backlight_off=&remote_backlight_off,
280 .is_backlight_on=&is_remote_backlight_on,
281 .backlight_set_timeout=&remote_backlight_set_timeout
283 #endif /* HAVE_REMOTE_LCD */
286 #ifdef HAVE_LCD_BITMAP
287 void screen_clear_area(struct screen * display, int xstart, int ystart,
288 int width, int height)
290 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
291 display->fillrect(xstart, ystart, width, height);
292 display->set_drawmode(DRMODE_SOLID);
294 #endif