2012-10-08 15:39:03 +00:00
|
|
|
require "unireader"
|
|
|
|
|
2012-10-13 09:42:21 +00:00
|
|
|
PICViewer = UniReader:new{}
|
|
|
|
|
|
|
|
function PICViewer:setDefaults()
|
|
|
|
self.show_overlap_enable = false
|
|
|
|
self.show_links_enable = false
|
|
|
|
end
|
2012-10-08 15:39:03 +00:00
|
|
|
|
|
|
|
function PICViewer:open(filename)
|
|
|
|
ok, self.doc = pcall(pic.openDocument, filename)
|
|
|
|
if not ok then
|
|
|
|
return ok, self.doc
|
|
|
|
end
|
|
|
|
return ok
|
|
|
|
end
|
2012-10-10 12:22:28 +00:00
|
|
|
|
|
|
|
function PICViewer:_drawReadingInfo()
|
|
|
|
local width = G_width
|
|
|
|
local face = Font:getFace("rifont", 20)
|
2012-10-11 21:22:45 +00:00
|
|
|
local page_width, page_height, page_components = self.doc:getOriginalPageSize()
|
2012-10-10 12:22:28 +00:00
|
|
|
|
|
|
|
-- display memory, time, battery and image info on top of page
|
|
|
|
fb.bb:paintRect(0, 0, width, 40+6*2, 0)
|
|
|
|
renderUtf8Text(fb.bb, 10, 15+6, face,
|
|
|
|
"M: "..
|
2012-10-13 08:36:37 +00:00
|
|
|
math.ceil( self.cache_current_memsize / 1024 ).."/"..math.ceil( self.cache_max_memsize / 1024 ).."k", true)
|
2012-10-10 12:22:28 +00:00
|
|
|
local txt = os.date("%a %d %b %Y %T").." ["..BatteryLevel().."]"
|
2012-10-10 12:55:38 +00:00
|
|
|
local w = sizeUtf8Text(0, width, face, txt, true).x
|
2012-10-10 12:22:28 +00:00
|
|
|
renderUtf8Text(fb.bb, width - w - 10, 15+6, face, txt, true)
|
|
|
|
renderUtf8Text(fb.bb, 10, 15+6+22, face,
|
|
|
|
"Gm:"..string.format("%.1f",self.globalgamma)..", "..
|
2012-10-13 08:36:37 +00:00
|
|
|
tostring(page_width).."x"..tostring(page_height).."x"..tostring(page_components)..
|
|
|
|
" ("..tostring(math.ceil(page_width*page_height*page_components/1024)).."k), "..
|
2012-10-10 12:22:28 +00:00
|
|
|
string.format("%.1fx", self.globalzoom), true)
|
|
|
|
end
|
2012-10-13 12:26:06 +00:00
|
|
|
|
|
|
|
function PICViewer:init()
|
|
|
|
self:addAllCommands()
|
|
|
|
self:adjustCommands()
|
|
|
|
end
|
|
|
|
|
|
|
|
function PICViewer:adjustCommands()
|
|
|
|
self.commands:del(KEY_G, nil, "G")
|
|
|
|
self.commands:del(KEY_T, nil, "T")
|
|
|
|
self.commands:del(KEY_B, nil, "B")
|
|
|
|
self.commands:del(KEY_B, MOD_ALT, "B")
|
|
|
|
self.commands:del(KEY_B, MOD_SHIFT, "B")
|
|
|
|
self.commands:del(KEY_R, MOD_SHIFT, "R")
|
|
|
|
self.commands:del(KEY_DOT, nil, ".")
|
|
|
|
self.commands:del(KEY_N, nil, "N")
|
|
|
|
self.commands:del(KEY_L, nil, "L")
|
|
|
|
self.commands:del(KEY_L, MOD_SHIFT, "L")
|
|
|
|
self.commands:del(KEY_N, MOD_SHIFT, "N")
|
2012-10-13 13:20:34 +00:00
|
|
|
self.commands:del(KEY_J,MOD_SHIFT,"J")
|
|
|
|
self.commands:del(KEY_K,MOD_SHIFT,"K")
|
|
|
|
self.commands:del(KEY_BACK,nil,"Back")
|
|
|
|
self.commands:del(KEY_BACK,MOD_SHIFT,"Back")
|
2012-10-13 12:26:06 +00:00
|
|
|
self.commands:delGroup("[1, 2 .. 9, 0]")
|
|
|
|
end
|