Use wxBitmapBundle in wxHeaderColumn

This commit is contained in:
Alexander Koshelev
2022-02-18 10:57:31 +03:00
committed by Vadim Zeitlin
parent 3aad506c5b
commit 33d8510d41
16 changed files with 135 additions and 44 deletions

View File

@@ -490,7 +490,7 @@ public:
} }
// ctor for the bitmap columns // ctor for the bitmap columns
wxDataViewColumnBase(const wxBitmap& bitmap, wxDataViewColumnBase(const wxBitmapBundle& bitmap,
wxDataViewRenderer *renderer, wxDataViewRenderer *renderer,
unsigned int model_column) unsigned int model_column)
: m_bitmap(bitmap) : m_bitmap(bitmap)
@@ -511,8 +511,9 @@ public:
// implement some of base class pure virtuals (the rest is port-dependent // implement some of base class pure virtuals (the rest is port-dependent
// and done differently in generic and native versions) // and done differently in generic and native versions)
virtual void SetBitmap( const wxBitmap& bitmap ) wxOVERRIDE { m_bitmap = bitmap; } virtual void SetBitmap( const wxBitmapBundle& bitmap ) wxOVERRIDE { m_bitmap = bitmap; }
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; } virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap.GetBitmap(wxDefaultSize); }
virtual wxBitmapBundle GetBitmapBundle() const wxOVERRIDE { return m_bitmap; }
// Special accessor for use by wxWidgets only returning the width that was // Special accessor for use by wxWidgets only returning the width that was
// explicitly set, either by the application, using SetWidth(), or by the // explicitly set, either by the application, using SetWidth(), or by the
@@ -523,7 +524,7 @@ public:
protected: protected:
wxDataViewRenderer *m_renderer; wxDataViewRenderer *m_renderer;
int m_model_column; int m_model_column;
wxBitmap m_bitmap; wxBitmapBundle m_bitmap;
wxDataViewCtrl *m_owner; wxDataViewCtrl *m_owner;
private: private:

View File

@@ -46,7 +46,7 @@ public:
Init(width, align, flags); Init(width, align, flags);
} }
wxDataViewColumn(const wxBitmap& bitmap, wxDataViewColumn(const wxBitmapBundle& bitmap,
wxDataViewRenderer *renderer, wxDataViewRenderer *renderer,
unsigned int model_column, unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH, int width = wxDVC_DEFAULT_WIDTH,
@@ -125,7 +125,7 @@ public:
return m_sortAscending; return m_sortAscending;
} }
virtual void SetBitmap( const wxBitmap& bitmap ) wxOVERRIDE virtual void SetBitmap( const wxBitmapBundle& bitmap ) wxOVERRIDE
{ {
wxDataViewColumnBase::SetBitmap(bitmap); wxDataViewColumnBase::SetBitmap(bitmap);
UpdateWidth(); UpdateWidth();

View File

@@ -46,6 +46,7 @@ public:
virtual wxString GetTitle() const wxOVERRIDE { return m_grid->GetColLabelValue(m_col); } virtual wxString GetTitle() const wxOVERRIDE { return m_grid->GetColLabelValue(m_col); }
virtual wxBitmap GetBitmap() const wxOVERRIDE { return wxNullBitmap; } virtual wxBitmap GetBitmap() const wxOVERRIDE { return wxNullBitmap; }
virtual wxBitmapBundle GetBitmapBundle() const wxOVERRIDE { return wxBitmapBundle(); }
virtual int GetWidth() const wxOVERRIDE { return m_grid->GetColSize(m_col); } virtual int GetWidth() const wxOVERRIDE { return m_grid->GetColSize(m_col); }
virtual int GetMinWidth() const wxOVERRIDE { return m_grid->GetColMinimalWidth(m_col); } virtual int GetMinWidth() const wxOVERRIDE { return m_grid->GetColMinimalWidth(m_col); }
virtual wxAlignment GetAlignment() const wxOVERRIDE virtual wxAlignment GetAlignment() const wxOVERRIDE

View File

@@ -26,7 +26,7 @@ public:
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE ); int flags = wxDATAVIEW_COL_RESIZABLE );
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, wxDataViewColumn( const wxBitmapBundle &bitmap, wxDataViewRenderer *renderer,
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE ); int flags = wxDATAVIEW_COL_RESIZABLE );
@@ -35,7 +35,7 @@ public:
// setters: // setters:
virtual void SetTitle( const wxString &title ) wxOVERRIDE; virtual void SetTitle( const wxString &title ) wxOVERRIDE;
virtual void SetBitmap( const wxBitmap &bitmap ) wxOVERRIDE; virtual void SetBitmap( const wxBitmapBundle &bitmap ) wxOVERRIDE;
virtual void SetOwner( wxDataViewCtrl *owner ) wxOVERRIDE; virtual void SetOwner( wxDataViewCtrl *owner ) wxOVERRIDE;

