From 68bd393b2730b2e444ecac803e241755facc042e Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Mon, 30 Jun 2014 18:41:30 +0000 Subject: [PATCH] Disabled bitmaps of toolbar tools are now rendered at the correct position if using GTK3. Extend toolbar sample to include a button with a custom disabled bitmap. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76801 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/toolbar/toolbar.cpp | 5 ++++- src/gtk/toolbar.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index d57a548fdb..0e313d771a 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -209,6 +209,7 @@ enum IDM_TOOLBAR_OTHER_1, IDM_TOOLBAR_OTHER_2, IDM_TOOLBAR_OTHER_3, + IDM_TOOLBAR_OTHER_4, // tools menu items IDM_TOOLBAR_ENABLEPRINT, @@ -300,7 +301,7 @@ bool MyApp::OnInit() // Create the main frame window MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, wxT("wxToolBar Sample"), - wxPoint(100, 100), wxSize(650, 300)); + wxPoint(100, 100), wxSize(650, 350)); frame->Show(true); @@ -739,6 +740,8 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_3, wxT("Third"), wxBITMAP(save)); m_tbar->AddSeparator(); m_tbar->AddTool(wxID_HELP, wxT("Help"), wxBITMAP(help)); + m_tbar->AddTool(IDM_TOOLBAR_OTHER_4, wxT("Disabled"), wxBITMAP(cut), wxBITMAP(paste)); + m_tbar->EnableTool(IDM_TOOLBAR_OTHER_4, false); m_tbar->Realize(); } diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index ebc50a073e..2a200c8312 100644 --- a/src/gtk/toolbar.cpp +++ b/src/gtk/toolbar.cpp @@ -189,11 +189,13 @@ image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool) gtk_widget_get_allocation(widget, &alloc); GtkRequisition req; gtk_widget_get_requisition(widget, &req); - const int x = alloc.x + (alloc.width - req.width) / 2; - const int y = alloc.y + (alloc.height - req.height) / 2; #ifdef __WXGTK3__ + const int x = (alloc.width - req.width) / 2; + const int y = (alloc.height - req.height) / 2; bitmap.Draw(cr, x, y); #else + const int x = alloc.x + (alloc.width - req.width) / 2; + const int y = alloc.y + (alloc.height - req.height) / 2; gdk_draw_pixbuf( gtk_widget_get_window(widget), gtk_widget_get_style(widget)->black_gc, bitmap.GetPixbuf(), 0, 0, x, y,