Oops...that wasn't suppose to get left there. :P
[Rockbox.git] / apps / screen_access.h
blobe40943f003d0c4b6dc9c1f83289e402a69c2e2ee
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 #ifndef _SCREEN_ACCESS_H_
21 #define _SCREEN_ACCESS_H_
23 #include "lcd.h"
24 #include "buttonbar.h"
26 enum screen_type {
27 SCREEN_MAIN
28 #ifdef HAVE_REMOTE_LCD
29 ,SCREEN_REMOTE
30 #endif
33 #if defined(HAVE_REMOTE_LCD) && !defined (ROCKBOX_HAS_LOGF)
34 #define NB_SCREENS 2
35 #else
36 #define NB_SCREENS 1
37 #endif
39 #if NB_SCREENS == 1
40 #define FOR_NB_SCREENS(i) i = 0;
41 #else
42 #define FOR_NB_SCREENS(i) for(i = 0; i < NB_SCREENS; i++)
43 #endif
45 #ifdef HAVE_LCD_CHARCELLS
46 #define MAX_LINES_ON_SCREEN 2
47 #endif
49 typedef void screen_bitmap_part_func(const void *src, int src_x, int src_y,
50 int stride, int x, int y, int width, int height);
51 typedef void screen_bitmap_func(const void *src, int x, int y, int width,
52 int height);
54 struct screen
56 int width, height;
57 int nb_lines;
58 enum screen_type screen_type;
59 int depth;
60 int char_width;
61 int char_height;
62 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
63 bool has_disk_led;
64 #endif
65 #ifdef HAS_BUTTONBAR
66 bool has_buttonbar;
67 #endif
68 void (*setmargins)(int x, int y);
69 int (*getxmargin)(void);
70 int (*getymargin)(void);
72 int (*getstringsize)(const unsigned char *str, int *w, int *h);
73 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
74 void (*setfont)(int newfont);
76 void (*scroll_step)(int pixels);
77 void (*puts_style_offset)(int x, int y, const unsigned char *str,
78 int style, int offset);
79 void (*puts_scroll_style)(int x, int y, const unsigned char *string,
80 int style);
81 void (*puts_scroll_style_offset)(int x, int y, const unsigned char *string,
82 int style, int offset);
83 void (*mono_bitmap)(const unsigned char *src,
84 int x, int y, int width, int height);
85 void (*mono_bitmap_part)(const unsigned char *src, int src_x, int src_y,
86 int stride, int x, int y, int width, int height);
87 void (*bitmap)(const void *src,
88 int x, int y, int width, int height);
89 void (*bitmap_part)(const void *src, int src_x, int src_y,
90 int stride, int x, int y, int width, int height);
91 void (*transparent_bitmap)(const void *src,
92 int x, int y, int width, int height);
93 void (*transparent_bitmap_part)(const void *src, int src_x, int src_y,
94 int stride, int x, int y, int width, int height);
95 void (*set_drawmode)(int mode);
96 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
97 unsigned (*color_to_native)(unsigned color);
98 #endif
99 #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1))
100 unsigned (*get_background)(void);
101 unsigned (*get_foreground)(void);
102 void (*set_background)(unsigned background);
103 void (*set_foreground)(unsigned foreground);
104 #endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */
105 void (*update_rect)(int x, int y, int width, int height);
106 void (*fillrect)(int x, int y, int width, int height);
107 void (*drawrect)(int x, int y, int width, int height);
108 void (*drawpixel)(int x, int y);
109 void (*drawline)(int x1, int y1, int x2, int y2);
110 void (*vline)(int x, int y1, int y2);
111 void (*hline)(int x1, int x2, int y);
112 void (*invertscroll) (int x, int y);
113 #endif /* HAVE_LCD_BITMAP || HAVE_REMOTE_LCD */
115 #ifdef HAVE_LCD_CHARCELLS /* no charcell remote LCDs so far */
116 void (*double_height)(bool on);
117 void (*putc)(int x, int y, unsigned long ucs);
118 void (*icon)(int icon, bool enable);
119 unsigned long (*get_locked_pattern)(void);
120 void (*define_pattern)(unsigned long ucs, const char *pattern);
121 #endif
122 void (*init)(void);
123 void (*putsxy)(int x, int y, const unsigned char *str);
124 void (*puts)(int x, int y, const unsigned char *str);
125 void (*puts_offset)(int x, int y, const unsigned char *str, int offset);
126 void (*puts_scroll)(int x, int y, const unsigned char *string);
127 void (*puts_scroll_offset)(int x, int y, const unsigned char *string,
128 int offset);
129 void (*scroll_speed)(int speed);
130 void (*scroll_delay)(int ms);
131 void (*stop_scroll)(void);
132 void (*clear_display)(void);
133 void (*update)(void);
134 void (*backlight_on)(void);
135 void (*backlight_off)(void);
136 bool (*is_backlight_on)(void);
137 void (*backlight_set_timeout)(int index);
141 * Initializes the given screen structure for a given display
142 * - screen : the screen structure
143 * - display_type : currently 2 possibles values : MAIN or REMOTE
145 extern void screen_init(struct screen * screen, enum screen_type screen_type);
147 #ifdef HAS_BUTTONBAR
149 * Sets if the given screen has a buttonbar or not
150 * - screen : the screen structure
151 * - has : a boolean telling wether the current screen will have a buttonbar or not
153 #define screen_has_buttonbar(screen, has_btnb) \
154 (screen)->has_buttonbar=has_btnb;
155 #endif
158 * Sets the x margin in pixels for the given screen
159 * - screen : the screen structure
160 * - xmargin : the number of pixels to the left of the screen
162 #define screen_set_xmargin(screen, xmargin) \
163 (screen)->setmargins(xmargin, (screen)->getymargin());
166 * Sets the y margin in pixels for the given screen
167 * - screen : the screen structure
168 * - xmargin : the number of pixels to the top of the screen
170 #define screen_set_ymargin(screen, ymargin) \
171 (screen)->setmargins((screen)->getxmargin(), ymargin);
173 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD)
175 * Clear only a given area of the screen
176 * - screen : the screen structure
177 * - xstart, ystart : where the area starts
178 * - width, height : size of the area
180 void screen_clear_area(struct screen * display, int xstart, int ystart,
181 int width, int height);
182 #endif
185 * Initializes the whole screen_access api
187 extern void screen_access_init(void);
190 * exported screens array that should be used
191 * by each app that wants to write to access display
193 extern struct screen screens[NB_SCREENS];
195 #endif /*_SCREEN_ACCESS_H_*/