make sure closing the application aborts the remaining HttpGet objects. Should fix...
[Rockbox.git] / apps / screen_access.h
blob822aab4a88977fa2a6e001baa7d65cc9bc0de0ef
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 bool is_color;
61 #ifdef HAVE_LCD_BITMAP
62 int pixel_format;
63 #endif
64 int char_width;
65 int char_height;
66 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
67 bool has_disk_led;
68 #endif
69 #ifdef HAS_BUTTONBAR
70 bool has_buttonbar;
71 #endif
72 void (*setmargins)(int x, int y);
73 int (*getxmargin)(void);
74 int (*getymargin)(void);
76 int (*getstringsize)(const unsigned char *str, int *w, int *h);
77 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
78 void (*setfont)(int newfont);
80 void (*scroll_step)(int pixels);
81 void (*puts_style_offset)(int x, int y, const unsigned char *str,
82 int style, int offset);
83 void (*puts_scroll_style)(int x, int y, const unsigned char *string,
84 int style);
85 void (*puts_scroll_style_offset)(int x, int y, const unsigned char *string,
86 int style, int offset);
87 void (*mono_bitmap)(const unsigned char *src,
88 int x, int y, int width, int height);
89 void (*mono_bitmap_part)(const unsigned char *src, int src_x, int src_y,
90 int stride, int x, int y, int width, int height);
91 void (*bitmap)(const void *src,
92 int x, int y, int width, int height);
93 void (*bitmap_part)(const void *src, int src_x, int src_y,
94 int stride, int x, int y, int width, int height);
95 void (*transparent_bitmap)(const void *src,
96 int x, int y, int width, int height);
97 void (*transparent_bitmap_part)(const void *src, int src_x, int src_y,
98 int stride, int x, int y, int width, int height);
99 void (*set_drawmode)(int mode);
100 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
101 unsigned (*color_to_native)(unsigned color);
102 #endif
103 #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1))
104 unsigned (*get_background)(void);
105 unsigned (*get_foreground)(void);
106 void (*set_background)(unsigned background);
107 void (*set_foreground)(unsigned foreground);
108 #endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */
109 void (*update_rect)(int x, int y, int width, int height);
110 void (*fillrect)(int x, int y, int width, int height);
111 void (*drawrect)(int x, int y, int width, int height);
112 void (*drawpixel)(int x, int y);
113 void (*drawline)(int x1, int y1, int x2, int y2);
114 void (*vline)(int x, int y1, int y2);
115 void (*hline)(int x1, int x2, int y);
116 void (*invertscroll) (int x, int y);
117 #endif /* HAVE_LCD_BITMAP || HAVE_REMOTE_LCD */
119 #ifdef HAVE_LCD_CHARCELLS /* no charcell remote LCDs so far */
120 void (*double_height)(bool on);
121 void (*putc)(int x, int y, unsigned long ucs);
122 void (*icon)(int icon, bool enable);
123 unsigned long (*get_locked_pattern)(void);
124 void (*define_pattern)(unsigned long ucs, const char *pattern);
125 void (*unlock_pattern)(unsigned long ucs);
126 #endif
127 void (*init)(void);
128 void (*putsxy)(int x, int y, const unsigned char *str);
129 void (*puts)(int x, int y, const unsigned char *str);
130 void (*puts_offset)(int x, int y, const unsigned char *str, int offset);
131 void (*puts_scroll)(int x, int y, const unsigned char *string);
132 void (*puts_scroll_offset)(int x, int y, const unsigned char *string,
133 int offset);
134 void (*scroll_speed)(int speed);
135 void (*scroll_delay)(int ms);
136 void (*stop_scroll)(void);
137 void (*clear_display)(void);
138 void (*update)(void);
139 void (*backlight_on)(void);
140 void (*backlight_off)(void);
141 bool (*is_backlight_on)(void);
142 void (*backlight_set_timeout)(int index);
146 * Initializes the given screen structure for a given display
147 * - screen : the screen structure
148 * - display_type : currently 2 possibles values : MAIN or REMOTE
150 extern void screen_init(struct screen * screen, enum screen_type screen_type);
152 #ifdef HAS_BUTTONBAR
154 * Sets if the given screen has a buttonbar or not
155 * - screen : the screen structure
156 * - has : a boolean telling wether the current screen will have a buttonbar or not
158 #define screen_has_buttonbar(screen, has_btnb) \
159 (screen)->has_buttonbar=has_btnb;
160 #endif
163 * Sets the x margin in pixels for the given screen
164 * - screen : the screen structure
165 * - xmargin : the number of pixels to the left of the screen
167 #define screen_set_xmargin(screen, xmargin) \
168 (screen)->setmargins(xmargin, (screen)->getymargin());
171 * Sets the y margin in pixels for the given screen
172 * - screen : the screen structure
173 * - xmargin : the number of pixels to the top of the screen
175 #define screen_set_ymargin(screen, ymargin) \
176 (screen)->setmargins((screen)->getxmargin(), ymargin);
178 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD)
180 * Clear only a given area of the screen
181 * - screen : the screen structure
182 * - xstart, ystart : where the area starts
183 * - width, height : size of the area
185 void screen_clear_area(struct screen * display, int xstart, int ystart,
186 int width, int height);
187 #endif
190 * Initializes the whole screen_access api
192 extern void screen_access_init(void);
195 * exported screens array that should be used
196 * by each app that wants to write to access display
198 extern struct screen screens[NB_SCREENS];
200 #endif /*_SCREEN_ACCESS_H_*/