diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index e4027d7d5c..b2dc732a66 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -293,15 +293,21 @@ void wxAuiGenericToolBarArt::DrawButton( int bmpX = 0, bmpY = 0; int textX = 0, textY = 0; + const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED + ? item.GetDisabledBitmap() + : item.GetBitmap(); + + const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0); + if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) { bmpX = rect.x + (rect.width/2) - - (item.GetBitmap().GetScaledWidth()/2); + (bmpSize.x/2); bmpY = rect.y + ((rect.height-textHeight)/2) - - (item.GetBitmap().GetScaledHeight()/2); + (bmpSize.y/2); textX = rect.x + (rect.width/2) - (textWidth/2) + 1; textY = rect.y + rect.height - textHeight - 1; @@ -312,9 +318,9 @@ void wxAuiGenericToolBarArt::DrawButton( bmpY = rect.y + (rect.height/2) - - (item.GetBitmap().GetScaledHeight()/2); + (bmpSize.y/2); - textX = bmpX + wnd->FromDIP(3) + item.GetBitmap().GetScaledWidth(); + textX = bmpX + wnd->FromDIP(3) + bmpSize.x; textY = rect.y + (rect.height/2) - (textHeight/2); @@ -351,12 +357,6 @@ void wxAuiGenericToolBarArt::DrawButton( } } - wxBitmap bmp; - if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED) - bmp = item.GetDisabledBitmap(); - else - bmp = item.GetBitmap(); - if ( bmp.IsOk() ) dc.DrawBitmap(bmp, bmpX, bmpY, true); @@ -596,8 +596,9 @@ wxSize wxAuiGenericToolBarArt::GetToolSize( if (!item.GetBitmap().IsOk() && !(m_flags & wxAUI_TB_TEXT)) return wnd->FromDIP(wxSize(16,16)); - int width = item.GetBitmap().GetScaledWidth(); - int height = item.GetBitmap().GetScaledHeight(); + const wxBitmap& bmp = item.GetBitmap(); + int width = bmp.IsOk() ? bmp.GetScaledWidth() : 0; + int height = bmp.IsOk() ? bmp.GetScaledHeight() : 0; if (m_flags & wxAUI_TB_TEXT) {