2013-02-19 11:16:42 +00:00
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
ReaderKoptListener = EventListener:new{}
|
2013-02-19 11:16:42 +00:00
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
function ReaderKoptListener:setZoomMode(zoom_mode)
|
2013-02-19 11:16:42 +00:00
|
|
|
if self.document.configurable.text_wrap == 1 then
|
2013-02-20 11:29:14 +00:00
|
|
|
-- in reflow mode only "page" zoom mode is valid so override any other zoom mode
|
2013-02-20 03:50:36 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "page", "koptlistener"))
|
2013-02-19 11:16:42 +00:00
|
|
|
else
|
2013-02-20 11:29:14 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", zoom_mode, "koptlistener"))
|
2013-02-19 11:16:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
function ReaderKoptListener:onReadSettings(config)
|
|
|
|
-- normal zoom mode is zoom mode used in non-reflow mode.
|
|
|
|
self.normal_zoom_mode = config:readSetting("normal_zoom_mode") or "page"
|
|
|
|
self:setZoomMode(self.normal_zoom_mode)
|
|
|
|
end
|
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
function ReaderKoptListener:onCloseDocument()
|
|
|
|
self.ui.doc_settings:saveSetting("normal_zoom_mode", self.normal_zoom_mode)
|
|
|
|
end
|
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
function ReaderKoptListener:onRestoreZoomMode()
|
|
|
|
-- "RestoreZoomMode" event is sent when reflow mode on/off is toggled
|
|
|
|
self:setZoomMode(self.normal_zoom_mode)
|
2013-02-19 11:16:42 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
function ReaderKoptListener:onSetZoomMode(zoom_mode, orig)
|
2013-02-20 11:29:14 +00:00
|
|
|
if orig == "koptlistener" then return end
|
|
|
|
-- capture zoom mode set outside of koptlistener which should always be normal zoom mode
|
|
|
|
self.normal_zoom_mode = zoom_mode
|
|
|
|
self:setZoomMode(self.normal_zoom_mode)
|
2013-02-19 11:16:42 +00:00
|
|
|
end
|
2013-03-10 06:23:26 +00:00
|
|
|
|
|
|
|
function ReaderKoptListener:onSetDimensions(dimensions)
|
|
|
|
-- called later than reader zooming
|
|
|
|
self.ui:handleEvent(Event:new("InitScrollPageStates"))
|
2013-03-19 13:36:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderKoptListener:onFineTuningFontSize(delta)
|
|
|
|
self.document.configurable.font_size = self.document.configurable.font_size + delta
|
|
|
|
end
|
2013-04-23 22:59:52 +00:00
|
|
|
|
|
|
|
function ReaderKoptListener:onZoomUpdate(zoom)
|
|
|
|
-- an exceptional case is reflow mode
|
|
|
|
if self.document.configurable.text_wrap == 1 then
|
|
|
|
self.view.state.zoom = 1.0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-19 19:33:58 +00:00
|
|
|
-- misc koptoption handler
|
|
|
|
function ReaderKoptListener:onDocLangUpdate(lang)
|
|
|
|
if lang == "chi_sim" or lang == "chi_tra" or
|
|
|
|
lang == "jpn" or lang == "kor" then
|
|
|
|
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[1]
|
|
|
|
else
|
|
|
|
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[3]
|
|
|
|
end
|
|
|
|
end
|