View File

@@ -10,7 +10,7 @@
#ifndef _WX_HEADERCOL_H_ #ifndef _WX_HEADERCOL_H_
#define _WX_HEADERCOL_H_ #define _WX_HEADERCOL_H_
#include "wx/bitmap.h" #include "wx/bmpbndl.h"
#if wxUSE_HEADERCTRL #if wxUSE_HEADERCTRL
@@ -89,8 +89,15 @@ public:
// title is the string shown for this column // title is the string shown for this column
virtual wxString GetTitle() const = 0; virtual wxString GetTitle() const = 0;
// bitmap shown (instead of text) in the column header // This function exists only for backwards compatibility, it's recommended to override
virtual wxBitmap GetBitmap() const = 0; \ // GetBitmapBundle() in the new code and override this one to do nothing, as it will
// never be called if GetBitmapBundle() is overridden.
virtual wxBitmap GetBitmap() const = 0;
// Override this function to return the bundle containing the bitmap to show in the
// column header. By default delegates to GetBitmap() but should be overridden if
// the bitmaps are used.
virtual wxBitmapBundle GetBitmapBundle() const { return GetBitmap(); }
// width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning // width of the column in pixels, can be set to wxCOL_WIDTH_DEFAULT meaning
// unspecified/default // unspecified/default
@@ -161,7 +168,7 @@ class WXDLLIMPEXP_CORE wxSettableHeaderColumn : public wxHeaderColumn
{ {
public: public:
virtual void SetTitle(const wxString& title) = 0; virtual void SetTitle(const wxString& title) = 0;
virtual void SetBitmap(const wxBitmap& bitmap) = 0; virtual void SetBitmap(const wxBitmapBundle& bitmap) = 0;
virtual void SetWidth(int width) = 0; virtual void SetWidth(int width) = 0;
virtual void SetMinWidth(int minWidth) = 0; virtual void SetMinWidth(int minWidth) = 0;
virtual void SetAlignment(wxAlignment align) = 0; virtual void SetAlignment(wxAlignment align) = 0;
@@ -221,7 +228,7 @@ public:
Init(); Init();
} }
wxHeaderColumnSimple(const wxBitmap& bitmap, wxHeaderColumnSimple(const wxBitmapBundle& bitmap,
int width = wxCOL_WIDTH_DEFAULT, int width = wxCOL_WIDTH_DEFAULT,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxCOL_DEFAULT_FLAGS) int flags = wxCOL_DEFAULT_FLAGS)
@@ -237,8 +244,9 @@ public:
virtual void SetTitle(const wxString& title) wxOVERRIDE { m_title = title; } virtual void SetTitle(const wxString& title) wxOVERRIDE { m_title = title; }
virtual wxString GetTitle() const wxOVERRIDE { return m_title; } virtual wxString GetTitle() const wxOVERRIDE { return m_title; }
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE { m_bitmap = bitmap; } virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE { m_bitmap = bitmap; }
wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; } wxBitmap GetBitmap() const wxOVERRIDE { wxFAIL_MSG("unreachable"); return wxNullBitmap; }
wxBitmapBundle GetBitmapBundle() const wxOVERRIDE { return m_bitmap; }
virtual void SetWidth(int width) wxOVERRIDE { m_width = width; } virtual void SetWidth(int width) wxOVERRIDE { m_width = width; }
virtual int GetWidth() const wxOVERRIDE { return m_width; } virtual int GetWidth() const wxOVERRIDE { return m_width; }
@@ -273,7 +281,7 @@ private:
} }
wxString m_title; wxString m_title;
wxBitmap m_bitmap; wxBitmapBundle m_bitmap;
int m_width, int m_width,
m_minWidth; m_minWidth;
wxAlignment m_align; wxAlignment m_align;

