replace use of deprecated GtkPixmap

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2006-10-14 16:49:14 +00:00
parent 7cd7bc23d5
commit eba91e51e8

View File

@@ -124,21 +124,17 @@ public:
} }
} }
void SetPixmap(const wxBitmap& bitmap) void SetImage(const wxBitmap& bitmap)
{ {
if (bitmap.Ok()) if (bitmap.Ok())
{ {
GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() // setting from pixmap doesn't seem to work right, but pixbuf works well
: (GdkBitmap *)NULL; gtk_image_set_from_pixbuf((GtkImage*)m_image, bitmap.GetPixbuf());
if (bitmap.HasPixbuf())
gtk_image_set_from_pixbuf( GTK_IMAGE(m_pixmap), bitmap.GetPixbuf() );
else
gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask );
} }
} }
GtkWidget *m_item; GtkWidget *m_item;
GtkWidget *m_pixmap; GtkWidget *m_image;
protected: protected:
void Init(); void Init();
@@ -176,7 +172,7 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
{ {
tool->Toggle(); tool->Toggle();
tool->SetPixmap(tool->GetBitmap()); tool->SetImage(tool->GetBitmap());
if ( tool->IsRadio() && !tool->IsToggled() ) if ( tool->IsRadio() && !tool->IsToggled() )
{ {
@@ -190,7 +186,7 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
// revert back // revert back
tool->Toggle(); tool->Toggle();
tool->SetPixmap(tool->GetBitmap()); tool->SetImage(tool->GetBitmap());
} }
} }
} }
@@ -237,7 +233,7 @@ static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent),
void wxToolBarTool::Init() void wxToolBarTool::Init()
{ {
m_item = m_item =
m_pixmap = (GtkWidget *)NULL; m_image = NULL;
} }
wxToolBarToolBase *wxToolBar::CreateTool(int id, wxToolBarToolBase *wxToolBar::CreateTool(int id,
@@ -376,30 +372,10 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
wxCHECK_MSG( bitmap.GetPixmap() != NULL, false, wxCHECK_MSG( bitmap.GetPixmap() != NULL, false,
wxT("wxToolBar::Add needs a wxBitmap") ); wxT("wxToolBar::Add needs a wxBitmap") );
GtkWidget *tool_pixmap = (GtkWidget *)NULL; tool->m_image = gtk_image_new();
tool->SetImage(bitmap);
gtk_misc_set_alignment((GtkMisc*)tool->m_image, 0.5, 0.5);
if (bitmap.HasPixbuf())
{
tool_pixmap = gtk_image_new();
tool->m_pixmap = tool_pixmap;
tool->SetPixmap(bitmap);
}
else
{
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkBitmap *mask = (GdkBitmap *)NULL;
if ( bitmap.GetMask() )
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask );
gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
}
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
tool->m_pixmap = tool_pixmap;
} }
} }
@@ -451,18 +427,13 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
? NULL ? NULL
: (const char*) wxGTK_CONV( tool->GetShortHelp() ), : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
"", // tooltip_private_text (?) "", // tooltip_private_text (?)
tool->m_pixmap, tool->m_image,
(GtkSignalFunc)gtk_toolbar_callback, (GtkSignalFunc)gtk_toolbar_callback,
(gpointer)tool, (gpointer)tool,
posGtk posGtk
); );
if ( !tool->m_item ) wxCHECK_MSG(tool->m_item != NULL, false, _T("gtk_toolbar_insert_element() failed"));
{
wxFAIL_MSG( _T("gtk_toolbar_insert_element() failed") );
return false;
}
g_signal_connect (tool->m_item, "enter_notify_event", g_signal_connect (tool->m_item, "enter_notify_event",
G_CALLBACK (gtk_toolbar_tool_callback), G_CALLBACK (gtk_toolbar_tool_callback),
@@ -544,7 +515,7 @@ void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
GtkWidget *item = tool->m_item; GtkWidget *item = tool->m_item;
if ( item && GTK_IS_TOGGLE_BUTTON(item) ) if ( item && GTK_IS_TOGGLE_BUTTON(item) )
{ {
tool->SetPixmap(tool->GetBitmap()); tool->SetImage(tool->GetBitmap());
m_blockEvent = true; m_blockEvent = true;