mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Add columnlist:SizeColumnToData
This commit is contained in:
parent
40c65f1b8f
commit
3493e78813
@ -933,4 +933,31 @@ function newobject:GetColumnResizeEnabled()
|
||||
|
||||
return self.canresizecolumns
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SizeColumnToData(columnid)
|
||||
- desc: sizes a column to the width of its largest data
|
||||
string
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SizeColumnToData(columnid)
|
||||
|
||||
local column = self.children[columnid]
|
||||
local list = self.internals[1]
|
||||
local largest = 0
|
||||
|
||||
for k, v in ipairs(list.children) do
|
||||
local width = v:GetFont():getWidth(self:GetCellText(k, columnid))
|
||||
if width > largest then
|
||||
largest = width + v.textx
|
||||
end
|
||||
end
|
||||
|
||||
if largest <= 0 then
|
||||
largest = 10
|
||||
end
|
||||
|
||||
self:SetColumnWidth(columnid, largest)
|
||||
return self
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user