Add a get_offset API call to make codec_advance_buffer_loc_callback work.
[Rockbox.git] / apps / screen_access.c
blob0d7017984e2e73abaf7e768f543274485f85dce7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Kevin Ferrare
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 <lcd.h>
21 #include <lcd-remote.h>
22 #include "backlight.h"
23 #include <font.h>
24 #include <button.h>
25 #include <sprintf.h>
26 #include <settings.h>
27 #include <kernel.h>
28 #include <icons.h>
30 #include "screen_access.h"
31 #include "textarea.h"
33 struct screen screens[NB_SCREENS] =
36 .screen_type=SCREEN_MAIN,
37 .width=LCD_WIDTH,
38 .height=LCD_HEIGHT,
39 .depth=LCD_DEPTH,
40 #if defined(HAVE_LCD_COLOR)
41 .is_color=true,
42 #else
43 .is_color=false,
44 #endif
45 #ifdef HAVE_LCD_BITMAP
46 .pixel_format=LCD_PIXELFORMAT,
47 #endif
48 #if (CONFIG_LED == LED_VIRTUAL)
49 .has_disk_led=false,
50 #elif defined(HAVE_REMOTE_LCD)
51 .has_disk_led=true,
52 #endif
53 .setmargins=&lcd_setmargins,
54 .getymargin=&lcd_getymargin,
55 .getxmargin=&lcd_getxmargin,
56 .getstringsize=&lcd_getstringsize,
57 #ifdef HAVE_LCD_BITMAP
58 .setfont=&lcd_setfont,
59 .mono_bitmap=&lcd_mono_bitmap,
60 .mono_bitmap_part=&lcd_mono_bitmap_part,
61 .set_drawmode=&lcd_set_drawmode,
62 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
63 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
64 #if LCD_DEPTH <= 2
65 /* No transparency yet for grayscale and mono lcd */
66 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
67 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
68 #else
69 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
70 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
71 #endif
72 #if LCD_DEPTH > 1
73 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
74 .color_to_native=&lcd_color_to_native,
75 #endif
76 .get_background=&lcd_get_background,
77 .get_foreground=&lcd_get_foreground,
78 .set_background=&lcd_set_background,
79 .set_foreground=&lcd_set_foreground,
80 #ifdef HAVE_LCD_COLOR
81 .set_selector_start=&lcd_set_selector_start,
82 .set_selector_end=&lcd_set_selector_end,
83 .set_selector_text=&lcd_set_selector_text,
84 #endif
85 #endif /* LCD_DEPTH > 1 */
86 .update_rect=&lcd_update_rect,
87 .fillrect=&lcd_fillrect,
88 .drawrect=&lcd_drawrect,
89 .drawpixel=&lcd_drawpixel,
90 .drawline=&lcd_drawline,
91 .vline=&lcd_vline,
92 .hline=&lcd_hline,
93 .scroll_step=&lcd_scroll_step,
94 .puts_style_offset=&lcd_puts_style_offset,
95 .puts_scroll_style=&lcd_puts_scroll_style,
96 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
97 #endif /* HAVE_LCD_BITMAP */
99 #ifdef HAVE_LCD_CHARCELLS
100 .double_height=&lcd_double_height,
101 .putc=&lcd_putc,
102 .get_locked_pattern=&lcd_get_locked_pattern,
103 .define_pattern=&lcd_define_pattern,
104 .unlock_pattern=&lcd_unlock_pattern,
105 .icon=&lcd_icon,
106 #endif /* HAVE_LCD_CHARCELLS */
108 .putsxy=&lcd_putsxy,
109 .puts=&lcd_puts,
110 .puts_offset=&lcd_puts_offset,
111 .puts_scroll=&lcd_puts_scroll,
112 .puts_scroll_offset=&lcd_puts_scroll_offset,
113 .scroll_speed=&lcd_scroll_speed,
114 .scroll_delay=&lcd_scroll_delay,
115 .stop_scroll=&lcd_stop_scroll,
116 .clear_display=&lcd_clear_display,
117 .update=&lcd_update,
118 .backlight_on=&backlight_on,
119 .backlight_off=&backlight_off,
120 .is_backlight_on=&is_backlight_on,
121 .backlight_set_timeout=&backlight_set_timeout,
122 #ifdef HAS_BUTTONBAR
123 .has_buttonbar=false
124 #endif
126 #if NB_SCREENS == 2
128 .screen_type=SCREEN_REMOTE,
129 .width=LCD_REMOTE_WIDTH,
130 .height=LCD_REMOTE_HEIGHT,
131 .depth=LCD_REMOTE_DEPTH,
132 .is_color=false,/* No color remotes yet */
133 .pixel_format=LCD_REMOTE_PIXELFORMAT,
134 .has_disk_led=false,
135 .setmargins=&lcd_remote_setmargins,
136 .getymargin=&lcd_remote_getymargin,
137 .getxmargin=&lcd_remote_getxmargin,
138 .getstringsize=&lcd_remote_getstringsize,
139 #if 1 /* all remote LCDs are bitmapped so far */
140 .setfont=&lcd_remote_setfont,
141 .mono_bitmap=&lcd_remote_mono_bitmap,
142 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
143 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
144 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
145 .set_drawmode=&lcd_remote_set_drawmode,
146 #if LCD_REMOTE_DEPTH <= 2
147 /* No transparency yet for grayscale and mono lcd */
148 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
149 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
150 /* No colour remotes yet */
151 #endif
152 #if LCD_REMOTE_DEPTH > 1
153 #if defined(HAVE_LCD_COLOR)
154 .color_to_native=&lcd_remote_color_to_native,
155 #endif
156 .get_background=&lcd_remote_get_background,
157 .get_foreground=&lcd_remote_get_foreground,
158 .set_background=&lcd_remote_set_background,
159 .set_foreground=&lcd_remote_set_foreground,
160 #endif /* LCD_REMOTE_DEPTH > 1 */
161 .update_rect=&lcd_remote_update_rect,
162 .fillrect=&lcd_remote_fillrect,
163 .drawrect=&lcd_remote_drawrect,
164 .drawpixel=&lcd_remote_drawpixel,
165 .drawline=&lcd_remote_drawline,
166 .vline=&lcd_remote_vline,
167 .hline=&lcd_remote_hline,
168 .scroll_step=&lcd_remote_scroll_step,
169 .puts_style_offset=&lcd_remote_puts_style_offset,
170 .puts_scroll_style=&lcd_remote_puts_scroll_style,
171 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
172 #endif /* 1 */
174 #if 0 /* no charcell remote LCDs so far */
175 .double_height=&lcd_remote_double_height,
176 .putc=&lcd_remote_putc,
177 .get_locked_pattern=&lcd_remote_get_locked_pattern,
178 .define_pattern=&lcd_remote_define_pattern,
179 .icon=&lcd_remote_icon,
180 #endif /* 0 */
181 .putsxy=&lcd_remote_putsxy,
182 .puts=&lcd_remote_puts,
183 .puts_offset=&lcd_remote_puts_offset,
184 .puts_scroll=&lcd_remote_puts_scroll,
185 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
186 .scroll_speed=&lcd_remote_scroll_speed,
187 .scroll_delay=&lcd_remote_scroll_delay,
188 .stop_scroll=&lcd_remote_stop_scroll,
189 .clear_display=&lcd_remote_clear_display,
190 .update=&lcd_remote_update,
191 .backlight_on=&remote_backlight_on,
192 .backlight_off=&remote_backlight_off,
193 .is_backlight_on=&is_remote_backlight_on,
194 .backlight_set_timeout=&remote_backlight_set_timeout
196 #endif /* HAVE_REMOTE_LCD */
199 #ifdef HAVE_LCD_BITMAP
200 void screen_clear_area(struct screen * display, int xstart, int ystart,
201 int width, int height)
203 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
204 display->fillrect(xstart, ystart, width, height);
205 display->set_drawmode(DRMODE_SOLID);
207 #endif
209 void screen_access_init(void)
211 int i;
212 FOR_NB_SCREENS(i)
214 #ifdef HAVE_LCD_BITMAP
215 ((struct screen*)&screens[i])->setfont(FONT_UI);
216 #endif
217 gui_textarea_update_nblines(&screens[i]);