FryGUI

BlitzMax Forums/BlitzMax Programming/FryGUI

I think this works:

Type fry_TImageButton Extends fry_TImage
	
	Field gLink:fry_TScreen	'clicking button will switch to this screen
	
	Rem
		Update when the mouse is over
	End Rem
	Method UpdateMouseOver(x:Int, y:Int)
	
		super.UpdateMouseOver(x, y)
	
	End Method
	
	Rem
		Update when the mouse is pressed
	End Rem
	Method UpdateMouseDown(x:Int, y:Int)
	
		super.UpdateMouseDown(x, y)
		
		fry_CreateEvent(fry_EVENT_GADGETACTION, Self, 0, 0, 0, Null)
		
	End Method
	
	Rem
		Update when the mouse is released
	End Rem
	Method UpdateMouseRelease(x:Int, y:Int)
	
		super.UpdateMouseRelease(x, y)
		
		fry_CreateEvent(fry_EVENT_GADGETSELECT, Self, 0, 0, 0, Null)
		
		If gLink <> Null Then
			fry_GUI.SetScreen(gLink)
			fry_CreateEvent(fry_EVENT_SETSCREEN, Self, 0, 0, 0, gLink)
		End If
		
	End Method

	Rem	
		bbdoc: Set the link
		about: When clicked, the GUI will change to the specified screen. Set to $Null to disable.
	End Rem
	Method SetLink(screen:fry_TScreen)
		
		gLink = screen
		
	End Method
	
	Rem
		bbdoc: Set the link using the screen's name
		about: Sets the link, specifying the name of the screen instead of the screen gadget.
	End Rem
	Method SetNameLink(screen:String)
	
		Local scr:fry_TScreen = fry_GUI.GetScreen(screen)
		If scr <> Null Then SetLink(scr)
		
	End Method
	
	Rem
			Create an Image gadget
		End Rem
		Function Create:fry_TImageButton(name:String, URL:String, x:Int, y:Int, w:Int, h:Int, parent:fry_TGadget)
		
			Local this:fry_TImageButton = New fry_TImageButton
			
			this.gImage = LoadImage(URL, FILTEREDIMAGE)
			If this.gImage = Null Then DebugLog "Image: "+URL+" not loaded."
			this.gURL = URL
			
			If this.gImage = Null Then Return Null
					
			this.PopulateGadget(name, x, y, w, h, parent)
			
			this.SetDimensions(w, h)
			
			Return this
			
		End Function
		
	End Type
	
	
	Rem
		bbdoc: Create an image
		returns: a #fry_TImage gadget
		about: Creates an image, loaded from the given @url, with the specified @name and dimensions. 
		The @parent will usually be a panel, but can be another 	gadget.
	End Rem
Function fry_CreateImageButton:fry_TImageButton(name:String, URL:String, x:Int, y:Int, w:Int, h:Int, parent:fry_TGadget = Null)
	
		If name = "" Then Return Null
		
		Local image:fry_TImageButton = fry_TImageButton.Create(name, URL, x, y, w, h, parent)
		
		Return image
		
End Function


It should create an image button.

I'm sure Fry you can tidy it up...