Accept wxBitmapBundle in wxDataViewBitmapRenderer too
This allows returning the entire bundle from the model GetValue() function to let the renderer itself to select the best matching bitmap to use.
This commit is contained in:
@@ -1317,7 +1317,11 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype,
|
||||
|
||||
bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value )
|
||||
{
|
||||
if (value.GetType() == wxT("wxBitmap"))
|
||||
if (value.GetType() == wxT("wxBitmapBundle"))
|
||||
{
|
||||
m_bitmapBundle << value;
|
||||
}
|
||||
else if (value.GetType() == wxT("wxBitmap"))
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap << value;
|
||||
@@ -1346,7 +1350,8 @@ bool
|
||||
wxDataViewBitmapRenderer::IsCompatibleVariantType(const wxString& variantType) const
|
||||
{
|
||||
// We can accept values of any types checked by SetValue().
|
||||
return variantType == wxS("wxBitmap")
|
||||
return variantType == wxS("wxBitmapBundle")
|
||||
|| variantType == wxS("wxBitmap")
|
||||
|| variantType == wxS("wxIcon");
|
||||
}
|
||||
|
||||
|
||||
@@ -2569,22 +2569,32 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype,
|
||||
|
||||
bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value )
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
if (value.GetType() == wxS("wxBitmap"))
|
||||
wxBitmapBundle bitmapBundle;
|
||||
if (value.GetType() == wxS("wxBitmapBundle"))
|
||||
{
|
||||
bitmapBundle << value;
|
||||
}
|
||||
else if (value.GetType() == wxS("wxBitmap"))
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap << value;
|
||||
bitmapBundle = wxBitmapBundle(bitmap);
|
||||
}
|
||||
else if (value.GetType() == wxS("wxIcon"))
|
||||
{
|
||||
wxIcon icon;
|
||||
icon << value;
|
||||
bitmap.CopyFromIcon(icon);
|
||||
bitmapBundle = wxBitmapBundle(icon);
|
||||
}
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
WX_CELL_RENDERER_PIXBUF(m_renderer)->Set(bitmap);
|
||||
WX_CELL_RENDERER_PIXBUF(m_renderer)->Set(bitmapBundle);
|
||||
#else
|
||||
g_object_set(G_OBJECT(m_renderer), "pixbuf", bitmap.IsOk() ? bitmap.GetPixbuf() : NULL, NULL);
|
||||
g_object_set(G_OBJECT(m_renderer),
|
||||
"pixbuf",
|
||||
bitmapBundle.IsOk() ? bitmapBundle.GetBitmap(wxDefaultSize).GetPixbuf()
|
||||
: NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@@ -2599,7 +2609,8 @@ bool
|
||||
wxDataViewBitmapRenderer::IsCompatibleVariantType(const wxString& variantType) const
|
||||
{
|
||||
// We can accept values of any types checked by SetValue().
|
||||
return variantType == wxS("wxBitmap")
|
||||
return variantType == wxS("wxBitmapBundle")
|
||||
|| variantType == wxS("wxBitmap")
|
||||
|| variantType == wxS("wxIcon");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "wx/osx/private/available.h"
|
||||
#include "wx/osx/private/datatransfer.h"
|
||||
#include "wx/osx/cocoa/dataview.h"
|
||||
|
||||
#include "wx/private/bmpbndl.h"
|
||||
|
||||
#include "wx/renderer.h"
|
||||
#include "wx/stopwatch.h"
|
||||
#include "wx/dcgraph.h"
|
||||
@@ -2983,6 +2986,13 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(const wxString& varianttype,
|
||||
bool wxDataViewBitmapRenderer::MacRender()
|
||||
{
|
||||
if (GetValue().GetType() == wxS("wxBitmap"))
|
||||
{
|
||||
wxBitmapBundle bundle;
|
||||
bundle << GetValue();
|
||||
if (bundle.IsOk())
|
||||
[GetNativeData()->GetItemCell() setObjectValue:wxOSXGetImageFromBundle(bundle)];
|
||||
}
|
||||
else if (GetValue().GetType() == wxS("wxBitmap"))
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap << GetValue();
|
||||
@@ -3003,7 +3013,8 @@ bool
|
||||
wxDataViewBitmapRenderer::IsCompatibleVariantType(const wxString& variantType) const
|
||||
{
|
||||
// We can accept values of any types checked by SetValue().
|
||||
return variantType == wxS("wxBitmap")
|
||||
return variantType == wxS("wxBitmapBundle")
|
||||
|| variantType == wxS("wxBitmap")
|
||||
|| variantType == wxS("wxIcon");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user