|
|
@ -1,7 +1,6 @@
|
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
|
|
|
local ButtonTable = require("ui/widget/buttontable")
|
|
|
|
local ButtonTable = require("ui/widget/buttontable")
|
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
|
|
|
local CloseButton = require("ui/widget/closebutton")
|
|
|
|
|
|
|
|
local Device = require("device")
|
|
|
|
local Device = require("device")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local Geom = require("ui/geometry")
|
|
|
|
local Geom = require("ui/geometry")
|
|
|
@ -10,7 +9,6 @@ local Font = require("ui/font")
|
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
|
|
|
local OverlapGroup = require("ui/widget/overlapgroup")
|
|
|
|
|
|
|
|
local NumberPickerWidget = require("ui/widget/numberpickerwidget")
|
|
|
|
local NumberPickerWidget = require("ui/widget/numberpickerwidget")
|
|
|
|
local Size = require("ui/size")
|
|
|
|
local Size = require("ui/size")
|
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
|
|
@ -27,17 +25,15 @@ local DateWidget = InputContainer:new{
|
|
|
|
height = nil,
|
|
|
|
height = nil,
|
|
|
|
day = 1,
|
|
|
|
day = 1,
|
|
|
|
month = 1,
|
|
|
|
month = 1,
|
|
|
|
year = 2017,
|
|
|
|
year = 2021,
|
|
|
|
ok_text = _("OK"),
|
|
|
|
ok_text = _("Apply"),
|
|
|
|
cancel_text = _("Cancel"),
|
|
|
|
cancel_text = _("Close"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function DateWidget:init()
|
|
|
|
function DateWidget:init()
|
|
|
|
self.medium_font_face = Font:getFace("ffont")
|
|
|
|
|
|
|
|
self.light_bar = {}
|
|
|
|
|
|
|
|
self.screen_width = Screen:getWidth()
|
|
|
|
self.screen_width = Screen:getWidth()
|
|
|
|
self.screen_height = Screen:getHeight()
|
|
|
|
self.screen_height = Screen:getHeight()
|
|
|
|
self.width = math.floor(self.screen_width * 0.95)
|
|
|
|
self.width = self.width or math.floor(math.min(self.screen_width, self.screen_height) * 0.8)
|
|
|
|
if Device:hasKeys() then
|
|
|
|
if Device:hasKeys() then
|
|
|
|
self.key_events = {
|
|
|
|
self.key_events = {
|
|
|
|
Close = { {"Back"}, doc = "close date widget" }
|
|
|
|
Close = { {"Back"}, doc = "close date widget" }
|
|
|
@ -64,16 +60,14 @@ end
|
|
|
|
function DateWidget:update()
|
|
|
|
function DateWidget:update()
|
|
|
|
local year_widget = NumberPickerWidget:new{
|
|
|
|
local year_widget = NumberPickerWidget:new{
|
|
|
|
show_parent = self,
|
|
|
|
show_parent = self,
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
|
|
|
value = self.year,
|
|
|
|
value = self.year,
|
|
|
|
value_min = 2017,
|
|
|
|
value_min = 2021,
|
|
|
|
value_max = 2037,
|
|
|
|
value_max = 2041,
|
|
|
|
value_step = 1,
|
|
|
|
value_step = 1,
|
|
|
|
value_hold_step = 4,
|
|
|
|
value_hold_step = 4,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local month_widget = NumberPickerWidget:new{
|
|
|
|
local month_widget = NumberPickerWidget:new{
|
|
|
|
show_parent = self,
|
|
|
|
show_parent = self,
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
|
|
|
value = self.month,
|
|
|
|
value = self.month,
|
|
|
|
value_min = 1,
|
|
|
|
value_min = 1,
|
|
|
|
value_max = 12,
|
|
|
|
value_max = 12,
|
|
|
@ -82,7 +76,6 @@ function DateWidget:update()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local day_widget = NumberPickerWidget:new{
|
|
|
|
local day_widget = NumberPickerWidget:new{
|
|
|
|
show_parent = self,
|
|
|
|
show_parent = self,
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
|
|
|
value = self.day,
|
|
|
|
value = self.day,
|
|
|
|
value_min = 1,
|
|
|
|
value_min = 1,
|
|
|
|
value_max = 31,
|
|
|
|
value_max = 31,
|
|
|
@ -96,7 +89,7 @@ function DateWidget:update()
|
|
|
|
alignment = "center",
|
|
|
|
alignment = "center",
|
|
|
|
face = self.title_face,
|
|
|
|
face = self.title_face,
|
|
|
|
bold = true,
|
|
|
|
bold = true,
|
|
|
|
width = math.floor(self.screen_width * 0.1),
|
|
|
|
width = math.floor(self.screen_width * 0.02),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local date_group = HorizontalGroup:new{
|
|
|
|
local date_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
align = "center",
|
|
|
@ -114,8 +107,7 @@ function DateWidget:update()
|
|
|
|
TextWidget:new{
|
|
|
|
TextWidget:new{
|
|
|
|
text = self.title_text,
|
|
|
|
text = self.title_text,
|
|
|
|
face = self.title_face,
|
|
|
|
face = self.title_face,
|
|
|
|
bold = true,
|
|
|
|
max_width = self.width - 2 * (Size.padding.default + Size.margin.title),
|
|
|
|
width = math.floor(self.screen_width * 0.95),
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local date_line = LineWidget:new{
|
|
|
|
local date_line = LineWidget:new{
|
|
|
@ -124,14 +116,6 @@ function DateWidget:update()
|
|
|
|
h = Size.line.thick,
|
|
|
|
h = Size.line.thick,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local date_bar = OverlapGroup:new{
|
|
|
|
|
|
|
|
dimen = {
|
|
|
|
|
|
|
|
w = self.width,
|
|
|
|
|
|
|
|
h = date_title:getSize().h
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
date_title,
|
|
|
|
|
|
|
|
CloseButton:new{ window = self, padding_top = Size.margin.title, },
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local buttons = {
|
|
|
|
local buttons = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -170,11 +154,11 @@ function DateWidget:update()
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
|
|
|
VerticalGroup:new{
|
|
|
|
VerticalGroup:new{
|
|
|
|
align = "left",
|
|
|
|
align = "left",
|
|
|
|
date_bar,
|
|
|
|
date_title,
|
|
|
|
date_line,
|
|
|
|
date_line,
|
|
|
|
CenterContainer:new{
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = math.floor(self.screen_width * 0.95),
|
|
|
|
w = self.width,
|
|
|
|
h = math.floor(date_group:getSize().h * 1.2),
|
|
|
|
h = math.floor(date_group:getSize().h * 1.2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
date_group
|
|
|
|
date_group
|
|
|
|