Thank you!
With Refresh it works fine...
But however there are flickering:
Use space to switch between slow and quick mode. Or should I set some style attributes in Create call of the DrawPanel?
cu olli
With Refresh it works fine...
But however there are flickering:
SuperStrict Framework wx.wx Import wx.wxApp Import wx.wxFrame Import wx.wxPanel Import wx.wxTimer Import wx.wxAutoBufferedPaintDC Import BRL.Random Global Application : TApplication, .. Frame : TFrame Application = New TApplication Application.Run() Type TApplication Extends wxApp Method OnInit:Int() Frame = New TFrame Frame.Create(,,"Drawing test") SetTopWindow(Frame) Frame.Show() Return True End Method End Type Type TFrame Extends wxFrame Field Panel : TDrawPanel Method OnInit() Local Sizer : wxBoxSizer Sizer = New wxBoxSizer.Create(wxVERTICAL) Panel = New TDrawPanel Panel.Create(Self, wxID_ANY) Sizer.Add(Panel, 1, wxALL|wxEXPAND, 0) Self.SetSizer(Sizer) Self.Layout() End Method End Type Type TDrawPanel Extends wxPanel Field Color : Byte[3], .. Timer : wxTimer, .. Slow : Int Method OnInit() Timer = New wxTimer.Create(Self) ConnectAny(wxEVT_TIMER, OnTick) ConnectAny(wxEVT_KEY_UP, OnKeyUp) ConnectNoId(wxEVT_PAINT, OnPaint) Timer.Start(1000) End Method Method SetColor(Red:Byte, Green:Byte, Blue:Byte) Color[0] = Red Color[1] = Green Color[2] = Blue End Method Function OnPaint(Event:wxEvent) Local DrawPanel : TDrawPanel, .. DC : wxAutoBufferedPaintDC DrawPanel = TDrawPanel(Event.Parent) DC = New wxAutoBufferedPaintDC.CreatePaintDC(DrawPanel) DrawPanel.PrepareDC(DC) Local Colour : wxColour Colour = New wxColour.Create(.. DrawPanel.Color[0], .. DrawPanel.Color[1], .. DrawPanel.Color[2]) DC.SetBackground(New wxBrush.CreateFromColour(Colour)) DC.Clear() DC.Free() End Function Function OnKeyUp(Event:wxEvent) Local DrawPanel : TDrawPanel DrawPanel = TDrawPanel(Event.Parent) If wxKeyEvent(Event).GetKeyCode() = Asc(" ") Then DrawPanel.Slow = Not DrawPanel.Slow DrawPanel.Timer.Stop() If DrawPanel.Slow Then DrawPanel.Timer.Start(1000) Else DrawPanel.Timer.Start(5) EndIf EndIf End Function Function OnTick(Event:wxEvent) Local DrawPanel : TDrawPanel DrawPanel = TDrawPanel(Event.Parent) DrawPanel.SetColor(Rand(0, 255), Rand(0, 255), Rand(0, 255)) DrawPanel.Refresh() End Function End Type
Use space to switch between slow and quick mode. Or should I set some style attributes in Create call of the DrawPanel?
cu olli