Attaching objects to tabbers and updating.

BlitzMax Forums/MaxGUI Module/Attaching objects to tabbers and updating.

Ryan Burnside(Posted 2008) [#1]
Recently I have needed to create a small pop up with tabbers. My problem is attaching individual gadgets to each tabber page and then updating them.

I've read the maxGUI tutorials on Tabbers and the author does not offer a way to create each tabber with their own attached Tgadgets.

Here is my current code, I need a special canvas for each tabber page or perhaps one canvas object that works between the three pages. How do I check which tab is down and update accordingly?

' GUI application to adjust RGB levels of a photograph
Strict

Global start_x:Float = 320
Global start_y:Float = 240

' a simple spline type

Function spline_f:Float(p:Float, p1:Float, p2:Float, t:Float) 
	Local a:Float = (1 - t) 
	Return (a ^ 2.0 * p) + (2.0 * t * a * p1) + (t ^ 2 * p2) 
End Function

Function draw_spline(x:Float, y:Float, x2:Float, y2:Float, x3:Float, y3:Float, divisions:Float) 
	
End Function

' create the window and tabbers
Local MyWindow:TGadget = CreateWindow("Color Curves", 320, 320, 312, 324, Null, 1) 
Local Tabber:TGadget = CreateTabber(0, 0, 312, 300, MyWindow) 
' make some canvases (canvi?) to house the Red,Green, and Blue curve drawings respectivly
Local red_canvas:TGadget = CreateCanvas(12, 12, 255, 255, tabber) 
red_canvas.SetColor(0, 0, 0) 

Local green_canvas:TGadget = CreateCanvas(12, 12, 255, 255, tabber) 
green_canvas.SetColor(0, 0, 0) 

Local blue_canvas:TGadget = CreateCanvas(12, 12, 255, 255, tabber) 
blue_canvas.SetColor(255, 255, 255) 

' create tabs
AddGadgetItem(Tabber, "Red Curve", 0, 0, "Adjust red levels.") 
AddGadgetItem (Tabber, "Green Curve", 0, 0, "Adjust green levels.") 
AddGadgetItem (Tabber, "Blue Curve", 0, 0, "Adjust blue levels.") 


Repeat
	WaitEvent() 
	Select EventID() 
		Case EVENT_WINDOWCLOSE
     	End
	
		Case EVENT_GADGETPAINT
		
    			SetGraphics CanvasGraphics (red_canvas) 
			SetColor(255, 0, 0) 
    			DrawText("Red Canvas", 0, 0) 
			Flip
			
			SetGraphics CanvasGraphics (green_canvas) 
			SetColor(0, 255, 0) 
    			DrawText("Green Canvas", 0, 0) 
			Flip
			
			SetGraphics CanvasGraphics (blue_canvas) 
			SetColor(0, 0, 255) 
    			DrawText("Blue Canvas", 0, 0) 
			Flip
	
   End Select
Forever



Jesse(Posted 2008) [#2]
you only really need one canvas. I hope this helps you understand it better:

having more than one canvas is a waste of resources. Or maybe it's cause I don't know how to do it that way :-).


degac(Posted 2008) [#3]
You can have different canvas for each tabs...
I used the basic example that comes with MaxGUI



Jesse(Posted 2008) [#4]
using degac sample and an eventhook, I think this is more or less what you want.



Ryan Burnside(Posted 2008) [#5]
Thanks gentlemen.