mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Merge pull request #15 from Tourahi/master
Ability to change the font of the columnlist rows.
This commit is contained in:
commit
b8a82b51a7
@ -14,7 +14,7 @@ local newobject = loveframes.NewObject("columnlist", "loveframes_object_columnli
|
|||||||
- desc: intializes the element
|
- desc: intializes the element
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:initialize()
|
function newobject:initialize()
|
||||||
|
|
||||||
self.type = "columnlist"
|
self.type = "columnlist"
|
||||||
self.width = 300
|
self.width = 300
|
||||||
self.height = 100
|
self.height = 100
|
||||||
@ -39,7 +39,7 @@ function newobject:initialize()
|
|||||||
|
|
||||||
local list = loveframes.objects["columnlistarea"]:new(self)
|
local list = loveframes.objects["columnlistarea"]:new(self)
|
||||||
table.insert(self.internals, list)
|
table.insert(self.internals, list)
|
||||||
|
|
||||||
self:SetDrawFunc()
|
self:SetDrawFunc()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,48 +48,48 @@ end
|
|||||||
- desc: updates the object
|
- desc: updates the object
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:update(dt)
|
function newobject:update(dt)
|
||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
|
|
||||||
if state ~= selfstate then
|
if state ~= selfstate then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local visible = self.visible
|
local visible = self.visible
|
||||||
local alwaysupdate = self.alwaysupdate
|
local alwaysupdate = self.alwaysupdate
|
||||||
|
|
||||||
if not visible then
|
if not visible then
|
||||||
if not alwaysupdate then
|
if not alwaysupdate then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local parent = self.parent
|
local parent = self.parent
|
||||||
local base = loveframes.base
|
local base = loveframes.base
|
||||||
local children = self.children
|
local children = self.children
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local update = self.Update
|
local update = self.Update
|
||||||
|
|
||||||
self:CheckHover()
|
self:CheckHover()
|
||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v.columnid = k
|
v.columnid = k
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.startadjustment = false
|
self.startadjustment = false
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
update(self, dt)
|
update(self, dt)
|
||||||
end
|
end
|
||||||
@ -108,49 +108,49 @@ function newobject:draw()
|
|||||||
if not self.visible then
|
if not self.visible then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local vbody = self.internals[1]:GetVerticalScrollBody()
|
local vbody = self.internals[1]:GetVerticalScrollBody()
|
||||||
local hbody = self.internals[1]:GetHorizontalScrollBody()
|
local hbody = self.internals[1]:GetHorizontalScrollBody()
|
||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
|
|
||||||
if vbody then
|
if vbody then
|
||||||
width = width - vbody.width
|
width = width - vbody.width
|
||||||
end
|
end
|
||||||
|
|
||||||
if hbody then
|
if hbody then
|
||||||
height = height - hbody.height
|
height = height - hbody.height
|
||||||
end
|
end
|
||||||
|
|
||||||
local stencilfunc = function()
|
local stencilfunc = function()
|
||||||
love.graphics.rectangle("fill", self.x, self.y, width, height)
|
love.graphics.rectangle("fill", self.x, self.y, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set the object's draw order
|
-- set the object's draw order
|
||||||
self:SetDrawOrder()
|
self:SetDrawOrder()
|
||||||
|
|
||||||
local drawfunc = self.Draw or self.drawfunc
|
local drawfunc = self.Draw or self.drawfunc
|
||||||
if drawfunc then
|
if drawfunc then
|
||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
if internals then
|
if internals then
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
v:draw()
|
v:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.stencil(stencilfunc)
|
love.graphics.stencil(stencilfunc)
|
||||||
love.graphics.setStencilTest("greater", 0)
|
love.graphics.setStencilTest("greater", 0)
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
if children then
|
if children then
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:draw()
|
v:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local drawfunc = self.DrawOver or self.drawoverfunc
|
local drawfunc = self.DrawOver or self.drawoverfunc
|
||||||
if drawfunc then
|
if drawfunc then
|
||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
@ -167,36 +167,36 @@ function newobject:mousepressed(x, y, button)
|
|||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
|
|
||||||
if state ~= selfstate then
|
if state ~= selfstate then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local visible = self.visible
|
local visible = self.visible
|
||||||
|
|
||||||
if not visible then
|
if not visible then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
local children = self.children
|
local children = self.children
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
|
|
||||||
if hover and button == 1 then
|
if hover and button == 1 then
|
||||||
local baseparent = self:GetBaseParent()
|
local baseparent = self:GetBaseParent()
|
||||||
if baseparent and baseparent.type == "frame" then
|
if baseparent and baseparent.type == "frame" then
|
||||||
baseparent:MakeTop()
|
baseparent:MakeTop()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
v:mousepressed(x, y, button)
|
v:mousepressed(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:mousepressed(x, y, button)
|
v:mousepressed(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -207,28 +207,28 @@ function newobject:mousereleased(x, y, button)
|
|||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
|
|
||||||
if state ~= selfstate then
|
if state ~= selfstate then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local visible = self.visible
|
local visible = self.visible
|
||||||
|
|
||||||
if not visible then
|
if not visible then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
v:mousereleased(x, y, button)
|
v:mousereleased(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:mousereleased(x, y, button)
|
v:mousereleased(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -236,16 +236,16 @@ end
|
|||||||
- desc: positions the object's columns
|
- desc: positions the object's columns
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:PositionColumns()
|
function newobject:PositionColumns()
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
|
|
||||||
for k, v in ipairs(self.children) do
|
for k, v in ipairs(self.children) do
|
||||||
v:SetPos(x, 0)
|
v:SetPos(x, 0)
|
||||||
x = x + v.width
|
x = x + v.width
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -259,15 +259,15 @@ function newobject:AddColumn(name)
|
|||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
|
|
||||||
loveframes.objects["columnlistheader"]:new(name, self)
|
loveframes.objects["columnlistheader"]:new(name, self)
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
|
|
||||||
list:SetSize(width, height)
|
list:SetSize(width, height)
|
||||||
list:SetPos(0, 0)
|
list:SetPos(0, 0)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -279,10 +279,10 @@ function newobject:AddRow(...)
|
|||||||
local arg = {...}
|
local arg = {...}
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
list:AddRow(arg)
|
list:AddRow(arg)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -293,7 +293,7 @@ function newobject:GetColumnSize()
|
|||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
local numchildren = #self.children
|
local numchildren = #self.children
|
||||||
|
|
||||||
if numchildren > 0 then
|
if numchildren > 0 then
|
||||||
local column = self.children[1]
|
local column = self.children[1]
|
||||||
local colwidth = column.width
|
local colwidth = column.width
|
||||||
@ -302,7 +302,7 @@ function newobject:GetColumnSize()
|
|||||||
else
|
else
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -310,31 +310,31 @@ end
|
|||||||
- desc: sets the object's size
|
- desc: sets the object's size
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SetSize(width, height, r1, r2)
|
function newobject:SetSize(width, height, r1, r2)
|
||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
if r1 then
|
if r1 then
|
||||||
self.width = self.parent.width * width
|
self.width = self.parent.width * width
|
||||||
else
|
else
|
||||||
self.width = width
|
self.width = width
|
||||||
end
|
end
|
||||||
|
|
||||||
if r2 then
|
if r2 then
|
||||||
self.height = self.parent.height * height
|
self.height = self.parent.height * height
|
||||||
else
|
else
|
||||||
self.height = height
|
self.height = height
|
||||||
end
|
end
|
||||||
|
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
|
|
||||||
list:SetSize(width, height)
|
list:SetSize(width, height)
|
||||||
list:SetPos(0, 0)
|
list:SetPos(0, 0)
|
||||||
list:CalculateSize()
|
list:CalculateSize()
|
||||||
list:RedoLayout()
|
list:RedoLayout()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -342,25 +342,25 @@ end
|
|||||||
- desc: sets the object's width
|
- desc: sets the object's width
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SetWidth(width, relative)
|
function newobject:SetWidth(width, relative)
|
||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
if relative then
|
if relative then
|
||||||
self.width = self.parent.width * width
|
self.width = self.parent.width * width
|
||||||
else
|
else
|
||||||
self.width = width
|
self.width = width
|
||||||
end
|
end
|
||||||
|
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
|
|
||||||
list:SetSize(width)
|
list:SetSize(width)
|
||||||
list:SetPos(0, 0)
|
list:SetPos(0, 0)
|
||||||
list:CalculateSize()
|
list:CalculateSize()
|
||||||
list:RedoLayout()
|
list:RedoLayout()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -368,25 +368,25 @@ end
|
|||||||
- desc: sets the object's height
|
- desc: sets the object's height
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SetHeight(height, relative)
|
function newobject:SetHeight(height, relative)
|
||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
if relative then
|
if relative then
|
||||||
self.height = self.parent.height * height
|
self.height = self.parent.height * height
|
||||||
else
|
else
|
||||||
self.height = height
|
self.height = height
|
||||||
end
|
end
|
||||||
|
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
|
|
||||||
list:SetSize(height)
|
list:SetSize(height)
|
||||||
list:SetPos(0, 0)
|
list:SetPos(0, 0)
|
||||||
list:CalculateSize()
|
list:CalculateSize()
|
||||||
list:RedoLayout()
|
list:RedoLayout()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -398,10 +398,10 @@ function newobject:SetMaxColorIndex(num)
|
|||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
list.colorindexmax = num
|
list.colorindexmax = num
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -412,10 +412,10 @@ function newobject:Clear()
|
|||||||
|
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
list:Clear()
|
list:Clear()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -429,17 +429,17 @@ function newobject:SetAutoScroll(bool)
|
|||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
local scrollbar = list:GetScrollBar()
|
local scrollbar = list:GetScrollBar()
|
||||||
|
|
||||||
self.autoscroll = bool
|
self.autoscroll = bool
|
||||||
|
|
||||||
if list then
|
if list then
|
||||||
if scrollbar then
|
if scrollbar then
|
||||||
scrollbar.autoscroll = bool
|
scrollbar.autoscroll = bool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -452,7 +452,7 @@ function newobject:SetButtonScrollAmount(amount)
|
|||||||
self.buttonscrollamount = amount
|
self.buttonscrollamount = amount
|
||||||
self.internals[1].buttonscrollamount = amount
|
self.internals[1].buttonscrollamount = amount
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -463,7 +463,7 @@ end
|
|||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetButtonScrollAmount()
|
||||||
|
|
||||||
return self.buttonscrollamount
|
return self.buttonscrollamount
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -475,7 +475,7 @@ function newobject:SetMouseWheelScrollAmount(amount)
|
|||||||
self.mousewheelscrollamount = amount
|
self.mousewheelscrollamount = amount
|
||||||
self.internals[1].mousewheelscrollamount = amount
|
self.internals[1].mousewheelscrollamount = amount
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -485,7 +485,7 @@ end
|
|||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetButtonScrollAmount()
|
||||||
|
|
||||||
return self.mousewheelscrollamount
|
return self.mousewheelscrollamount
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -497,17 +497,17 @@ function newobject:SetColumnHeight(height)
|
|||||||
local children = self.children
|
local children = self.children
|
||||||
local internals = self.internals
|
local internals = self.internals
|
||||||
local list = internals[1]
|
local list = internals[1]
|
||||||
|
|
||||||
self.columnheight = height
|
self.columnheight = height
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:SetHeight(height)
|
v:SetHeight(height)
|
||||||
end
|
end
|
||||||
|
|
||||||
list:CalculateSize()
|
list:CalculateSize()
|
||||||
list:RedoLayout()
|
list:RedoLayout()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -520,7 +520,7 @@ function newobject:SetDTScrolling(bool)
|
|||||||
self.dtscrolling = bool
|
self.dtscrolling = bool
|
||||||
self.internals[1].dtscrolling = bool
|
self.internals[1].dtscrolling = bool
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -531,7 +531,7 @@ end
|
|||||||
function newobject:GetDTScrolling()
|
function newobject:GetDTScrolling()
|
||||||
|
|
||||||
return self.dtscrolling
|
return self.dtscrolling
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -542,16 +542,16 @@ end
|
|||||||
function newobject:SelectRow(row, ctrl)
|
function newobject:SelectRow(row, ctrl)
|
||||||
|
|
||||||
local selectionenabled = self.selectionenabled
|
local selectionenabled = self.selectionenabled
|
||||||
|
|
||||||
if not selectionenabled then
|
if not selectionenabled then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local children = list.children
|
local children = list.children
|
||||||
local multiselect = self.multiselect
|
local multiselect = self.multiselect
|
||||||
local onrowselected = self.OnRowSelected
|
local onrowselected = self.OnRowSelected
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
if v == row then
|
if v == row then
|
||||||
if v.selected and ctrl then
|
if v.selected and ctrl then
|
||||||
@ -568,9 +568,9 @@ function newobject:SelectRow(row, ctrl)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -582,7 +582,7 @@ function newobject:DeselectRow(row)
|
|||||||
|
|
||||||
row.selected = false
|
row.selected = false
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -590,19 +590,19 @@ end
|
|||||||
- desc: gets the object's selected rows
|
- desc: gets the object's selected rows
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetSelectedRows()
|
function newobject:GetSelectedRows()
|
||||||
|
|
||||||
local rows = {}
|
local rows = {}
|
||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local children = list.children
|
local children = list.children
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
if v.selected then
|
if v.selected then
|
||||||
table.insert(rows, v)
|
table.insert(rows, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -614,7 +614,7 @@ function newobject:SetSelectionEnabled(bool)
|
|||||||
|
|
||||||
self.selectionenabled = bool
|
self.selectionenabled = bool
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -625,7 +625,7 @@ end
|
|||||||
function newobject:GetSelectionEnabled()
|
function newobject:GetSelectionEnabled()
|
||||||
|
|
||||||
return self.selectionenabled
|
return self.selectionenabled
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -637,7 +637,7 @@ function newobject:SetMultiselectEnabled(bool)
|
|||||||
|
|
||||||
self.multiselect = bool
|
self.multiselect = bool
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -648,7 +648,7 @@ end
|
|||||||
function newobject:GetMultiselectEnabled()
|
function newobject:GetMultiselectEnabled()
|
||||||
|
|
||||||
return self.multiselect
|
return self.multiselect
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -658,15 +658,15 @@ end
|
|||||||
function newobject:RemoveColumn(id)
|
function newobject:RemoveColumn(id)
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
if k == id then
|
if k == id then
|
||||||
v:Remove()
|
v:Remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -676,15 +676,15 @@ end
|
|||||||
function newobject:SetColumnName(id, name)
|
function newobject:SetColumnName(id, name)
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
if k == id then
|
if k == id then
|
||||||
v.name = name
|
v.name = name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -694,15 +694,15 @@ end
|
|||||||
function newobject:GetColumnName(id)
|
function newobject:GetColumnName(id)
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
if k == id then
|
if k == id then
|
||||||
return v.name
|
return v.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -714,7 +714,7 @@ end
|
|||||||
modifications.
|
modifications.
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SizeToChildren(max)
|
function newobject:SizeToChildren(max)
|
||||||
|
|
||||||
local oldheight = self.height
|
local oldheight = self.height
|
||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local listchildren = list.children
|
local listchildren = list.children
|
||||||
@ -724,15 +724,15 @@ function newobject:SizeToChildren(max)
|
|||||||
local h = listchildren[1].height
|
local h = listchildren[1].height
|
||||||
local c = #listchildren
|
local c = #listchildren
|
||||||
local height = buf + h*c
|
local height = buf + h*c
|
||||||
|
|
||||||
if max then
|
if max then
|
||||||
height = math.min(max, oldheight)
|
height = math.min(max, oldheight)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetSize(width, height)
|
self:SetSize(width, height)
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -744,11 +744,11 @@ function newobject:RemoveRow(id)
|
|||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local listchildren = list.children
|
local listchildren = list.children
|
||||||
local row = listchildren[id]
|
local row = listchildren[id]
|
||||||
|
|
||||||
if row then
|
if row then
|
||||||
row:Remove()
|
row:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
list:CalculateSize()
|
list:CalculateSize()
|
||||||
list:RedoLayout()
|
list:RedoLayout()
|
||||||
return self
|
return self
|
||||||
@ -760,17 +760,17 @@ end
|
|||||||
- desc: sets a cell's text
|
- desc: sets a cell's text
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SetCellText(text, rowid, columnid)
|
function newobject:SetCellText(text, rowid, columnid)
|
||||||
|
|
||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local listchildren = list.children
|
local listchildren = list.children
|
||||||
local row = listchildren[rowid]
|
local row = listchildren[rowid]
|
||||||
|
|
||||||
if row and row.columndata[columnid]then
|
if row and row.columndata[columnid]then
|
||||||
row.columndata[columnid] = text
|
row.columndata[columnid] = text
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -778,15 +778,15 @@ end
|
|||||||
- desc: gets a cell's text
|
- desc: gets a cell's text
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetCellText(rowid, columnid)
|
function newobject:GetCellText(rowid, columnid)
|
||||||
|
|
||||||
local row = self.internals[1].children[rowid]
|
local row = self.internals[1].children[rowid]
|
||||||
|
|
||||||
if row and row.columndata[columnid] then
|
if row and row.columndata[columnid] then
|
||||||
return row.columndata[columnid]
|
return row.columndata[columnid]
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -798,15 +798,15 @@ function newobject:SetRowColumnData(rowid, columndata)
|
|||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local listchildren = list.children
|
local listchildren = list.children
|
||||||
local row = listchildren[rowid]
|
local row = listchildren[rowid]
|
||||||
|
|
||||||
if row then
|
if row then
|
||||||
for k, v in ipairs(columndata) do
|
for k, v in ipairs(columndata) do
|
||||||
row.columndata[k] = tostring(v)
|
row.columndata[k] = tostring(v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -816,13 +816,13 @@ end
|
|||||||
function newobject:GetTotalColumnWidth()
|
function newobject:GetTotalColumnWidth()
|
||||||
|
|
||||||
local width = 0
|
local width = 0
|
||||||
|
|
||||||
for k, v in ipairs(self.children) do
|
for k, v in ipairs(self.children) do
|
||||||
width = width + v.width
|
width = width + v.width
|
||||||
end
|
end
|
||||||
|
|
||||||
return width
|
return width
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -842,9 +842,9 @@ function newobject:SetColumnWidth(id, width)
|
|||||||
self.internals[1]:CalculateSize()
|
self.internals[1]:CalculateSize()
|
||||||
self.internals[1]:RedoLayout()
|
self.internals[1]:RedoLayout()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -857,9 +857,9 @@ function newobject:GetColumnWidth(id)
|
|||||||
if column then
|
if column then
|
||||||
return column.width
|
return column.width
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -872,22 +872,22 @@ function newobject:ResizeColumns()
|
|||||||
local children = self.children
|
local children = self.children
|
||||||
local width = 0
|
local width = 0
|
||||||
local vbody = self.internals[1]:GetVerticalScrollBody()
|
local vbody = self.internals[1]:GetVerticalScrollBody()
|
||||||
|
|
||||||
if vbody then
|
if vbody then
|
||||||
width = (self:GetWidth() - vbody:GetWidth())/#children
|
width = (self:GetWidth() - vbody:GetWidth())/#children
|
||||||
else
|
else
|
||||||
width = self:GetWidth()/#children
|
width = self:GetWidth()/#children
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:SetWidth(width)
|
v:SetWidth(width)
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
self.internals[1]:CalculateSize()
|
self.internals[1]:CalculateSize()
|
||||||
self.internals[1]:RedoLayout()
|
self.internals[1]:RedoLayout()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -898,7 +898,7 @@ function newobject:SetDefaultColumnWidth(width)
|
|||||||
|
|
||||||
self.defaultcolumnwidth = width
|
self.defaultcolumnwidth = width
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -908,7 +908,7 @@ end
|
|||||||
function newobject:GetDefaultColumnWidth()
|
function newobject:GetDefaultColumnWidth()
|
||||||
|
|
||||||
return self.defaultcolumnwidth
|
return self.defaultcolumnwidth
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -920,7 +920,7 @@ function newobject:SetColumnResizeEnabled(bool)
|
|||||||
|
|
||||||
self.canresizecolumns = bool
|
self.canresizecolumns = bool
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -931,7 +931,7 @@ end
|
|||||||
function newobject:GetColumnResizeEnabled()
|
function newobject:GetColumnResizeEnabled()
|
||||||
|
|
||||||
return self.canresizecolumns
|
return self.canresizecolumns
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -944,21 +944,21 @@ function newobject:SizeColumnToData(columnid)
|
|||||||
local column = self.children[columnid]
|
local column = self.children[columnid]
|
||||||
local list = self.internals[1]
|
local list = self.internals[1]
|
||||||
local largest = 0
|
local largest = 0
|
||||||
|
|
||||||
for k, v in ipairs(list.children) do
|
for k, v in ipairs(list.children) do
|
||||||
local width = v:GetFont():getWidth(self:GetCellText(k, columnid))
|
local width = v:GetFont():getWidth(self:GetCellText(k, columnid))
|
||||||
if width > largest then
|
if width > largest then
|
||||||
largest = width + v.textx
|
largest = width + v.textx
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if largest <= 0 then
|
if largest <= 0 then
|
||||||
largest = 10
|
largest = 10
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetColumnWidth(columnid, largest)
|
self:SetColumnWidth(columnid, largest)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -969,15 +969,36 @@ function newobject:SetColumnOrder(curid, newid)
|
|||||||
|
|
||||||
local column = self.children[curid]
|
local column = self.children[curid]
|
||||||
local totalcolumns = #self.children
|
local totalcolumns = #self.children
|
||||||
|
|
||||||
if column and totalcolumns > 1 and newid <= totalcolumns and newid >= 1 then
|
if column and totalcolumns > 1 and newid <= totalcolumns and newid >= 1 then
|
||||||
column:Remove()
|
column:Remove()
|
||||||
table.insert(self.children, newid, column)
|
table.insert(self.children, newid, column)
|
||||||
self:PositionColumns()
|
self:PositionColumns()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: SetRowsFont(font)
|
||||||
|
- desc: sets the font of the rows.
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:SetAllRowsFont(font)
|
||||||
|
local list = self.internals[1]
|
||||||
|
for k, v in ipairs(list.children) do
|
||||||
|
v:SetFont(font)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: SetRowFont(font, id)
|
||||||
|
- desc: sets the font of the row with the provided id.
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:SetRowFont(font, id)
|
||||||
|
local list = self.internals[1]
|
||||||
|
assert( id >= 1, "The id must be >= 1")
|
||||||
|
list.children[id]:SetFont(font)
|
||||||
end
|
end
|
||||||
|
|
||||||
---------- module end ----------
|
---------- module end ----------
|
||||||
|
Loading…
Reference in New Issue
Block a user