Use a single wxBitmapBundle in wxDataViewBitmapRenderer
Instead of using either a wxBitmap or a wxIcon, always use the same wxBitmapBundle object to store whatever we are rendering. This slightly simplifies the code and prepares for further changes, but nothing real changes yet.
This commit is contained in:
@@ -112,8 +112,7 @@ public:
|
||||
virtual wxSize GetSize() const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
wxIcon m_icon;
|
||||
wxBitmap m_bitmap;
|
||||
wxBitmapBundle m_bitmapBundle;
|
||||
|
||||
protected:
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer);
|
||||
|
||||
@@ -1319,16 +1319,19 @@ bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value )
|
||||
{
|
||||
if (value.GetType() == wxT("wxBitmap"))
|
||||
{
|
||||
m_bitmap << value;
|
||||
wxBitmap bitmap;
|
||||
bitmap << value;
|
||||
m_bitmapBundle = wxBitmapBundle(bitmap);
|
||||
}
|
||||
else if (value.GetType() == wxT("wxIcon"))
|
||||
{
|
||||
m_icon << value;
|
||||
wxIcon icon;
|
||||
icon << value;
|
||||
m_bitmapBundle = wxBitmapBundle(icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_icon = wxNullIcon;
|
||||
m_bitmap = wxNullBitmap;
|
||||
m_bitmapBundle.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1348,20 +1351,20 @@ wxString wxDataViewBitmapRenderer::GetAccessibleDescription() const
|
||||
|
||||
bool wxDataViewBitmapRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
|
||||
{
|
||||
if (m_bitmap.IsOk())
|
||||
dc->DrawBitmap( m_bitmap, cell.x, cell.y, true /* use mask */ );
|
||||
else if (m_icon.IsOk())
|
||||
dc->DrawIcon( m_icon, cell.x, cell.y );
|
||||
if (m_bitmapBundle.IsOk())
|
||||
{
|
||||
dc->DrawBitmap( m_bitmapBundle.GetBitmapFor(GetView()),
|
||||
cell.x, cell.y,
|
||||
true /* use mask */ );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxSize wxDataViewBitmapRenderer::GetSize() const
|
||||
{
|
||||
if (m_bitmap.IsOk())
|
||||
return wxSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
|
||||
else if (m_icon.IsOk())
|
||||
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
|
||||
if (m_bitmapBundle.IsOk())
|
||||
return m_bitmapBundle.GetPreferredBitmapSizeFor(GetView());
|
||||
|
||||
return GetView()->FromDIP(wxSize(wxDVC_DEFAULT_RENDERER_SIZE,
|
||||
wxDVC_DEFAULT_RENDERER_SIZE));
|
||||
|
||||
Reference in New Issue
Block a user