2013-03-12 17:18:53 +00:00
|
|
|
require "ui/widget/container"
|
2012-06-10 15:52:09 +00:00
|
|
|
|
|
|
|
--[[
|
|
|
|
Widget that displays an informational message
|
|
|
|
|
|
|
|
it vanishes on key press or after a given timeout
|
|
|
|
]]
|
|
|
|
InfoMessage = InputContainer:new{
|
|
|
|
face = Font:getFace("infofont", 25),
|
|
|
|
text = "",
|
2013-02-02 06:36:29 +00:00
|
|
|
timeout = nil, -- in seconds
|
2012-06-10 15:52:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function InfoMessage:init()
|
2013-02-02 06:36:29 +00:00
|
|
|
if Device:hasKeyboard() then
|
|
|
|
key_events = {
|
2013-04-08 07:29:23 +00:00
|
|
|
AnyKeyPressed = { { Input.group.Any },
|
|
|
|
seqtext = "any key", doc = _("close dialog") }
|
2013-02-02 06:36:29 +00:00
|
|
|
}
|
2013-03-17 04:15:21 +00:00
|
|
|
else
|
|
|
|
self.ges_events.TapClose = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "tap",
|
|
|
|
range = Geom:new{
|
|
|
|
x = 0, y = 0,
|
|
|
|
w = Screen:getWidth(),
|
|
|
|
h = Screen:getHeight(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-02 06:36:29 +00:00
|
|
|
end
|
2012-06-10 15:52:09 +00:00
|
|
|
-- we construct the actual content here because self.text is only available now
|
|
|
|
self[1] = CenterContainer:new{
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
FrameContainer:new{
|
|
|
|
margin = 2,
|
|
|
|
background = 0,
|
|
|
|
HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
ImageWidget:new{
|
|
|
|
file = "resources/info-i.png"
|
|
|
|
},
|
|
|
|
HorizontalSpan:new{ width = 10 },
|
|
|
|
TextBoxWidget:new{
|
|
|
|
text = self.text,
|
|
|
|
face = Font:getFace("cfont", 30)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function InfoMessage:onShow()
|
|
|
|
-- triggered by the UIManager after we got successfully shown (not yet painted)
|
|
|
|
if self.timeout then
|
|
|
|
UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end)
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function InfoMessage:onAnyKeyPressed()
|
|
|
|
-- triggered by our defined key events
|
|
|
|
UIManager:close(self)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2013-03-17 04:15:21 +00:00
|
|
|
function InfoMessage:onTapClose()
|
|
|
|
UIManager:close(self)
|
|
|
|
return true
|
|
|
|
end
|