From 71514001b0d46dae5e3bcd925077b7f16b7d4650 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 12 Jan 2013 15:20:37 +0800 Subject: [PATCH] cre: load document afer set font Conflicts: cre.cpp crereader.lua --- cre.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cre.cpp b/cre.cpp index ffb1c8316..aaa6a8050 100644 --- a/cre.cpp +++ b/cre.cpp @@ -44,12 +44,11 @@ static int initCache(lua_State *L) { return 0; } -static int openDocument(lua_State *L) { - const char *file_name = luaL_checkstring(L, 1); - const char *style_sheet = luaL_checkstring(L, 2); - int width = luaL_checkint(L, 3); - int height = luaL_checkint(L, 4); - LVDocViewMode view_mode = (LVDocViewMode)luaL_checkint(L, 5); +static int newDocView(lua_State *L) { + const char *style_sheet = luaL_checkstring(L, 1); + int width = luaL_checkint(L, 2); + int height = luaL_checkint(L, 3); + LVDocViewMode view_mode = (LVDocViewMode)luaL_checkint(L, 4); lString8 css; CreDocument *doc = (CreDocument*) lua_newuserdata(L, sizeof(CreDocument)); @@ -66,11 +65,7 @@ static int openDocument(lua_State *L) { } doc->text_view->setViewMode(view_mode, -1); doc->text_view->Resize(width, height); - doc->text_view->LoadDocument(file_name); doc->text_view->setPageHeaderInfo(PGHDR_AUTHOR|PGHDR_TITLE|PGHDR_PAGE_NUMBER|PGHDR_PAGE_COUNT|PGHDR_CHAPTER_MARKS|PGHDR_CLOCK); - doc->text_view->setStatusFontFace(lString8("Droid Sans")); - doc->dom_doc = doc->text_view->getDocument(); - doc->text_view->Render(); return 1; } @@ -89,6 +84,17 @@ static int setGammaIndex(lua_State *L) { return 0; } +static int loadDocument(lua_State *L) { + CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument"); + const char *file_name = luaL_checkstring(L, 2); + + doc->text_view->LoadDocument(file_name); + doc->dom_doc = doc->text_view->getDocument(); + doc->text_view->Render(); + + return 0; +} + static int closeDocument(lua_State *L) { CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument"); @@ -637,7 +643,7 @@ static int findText(lua_State *L) { static const struct luaL_Reg cre_func[] = { {"initCache", initCache}, - {"openDocument", openDocument}, + {"newDocView", newDocView}, {"getFontFaces", getFontFaces}, {"getGammaIndex", getGammaIndex}, {"setGammaIndex", setGammaIndex}, @@ -646,6 +652,7 @@ static const struct luaL_Reg cre_func[] = { }; static const struct luaL_Reg credocument_meth[] = { + {"loadDocument", loadDocument}, /*--- get methods ---*/ {"getPages", getNumberOfPages}, {"getCurrentPage", getCurrentPage},