Thanks a lot!
I actually solve the problem so:
I use a empty bitmap as backbuffer and draw into via wxMemoryDC. The bitmap is resized if the panel is resized.
On the paint event the complete backbuffer is drawn.
Also I have an extern timer event, that fill the oscilloscope with new sample data and than call Oscilloscope.Refresh() if there anough sample recordet.
Seem to be flicker free in combination with SetBackgroundStyle(wxBG_STYLE_CUSTOM)
(I must say I haven't realize the method with wxAutoBufferedPaintDC ^^)
The wxPlotCtrl looks good but I think it is easyer for me to program my own control. But thank you!
cu olli
I actually solve the problem so:
Type TOscilloscope Extends wxPanel Field Samples : Int[] Field Bitmap : wxBitmap Field Width : Int Field Height : Int Method OnInit() GetClientSize(Width, Height) Bitmap = New wxBitmap.CreateEmpty(Width, Height) ConnectAny(wxEVT_SIZE, OnSize) ConnectAny(wxEVT_PAINT, OnPaint) End Method Method Draw() Local DC : wxMemoryDC, .. Brush : wxBrush, .. Pen : wxPen Local IndexFactor : Float, .. SampleFactor : Float, .. Index : Int, .. X : Int, .. Y : Int ' Draw into bitmap DC = New wxMemoryDC.Create() DC.SelectObject(Self.Bitmap) Brush = New wxBrush.CreateFromColour(New wxColour.Create(188, 188, 188)) DC.SetBackground(Brush) DC.Clear() Pen = New wxPen.CreateFromColour(New wxColour.Create(200, 50, 50)) DC.SetPen(Pen) DC.DrawLine(0, -TRecorder.Threshold*Float(Height/2) + Height/2, .. Width, -TRecorder.Threshold*Float(Height/2) + Height/2) IndexFactor = Float(TRecorder.NumSamples)/Float(Width) SampleFactor = Float(Height)/Float($8000) Pen = New wxPen.CreateFromColour(New wxColour.Create(50, 50, 200)) DC.SetPen(Pen) If Self.Samples Then For X = 1 Until Width Index = X*IndexFactor If Index >= TRecorder.NumSamples Then Index = TRecorder.NumSamples - 1 Y = Int(Samples[Index]*SampleFactor) + Height/2 If Y < 0 Then Y = 0 If Y >= Height Then Y = Height - 1 DC.DrawLine(X, Height/2, X, Y) Next Else DC.DrawLine(0, Height/2, Width, Height/2) EndIf DC.SelectObject(wxNullBitmap) DC.Free() Refresh() End Method Function OnSize(E:wxEvent) Local Event : wxSizeEvent, .. _Self : TOscilloscope Event = wxSizeEvent(E) _Self = TOscilloscope(Event.Parent) ' Resize bitmap and draw into _Self.GetClientSize(_Self.Width, _Self.Height) _Self.Bitmap = New wxBitmap.CreateEmpty(_Self.Width, _Self.Height) _Self.Draw() End Function Function OnPaint(E:wxEvent) Local Event : wxPaintEvent, .. _Self : TOscilloscope, .. DC : wxPaintDC Event = wxPaintEvent(E) _Self = TOscilloscope(Event.Parent) DC = New wxPaintDC.Create(_Self) _Self.PrepareDC(DC) DC.DrawBitmap(_Self.Bitmap, 0, 0) DC.Free() End Function End Type
I use a empty bitmap as backbuffer and draw into via wxMemoryDC. The bitmap is resized if the panel is resized.
On the paint event the complete backbuffer is drawn.
Also I have an extern timer event, that fill the oscilloscope with new sample data and than call Oscilloscope.Refresh() if there anough sample recordet.
Seem to be flicker free in combination with SetBackgroundStyle(wxBG_STYLE_CUSTOM)
(I must say I haven't realize the method with wxAutoBufferedPaintDC ^^)
The wxPlotCtrl looks good but I think it is easyer for me to program my own control. But thank you!
cu olli