Change the manual tabe colours so that we have a darker blue for the header, then...
[kugel-rb.git] / apps / screen_access.c
blobd0b483f3f4741869aa1191ad22ad8d096268f088
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"
34 #include "backdrop.h"
36 /* some helper functions to calculate metrics on the fly */
37 static int screen_helper_getcharwidth(void)
39 #ifdef HAVE_LCD_BITMAP
40 return font_get(lcd_getfont())->maxwidth;
41 #else
42 return 1;
43 #endif
46 static int screen_helper_getcharheight(void)
48 #ifdef HAVE_LCD_BITMAP
49 return font_get(lcd_getfont())->height;
50 #else
51 return 1;
52 #endif
55 static int screen_helper_getnblines(void)
57 int height=screens[0].lcdheight;
58 #ifdef HAVE_LCD_BITMAP
59 if(global_settings.statusbar)
60 height -= STATUSBAR_HEIGHT;
61 #ifdef HAVE_BUTTONBAR
62 if(global_settings.buttonbar && screens[0].has_buttonbar)
63 height -= BUTTONBAR_HEIGHT;
64 #endif
65 #endif
66 return height / screens[0].getcharheight();
69 #if NB_SCREENS == 2
70 static int screen_helper_remote_getcharwidth(void)
72 #ifdef HAVE_LCD_BITMAP
73 return font_get(lcd_remote_getfont())->maxwidth;
74 #else
75 return 1;
76 #endif
79 static int screen_helper_remote_getcharheight(void)
81 #ifdef HAVE_LCD_BITMAP
82 return font_get(lcd_remote_getfont())->height;
83 #else
84 return 1;
85 #endif
88 static int screen_helper_remote_getnblines(void)
90 int height=screens[1].lcdheight;
91 #ifdef HAVE_LCD_BITMAP
92 if(global_settings.statusbar)
93 height -= STATUSBAR_HEIGHT;
94 #ifdef HAVE_BUTTONBAR
95 if(global_settings.buttonbar && screens[0].has_buttonbar)
96 height -= BUTTONBAR_HEIGHT;
97 #endif
98 #endif
99 return height / screens[1].getcharheight();
101 #endif
103 struct screen screens[NB_SCREENS] =
106 .screen_type=SCREEN_MAIN,
107 .lcdwidth=LCD_WIDTH,
108 .lcdheight=LCD_HEIGHT,
109 .depth=LCD_DEPTH,
110 .getnblines=&screen_helper_getnblines,
111 #if defined(HAVE_LCD_COLOR)
112 .is_color=true,
113 #else
114 .is_color=false,
115 #endif
116 #ifdef HAVE_LCD_BITMAP
117 .pixel_format=LCD_PIXELFORMAT,
118 #endif
119 .getcharwidth=screen_helper_getcharwidth,
120 .getcharheight=screen_helper_getcharheight,
121 #if (CONFIG_LED == LED_VIRTUAL)
122 .has_disk_led=false,
123 #elif defined(HAVE_REMOTE_LCD)
124 .has_disk_led=true,
125 #endif
126 .set_viewport=&lcd_set_viewport,
127 .getwidth=&lcd_getwidth,
128 .getheight=&lcd_getheight,
129 .getstringsize=&lcd_getstringsize,
130 #ifdef HAVE_LCD_BITMAP
131 .setfont=&lcd_setfont,
132 .getfont=&lcd_getfont,
133 .mono_bitmap=&lcd_mono_bitmap,
134 .mono_bitmap_part=&lcd_mono_bitmap_part,
135 .set_drawmode=&lcd_set_drawmode,
136 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
137 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
138 #if LCD_DEPTH <= 2
139 /* No transparency yet for grayscale and mono lcd */
140 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
141 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
142 #else
143 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
144 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
145 #endif
146 #if LCD_DEPTH > 1
147 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
148 .color_to_native=&lcd_color_to_native,
149 #endif
150 .get_background=&lcd_get_background,
151 .get_foreground=&lcd_get_foreground,
152 .set_background=&lcd_set_background,
153 .set_foreground=&lcd_set_foreground,
154 #ifdef HAVE_LCD_COLOR
155 .set_selector_start=&lcd_set_selector_start,
156 .set_selector_end=&lcd_set_selector_end,
157 .set_selector_text=&lcd_set_selector_text,
158 #endif
159 #endif /* LCD_DEPTH > 1 */
160 .update_rect=&lcd_update_rect,
161 .update_viewport_rect=&lcd_update_viewport_rect,
162 .fillrect=&lcd_fillrect,
163 .drawrect=&lcd_drawrect,
164 .drawpixel=&lcd_drawpixel,
165 .drawline=&lcd_drawline,
166 .vline=&lcd_vline,
167 .hline=&lcd_hline,
168 .scroll_step=&lcd_scroll_step,
169 .puts_style_offset=&lcd_puts_style_offset,
170 .puts_scroll_style=&lcd_puts_scroll_style,
171 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
172 #endif /* HAVE_LCD_BITMAP */
174 #ifdef HAVE_LCD_CHARCELLS
175 .double_height=&lcd_double_height,
176 .putc=&lcd_putc,
177 .get_locked_pattern=&lcd_get_locked_pattern,
178 .define_pattern=&lcd_define_pattern,
179 .unlock_pattern=&lcd_unlock_pattern,
180 .icon=&lcd_icon,
181 #endif /* HAVE_LCD_CHARCELLS */
183 .putsxy=&lcd_putsxy,
184 .puts=&lcd_puts,
185 .puts_offset=&lcd_puts_offset,
186 .puts_scroll=&lcd_puts_scroll,
187 .puts_scroll_offset=&lcd_puts_scroll_offset,
188 .scroll_speed=&lcd_scroll_speed,
189 .scroll_delay=&lcd_scroll_delay,
190 .stop_scroll=&lcd_stop_scroll,
191 .clear_display=&lcd_clear_display,
192 .clear_viewport=&lcd_clear_viewport,
193 .scroll_stop=&lcd_scroll_stop,
194 .scroll_stop_line=&lcd_scroll_stop_line,
195 .update=&lcd_update,
196 .update_viewport=&lcd_update_viewport,
197 .backlight_on=&backlight_on,
198 .backlight_off=&backlight_off,
199 .is_backlight_on=&is_backlight_on,
200 .backlight_set_timeout=&backlight_set_timeout,
201 .backdrop_load=&backdrop_load,
202 .backdrop_unload=&backdrop_unload,
203 .backdrop_show=&backdrop_show,
204 #ifdef HAVE_BUTTONBAR
205 .has_buttonbar=false,
206 #endif
208 #if NB_SCREENS == 2
210 .screen_type=SCREEN_REMOTE,
211 .lcdwidth=LCD_REMOTE_WIDTH,
212 .lcdheight=LCD_REMOTE_HEIGHT,
213 .depth=LCD_REMOTE_DEPTH,
214 .getnblines=&screen_helper_remote_getnblines,
215 .is_color=false,/* No color remotes yet */
216 .pixel_format=LCD_REMOTE_PIXELFORMAT,
217 .getcharwidth=screen_helper_remote_getcharwidth,
218 .getcharheight=screen_helper_remote_getcharheight,
219 .has_disk_led=false,
220 .set_viewport=&lcd_remote_set_viewport,
221 .getwidth=&lcd_remote_getwidth,
222 .getheight=&lcd_remote_getheight,
223 .getstringsize=&lcd_remote_getstringsize,
224 #if 1 /* all remote LCDs are bitmapped so far */
225 .setfont=&lcd_remote_setfont,
226 .getfont=&lcd_remote_getfont,
227 .mono_bitmap=&lcd_remote_mono_bitmap,
228 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
229 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
230 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
231 .set_drawmode=&lcd_remote_set_drawmode,
232 #if LCD_REMOTE_DEPTH <= 2
233 /* No transparency yet for grayscale and mono lcd */
234 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
235 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
236 /* No colour remotes yet */
237 #endif
238 #if LCD_REMOTE_DEPTH > 1
239 #if defined(HAVE_LCD_COLOR)
240 .color_to_native=&lcd_remote_color_to_native,
241 #endif
242 .get_background=&lcd_remote_get_background,
243 .get_foreground=&lcd_remote_get_foreground,
244 .set_background=&lcd_remote_set_background,
245 .set_foreground=&lcd_remote_set_foreground,
246 #endif /* LCD_REMOTE_DEPTH > 1 */
247 .update_rect=&lcd_remote_update_rect,
248 .update_viewport_rect=&lcd_remote_update_viewport_rect,
249 .fillrect=&lcd_remote_fillrect,
250 .drawrect=&lcd_remote_drawrect,
251 .drawpixel=&lcd_remote_drawpixel,
252 .drawline=&lcd_remote_drawline,
253 .vline=&lcd_remote_vline,
254 .hline=&lcd_remote_hline,
255 .scroll_step=&lcd_remote_scroll_step,
256 .puts_style_offset=&lcd_remote_puts_style_offset,
257 .puts_scroll_style=&lcd_remote_puts_scroll_style,
258 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
259 #endif /* 1 */
261 #if 0 /* no charcell remote LCDs so far */
262 .double_height=&lcd_remote_double_height,
263 .putc=&lcd_remote_putc,
264 .get_locked_pattern=&lcd_remote_get_locked_pattern,
265 .define_pattern=&lcd_remote_define_pattern,
266 .icon=&lcd_remote_icon,
267 #endif /* 0 */
268 .putsxy=&lcd_remote_putsxy,
269 .puts=&lcd_remote_puts,
270 .puts_offset=&lcd_remote_puts_offset,
271 .puts_scroll=&lcd_remote_puts_scroll,
272 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
273 .scroll_speed=&lcd_remote_scroll_speed,
274 .scroll_delay=&lcd_remote_scroll_delay,
275 .stop_scroll=&lcd_remote_stop_scroll,
276 .clear_display=&lcd_remote_clear_display,
277 .clear_viewport=&lcd_remote_clear_viewport,
278 .scroll_stop=&lcd_remote_scroll_stop,
279 .scroll_stop_line=&lcd_remote_scroll_stop_line,
280 .update=&lcd_remote_update,
281 .update_viewport=&lcd_remote_update_viewport,
282 .backlight_on=&remote_backlight_on,
283 .backlight_off=&remote_backlight_off,
284 .is_backlight_on=&is_remote_backlight_on,
285 .backlight_set_timeout=&remote_backlight_set_timeout,
286 .backdrop_load=&remote_backdrop_load,
287 .backdrop_unload=&remote_backdrop_unload,
288 .backdrop_show=&remote_backdrop_show,
290 #endif /* HAVE_REMOTE_LCD */
293 #ifdef HAVE_LCD_BITMAP
294 void screen_clear_area(struct screen * display, int xstart, int ystart,
295 int width, int height)
297 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
298 display->fillrect(xstart, ystart, width, height);
299 display->set_drawmode(DRMODE_SOLID);
301 #endif