View File

@@ -33,7 +33,7 @@ public:
int width = wxDVC_DEFAULT_WIDTH, int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE); int flags = wxDATAVIEW_COL_RESIZABLE);
wxDataViewColumn(const wxBitmap& bitmap, wxDataViewColumn(const wxBitmapBundle& bitmap,
wxDataViewRenderer* renderer, wxDataViewRenderer* renderer,
unsigned int model_column, unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH, int width = wxDVC_DEFAULT_WIDTH,
@@ -53,7 +53,7 @@ public:
virtual bool IsHidden() const wxOVERRIDE; virtual bool IsHidden() const wxOVERRIDE;
virtual void SetAlignment (wxAlignment align) wxOVERRIDE; virtual void SetAlignment (wxAlignment align) wxOVERRIDE;
virtual void SetBitmap (wxBitmap const& bitmap) wxOVERRIDE; virtual void SetBitmap (wxBitmapBundle const& bitmap) wxOVERRIDE;
virtual void SetFlags (int flags) wxOVERRIDE { m_flags = flags; /*SetIndividualFlags(flags); */ } virtual void SetFlags (int flags) wxOVERRIDE { m_flags = flags; /*SetIndividualFlags(flags); */ }
virtual void SetHidden (bool hidden) wxOVERRIDE; virtual void SetHidden (bool hidden) wxOVERRIDE;
virtual void SetMaxWidth (int maxWidth); virtual void SetMaxWidth (int maxWidth);

View File

@@ -15,7 +15,7 @@ public:
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE ); int flags = wxDATAVIEW_COL_RESIZABLE );
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, wxDataViewColumn( const wxBitmapBundle &bitmap, wxDataViewRenderer *renderer,
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE ); int flags = wxDATAVIEW_COL_RESIZABLE );
@@ -24,7 +24,7 @@ public:
// setters: // setters:
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
virtual void SetBitmap( const wxBitmap &bitmap ); virtual void SetBitmap( const wxBitmapBundle &bitmap );
virtual void SetOwner( wxDataViewCtrl *owner ); virtual void SetOwner( wxDataViewCtrl *owner );

View File

