My Label instead of DLabel

Hello, I have some serious bugs with this.
Can you see any problem in the code?

[lua]
Panel = {}

function Panel:Paint()

draw.SimpleText(self.Text,self.Font,self.PosX,self.PosY,Color(255,255,255,255),self.Align,self.VAlign)

end

function Panel:SetText(text)

self.Text = text

end

function Panel:SetFont(font)

self.Font = font

end

function Panel:SetPos(x,y)

self.PosX = x
self.PosY = y

end

function Panel:SetAlign(x,y)

self.Align = x
self.VAlign = y

end
vgui.Register(“GLabel”,Panel)
[/lua]
Text spawning code:
[lua]
local BName = vgui.Create(“GLabel”,BPanel)
BName:SetPos(50,4)
BName:SetText(Types[k].name)
BName:SetFont(“TabLarge”)
BName:SetAlign(1,0)
–BName:SetWidth(96)
[/lua]

If I turn on SetWidth it works but I have a problem, there should be texts next those icons.
I put them to the top of the panel and they were visible there.
And if I added SetTall() then they were visible from the top until the Tall

Pictures :
http://img27.imageshack.us/img27/7940/hl22012011206592086.th.jpg
http://img535.imageshack.us/img535/2271/hl22012011207020138.th.jpg

It’s not easy to understand what the problem is. Are you saying that when you don’t use SetWidth, some of the text on the topmost label becomes chopped off? I’m guessing from the pictures.

If so, there is a function, SizeToContents which you can use to automatically make the invisible text-drawing area for the label the same size as the text.

The problem is that when I use it on those material texts you see down it doesn’t work because of the tall. It thinks that the text is the whole panel or I don’t know.
I show you pictures
SetTall : 45
http://img217.imageshack.us/img217/1209/hl22012011317312268.th.jpg
SetTall : 65
http://img84.imageshack.us/img84/6619/hl22012011317314518.th.jpg
SetTall : 80
http://img850.imageshack.us/img850/8697/hl22012011317320748.th.jpg

Code :
[lua]
for k,v in pairs(Types[k].res) do
local BRAmount = vgui.Create(“GLabel”,BPanel)
BRAmount:SetPos(30,i*20)
BRAmount:SetText(v)
BRAmount:SetFont(“TargetIDSmall”)
BRAmount:SetTall(80)

i = i + 1

end
[/lua]

By the way, I tried :SizeToContents but it doesn’t work :confused:

You can only use SizeToContents if its derived from DLabel ( I think )

Quoting yourself doesn’t make you any less wrong. In the piece of code in the OP, You aren’t deriving from DLabel , one can then assume that when you said “SizeToContents doesn’t work” , what you actually meant was that the function didn’t exist, and in which case my point stands, you need to derive it from DLabel to work.

Either way you are wrong when you quote yourself in your last post, because it means either you were to arrogant to actually try it, or that you weren’t precise enough in the description of your problem , and in which case it’s not our fault if your problem doesn’t get resolved.

ok