Goober,
I use one Type for all gizmos. As Shifty Geezer has suggested you can add a ID field to the Type. I would go a step further by adding a Array of Types to store a pointer to the gizmos by ID. This will allow you to access properties of individual gizmos by ID.
Heres an excerpt of code from MAUI. For example purposes only:)
Type MAUI_Gizmo
Field id%
Field typeid%
Field format% ;1:2D, 2:3D
Field templateid%
Field parentid%
Field relativeid% ;first child, sibling
Field x#
Field y#
Field z#
Field width#
Field height#
Field depth#
Field order%
Field pointer[5]
Field entity%[5]
Field texture%[5]
Field sound%[5]
Field propertyname$[4]
Field propertyvalue$[4]
Field propertydatatype%[4]
Field event%
Field behavior%[5]
Field action%[5]
Field state%
End Type
Const MAUI_GIZMO_MAX=100 ;max number of gizmos
Dim MAUI_GizmoID.MAUI_Gizmo(MAUI_GIZMO_MAX) ;<--- Array of Types
Global MAUI_Gizmos ;current number of gizmos
Function MAUI_GizmoNew.MAUI_Gizmo()
this.MAUI_Gizmo = New MAUI_Gizmo
MAUI_Gizmos=MAUI_Gizmos+1 ; Simple ID management
this\id=MAUI_Gizmos
;default values
this\format=1
this\width=32
this\height=32
this\state=1
MAUI_GizmoID(this\id)=this ;<--- Record ID: Stores pointer to record in Array of Types
Return this
End Function
Function MAUI_GizmoCreate%(parentid%,typeid%,x#,y#,width#,height#)
this.MAUI_Gizmo = MAUI_GizmoNew()
this\parentid%=parentid%
this\typeid%=typeid%
this\x#=x#
this\y#=y#
this\width#=width#
this\height#=height#
Return this
End Function
Now you can create and access gizmos individually by ID. Whats really cool about this method is that there are variety of ways you can manage ID assignment. For example you can use a stack to push and pop IDs to recycle IDs. Very good for gizmos that are constant created and deleted. Anyhows...
;Create a gizmo; returns the Id of the Gizmo
MyGizmo=MAUI_GizmoCreate(MAUI_GIZMO_CANVAS,MAUI_GIZMO_WINDOW,0,0,256,256)
;Access gizmo properties
MAUI_GizmoID(MyGizmo)\x#=16
;-OR-
MyGizmo1.MAUI_Gizmo=MAUI_GizmoID(MyGizmo)
MyGizmo1\x#=16