max2d + wxgadgets
BlitzMax Forums/Brucey's Modules/max2d + wxgadgets
| ||
hi im trying to create a canvas for max2d and drawing some gadgets at the same time. I tried to merge the read-only text example and the max2d example:
SuperStrict
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxPanel
Import wx.wxTextCtrl
Import wx.wxmax2D
Import wx.wxTimer
Type MyTextCtrl Extends wxTextCtrl
EndType
Type mypanel Extends wxPanel
Method oninit()
SetAutoLayout( True )
EndMethod
EndType
New MyApp.run()
Type MyApp Extends wxApp
Field frame:MyFrame
Field panel:MyPanel
Method OnInit:Int()
' Create the main application windowType MyFrame Extends wxFrame
frame = MyFrame(New MyFrame.Create( , , "Kingdom" , , , 640 , 480) )
Local panel:mypanel = MyPanel(New MyPanel.Create( frame, 0, 0, 640, 200 ))
Local readonly:mytextctrl = MyTextCtrl(New MyTextCtrl.Create( panel, wxID_ANY, "Read only", 10,90, 140,100 , wxTE_READONLY|wxTE_MULTILINE | wxHSCROLL ))
readonly.AppendText(" Appended.")
' 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.CreateWin(Self))
ConnectAny(wxEVT_CLOSE, OnClose)
End Method
Function OnClose(event:wxEvent)
MyFrame(event.parent).canvas.timer.Stop() ' stop the timer!
wxWindow(event.parent).Destroy() ' remove the frame
End Function
Function OnQuit(event:wxEvent)
wxWindow(event.parent).Close(True)
End Function
End Type
Type MyCanvas Extends wxWindow
Field timer:wxTimer
Method OnInit()
SetBackgroundStyle(wxBG_STYLE_CUSTOM)
timer = New wxTimer.Create(Self)
ConnectAny(wxEVT_PAINT, OnPaint)
ConnectAny(wxEVT_TIMER, OnTick)
timer.Start(30)
End Method
Function OnPaint(event:wxEvent)
Local canvas:MyCanvas = MyCanvas(event.parent)
SetGraphics wxGraphics(canvas)
SetColor(0, 0, 0)
Cls
DrawLine 200,200,250,250
Flip
End Function
Function OnTick(event:wxEvent)
wxWindow(event.parent).Refresh()
End Function
End Type
but i can just see a white square |
| ||
| has anyone done this sucessfully? |
| ||
| Me thinks something went wrong somewhere in your example :-) Doesn't appear to do much here either. |
| ||
| could I have an example of max2d plus widgets please? |
| ||
| The glmax2d sample shows how to use the wxGLCanvas on a window. You import wx.wxGLMax2D, which is a special version of BRL.GLMax2D that works better with wxWidgets. If you want to use the DX max2d driver, I'm not very experienced with the Win32 side of things... but since you can get access to the HWND handle of a wxWindow, it should be relatively easy to connect the two together. Has anyone tried it? I did manage to demo the Blitz3DSDK running on a wxWindow instance at one point for someone. |
| ||
| I managed to get a textcontrol to appear but I dont why it appears at that place, or why the rest of the screen is covered in gray so that I cant see the clock |
| ||
| Here's a slightly tweaked version of your example : I've added coords/sizing to the canvas, and changed the main panel - The control added to a frame should be either a sizer or a container type, and by default (only) fills the whole child area of the frame. Tested on Mac (PPC)... but expect it to work on Win32 also... :-) |
| ||
| aha! so you put the canvas on the panel instead of the frame AND you specified the size and position of the canvas thanks! |