i have a problem with icons :(

issue:
when i refresh the list the icons like cut in half.

this is before
http://bizen.dk/before.png

this is after
http://bizen.dk/after.png

[lua]
local Inv = { }
Inv.Items = { }
Inv.Space = 30
Inv.UsedSpace = 0
local SelectedItem = nil
local DermaList
local DermaPanel

function OpenInventory()
SelectedItem = nil
DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 600, 500 )
DermaPanel:SetTitle( “Your Inventory” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel.PaintOver = function()
draw.SimpleText(“Space: “…Inv.UsedSpace…”/”…Inv.Space,“Trebuchet19”,500,460,Color(255,255,255,255))
draw.SimpleText(“Selected:”,“Trebuchet19”,230,460,Color(255,255,255,255))
–if SelectedItem then
– draw.SimpleText("""…string.upper(SelectedItem.name)…""",“Trebuchet19”,295,460,Color(255,255,255,255))
–end
end

DermaList = vgui.Create( "DPanelList", DermaPanel )
DermaList:SetPos( 5,25 )
DermaList:SetSize( 590, 420 )
DermaList:SetSpacing( 2 )
DermaList:SetPadding( 4 )
DermaList:EnableHorizontal( true )
DermaList:EnableVerticalScrollbar( true )

local UseButton = vgui.Create( "DButton" )
UseButton:SetParent( DermaPanel )
UseButton:SetText( "Use" )
UseButton:SetPos( 10, 460 )
UseButton:SetSize( 100, 25 )
UseButton.DoClick = function ()
	surface.PlaySound( "ui/buttonclickrelease.wav" )
	RefreshList()
end

local DropButton = vgui.Create( "DButton" )
DropButton:SetParent( DermaPanel )
DropButton:SetText( "Drop" )
DropButton:SetPos( 120, 460 )
DropButton:SetSize( 100, 25 )
DropButton.DoClick = function () 
	surface.PlaySound( "ui/buttonclickrelease.wav" )
	RefreshList()
end

BuildList()

end
concommand.Add(“OpenInventory”, OpenInventory)

function AddItem(data)
local item = data:ReadString()
local mdl = data:ReadString()
local amount = data:ReadLong()
if amount == nil then amount = 0 end

table.insert(Inv.Items,{item = item, mdl = mdl, amount = amount})

end

function RefreshSpace()
local a = 0
for k, v in pairs(Inv.Items) do
a = a + v.amount
end
Inv.UsedSpace = a
end

function RefreshList()
for k, v in pairs(DermaList:GetItems()) do
DermaList:RemoveItem(v)
end
BuildList()
DermaPanel:InvalidateLayout(true, true)
DermaList:InvalidateLayout(true, true)
RefreshSpace()
end

function BuildList()
for k, v in pairs(Inv.Items) do
local icon = vgui.Create( “SpawnIcon”, IconList )
icon.item = v.item
icon.name = FixName(v.item)
icon.amount = v.amount
icon:SetModel( v.mdl )
icon:SetToolTip( icon.name )
icon:SetIconSize(64)
DermaList:AddItem( icon )
icon.DoClick = function( icon )
surface.PlaySound( “ui/buttonclickrelease.wav” )
SelectedItem = icon
end
icon.PaintOver = function( icon )
draw.SimpleText(icon.amount,“Trebuchet18”,48,2,Color(255,255,255,255))
end
end
end

function FixName(name)
local name = string.Explode("_", name)
return string.Implode(" ", name)
end

table.insert(Inv.Items,{item = “1”, mdl = “models/props_c17/consolebox03a.mdl”, amount = 1})
table.insert(Inv.Items,{item = “2”, mdl = “models/props_c17/FurnitureCouch001a.mdl”, amount = 1})
table.insert(Inv.Items,{item = “3”, mdl = “models/props_c17/pulleywheels_large01.mdl”, amount = 1})
table.insert(Inv.Items,{item = “4”, mdl = “models/props_c17/FurnitureWashingmachine001a.mdl”, amount = 1})
table.insert(Inv.Items,{item = “5”, mdl = “models/props_c17/consolebox03a.mdl”, amount = 1})
table.insert(Inv.Items,{item = “6”, mdl = “models/props_c17/FurnitureCouch001a.mdl”, amount = 1})
[/lua]

[editline]27th October 2011[/editline]

fixed it with this

[lua]
local Inv = { }
Inv.Items = { }
Inv.Space = 30
Inv.UsedSpace = 0
local SelectedItem = nil
local DermaList
local DermaPanel

function OpenInventory()
SelectedItem = nil
DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 600, 500 )
DermaPanel:SetTitle( “Your Inventory” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
DermaPanel.PaintOver = function()
draw.SimpleText(“Space: “…Inv.UsedSpace…”/”…Inv.Space,“Trebuchet19”,500,460,Color(255,255,255,255))
draw.SimpleText(“Selected:”,“Trebuchet19”,230,460,Color(255,255,255,255))
if SelectedItem and SelectedItem:IsValid() then
draw.SimpleText("""…string.upper(SelectedItem.name)…""",“Trebuchet20”,295,460,Color(255,255,255,255))
end
end

DermaList = vgui.Create( "DPanelList", DermaPanel )
DermaList:SetPos( 5,25 )
DermaList:SetSize( 590, 420 )
DermaList:SetSpacing( 2 )
DermaList:SetPadding( 4 )
DermaList:EnableHorizontal( true )
DermaList:EnableVerticalScrollbar( true )

local UseButton = vgui.Create( "DButton" )
UseButton:SetParent( DermaPanel )
UseButton:SetText( "Use" )
UseButton:SetPos( 10, 460 )
UseButton:SetSize( 100, 25 )
UseButton.DoClick = function ()
	surface.PlaySound( "ui/buttonclickrelease.wav" )
end

local DropButton = vgui.Create( "DButton" )
DropButton:SetParent( DermaPanel )
DropButton:SetText( "Drop" )
DropButton:SetPos( 120, 460 )
DropButton:SetSize( 100, 25 )
DropButton.DoClick = function () 
	surface.PlaySound( "ui/buttonclickrelease.wav" )
	InvTakeItem(SelectedItem)
end

for k, v in pairs(Inv.Items) do
	local icon = vgui.Create( "SpawnIcon", IconList ) 
	icon.item = v.item
	icon.name = FixName(v.item)
	icon.amount = v.amount
	icon:SetModel( v.mdl )
	icon:SetToolTip( icon.name )
	icon:SetIconSize(64)
	DermaList:AddItem( icon )
	icon.DoClick = function( icon ) 
		surface.PlaySound( "ui/buttonclickrelease.wav" )
		SelectedItem = icon
	end
	icon.PaintOver = function( icon )
		draw.SimpleText(icon.amount,"Trebuchet18",48,2,Color(255,255,255,255))
	end
end
InvRefreshSpace()

end
concommand.Add(“OpenInventory”, OpenInventory)

function InvAddItem(data)
local item = data:ReadString()
local mdl = data:ReadString()
local amount = data:ReadLong()
if amount == nil then amount = 0 end
for k, v in pairs(Inv.Items) do
if v.item == item then
amount = amount + v.amount
break
end
end
table.insert(Inv.Items,{item = item, mdl = mdl, amount = amount + a})
InvRefreshSpace()
end

function InvTakeItem(item)
if item and !item:IsValid() then return end
item.amount = item.amount - 1
if item.amount == 0 then
InvRemoveItem(item)
InvRefreshSpace()
end
end

function InvRemoveItem(item)
DermaList:RemoveItem(item)
DermaList:Rebuild()
end

function InvRefreshSpace()
local a = 0
for k, v in pairs(Inv.Items) do
a = a + v.amount
end
Inv.UsedSpace = a
end

local function FixName(name)
local name = string.Explode("_", name)
return string.Implode(" ", name)
end

table.insert(Inv.Items,{item = “1”, mdl = “models/props_c17/consolebox03a.mdl”, amount = 12})
table.insert(Inv.Items,{item = “2”, mdl = “models/props_c17/FurnitureCouch001a.mdl”, amount = 3})
table.insert(Inv.Items,{item = “3”, mdl = “models/props_c17/pulleywheels_large01.mdl”, amount = 6})
table.insert(Inv.Items,{item = “4”, mdl = “models/props_c17/FurnitureWashingmachine001a.mdl”, amount = 2})
[/lua]