@@ -78,12 +78,24 @@ public:
virtual wxString GetTitle() const = 0; virtual wxString GetTitle() const = 0;
/** /**
Returns the bitmap in the header of the column, if any. This function exists only for backwards compatibility, it's recommended to override
GetBitmapBundle() in the new code and override this one to do nothing, as it will
If the column has no associated bitmap, wxNullBitmap should be returned. never be called if GetBitmapBundle() is overridden.
*/ */
virtual wxBitmap GetBitmap() const = 0; virtual wxBitmap GetBitmap() const = 0;
/**
Returns the bitmap in the header of the column, if any.
If the column has no associated bitmap, empty wxBitmapBundle should be returned.
Override this function to return the bundle containing the bitmap to show in the
column header. By default delegates to GetBitmap() but should be overridden if
the bitmaps are used.
@since 3.1.6
*/
virtual wxBitmapBundle GetBitmapBundle() const;
/** /**
Returns the current width of the column. Returns the current width of the column.
@@ -205,7 +217,7 @@ public:
Notice that the bitmaps displayed in different columns of the same Notice that the bitmaps displayed in different columns of the same
control must all be of the same size. control must all be of the same size.
*/ */
virtual void SetBitmap(const wxBitmap& bitmap) = 0; virtual void SetBitmap(const wxBitmapBundle& bitmap) = 0;
/** /**
Set the column width. Set the column width.
@@ -409,7 +421,7 @@ public:
wxAlignment align = wxALIGN_NOT, wxAlignment align = wxALIGN_NOT,
int flags = wxCOL_DEFAULT_FLAGS); int flags = wxCOL_DEFAULT_FLAGS);
wxHeaderColumnSimple(const wxBitmap &bitmap, wxHeaderColumnSimple(const wxBitmapBundle &bitmap,
int width = wxCOL_WIDTH_DEFAULT, int width = wxCOL_WIDTH_DEFAULT,
wxAlignment align = wxALIGN_CENTER, wxAlignment align = wxALIGN_CENTER,
int flags = wxCOL_DEFAULT_FLAGS); int flags = wxCOL_DEFAULT_FLAGS);
@@ -421,8 +433,9 @@ public:
virtual void SetTitle(const wxString& title); virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const; virtual wxString GetTitle() const;
virtual void SetBitmap(const wxBitmap& bitmap); virtual void SetBitmap(const wxBitmapBundle& bitmap);
virtual wxBitmap GetBitmap() const; virtual wxBitmap GetBitmap() const;
virtual wxBitmapBundle GetBitmapBundle() const;
virtual void SetWidth(int width); virtual void SetWidth(int width);
virtual int GetWidth() const; virtual int GetWidth() const;
virtual void SetMinWidth(int minWidth); virtual void SetMinWidth(int minWidth);

View File

@@ -113,9 +113,9 @@ int wxHeaderCtrlBase::GetColumnTitleWidth(const wxHeaderColumn& col)
w += wxRendererNative::Get().GetHeaderButtonMargin(this); w += wxRendererNative::Get().GetHeaderButtonMargin(this);
// if a bitmap is used, add space for it and 2px border: // if a bitmap is used, add space for it and 2px border:
wxBitmap bmp = col.GetBitmap(); wxBitmapBundle bmp = col.GetBitmapBundle();
if ( bmp.IsOk() ) if ( bmp.IsOk() )
w += bmp.GetWidth() + 2; w += bmp.GetPreferredLogicalSizeFor(this).GetWidth() + 2;
return w; return w;
} }

View File

@@ -553,7 +553,7 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
wxHeaderButtonParams params; wxHeaderButtonParams params;
params.m_labelText = col.GetTitle(); params.m_labelText = col.GetTitle();
params.m_labelBitmap = col.GetBitmap(); params.m_labelBitmap = col.GetBitmapBundle().GetBitmapFor(this);
params.m_labelAlignment = col.GetAlignment(); params.m_labelAlignment = col.GetAlignment();
#ifdef __WXGTK__ #ifdef __WXGTK__

View File

@@ -405,8 +405,8 @@ wxRendererGeneric::DrawHeaderButtonContents(wxWindow *win,
// draw the bitmap if there is one // draw the bitmap if there is one
if ( params && params->m_labelBitmap.IsOk() ) if ( params && params->m_labelBitmap.IsOk() )
{ {
int w = params->m_labelBitmap.GetWidth(); int w = params->m_labelBitmap.GetLogicalWidth();
int h = params->m_labelBitmap.GetHeight(); int h = params->m_labelBitmap.GetLogicalHeight();
const int margin = 1; // an extra pixel on either side of the bitmap const int margin = 1; // an extra pixel on either side of the bitmap

View File

@@ -3228,6 +3228,42 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
} // extern "C" } // extern "C"
namespace
{
// Define a custom bitmap provider here as we don't have a valid window to use
// with the standard provider when we need to initialize the image yet, so we
// have to use the column -- which will have the associated window by the time
// we actually need to use it.
struct BitmapProvider : wxGtkImage::BitmapProvider
{
explicit BitmapProvider(wxDataViewColumn* column) : m_column(column) { }
virtual double GetScale() const wxOVERRIDE;
virtual wxBitmap Get() const wxOVERRIDE;
wxDataViewColumn* const m_column;
};
double BitmapProvider::GetScale() const
{
wxDataViewCtrl* const ctrl = m_column->GetOwner();
wxCHECK_MSG( ctrl, 1.0, "no valid window, using default scale factor" );
return ctrl->GetDPIScaleFactor();
}
wxBitmap BitmapProvider::Get() const
{
#ifdef __WXGTK3__
if (IsScaled())
return GetAtScale(m_column->GetBitmapBundle());
#endif
return wxBitmap();
}
} // namespace
#include <wx/listimpl.cpp> #include <wx/listimpl.cpp>
WX_DEFINE_LIST(wxDataViewColumnList) WX_DEFINE_LIST(wxDataViewColumnList)
@@ -3241,7 +3277,7 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *c
SetTitle( title ); SetTitle( title );
} }
wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, wxDataViewColumn::wxDataViewColumn( const wxBitmapBundle &bitmap, wxDataViewRenderer *cell,
unsigned int model_column, int width, unsigned int model_column, int width,
wxAlignment align, int flags ) wxAlignment align, int flags )
: wxDataViewColumnBase( bitmap, cell, model_column ) : wxDataViewColumnBase( bitmap, cell, model_column )
@@ -3267,7 +3303,7 @@ void wxDataViewColumn::Init(wxAlignment align, int flags, int width)
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
gtk_widget_show( box ); gtk_widget_show( box );
// gtk_container_set_border_width((GtkContainer*)box, 2); // gtk_container_set_border_width((GtkContainer*)box, 2);
m_image = wxGtkImage::New(); m_image = wxGtkImage::New(new BitmapProvider(this));
gtk_box_pack_start(GTK_BOX(box), m_image, FALSE, FALSE, 1); gtk_box_pack_start(GTK_BOX(box), m_image, FALSE, FALSE, 1);
m_label = gtk_label_new(""); m_label = gtk_label_new("");
gtk_box_pack_end( GTK_BOX(box), GTK_WIDGET(m_label), FALSE, FALSE, 1 ); gtk_box_pack_end( GTK_BOX(box), GTK_WIDGET(m_label), FALSE, FALSE, 1 );
@@ -3332,7 +3368,7 @@ wxString wxDataViewColumn::GetTitle() const
); );
} }
void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap ) void wxDataViewColumn::SetBitmap( const wxBitmapBundle &bitmap )
{ {
wxDataViewColumnBase::SetBitmap( bitmap ); wxDataViewColumnBase::SetBitmap( bitmap );

View File

@@ -12,6 +12,8 @@
#include "wx/gtk/private/wrapgtk.h" #include "wx/gtk/private/wrapgtk.h"
#include "wx/gtk/private/image.h" #include "wx/gtk/private/image.h"
GdkWindow* wxGetTopLevelGDK();
namespace namespace
{ {
@@ -40,7 +42,15 @@ struct BitmapProviderDefault: wxGtkImage::BitmapProvider
double BitmapProviderDefault::GetScale() const double BitmapProviderDefault::GetScale() const
{ {
return m_win ? m_win->GetDPIScaleFactor() : 1.0; if ( m_win )
{
return m_win->GetDPIScaleFactor();
}
#if GTK_CHECK_VERSION(3,10,0)
return gdk_window_get_scale_factor(wxGetTopLevelGDK());
#else
return 1.0;
#endif
} }
wxBitmap BitmapProviderDefault::Get() const wxBitmap BitmapProviderDefault::Get() const

View File

@@ -123,6 +123,9 @@ protected:
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE; virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE;
// This function can be used as event handle for wxEVT_DPI_CHANGED event.
void WXHandleDPIChanged(wxDPIChangedEvent& event);
private: private:
// override MSW-specific methods needed for new control // override MSW-specific methods needed for new control
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const wxOVERRIDE; virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const wxOVERRIDE;
@@ -222,6 +225,8 @@ void wxMSWHeaderCtrl::Init()
m_colBeingDragged = -1; m_colBeingDragged = -1;
m_isColBeingResized = false; m_isColBeingResized = false;
m_customDraw = NULL; m_customDraw = NULL;
Bind(wxEVT_DPI_CHANGED, &wxMSWHeaderCtrl::WXHandleDPIChanged, this);
} }
bool wxMSWHeaderCtrl::Create(wxWindow *parent, bool wxMSWHeaderCtrl::Create(wxWindow *parent,
@@ -332,6 +337,18 @@ void wxMSWHeaderCtrl::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
} }
} }
void wxMSWHeaderCtrl::WXHandleDPIChanged(wxDPIChangedEvent& event)
{
delete m_imageList;
m_imageList = NULL;
for (unsigned int i = 0; i < m_numColumns; ++i)
{
UpdateHeader(i);
}
event.Skip();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMSWHeaderCtrl columns managements // wxMSWHeaderCtrl columns managements
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -443,7 +460,7 @@ void wxMSWHeaderCtrl::DoInsertItem(const wxHeaderColumn& col, unsigned int idx)
hdi.pszText = buf.data(); hdi.pszText = buf.data();
hdi.cchTextMax = wxStrlen(buf); hdi.cchTextMax = wxStrlen(buf);
const wxBitmap bmp = col.GetBitmap(); wxBitmap bmp = col.GetBitmapBundle().GetBitmapFor(this);
if ( bmp.IsOk() ) if ( bmp.IsOk() )
{ {
hdi.mask |= HDI_IMAGE; hdi.mask |= HDI_IMAGE;
@@ -451,8 +468,8 @@ void wxMSWHeaderCtrl::DoInsertItem(const wxHeaderColumn& col, unsigned int idx)
if ( HasFlag(wxHD_BITMAP_ON_RIGHT) ) if ( HasFlag(wxHD_BITMAP_ON_RIGHT) )
hdi.fmt |= HDF_BITMAP_ON_RIGHT; hdi.fmt |= HDF_BITMAP_ON_RIGHT;
const int bmpWidth = bmp.GetWidth(), const int bmpWidth = bmp.GetLogicalWidth(),
bmpHeight = bmp.GetHeight(); bmpHeight = bmp.GetLogicalHeight();
if ( !m_imageList ) if ( !m_imageList )
{ {

View File

@@ -3525,7 +3525,7 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title,
SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0); SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
} }
wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewColumn::wxDataViewColumn(const wxBitmapBundle& bitmap,
wxDataViewRenderer* renderer, wxDataViewRenderer* renderer,
unsigned int model_column, unsigned int model_column,
int width, int width,
@@ -3565,13 +3565,18 @@ void wxDataViewColumn::SetAlignment(wxAlignment align)
m_renderer->OSXUpdateAlignment(); m_renderer->OSXUpdateAlignment();
} }
void wxDataViewColumn::SetBitmap(const wxBitmap& bitmap) void wxDataViewColumn::SetBitmap(const wxBitmapBundle& bitmap)
{ {
// bitmaps and titles cannot exist at the same time - if the bitmap is set // bitmaps and titles cannot exist at the same time - if the bitmap is set
// the title is removed: // the title is removed:
m_title.clear(); m_title.clear();
wxDataViewColumnBase::SetBitmap(bitmap); wxDataViewColumnBase::SetBitmap(bitmap);
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:bitmap.GetNSImage()]; wxBitmap bmp = m_owner ? bitmap.GetBitmapFor(m_owner) : bitmap.GetBitmap(
bitmap.GetPreferredBitmapSizeAtScale(
wxOSXGetMainScreenContentScaleFactor()
)
);
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setImage:bmp.GetNSImage()];
} }
void wxDataViewColumn::SetMaxWidth(int maxWidth) void wxDataViewColumn::SetMaxWidth(int maxWidth)
@@ -3659,7 +3664,7 @@ void wxDataViewColumn::SetTitle(const wxString& title)
{ {
// bitmaps and titles cannot exist at the same time - if the title is set // bitmaps and titles cannot exist at the same time - if the title is set
// the bitmap is removed: // the bitmap is removed:
wxDataViewColumnBase::SetBitmap(wxBitmap()); wxDataViewColumnBase::SetBitmap(wxBitmapBundle());
m_title = title; m_title = title;
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:wxCFStringRef(title).AsNSString()]; [[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setStringValue:wxCFStringRef(title).AsNSString()];
} }

View File

@@ -22,7 +22,7 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *r
{ {
} }
wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, wxDataViewColumn::wxDataViewColumn( const wxBitmapBundle &bitmap, wxDataViewRenderer *renderer,
unsigned int model_column, int width, unsigned int model_column, int width,
wxAlignment align, wxAlignment align,
int flags ) int flags )
@@ -34,7 +34,7 @@ void wxDataViewColumn::SetTitle( const wxString &title )
{ {
} }
void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap ) void wxDataViewColumn::SetBitmap( const wxBitmapBundle &bitmap )
{ {
} }