diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-06-27 08:08:33 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-06-27 08:08:33 +0000 |
commit | 1ed3aba4f2dc486a7ac86cccec044d709b23ad5c (patch) | |
tree | b9e35a09cb5bd0240dcc2537e4f844a4dd40348b /apps/plugins/text_viewer | |
parent | 4b189764961da77f1ada942ca68ddce4acc575e9 (diff) | |
download | rockbox-1ed3aba4f2dc486a7ac86cccec044d709b23ad5c.tar.gz rockbox-1ed3aba4f2dc486a7ac86cccec044d709b23ad5c.zip |
text viewer: simplify display functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27152 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer')
-rw-r--r-- | apps/plugins/text_viewer/tv_display.c | 43 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_display.h | 58 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_window.c | 25 |
3 files changed, 48 insertions, 78 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c index 8d85ae2a72..05f968dc91 100644 --- a/apps/plugins/text_viewer/tv_display.c +++ b/apps/plugins/text_viewer/tv_display.c | |||
@@ -169,18 +169,24 @@ void tv_show_scrollbar(int window, int col, off_t cur_pos, int size) | |||
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void tv_fillrect(int col, int row, int rows) | 172 | #endif |
173 | { | ||
174 | display->fillrect(drawarea.x + col * col_width, drawarea.y + row * row_height, | ||
175 | drawarea.w - col * col_width, rows * row_height); | ||
176 | } | ||
177 | 173 | ||
178 | void tv_set_drawmode(int mode) | 174 | void tv_show_bookmarks(const int *rows, int count) |
179 | { | 175 | { |
180 | rb->lcd_set_drawmode(mode); | 176 | #ifdef HAVE_LCD_BITMAP |
181 | } | 177 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
178 | #endif | ||
182 | 179 | ||
180 | while (count--) | ||
181 | { | ||
182 | #ifdef HAVE_LCD_BITMAP | ||
183 | display->fillrect(drawarea.x, drawarea.y + rows[count] * row_height, | ||
184 | drawarea.w, row_height); | ||
185 | #else | ||
186 | display->putchar(bookmark.x, drawarea.y + rows[count], TV_BOOKMARK_ICON); | ||
183 | #endif | 187 | #endif |
188 | } | ||
189 | } | ||
184 | 190 | ||
185 | void tv_draw_text(int row, const unsigned char *text, int offset) | 191 | void tv_draw_text(int row, const unsigned char *text, int offset) |
186 | { | 192 | { |
@@ -203,13 +209,6 @@ void tv_draw_text(int row, const unsigned char *text, int offset) | |||
203 | #endif | 209 | #endif |
204 | } | 210 | } |
205 | 211 | ||
206 | #ifndef HAVE_LCD_BITMAP | ||
207 | void tv_put_bookmark_icon(int row) | ||
208 | { | ||
209 | display->putchar(bookmark.x, drawarea.y + row, TV_BOOKMARK_ICON); | ||
210 | } | ||
211 | #endif | ||
212 | |||
213 | void tv_init_display(void) | 212 | void tv_init_display(void) |
214 | { | 213 | { |
215 | display = rb->screens[SCREEN_MAIN]; | 214 | display = rb->screens[SCREEN_MAIN]; |
@@ -221,7 +220,13 @@ void tv_start_display(void) | |||
221 | display->set_viewport(&vp_info); | 220 | display->set_viewport(&vp_info); |
222 | #ifdef HAVE_LCD_BITMAP | 221 | #ifdef HAVE_LCD_BITMAP |
223 | drawmode = rb->lcd_get_drawmode(); | 222 | drawmode = rb->lcd_get_drawmode(); |
223 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
224 | #endif | 224 | #endif |
225 | |||
226 | #if LCD_DEPTH > 1 | ||
227 | rb->lcd_set_backdrop(NULL); | ||
228 | #endif | ||
229 | display->clear_viewport(); | ||
225 | } | 230 | } |
226 | 231 | ||
227 | void tv_end_display(void) | 232 | void tv_end_display(void) |
@@ -232,14 +237,6 @@ void tv_end_display(void) | |||
232 | display->set_viewport(NULL); | 237 | display->set_viewport(NULL); |
233 | } | 238 | } |
234 | 239 | ||
235 | void tv_clear_display(void) | ||
236 | { | ||
237 | #if LCD_DEPTH > 1 | ||
238 | rb->lcd_set_backdrop(NULL); | ||
239 | #endif | ||
240 | display->clear_viewport(); | ||
241 | } | ||
242 | |||
243 | void tv_update_display(void) | 240 | void tv_update_display(void) |
244 | { | 241 | { |
245 | display->update_viewport(); | 242 | display->update_viewport(); |
diff --git a/apps/plugins/text_viewer/tv_display.h b/apps/plugins/text_viewer/tv_display.h index 005011c756..aa30436c4c 100644 --- a/apps/plugins/text_viewer/tv_display.h +++ b/apps/plugins/text_viewer/tv_display.h | |||
@@ -66,18 +66,18 @@ void tv_init_scrollbar(off_t total, bool show_scrollbar); | |||
66 | * the size of text in displayed. | 66 | * the size of text in displayed. |
67 | */ | 67 | */ |
68 | void tv_show_scrollbar(int window, int col, off_t cur_pos, int size); | 68 | void tv_show_scrollbar(int window, int col, off_t cur_pos, int size); |
69 | 69 | #endif | |
70 | #else | ||
71 | 70 | ||
72 | /* | 71 | /* |
73 | * put the bookmark icon | 72 | * show bookmark |
74 | * | 73 | * |
75 | * [In] row | 74 | * [In] rows |
76 | * the row where the bookmark icon is put | 75 | * the array of row where the bookmark |
76 | * | ||
77 | * [In] count | ||
78 | * want to show bookmark count | ||
77 | */ | 79 | */ |
78 | void tv_put_bookmark_icon(int row); | 80 | void tv_show_bookmarks(const int *rows, int count); |
79 | |||
80 | #endif | ||
81 | 81 | ||
82 | /* common display functons */ | 82 | /* common display functons */ |
83 | 83 | ||
@@ -90,38 +90,9 @@ void tv_start_display(void); | |||
90 | /* end the display processing */ | 90 | /* end the display processing */ |
91 | void tv_end_display(void); | 91 | void tv_end_display(void); |
92 | 92 | ||
93 | /* clear the display */ | ||
94 | void tv_clear_display(void); | ||
95 | |||
96 | /*update the display */ | 93 | /*update the display */ |
97 | void tv_update_display(void); | 94 | void tv_update_display(void); |
98 | 95 | ||
99 | #ifdef HAVE_LCD_BITMAP | ||
100 | |||
101 | /* | ||
102 | * set the drawmode | ||
103 | * | ||
104 | * [In] mode | ||
105 | * new drawmode | ||
106 | */ | ||
107 | void tv_set_drawmode(int mode); | ||
108 | |||
109 | /* | ||
110 | * draw the rectangle that paints out inside | ||
111 | * | ||
112 | * [In] col | ||
113 | * the column of the upper left | ||
114 | * | ||
115 | * [In] row | ||
116 | * the row of the upper left | ||
117 | * | ||
118 | * [In] row | ||
119 | * draw rows | ||
120 | */ | ||
121 | void tv_fillrect(int col, int row, int rows); | ||
122 | |||
123 | #endif | ||
124 | |||
125 | /* | 96 | /* |
126 | * draw the text | 97 | * draw the text |
127 | * | 98 | * |
@@ -162,6 +133,19 @@ void tv_set_layout(int col_w, bool show_scrollbar); | |||
162 | void tv_set_layout(int col_w); | 133 | void tv_set_layout(int col_w); |
163 | 134 | ||
164 | #endif | 135 | #endif |
136 | |||
137 | /* | ||
138 | * get the draw area info | ||
139 | * | ||
140 | * [Out] width | ||
141 | * width of the draw area | ||
142 | * | ||
143 | * [Out] cols | ||
144 | * column count of the draw area | ||
145 | * | ||
146 | * [Out] width | ||
147 | * row count of the draw area | ||
148 | */ | ||
165 | void tv_get_drawarea_info(int *width, int *cols, int *rows); | 149 | void tv_get_drawarea_info(int *width, int *cols, int *rows); |
166 | 150 | ||
167 | /* viewport functions */ | 151 | /* viewport functions */ |
diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c index 16be8845ef..c83c6080bd 100644 --- a/apps/plugins/text_viewer/tv_window.c +++ b/apps/plugins/text_viewer/tv_window.c | |||
@@ -54,29 +54,23 @@ static bool tv_set_font(const unsigned char *font) | |||
54 | } | 54 | } |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | static void tv_show_bookmarks(const struct tv_screen_pos *top_pos) | 57 | static void tv_draw_bookmarks(const struct tv_screen_pos *top_pos) |
58 | { | 58 | { |
59 | struct tv_screen_pos bookmarks[TV_MAX_BOOKMARKS]; | 59 | struct tv_screen_pos bookmarks[TV_MAX_BOOKMARKS]; |
60 | int disp_bookmarks[TV_MAX_BOOKMARKS]; | ||
60 | int count = tv_get_bookmark_positions(bookmarks); | 61 | int count = tv_get_bookmark_positions(bookmarks); |
62 | int disp_count = 0; | ||
61 | int line; | 63 | int line; |
62 | 64 | ||
63 | #ifdef HAVE_LCD_BITMAP | ||
64 | tv_set_drawmode(DRMODE_COMPLEMENT); | ||
65 | #endif | ||
66 | |||
67 | while (count--) | 65 | while (count--) |
68 | { | 66 | { |
69 | line = (bookmarks[count].page - top_pos->page) * display_lines | 67 | line = (bookmarks[count].page - top_pos->page) * display_lines |
70 | + (bookmarks[count].line - top_pos->line); | 68 | + (bookmarks[count].line - top_pos->line); |
71 | if (line >= 0 && line < display_lines) | 69 | if (line >= 0 && line < display_lines) |
72 | { | 70 | disp_bookmarks[disp_count++] = line; |
73 | #ifdef HAVE_LCD_BITMAP | ||
74 | tv_fillrect(0, line, 1); | ||
75 | #else | ||
76 | tv_put_bookmark_icon(line); | ||
77 | #endif | ||
78 | } | ||
79 | } | 71 | } |
72 | |||
73 | tv_show_bookmarks(disp_bookmarks, disp_count); | ||
80 | } | 74 | } |
81 | 75 | ||
82 | void tv_draw_window(void) | 76 | void tv_draw_window(void) |
@@ -90,11 +84,6 @@ void tv_draw_window(void) | |||
90 | 84 | ||
91 | tv_start_display(); | 85 | tv_start_display(); |
92 | 86 | ||
93 | #ifdef HAVE_LCD_BITMAP | ||
94 | tv_set_drawmode(DRMODE_SOLID); | ||
95 | #endif | ||
96 | tv_clear_display(); | ||
97 | |||
98 | tv_read_start(cur_window, (cur_column > 0)); | 87 | tv_read_start(cur_window, (cur_column > 0)); |
99 | 88 | ||
100 | for (line = 0; line < display_lines; line++) | 89 | for (line = 0; line < display_lines; line++) |
@@ -112,7 +101,7 @@ void tv_draw_window(void) | |||
112 | tv_show_header(); | 101 | tv_show_header(); |
113 | tv_show_footer(&pos); | 102 | tv_show_footer(&pos); |
114 | #endif | 103 | #endif |
115 | tv_show_bookmarks(&pos); | 104 | tv_draw_bookmarks(&pos); |
116 | 105 | ||
117 | tv_update_display(); | 106 | tv_update_display(); |
118 | tv_end_display(); | 107 | tv_end_display(); |