@ -129,21 +129,46 @@ function InfoMessage:init()
width = text_width ,
}
end
self.movable = MovableContainer : new {
FrameContainer : new {
background = Blitbuffer.COLOR_WHITE ,
HorizontalGroup : new {
align = " center " ,
image_widget ,
HorizontalSpan : new { width = ( self.show_icon and Size.span . horizontal_default or 0 ) } ,
text_widget ,
}
local frame = FrameContainer : new {
background = Blitbuffer.COLOR_WHITE ,
HorizontalGroup : new {
align = " center " ,
image_widget ,
HorizontalSpan : new { width = ( self.show_icon and Size.span . horizontal_default or 0 ) } ,
text_widget ,
}
}
self.movable = MovableContainer : new {
frame ,
}
self [ 1 ] = CenterContainer : new {
dimen = Screen : getSize ( ) ,
self.movable ,
}
if not self.height then
-- Reduce font size until widget fit screen height if needed
local cur_size = frame : getSize ( )
if cur_size and cur_size.h > 0.95 * Screen : getHeight ( ) then
local orig_font = text_widget.face . orig_font
local orig_size = text_widget.face . orig_size
local real_size = text_widget.face . size
if orig_size > 10 then -- don't go too small
while true do
orig_size = orig_size - 1
self.face = Font : getFace ( orig_font , orig_size )
-- scaleBySize() in Font:getFace() may give the same
-- real font size even if we decreased orig_size,
-- so check we really got a smaller real font size
if self.face . size < real_size then
break
end
end
-- re-init this widget
self : free ( )
self : init ( )
end
end
end
end
function InfoMessage : onCloseWidget ( )