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
//----------------------------------------------------------------------------
wxImage *GetBuffer() { return &m_buffer; }
bool NeedUpdate() { return m_needUpdate; }
+ void BlitBuffer( wxDC &dc );
+
private:
wxImage m_buffer;
bool m_needUpdate;
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 );
}
// 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
//----------------------------------------------------------------------------
ww = obj->GetWidth();
hh = obj->GetHeight();
- // if intersect
+ if (!obj->IsControl())
{
obj->Render( x, y, width, 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)
{
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 )
void wxCanvas::OnPaint(wxPaintEvent &event)
{
-#ifdef __WXMSW__
wxPaintDC dc(this);
-#endif
+ PrepareDC( dc );
m_needUpdate = TRUE;
it++;
}
+
+ BlitBuffer( dc );
}
void wxCanvas::OnMouse(wxMouseEvent &event)