1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Gilles Roux
12 * 2010 Yoshihisa Uchida
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 #include "tv_action.h"
25 #include "tv_bookmark.h"
27 #include "tv_screen_pos.h"
28 #include "tv_settings.h"
29 #include "tv_window.h"
31 bool tv_init(const unsigned char *file
)
35 /* initialize modules */
36 if (!tv_init_window())
39 /* load the preferences and bookmark */
40 tv_load_settings(file
);
42 /* select to read the page */
47 void tv_exit(void *parameter
)
51 /* save preference and bookmarks */
52 if (!tv_save_settings())
53 rb
->splash(HZ
, "Can't save preferences and bookmarks");
55 /* finalize modules */
61 struct tv_screen_pos pos
;
63 tv_copy_screen_pos(&pos
);
68 tv_move_screen(pos
.page
, pos
.line
, SEEK_SET
);
71 void tv_scroll_up(unsigned mode
)
76 if ((mode
== TV_VERTICAL_SCROLL_PAGE
) ||
77 (mode
== TV_VERTICAL_SCROLL_PREFS
&& preferences
->vertical_scroll_mode
== PAGE
))
80 #ifdef HAVE_LCD_BITMAP
81 offset_line
= (preferences
->page_mode
== OVERLAP
)? 1:0;
84 tv_move_screen(offset_page
, offset_line
, SEEK_CUR
);
87 void tv_scroll_down(unsigned mode
)
92 if ((mode
== TV_VERTICAL_SCROLL_PAGE
) ||
93 (mode
== TV_VERTICAL_SCROLL_PREFS
&& preferences
->vertical_scroll_mode
== PAGE
))
96 #ifdef HAVE_LCD_BITMAP
97 offset_line
= (preferences
->page_mode
== OVERLAP
)? -1:0;
100 tv_move_screen(offset_page
, offset_line
, SEEK_CUR
);
103 void tv_scroll_left(unsigned mode
)
105 int offset_window
= 0;
106 int offset_column
= 0;
108 if ((mode
== TV_HORIZONTAL_SCROLL_COLUMN
) ||
109 (mode
== TV_HORIZONTAL_SCROLL_PREFS
&& preferences
->horizontal_scroll_mode
== COLUMN
))
111 /* Scroll left one column */
116 /* Scroll left one window */
119 tv_move_window(offset_window
, offset_column
);
122 void tv_scroll_right(unsigned mode
)
124 int offset_window
= 0;
125 int offset_column
= 0;
127 if ((mode
== TV_HORIZONTAL_SCROLL_COLUMN
) ||
128 (mode
== TV_HORIZONTAL_SCROLL_PREFS
&& preferences
->horizontal_scroll_mode
== COLUMN
))
130 /* Scroll right one column */
135 /* Scroll right one window */
138 tv_move_window(offset_window
, offset_column
);
143 tv_move_screen(0, 0, SEEK_SET
);
148 tv_move_screen(0, 0, SEEK_END
);
149 if (preferences
->vertical_scroll_mode
== PAGE
)
150 tv_move_screen(0, -tv_get_screen_pos()->line
, SEEK_CUR
);
153 unsigned tv_menu(void)
156 struct tv_screen_pos cur_pos
;
157 off_t cur_file_pos
= tv_get_screen_pos()->file_pos
;
159 res
= tv_display_menu();
161 if (res
== TV_MENU_RESULT_EXIT_MENU
)
163 tv_convert_fpos(cur_file_pos
, &cur_pos
);
164 if (preferences
->vertical_scroll_mode
== PAGE
)
167 tv_move_screen(cur_pos
.page
, cur_pos
.line
, SEEK_SET
);
169 else if (res
== TV_MENU_RESULT_MOVE_PAGE
)
170 res
= TV_MENU_RESULT_EXIT_MENU
;
175 void tv_add_or_remove_bookmark(void)
177 tv_toggle_bookmark();