From: Robert Roebling Date: Tue, 29 Aug 2000 20:06:25 +0000 (+0000) Subject: Added wxCanvasControl before anyone else would do X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3b111dbe5329143c501d4ff8853691a832b7d2ab?hp=a103e4e201361e4a2747492a0042267475801b20 Added wxCanvasControl before anyone else would do any harm. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/canvas/canvas.h b/contrib/include/wx/canvas/canvas.h index 4c2e43bf80..b4a9b46dc8 100644 --- a/contrib/include/wx/canvas/canvas.h +++ b/contrib/include/wx/canvas/canvas.h @@ -74,6 +74,23 @@ private: wxImage m_image; }; +//---------------------------------------------------------------------------- +// wxCanvasControl +//---------------------------------------------------------------------------- + +class wxCanvasControl: public wxCanvasObject +{ +public: + wxCanvasControl( wxWindow *control ); + ~wxCanvasControl(); + + virtual void Move( int x, int y ); + void UpdateSize(); + +private: + wxWindow *m_control; +}; + //---------------------------------------------------------------------------- // wxCanvas //---------------------------------------------------------------------------- @@ -100,6 +117,8 @@ public: wxImage *GetBuffer() { return &m_buffer; } bool NeedUpdate() { return m_needUpdate; } + void BlitBuffer( wxDC &dc ); + private: wxImage m_buffer; bool m_needUpdate; diff --git a/contrib/samples/canvas/test/test.cpp b/contrib/samples/canvas/test/test.cpp index c64b2ea0f3..1e17c1e748 100644 --- a/contrib/samples/canvas/test/test.cpp +++ b/contrib/samples/canvas/test/test.cpp @@ -106,6 +106,9 @@ MyFrame::MyFrame() m_canvas->Append( new wxCanvasImage( image, 80, 50 ) ); + wxButton *button = new wxButton( m_canvas, -1, "Hello", wxPoint(130,50) ); + m_canvas->Append( new wxCanvasControl( button ) ); + m_timer = new wxTimer( this ); m_timer->Start( 150, FALSE ); } diff --git a/contrib/src/canvas/canvas.cpp b/contrib/src/canvas/canvas.cpp index 5f0b37105a..3556034ad6 100644 --- a/contrib/src/canvas/canvas.cpp +++ b/contrib/src/canvas/canvas.cpp @@ -89,6 +89,33 @@ void wxCanvasImage::WriteSVG( wxTextOutputStream &stream ) // no idea } +//---------------------------------------------------------------------------- +// wxCanvasCtrl +//---------------------------------------------------------------------------- + +wxCanvasControl::wxCanvasControl( wxWindow *control ) + : wxCanvasObject( -1, -1, -1, -1 ) +{ + m_control = control; + UpdateSize(); +} + +wxCanvasControl::~wxCanvasControl() +{ + m_control->Destroy(); +} + +void wxCanvasControl::Move( int x, int y ) +{ + m_control->Move( x, y ); +} + +void wxCanvasControl::UpdateSize() +{ + m_control->GetSize( &m_area.width, &m_area.height ); + m_control->GetPosition( &m_area.x, &m_area.y ); +} + //---------------------------------------------------------------------------- // wxCanvas //---------------------------------------------------------------------------- @@ -153,7 +180,7 @@ void wxCanvas::Update( int x, int y, int width, int height ) ww = obj->GetWidth(); hh = obj->GetHeight(); - // if intersect + if (!obj->IsControl()) { obj->Render( x, y, width, height ); } @@ -162,13 +189,8 @@ void wxCanvas::Update( int x, int y, int width, int height ) } } -void wxCanvas::UpdateNow() +void wxCanvas::BlitBuffer( wxDC &dc ) { - if (!m_needUpdate) return; - - wxClientDC dc( this ); - PrepareDC( dc ); - wxNode *node = m_updateRects.First(); while (node) { @@ -218,6 +240,18 @@ void wxCanvas::UpdateNow() m_updateRects.DeleteNode( node ); node = m_updateRects.First(); } + + m_needUpdate = FALSE; +} + +void wxCanvas::UpdateNow() +{ + if (!m_needUpdate) return; + + wxClientDC dc( this ); + PrepareDC( dc ); + + BlitBuffer( dc ); } void wxCanvas::Prepend( wxCanvasObject* obj ) @@ -266,9 +300,8 @@ void wxCanvas::Remove( wxCanvasObject* obj ) void wxCanvas::OnPaint(wxPaintEvent &event) { -#ifdef __WXMSW__ wxPaintDC dc(this); -#endif + PrepareDC( dc ); m_needUpdate = TRUE; @@ -290,6 +323,8 @@ void wxCanvas::OnPaint(wxPaintEvent &event) it++; } + + BlitBuffer( dc ); } void wxCanvas::OnMouse(wxMouseEvent &event)