summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-06-06 10:52:19 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-06-06 10:52:19 +0000
commit240b198d657b8f6c78ee5d2ce915005ac79fea75 (patch)
tree42ed188f165eeb4fd22c6510f2c10229f73d43eb /apps
parent19ac3453e0ed2b3fe458a0f4aeca4883c53b490e (diff)
downloadrockbox-240b198d657b8f6c78ee5d2ce915005ac79fea75.tar.gz
rockbox-240b198d657b8f6c78ee5d2ce915005ac79fea75.tar.bz2
rockbox-240b198d657b8f6c78ee5d2ce915005ac79fea75.zip
text viewer: can display the horizontal scroll bar.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26620 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/text_viewer/readme.txt2
-rw-r--r--apps/plugins/text_viewer/tv_menu.c51
-rw-r--r--apps/plugins/text_viewer/tv_preferences.c22
-rw-r--r--apps/plugins/text_viewer/tv_preferences.h11
-rw-r--r--apps/plugins/text_viewer/tv_settings.c26
-rw-r--r--apps/plugins/text_viewer/tv_window.c53
6 files changed, 107 insertions, 58 deletions
diff --git a/apps/plugins/text_viewer/readme.txt b/apps/plugins/text_viewer/readme.txt
index 37ba354a71..0e9bd7ce49 100644
--- a/apps/plugins/text_viewer/readme.txt
+++ b/apps/plugins/text_viewer/readme.txt
@@ -48,8 +48,6 @@ TODO list
- for the horizontal scroll, allow the select scroll by screen/scroll by column for the settings menu.
- - can display the horizontal scroll bar.
-
- draw images that are linked to the text. (<img src="...">)
- play audios that are linked to the text. (<audio src="...">)
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index e62b2de4be..ff2d6758a4 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -30,6 +30,42 @@
static struct tv_preferences new_prefs;
+/* scrollbar menu */
+#ifdef HAVE_LCD_BITMAP
+static bool tv_horizontal_scrollbar_setting(void)
+{
+ static const struct opt_items names[] = {
+ {"No", -1},
+ {"Yes", -1},
+ };
+
+ return rb->set_option("Horizontal Scrollbar", &new_prefs.horizontal_scrollbar, INT,
+ names, 2, NULL);
+}
+
+static bool tv_vertical_scrollbar_setting(void)
+{
+ static const struct opt_items names[] = {
+ {"No", -1},
+ {"Yes", -1},
+ };
+
+ return rb->set_option("Vertical Scrollbar", &new_prefs.vertical_scrollbar, INT,
+ names, 2, NULL);
+}
+
+MENUITEM_FUNCTION(horizontal_scrollbar_item, 0, "Horizontal",
+ tv_horizontal_scrollbar_setting,
+ NULL, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Vertical",
+ tv_vertical_scrollbar_setting,
+ NULL, NULL, Icon_NOICON);
+MAKE_MENU(scrollbar_menu, "Scrollbar", NULL, Icon_NOICON,
+ &horizontal_scrollbar_item, &vertical_scrollbar_item);
+#endif
+
+/* main menu */
+
static bool tv_encoding_setting(void)
{
static struct opt_items names[NUM_CODEPAGES];
@@ -109,17 +145,6 @@ static bool tv_page_mode_setting(void)
names, 2, NULL);
}
-static bool tv_scrollbar_setting(void)
-{
- static const struct opt_items names[] = {
- {"Off", -1},
- {"On", -1}
- };
-
- return rb->set_option("Show Scrollbar", &new_prefs.scrollbar_mode, INT,
- names, 2, NULL);
-}
-
static bool tv_header_setting(void)
{
int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2;
@@ -272,8 +297,6 @@ MENUITEM_FUNCTION(windows_item, 0, "Screens Per Page", tv_windows_setting,
MENUITEM_FUNCTION(alignment_item, 0, "Alignment", tv_alignment_setting,
NULL, NULL, Icon_NOICON);
#ifdef HAVE_LCD_BITMAP
-MENUITEM_FUNCTION(scrollbar_item, 0, "Show Scrollbar", tv_scrollbar_setting,
- NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", tv_page_mode_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(header_item, 0, "Show Header", tv_header_setting,
@@ -291,7 +314,7 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
&alignment_item,
#ifdef HAVE_LCD_BITMAP
- &scrollbar_item, &page_mode_item, &header_item, &footer_item, &font_item,
+ &scrollbar_menu, &page_mode_item, &header_item, &footer_item, &font_item,
#endif
&scroll_mode_item, &autoscroll_speed_item);
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index 777f6afdb9..ad4b0aa12b 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -43,16 +43,17 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
* - font
* - autoscroll_speed
*/
- if ((oldp == NULL) ||
- (oldp->word_mode != newp->word_mode) ||
- (oldp->line_mode != newp->line_mode) ||
- (oldp->windows != newp->windows) ||
- (oldp->scrollbar_mode != newp->scrollbar_mode) ||
- (oldp->encoding != newp->encoding) ||
+ if ((oldp == NULL) ||
+ (oldp->word_mode != newp->word_mode) ||
+ (oldp->line_mode != newp->line_mode) ||
+ (oldp->windows != newp->windows) ||
+ (oldp->horizontal_scrollbar != newp->horizontal_scrollbar) ||
+ (oldp->vertical_scrollbar != newp->vertical_scrollbar) ||
+ (oldp->encoding != newp->encoding) ||
#ifdef HAVE_LCD_BITMAP
- (oldp->header_mode != newp->header_mode) ||
- (oldp->footer_mode != newp->footer_mode) ||
- (rb->strcmp(oldp->font_name, newp->font_name)) ||
+ (oldp->header_mode != newp->header_mode) ||
+ (oldp->footer_mode != newp->footer_mode) ||
+ (rb->strcmp(oldp->font_name, newp->font_name)) ||
#endif
(rb->strcmp(oldp->file_name, newp->file_name)))
{
@@ -95,7 +96,8 @@ void tv_set_default_preferences(struct tv_preferences *p)
p->alignment = LEFT;
p->scroll_mode = PAGE;
p->page_mode = NO_OVERLAP;
- p->scrollbar_mode = SB_OFF;
+ p->horizontal_scrollbar = SB_OFF;
+ p->vertical_scrollbar = SB_OFF;
rb->memset(p->font_name, 0, MAX_PATH);
#ifdef HAVE_LCD_BITMAP
p->header_mode = HD_BOTH;
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index f74e3d7407..ca02c2b5c9 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -23,6 +23,11 @@
#ifndef PLUGIN_TEXT_VIEWER_PREFERENCES_H
#define PLUGIN_TEXT_VIEWER_PREFERENCES_H
+enum scrollbar_mode {
+ SB_OFF = 0,
+ SB_ON,
+};
+
struct tv_preferences {
enum {
WRAP = 0,
@@ -43,10 +48,8 @@ struct tv_preferences {
enum codepages encoding;
- enum {
- SB_OFF = 0,
- SB_ON,
- } scrollbar_mode;
+ enum scrollbar_mode horizontal_scrollbar;
+ enum scrollbar_mode vertical_scrollbar;
enum {
NO_OVERLAP = 0,
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index 3b9a684b94..bf6ae1e74a 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -39,14 +39,15 @@
* windows 1 (when version <= 0x32, this value is view_mode)
* alignment 1
* encoding 1
- * scrollbar_mode 1
+ * vertical_scrollbar 1
* (unused) 1 (for compatibility)
* page_mode 1
* page_number_mode 1
* title_mode 1
* scroll_mode 1
* autoscroll_speed 1
- * (reserved) 16
+ * horizontal_scrollbar 1
+ * (reserved) 15
* font name MAX_PATH
*/
@@ -54,7 +55,7 @@
#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat"
#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
-#define TV_GLOBAL_SETTINGS_VERSION 0x33
+#define TV_GLOBAL_SETTINGS_VERSION 0x34
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
@@ -77,14 +78,15 @@
* windows 1 (when version <= 0x33, this value is view_mode)
* alignment 1
* encoding 1
- * scrollbar_mode 1
+ * vertical_scrollbar 1
* (unused) 1 (for compatibility)
* page_mode 1
* header_mode 1
* footer_mode 1
* scroll_mode 1
* autoscroll_speed 1
- * (reserved) 16
+ * horizontal_scrollbar 1
+ * (reserved) 15
* font name MAX_PATH
* bookmark count 1
* [1st bookmark]
@@ -106,7 +108,7 @@
#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp"
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
-#define TV_SETTINGS_VERSION 0x34
+#define TV_SETTINGS_VERSION 0x35
#define TV_SETTINGS_HEADER_SIZE 4
#define TV_SETTINGS_FIRST_VERSION 0x32
@@ -143,8 +145,8 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
else
prefs->alignment = LEFT;
- prefs->encoding = *p++;
- prefs->scrollbar_mode = *p++;
+ prefs->encoding = *p++;
+ prefs->vertical_scrollbar = *p++;
/* skip need_scrollbar */
p++;
prefs->page_mode = *p++;
@@ -153,6 +155,11 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
prefs->scroll_mode = *p++;
prefs->autoscroll_speed = *p++;
+ if (version > 2)
+ prefs->horizontal_scrollbar = *p;
+ else
+ prefs->horizontal_scrollbar = SB_OFF;
+
rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
#ifdef HAVE_LCD_BITMAP
@@ -172,7 +179,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
*p++ = prefs->windows;
*p++ = prefs->alignment;
*p++ = prefs->encoding;
- *p++ = prefs->scrollbar_mode;
+ *p++ = prefs->vertical_scrollbar;
/* skip need_scrollbar */
p++;
*p++ = prefs->page_mode;
@@ -180,6 +187,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
*p++ = prefs->footer_mode;
*p++ = prefs->scroll_mode;
*p++ = prefs->autoscroll_speed;
+ *p++ = prefs->horizontal_scrollbar;
rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);
diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c
index bf27e2cfd5..72faf23565 100644
--- a/apps/plugins/text_viewer/tv_window.c
+++ b/apps/plugins/text_viewer/tv_window.c
@@ -27,7 +27,8 @@
#include "tv_text_reader.h"
#include "tv_window.h"
-#define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width
+#define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width
+#define TV_SCROLLBAR_HEIGHT 4
#ifndef HAVE_LCD_BITMAP
#define TV_BOOKMARK_ICON 0xe101
@@ -36,7 +37,7 @@
#ifdef HAVE_LCD_BITMAP
static int header_height;
static int footer_height;
-static bool need_scrollbar = false;
+static bool need_vertical_scrollbar = false;
#endif
static int start_width;
@@ -123,27 +124,41 @@ static void tv_show_scrollbar(off_t cur_pos, int size)
int items;
int min_shown;
int max_shown;
- int sb_begin_y;
+ int sb_width;
int sb_height;
- if (!need_scrollbar)
- return;
-
- items = (int) tv_get_total_text_size();
- min_shown = (int) cur_pos;
-
- max_shown = min_shown + size;
+ sb_height = LCD_HEIGHT - header_height - footer_height;
+ if (prefs->horizontal_scrollbar)
+ {
+ items = prefs->windows * window_columns;
+ min_shown = cur_window * window_columns + cur_column;
+ max_shown = min_shown + window_columns;
+ sb_width = (need_vertical_scrollbar)? TV_SCROLLBAR_WIDTH : 0;
+ sb_height -= TV_SCROLLBAR_HEIGHT;
+
+ rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN],
+ sb_width,
+ LCD_HEIGHT - footer_height - TV_SCROLLBAR_HEIGHT,
+ LCD_WIDTH - sb_width, TV_SCROLLBAR_HEIGHT,
+ items, min_shown, max_shown, HORIZONTAL);
+ }
- sb_begin_y = header_height;
- sb_height = LCD_HEIGHT - header_height - footer_height;
+ if (need_vertical_scrollbar)
+ {
+ items = (int) tv_get_total_text_size();
+ min_shown = (int) cur_pos;
+ max_shown = min_shown + size;
- rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN],0, sb_begin_y,
- TV_SCROLLBAR_WIDTH-1, sb_height,
- items, min_shown, max_shown, VERTICAL);
+ rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], 0, header_height,
+ TV_SCROLLBAR_WIDTH-1, sb_height,
+ items, min_shown, max_shown, VERTICAL);
+ }
}
static int tv_calc_display_lines(void)
{
+ int scrollbar_height = (prefs->horizontal_scrollbar)? TV_SCROLLBAR_HEIGHT : 0;
+
header_height = (prefs->header_mode == HD_SBAR || prefs->header_mode == HD_BOTH)?
STATUSBAR_HEIGHT : 0;
@@ -160,7 +175,7 @@ static int tv_calc_display_lines(void)
if (prefs->footer_mode == FT_PAGE || prefs->footer_mode == FT_BOTH)
footer_height += prefs->font->height;
- return (LCD_HEIGHT - header_height - footer_height) / prefs->font->height;
+ return (LCD_HEIGHT - header_height - footer_height - scrollbar_height) / prefs->font->height;
}
#endif
@@ -314,13 +329,13 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
window_width = LCD_WIDTH;
#ifdef HAVE_LCD_BITMAP
- need_scrollbar = false;
+ need_vertical_scrollbar = false;
start_width = 0;
tv_seek_top();
tv_set_read_conditions(prefs->windows, window_width);
- if (tv_traverse_lines() && prefs->scrollbar_mode)
+ if (tv_traverse_lines() && prefs->vertical_scrollbar)
{
- need_scrollbar = true;
+ need_vertical_scrollbar = true;
start_width = TV_SCROLLBAR_WIDTH;
}
tv_seek_top();