2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

add change view mode feature for crereader

This commit is contained in:
Qingping Hou 2012-12-09 01:45:25 +08:00
parent d631445636
commit c454d86b2c
3 changed files with 7 additions and 3 deletions

View File

@ -46,9 +46,9 @@ static int initCache(lua_State *L) {
static int openDocument(lua_State *L) { static int openDocument(lua_State *L) {
const char *file_name = luaL_checkstring(L, 1); const char *file_name = luaL_checkstring(L, 1);
const char *style_sheet = luaL_checkstring(L, 2); const char *style_sheet = luaL_checkstring(L, 2);
int width = luaL_checkint(L, 3); int width = luaL_checkint(L, 3);
int height = luaL_checkint(L, 4); int height = luaL_checkint(L, 4);
LVDocViewMode view_mode = (LVDocViewMode)luaL_checkint(L, 5);
lString8 css; lString8 css;
CreDocument *doc = (CreDocument*) lua_newuserdata(L, sizeof(CreDocument)); CreDocument *doc = (CreDocument*) lua_newuserdata(L, sizeof(CreDocument));
@ -63,7 +63,7 @@ static int openDocument(lua_State *L) {
doc->text_view->setStyleSheet(css); doc->text_view->setStyleSheet(css);
} }
} }
doc->text_view->setViewMode(DVM_SCROLL, -1); doc->text_view->setViewMode(view_mode, -1);
doc->text_view->Resize(width, height); doc->text_view->Resize(width, height);
doc->text_view->LoadDocument(file_name); doc->text_view->LoadDocument(file_name);
doc->dom_doc = doc->text_view->getDocument(); doc->dom_doc = doc->text_view->getDocument();

View File

@ -14,6 +14,7 @@ CREReader = UniReader:new{
font_zoom = 0, font_zoom = 0,
line_space_percent = 100, line_space_percent = 100,
view_mode = DCREREADER_VIEW_MODE,
} }
function CREReader:init() function CREReader:init()
@ -82,7 +83,7 @@ function CREReader:open(filename)
file_type = "cr3" file_type = "cr3"
end end
local style_sheet = "./data/"..file_type..".css" local style_sheet = "./data/"..file_type..".css"
ok, self.doc = pcall(cre.openDocument, filename, style_sheet, G_width, G_height) ok, self.doc = pcall(cre.openDocument, filename, style_sheet, G_width, G_height, self.view_mode)
if not ok then if not ok then
return false, "Error opening cre-document. " -- self.doc, will contain error message return false, "Error opening cre-document. " -- self.doc, will contain error message
end end

View File

@ -68,6 +68,9 @@ DPICVIEWER_COMICS_MODE_ENABLE = true
DPICVIEWER_RTL_MODE_ENABLE = false DPICVIEWER_RTL_MODE_ENABLE = false
DPICVIEWER_PAGE_MODE_ENABLE = false DPICVIEWER_PAGE_MODE_ENABLE = false
-- 0 for scroll mode, 1 for page mode
DCREREADER_VIEW_MODE = 1
-- supported extensions -- supported extensions
DPDFREADER_EXT = ";pdf;xps;cbz;zip;" DPDFREADER_EXT = ";pdf;xps;cbz;zip;"
DDJVUREADER_EXT = ";djvu;" DDJVUREADER_EXT = ";djvu;"