Parent/Child Type Structuring

Blitz3D Forums/Blitz3D Programming/Parent/Child Type Structuring

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

I think this is the kind of thing you mean. I use this type of thing for GUI stuff where I make a menu and add button types to it .... Basically, each button holds it's parent gadget so that they can be grouped together. It's not really necessary to store a GID% if you hold the gadget globally.

Simple non working example

Type GADGET
	Field GID% ; Gadget ID
	Field GIMAGE$ ; Image
	Field GX% ; X Pos
	Field GY% ; Y Pos
	Field GW% ; Gadget Width
	Field GH% ; Gadget Height
End Type

Type BUTTON
	Field Parent.GADGET
	Field Blah1
	Field Blah2
End Type

Global MENU1.GADGET = CreateGadget( 0, "mp3player1.bmp",100,100,300,200)
CreateButton( MENU1, 5, 5 )
CreateButton( MENU1, 2, 2 )

Global MENU2.GADGET = CreateGadget( 1, "Anotherbitmap.bmp",250,100,300,200)
CreateButton( MENU2, 5, 5 )
CreateButton( MENU2, 2, 2 )

;===========================================================
;===========================================================
;===========================================================

Function CreateButton( G.GADGET , Blah1, Blah2 )

	b.Button = New button
	b\Parent = G
	b\Blah1 = Blah1
	b\Blah2 = Blah2
	
End Function

;===========================================================
;===========================================================
;===========================================================

Function CreateGadget.Gadget(GID%,GIMAGE$,GX%,GY%,GW%,GH%) ;Create a Gadget

	G.GADGET = New GADGET
	G\GID% = GID%
	G\GIMAGE = LoadImage(GIMAGE$)
	G\GX% = GX%
	G\GY% = GY%
	G\GW% = GW%
	G\GH% = GH%

	Return G

End Function

;===========================================================
;===========================================================
;===========================================================