wx and graphviz

BlitzMax Modules Forums/Brucey's Modules/wx and graphviz

Brucey, have you got graphviz to work in wx yet?

This is all I have so far, the whole driver thingy has me mixed up. I tried to merge the glmax2d sample and a graphviz sample.
SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxglmax2D
Import wx.wxTimer

Import BaH.Graphviz
Import BaH.GraphvizMax2D

Import BRL.StandardIO
Import BRL.TextStream
'Import BRL.glmax2d

'?linux
Import "glsupport.bmx"
'?

Local renderSupport:TGVRenderSupport

'?linux
renderSupport = New TOpenGLRenderSupport
'?

Global Renderer:TGVGraphviz = TGVGraphviz.Create(800, 600, renderSupport)  ' with optional render support

Renderer.loadGraphText(LoadText("02.Dot")) 

SetGraphicsDriver GLMax2DDriver() 

renderer.layout("dot")
renderer.fit(800, 600)

Global mx:Int
Global my:Int
Global mz:Int
Global oldZ:Int
Global buttons:Int[] = New Int[3] 

Global currentGraph:Int = 1
Global currentLayout:Int = 1

New MyApp.run()


Type MyApp Extends wxApp

	Field frame:MyFrame

	Method OnInit:Int()

		' Create the main application windowType MyFrame Extends wxFrame

		frame = MyFrame(New MyFrame.Create(,,"", , , 640, 480))
		
		' Show it and tell the application that it's our main window
		frame.show(True)
		SetTopWindow(frame)

		Return True
	End Method

End Type

Type MyFrame Extends wxFrame

	Field canvas:MyCanvas

	Method OnInit() 
	
		canvas = MyCanvas(New MyCanvas.Create(Self, - 1, GRAPHICS_BACKBUFFER | GRAPHICS_DEPTHBUFFER)) 
	
		ConnectAny(wxEVT_CLOSE, OnClose)
	End Method
	
	Function OnClose(event:wxEvent)
		MyFrame(event.parent).canvas.timer.Stop() ' we really need to stop the timer on Mac...
		event.Skip()
	End Function

End Type


Type MyCanvas Extends wxGLCanvas

	Field timer:wxTimer

	Method OnInit()
		SetBackgroundStyle(wxBG_STYLE_CUSTOM)
	
		timer = New wxTimer.Create(Self)


		ConnectAny(wxEVT_TIMER, OnTick)

		timer.Start(100)
	End Method

	Method OnPaint(event:wxPaintEvent)
		Render()
	End Method

	Method Render()

	   SetGraphics CanvasGraphics2D(Self) 
		
		Cls

			drawStuff() 
		
		Flip

	End Method

	Function OnTick(event:wxEvent)
		wxWindow(event.parent).Refresh()
	End Function
	
	Method drawStuff() 
		SetColor(255, 255, 255) 
		
		mx = MouseX()
		my = MouseY()
		mz = MouseZ()
			
		' tell graphviz we've moved the mouse
		renderer.mouseMove(mx, my)
		
		For Local i:Int = 1 To 3
			If MouseDown(i)
				If Not buttons[i - 1] Then
					renderer.MouseDown(mx, my, i) ' mouse button press
					buttons[i - 1] = 1
				End If
			Else
				If buttons[i - 1] Then
					buttons[i - 1] = 0
					renderer.mouseUp(mx, my, i) ' mouse button release
				End If
			End If
		Next
		
		If mz <> oldZ Then
			If mz < oldZ Then
				renderer.mouseScroll(mx, my, -1) ' scroll up - zoom in
			Else
				renderer.mouseScroll(mx, my, 1) ' scroll down - zoom out
			End If
			oldZ = mz
		End If
	
		' refresh/redraw the graph
		renderer.refresh()
	
		' draw the current tooltip under the mouse - if there is one!
		renderer.drawTooltip(mx, my + 16)
		
		' get data for current object
		Local obj:TGViewObject = renderer.currentObject()
		
		If obj Then
			'SetImageFont(Null)
			
			SetColor 255, 100, 100
			
			DrawText obj.name, 400, 0
			DrawText obj.skind, 400, 15
			
			For Local i:Int = 0 Until obj.attributes.length			
				DrawText obj.attributes[i].name + " : " + obj.attributes[i].value, 400, 60 + i * 15
				
			Next
			
		End If
	
	End Method
	
End Type