Extending a MaxGUI control

BlitzMax Forums/BlitzMax Programming/Extending a MaxGUI control

has anyone done this yet? I would like to give it a go but I don't have a clue where to start.

For instance, if I wanted to create a new type of textarea, would I derive it from an existing textarea or do I have to go back to the based control?

In delphi, you would simply extend the class that most closely represents your new class and override the required methods.

How would you override the Paint() method? (or whatever the BMax equivalent is).

The following illustrates extending a TProxyGadget which allows you to override any TGadget method while maintaining platform neutrality (you don't care if you are extending a TWin32Gadget or a TFLTKGadget).
Strict 

Type TMyTextArea Extends TProxyGadget
	Field textarea:TGadget		

	Method Create:TMyTextArea(x,y,w,h,group:TGadget,style=0)
		textarea=CreateTextArea(x,y,w,h,group,style)	
		SetProxy textarea
		Return Self
	End Method

' and a quick override to make sure the proxy is working...

	Method SetText(text$)
		textarea.SetText ("***"+text+"***")
	End Method

End Type

' and a matching public constructor function

Function CreateMyTextArea:TMyTextArea(x,y,w,h,group:TGadget)
	Return New TMyTextArea.Create(x,y,w,h,group)
End Function


' and a modified createmytextarea.bmx test program....

Local window:TGadget
Local textarea:TGadget

window=CreateWindow("My Window",130,20,200,200,0,15|WINDOW_ACCEPTFILES)

textarea=CreateMyTextArea(0,0,ClientWidth(window),ClientHeight(window)/2,window)
SetGadgetLayout textarea,1,1,1,1
SetGadgetText textarea,"a textarea gadget~none line~nandanother"
ActivateGadget textarea

SelectTextAreaText textarea,1,1,TEXTAREA_LINES

Print TextAreaCursor(textarea,TEXTAREA_LINES) 
Print TextAreaSelLen(textarea,TEXTAREA_LINES) 

While WaitEvent()
	Print CurrentEvent.ToString()+" "+EventSourceHandle()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_APPTERMINATE
			End
	End Select
Wend


Hmm, EventGadgetSource() should be the proxy, so a little more work required here sorry...