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
This commit is contained in:
@@ -74,6 +74,23 @@ private:
|
|||||||
wxImage m_image;
|
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
|
// wxCanvas
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -100,6 +117,8 @@ public:
|
|||||||
wxImage *GetBuffer() { return &m_buffer; }
|
wxImage *GetBuffer() { return &m_buffer; }
|
||||||
bool NeedUpdate() { return m_needUpdate; }
|
bool NeedUpdate() { return m_needUpdate; }
|
||||||
|
|
||||||
|
void BlitBuffer( wxDC &dc );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxImage m_buffer;
|
wxImage m_buffer;
|
||||||
bool m_needUpdate;
|
bool m_needUpdate;
|
||||||
|
@@ -106,6 +106,9 @@ MyFrame::MyFrame()
|
|||||||
|
|
||||||
m_canvas->Append( new wxCanvasImage( image, 80, 50 ) );
|
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 = new wxTimer( this );
|
||||||
m_timer->Start( 150, FALSE );
|
m_timer->Start( 150, FALSE );
|
||||||
}
|
}
|
||||||
|
@@ -89,6 +89,33 @@ void wxCanvasImage::WriteSVG( wxTextOutputStream &stream )
|
|||||||
// no idea
|
// 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
|
// wxCanvas
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -153,7 +180,7 @@ void wxCanvas::Update( int x, int y, int width, int height )
|
|||||||
ww = obj->GetWidth();
|
ww = obj->GetWidth();
|
||||||
hh = obj->GetHeight();
|
hh = obj->GetHeight();
|
||||||
|
|
||||||
// if intersect
|
if (!obj->IsControl())
|
||||||
{
|
{
|
||||||
obj->Render( x, y, width, height );
|
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();
|
wxNode *node = m_updateRects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@@ -218,6 +240,18 @@ void wxCanvas::UpdateNow()
|
|||||||
m_updateRects.DeleteNode( node );
|
m_updateRects.DeleteNode( node );
|
||||||
node = m_updateRects.First();
|
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::Prepend( wxCanvasObject* obj )
|
||||||
@@ -266,9 +300,8 @@ void wxCanvas::Remove( wxCanvasObject* obj )
|
|||||||
|
|
||||||
void wxCanvas::OnPaint(wxPaintEvent &event)
|
void wxCanvas::OnPaint(wxPaintEvent &event)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
#endif
|
PrepareDC( dc );
|
||||||
|
|
||||||
m_needUpdate = TRUE;
|
m_needUpdate = TRUE;
|
||||||
|
|
||||||
@@ -290,6 +323,8 @@ void wxCanvas::OnPaint(wxPaintEvent &event)
|
|||||||
|
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlitBuffer( dc );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCanvas::OnMouse(wxMouseEvent &event)
|
void wxCanvas::OnMouse(wxMouseEvent &event)
|
||||||
|
Reference in New Issue
Block a user