2014-01-22 16:03:44 -02:00
|
|
|
local ButtonTable = require("ui/widget/buttontable")
|
|
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
2014-10-30 19:42:18 +01:00
|
|
|
local Device = require("device")
|
2014-01-22 16:03:44 -02:00
|
|
|
local GestureRange = require("ui/gesturerange")
|
|
|
|
|
local Geom = require("ui/geometry")
|
2014-10-30 19:42:18 +01:00
|
|
|
local Input = require("device").input
|
|
|
|
|
local Screen = require("device").screen
|
2014-01-22 16:03:44 -02:00
|
|
|
local UIManager = require("ui/uimanager")
|
2014-01-22 23:36:32 -05:00
|
|
|
local _ = require("gettext")
|
2014-10-22 15:34:11 +02:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2014-01-22 16:03:44 -02:00
|
|
|
|
|
|
|
|
local ButtonDialog = InputContainer:new{
|
2014-03-13 21:52:43 +08:00
|
|
|
buttons = nil,
|
|
|
|
|
tap_close_callback = nil,
|
2014-01-22 16:03:44 -02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ButtonDialog:init()
|
2014-06-10 15:57:10 +08:00
|
|
|
if Device:hasKeys() then
|
2014-03-13 21:52:43 +08:00
|
|
|
self.key_events = {
|
2014-06-10 15:57:10 +08:00
|
|
|
Close = { {"Back"}, doc = "close button dialog" }
|
2014-03-13 21:52:43 +08:00
|
|
|
}
|
2014-05-29 16:04:00 +08:00
|
|
|
end
|
|
|
|
|
if Device:isTouchDevice() then
|
2014-03-13 21:52:43 +08:00
|
|
|
self.ges_events.TapClose = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "tap",
|
|
|
|
|
range = Geom:new{
|
|
|
|
|
x = 0, y = 0,
|
|
|
|
|
w = Screen:getWidth(),
|
|
|
|
|
h = Screen:getHeight(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
self[1] = CenterContainer:new{
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
FrameContainer:new{
|
|
|
|
|
ButtonTable:new{
|
|
|
|
|
width = Screen:getWidth()*0.9,
|
|
|
|
|
buttons = self.buttons,
|
2014-05-01 18:37:12 +08:00
|
|
|
show_parent = self,
|
2014-03-13 21:52:43 +08:00
|
|
|
},
|
2014-10-22 15:34:11 +02:00
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2014-03-13 21:52:43 +08:00
|
|
|
bordersize = 2,
|
|
|
|
|
radius = 7,
|
|
|
|
|
padding = 2,
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-22 16:03:44 -02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ButtonDialog:onTapClose()
|
2014-03-13 21:52:43 +08:00
|
|
|
UIManager:close(self)
|
|
|
|
|
if self.tap_close_callback then
|
|
|
|
|
self.tap_close_callback()
|
|
|
|
|
end
|
|
|
|
|
return true
|
2014-01-22 16:03:44 -02:00
|
|
|
end
|
|
|
|
|
|
2014-06-10 15:57:10 +08:00
|
|
|
function ButtonDialog:onClose()
|
|
|
|
|
self:onTapClose()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-22 16:03:44 -02:00
|
|
|
return ButtonDialog
|