wait wait.. no, I'm getting confused again. check out my code:
Basically I want it so that I can add a load of buttons to a particular parent. When the parent is closed the children are hidden. when the parent is open the children are shown. The now visible children push the other buttons down too, like this:

Frankly I don't know what the hell I'm doing.
Global root:button
Type button
Field x,y,txt$,dy
Field children:TList
Field parent:button
Field over,open,height
Function create:button(x,y,txt$)
Local f:button=New button
f.x=x;f.y=y;f.txt=txt
Return f
End Function
Method update()
If open
If children<>Null
For Local i:button=EachIn children
i.update()
Next
EndIf
EndIf
draw()
End Method
Method draw()
Local yoff=0
Local xoff=0
If parent<>Null
If open And parent.open
yoff=parent.height+parent.y+(17*q)
xoff=parent.x+15
Else
yoff=0
xoff=parent.x+15
EndIf
Else
yoff=0
xoff=0
EndIf
over=mouseIn(x+xoff,y+yoff,222,17)
If over And MouseHit(1)
open=1-open
If open
If children<>Null Then height=(children.count()+1)*17
Else
height=0
EndIf
EndIf
SetColor 155,155,155
SetAlpha 0.9
'DrawImage panelImage,x+xoff,y+yoff
DrawRect x+xoff,y+yoff,222,17
SetAlpha 1.0;SetColor 255,255,255
DrawText Upper(txt)+" Open: "+open,x+5+xoff,y+3+yoff
' draw some extra info about children ie: (3)
If children<>Null' And txt<>""
Local t$="("+Upper(children.count())+") h:"+height
DrawText t,x+(222-TextWidth(t))-5+xoff,y+3+yoff
EndIf
End Method
Method addChild(t:button)
If t.txt="" Then t.open=True
t.parent=Self
If children=Null
children=CreateList()
EndIf
t.x=x
t.y=y+17
ListAddLast(children,t)
End Method
End Type
Function mouseIn(x,y,w,h)
Local mx=MouseX()
Local my=MouseY()
If mx>x And mx<x+w
If my>y And my<y+h
Return True
EndIf
EndIf
Return False
End Function
' --------------------------------------
root:button=button.create(50,50,"")
Local p:button=button.create(0,0,"AAAAAAA")
root.addChild(p)
p.addChild(button.create(0,0,"1 A"))
p.addChild(button.create(0,0,"1 B"))
p.addChild(button.create(0,0,"1 C"))
Local p2:button=button.create(0,0,"BBBBBBB")
root.addChild(p2)
p2.addChild(button.create(0,0,"2 A"))
p2.addChild(button.create(0,0,"2 B"))
p2.addChild(button.create(0,0,"2 C"))
Local p3:button=button.create(0,0,"CCCCCCC")
root.addChild(p3)
p3.addChild(button.create(0,0,"3 A"))
p3.addChild(button.create(0,0,"3 B"))
p3.addChild(button.create(0,0,"3 C"))
Graphics 640,480,0,60
While KeyHit(KEY_ESCAPE)=0
Cls
root.update()
Flip
Wend
End