]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxCanvasControl before anyone else would do
authorRobert Roebling <robert@roebling.de>
Tue, 29 Aug 2000 20:06:25 +0000 (20:06 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 29 Aug 2000 20:06:25 +0000 (20:06 +0000)
   any harm.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/include/wx/canvas/canvas.h
contrib/samples/canvas/test/test.cpp
contrib/src/canvas/canvas.cpp

index 4c2e43bf801ec7bede479d72121a1bddc509104b..b4a9b46dc88d0973d15a1a191c6e8d8c3a1b6e1f 100644 (file)
@@ -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;
index c64b2ea0f36e8369d806da2734aebdd8f8bca64b..1e17c1e748d548eeee31f5974ac193ea3ba37287 100644 (file)
@@ -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 );
 }
index 5f0b37105ad3722531183403011de6151a6947ae..3556034ad6ceda4f41d122d126cacd8f3c494f82 100644 (file)
@@ -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)