Merge branch 'gtk-always-use-wxgtkimage'
Ensure all buttons with images have associated wxGtkImage as this is required for showing high resolution bitmaps in them in high DPI. See https://github.com/wxWidgets/wxWidgets/pull/2548
This commit is contained in:
@@ -186,16 +186,10 @@ void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET(bitmap.IsOk(), "invalid bitmap");
|
wxCHECK_RET(bitmap.IsOk(), "invalid bitmap");
|
||||||
|
|
||||||
GtkWidget* image = gtk_button_get_image(GTK_BUTTON(m_widget));
|
GtkWidget* const image = gtk_button_get_image(GTK_BUTTON(m_widget));
|
||||||
if (image == NULL)
|
wxCHECK_RET(WX_GTK_IS_IMAGE(image), "must have image widget");
|
||||||
image = gtk_bin_get_child(GTK_BIN(m_widget));
|
|
||||||
|
|
||||||
wxCHECK_RET(GTK_IS_IMAGE(image), "must have image widget");
|
WX_GTK_IMAGE(image)->Set(bitmap);
|
||||||
|
|
||||||
if (WX_GTK_IS_IMAGE(image))
|
|
||||||
WX_GTK_IMAGE(image)->Set(bitmap);
|
|
||||||
else
|
|
||||||
gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxAnyButton::DoGetBitmap(State which) const
|
wxBitmap wxAnyButton::DoGetBitmap(State which) const
|
||||||
@@ -220,6 +214,14 @@ void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkWidget *image = gtk_button_get_image(GTK_BUTTON(m_widget));
|
GtkWidget *image = gtk_button_get_image(GTK_BUTTON(m_widget));
|
||||||
|
if ( image && !WX_GTK_IS_IMAGE(image) )
|
||||||
|
{
|
||||||
|
// This must be the GtkImage created for stock buttons, we
|
||||||
|
// want to replace it with our own wxGtkImage as only it
|
||||||
|
// handles showing appropriately-sized bitmaps in high DPI.
|
||||||
|
image = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ( image && !bitmap.IsOk() )
|
if ( image && !bitmap.IsOk() )
|
||||||
{
|
{
|
||||||
gtk_container_remove(GTK_CONTAINER(m_widget), image);
|
gtk_container_remove(GTK_CONTAINER(m_widget), image);
|
||||||
|
Reference in New Issue
Block a user