summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-06-28 11:17:47 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-06-28 11:17:47 +0000
commitcf6554d8914bd9c15f800399ede8750d93f8c74c (patch)
tree9f14e8a8d15481f8354074c412b0366d80be85ba /apps/plugins/text_viewer
parent31cf6d501338964538978f79be9a078deebdafdd (diff)
downloadrockbox-cf6554d8914bd9c15f800399ede8750d93f8c74c.zip
rockbox-cf6554d8914bd9c15f800399ede8750d93f8c74c.tar.gz
rockbox-cf6554d8914bd9c15f800399ede8750d93f8c74c.tar.bz2
rockbox-cf6554d8914bd9c15f800399ede8750d93f8c74c.tar.xz
text viewer: tv_window doesn't depend on the layout of the text viewer.
And display functions change the following. - some functions change to static functions. - fix the problem that font_changing flag is invalid value. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27165 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer')
-rw-r--r--apps/plugins/text_viewer/tv_display.c90
-rw-r--r--apps/plugins/text_viewer/tv_display.h92
-rw-r--r--apps/plugins/text_viewer/tv_window.c35
3 files changed, 108 insertions, 109 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c
index 0bbaf42..59b4bdf 100644
--- a/apps/plugins/text_viewer/tv_display.c
+++ b/apps/plugins/text_viewer/tv_display.c
@@ -82,14 +82,12 @@ struct tv_rect {
static struct viewport vp_info;
static bool is_initialized_vp = false;
+static struct screen* display;
+
#ifdef HAVE_LCD_BITMAP
static int drawmode = DRMODE_SOLID;
-static int totalsize;
-static bool show_vertical_scrollbar;
#endif
-static struct screen* display;
-
/* layout */
#ifdef HAVE_LCD_BITMAP
static struct tv_rect header;
@@ -101,15 +99,19 @@ static struct tv_rect bookmark;
#endif
static struct tv_rect drawarea;
+static bool show_vertical_scrollbar;
+
static int display_columns;
static int display_rows;
static int col_width = 1;
static int row_height = 1;
+static int totalsize;
+
#ifdef HAVE_LCD_BITMAP
-void tv_show_header(void)
+static void tv_show_header(void)
{
unsigned header_mode = header_mode;
@@ -117,7 +119,7 @@ void tv_show_header(void)
display->putsxy(header.x, header.y, preferences->file_name);
}
-void tv_show_footer(const struct tv_screen_pos *pos)
+static void tv_show_footer(const struct tv_screen_pos *pos)
{
unsigned char buf[12];
unsigned footer_mode = preferences->footer_mode;
@@ -132,13 +134,7 @@ void tv_show_footer(const struct tv_screen_pos *pos)
}
}
-void tv_init_scrollbar(off_t total, bool show_scrollbar)
-{
- totalsize = total;
- show_vertical_scrollbar = show_scrollbar;
-}
-
-void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
+static void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
{
int items;
int min_shown;
@@ -171,6 +167,12 @@ void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
#endif
+void tv_init_scrollbar(off_t total, bool show_scrollbar)
+{
+ totalsize = total;
+ show_vertical_scrollbar = show_scrollbar;
+}
+
void tv_show_bookmarks(const int *rows, int count)
{
#ifdef HAVE_LCD_BITMAP
@@ -188,6 +190,20 @@ void tv_show_bookmarks(const int *rows, int count)
}
}
+void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size)
+{
+#ifdef HAVE_LCD_BITMAP
+ tv_show_scrollbar(window, col, pos->file_pos, size);
+ tv_show_header();
+ tv_show_footer(pos);
+#else
+ (void)window;
+ (void)col;
+ (void)pos;
+ (void)size;
+#endif
+}
+
void tv_draw_text(int row, const unsigned char *text, int offset)
{
int xpos = -offset * col_width;
@@ -225,15 +241,13 @@ void tv_start_display(void)
void tv_end_display(void)
{
+ display->update_viewport();
+
#ifdef HAVE_LCD_BITMAP
rb->lcd_set_drawmode(drawmode);
#endif
- display->set_viewport(NULL);
-}
-void tv_update_display(void)
-{
- display->update_viewport();
+ display->set_viewport(NULL);
}
void tv_set_layout(bool show_scrollbar)
@@ -295,27 +309,29 @@ void tv_get_drawarea_info(int *width, int *cols, int *rows)
*rows = display_rows;
}
-#ifdef HAVE_LCD_BITMAP
-static void tv_undo_viewport(void)
-{
- if (is_initialized_vp)
- rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
-}
-
static void tv_change_viewport(void)
{
+#ifdef HAVE_LCD_BITMAP
struct viewport vp;
if (is_initialized_vp)
- tv_undo_viewport();
+ rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
else
is_initialized_vp = true;
rb->viewportmanager_theme_enable(SCREEN_MAIN, preferences->statusbar, &vp);
vp_info = vp;
vp_info.flags &= ~VP_FLAG_ALIGNMENT_MASK;
+#else
+ if (!is_initialized_vp)
+ {
+ rb->viewport_set_defaults(&vp_info, SCREEN_MAIN);
+ is_initialized_vp = true;
+ }
+#endif
}
+#ifdef HAVE_LCD_BITMAP
static bool tv_set_font(const unsigned char *font)
{
unsigned char path[MAX_PATH];
@@ -351,21 +367,14 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
tv_copy_preferences(&new_prefs);
rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH);
tv_set_preferences(&new_prefs);
- font_changing = false;
}
col_width = 2 * rb->font_get_width(preferences->font, ' ');
+ font_changing = false;
}
-
- tv_change_viewport();
#else
(void)oldp;
-
- if (!is_initialized_vp)
- {
- rb->viewport_set_defaults(&vp_info, SCREEN_MAIN);
- is_initialized_vp = true;
- }
#endif
+ tv_change_viewport();
}
bool tv_init_display(unsigned char **buf, size_t *size)
@@ -391,6 +400,15 @@ void tv_finalize_display(void)
}
/* undo viewport */
- tv_undo_viewport();
+ rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
+#endif
+}
+
+bool tv_exist_scrollbar(void)
+{
+#ifdef HAVE_LCD_BITMAP
+ return true;
+#else
+ return false;
#endif
}
diff --git a/apps/plugins/text_viewer/tv_display.h b/apps/plugins/text_viewer/tv_display.h
index 383f121..9726271 100644
--- a/apps/plugins/text_viewer/tv_display.h
+++ b/apps/plugins/text_viewer/tv_display.h
@@ -44,65 +44,59 @@ bool tv_init_display(unsigned char **buf, size_t *size);
/* finalize the display module */
void tv_finalize_display(void);
-
-/* layout parts accessing functions */
-
-#ifdef HAVE_LCD_BITMAP
-
-/* show headaer */
-void tv_show_header(void);
-
/*
- * show footer
+ * draw the text
*
- * [In] pos
- * the current position
+ * [In] row
+ * the row that displays the text
+ *
+ * [In] text
+ * text
+ *
+ * [In] offset
+ * display the text that is since offset columns
*/
-void tv_show_footer(const struct tv_screen_pos *pos);
+void tv_draw_text(int row, const unsigned char *text, int offset);
/*
- * initialize the scrollbar
+ * show bookmark
*
- * [In] total
- * total text size
+ * [In] rows
+ * the array of row where the bookmark
*
- * [In] show_scrollbar
- * true: show the vertical scrollbar
- * false: does not show the vertical scrollbar
+ * [In] count
+ * want to show bookmark count
*/
-void tv_init_scrollbar(off_t total, bool show_scrollbar);
+void tv_show_bookmarks(const int *rows, int count);
/*
- * show horizontal/vertical scrollbar
+ * update extra parts (header, footer, scrollbar, etc.)
*
* [In] window
- * the current window
+ * current window
*
* [In] col
- * the current column
+ * current column
*
- * [In] cur_pos
- * the current text position
+ * [In] pos
+ * current screen position (file position, page, line)
*
* [In] size
- * the size of text in displayed.
+ * the size of text which is displayed.
*/
-void tv_show_scrollbar(int window, int col, off_t cur_pos, int size);
-
-#endif
+void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size);
/*
- * show bookmark
+ * initialize the scrollbar
*
- * [In] rows
- * the array of row where the bookmark
+ * [In] total
+ * total text size
*
- * [In] count
- * want to show bookmark count
+ * [In] show_scrollbar
+ * true: show the vertical scrollbar
+ * false: does not show the vertical scrollbar
*/
-void tv_show_bookmarks(const int *rows, int count);
-
-/* common display functons */
+void tv_init_scrollbar(off_t total, bool show_scrollbar);
/* start the display processing */
void tv_start_display(void);
@@ -110,23 +104,6 @@ void tv_start_display(void);
/* end the display processing */
void tv_end_display(void);
-/*update the display */
-void tv_update_display(void);
-
-/*
- * draw the text
- *
- * [In] row
- * the row that displays the text
- *
- * [In] text
- * text
- *
- * [In] offset
- * display the text that is since offset columns
- */
-void tv_draw_text(int row, const unsigned char *text, int offset);
-
/* layout functions */
@@ -153,4 +130,13 @@ void tv_set_layout(bool show_scrollbar);
*/
void tv_get_drawarea_info(int *width, int *cols, int *rows);
+/*
+ * whether exist scrollbar
+ *
+ * return
+ * true exist scrollbar
+ * false does not exist scrollbar
+ */
+bool tv_exist_scrollbar(void);
+
#endif
diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c
index 748b5b4..9e35b49 100644
--- a/apps/plugins/text_viewer/tv_window.c
+++ b/apps/plugins/text_viewer/tv_window.c
@@ -77,14 +77,10 @@ void tv_draw_window(void)
size = tv_read_end();
-#ifdef HAVE_LCD_BITMAP
- tv_show_scrollbar(cur_window, cur_column, pos.file_pos, size);
- tv_show_header();
- tv_show_footer(&pos);
-#endif
tv_draw_bookmarks(&pos);
- tv_update_display();
+ tv_update_extra(cur_window, cur_column, &pos, size);
+
tv_end_display();
}
@@ -115,27 +111,26 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
tv_set_layout(need_vertical_scrollbar);
tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
-#ifdef HAVE_LCD_BITMAP
- tv_seek_top();
- tv_set_read_conditions(preferences->windows, window_width);
- if (tv_traverse_lines() && preferences->vertical_scrollbar)
+ if (tv_exist_scrollbar())
{
- need_vertical_scrollbar = true;
- tv_set_layout(need_vertical_scrollbar);
- tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
+ tv_seek_top();
+ tv_set_read_conditions(preferences->windows, window_width);
+ if (tv_traverse_lines() && preferences->vertical_scrollbar)
+ {
+ need_vertical_scrollbar = true;
+ tv_set_layout(need_vertical_scrollbar);
+ tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
+ }
+ tv_seek_top();
+ tv_init_scrollbar(tv_get_total_text_size(), need_vertical_scrollbar);
}
- tv_seek_top();
-#endif
-
- cur_column = 0;
if (cur_window >= preferences->windows)
cur_window = 0;
+ cur_column = 0;
+
tv_set_read_conditions(preferences->windows, window_width);
-#ifdef HAVE_LCD_BITMAP
- tv_init_scrollbar(tv_get_total_text_size(), need_vertical_scrollbar);
-#endif
}
bool tv_init_window(unsigned char **buf, size_t *size)