From 693cee36cb0b0194ca3e87d200d341b0330e05d5 Mon Sep 17 00:00:00 2001 From: comex Date: Wed, 25 Sep 2013 02:03:32 -0400 Subject: [PATCH] Hack up wx to support @2x images in the toolbar. Oh please let's switch to Qt... --- Externals/wxWidgets3/include/wx/bitmap.h | 8 +++++- Externals/wxWidgets3/src/aui/auibar.cpp | 29 ++++++++++---------- Externals/wxWidgets3/src/osx/core/bitmap.cpp | 3 ++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Externals/wxWidgets3/include/wx/bitmap.h b/Externals/wxWidgets3/include/wx/bitmap.h index 6d9ffe71b7..506ef6983d 100644 --- a/Externals/wxWidgets3/include/wx/bitmap.h +++ b/Externals/wxWidgets3/include/wx/bitmap.h @@ -305,7 +305,13 @@ wxBitmap:: #endif ConvertToDisabled(unsigned char brightness) const { - return ConvertToImage().ConvertToDisabled(brightness); + // XXX comex: scale support + wxImage disabledImage = ConvertToImage().ConvertToDisabled(brightness); + #ifdef __APPLE__ + return wxBitmap(disabledImage, -1, GetScaleFactor()); + #else + return disabledImage; + #endif } #endif // wxUSE_IMAGE diff --git a/Externals/wxWidgets3/src/aui/auibar.cpp b/Externals/wxWidgets3/src/aui/auibar.cpp index f2af2eb1f1..2bfcbe1b6a 100644 --- a/Externals/wxWidgets3/src/aui/auibar.cpp +++ b/Externals/wxWidgets3/src/aui/auibar.cpp @@ -1,3 +1,4 @@ +// XXX comex: scale support /////////////////////////////////////////////////////////////////////////////// // Name: src/aui/auibar.cpp @@ -279,11 +280,11 @@ void wxAuiDefaultToolBarArt::DrawButton( { bmpX = rect.x + (rect.width/2) - - (item.GetBitmap().GetWidth()/2); + (item.GetBitmap().GetScaledWidth()/2); bmpY = rect.y + ((rect.height-textHeight)/2) - - (item.GetBitmap().GetHeight()/2); + (item.GetBitmap().GetScaledHeight()/2); textX = rect.x + (rect.width/2) - (textWidth/2) + 1; textY = rect.y + rect.height - textHeight - 1; @@ -294,9 +295,9 @@ void wxAuiDefaultToolBarArt::DrawButton( bmpY = rect.y + (rect.height/2) - - (item.GetBitmap().GetHeight()/2); + (item.GetBitmap().GetScaledHeight()/2); - textX = bmpX + 3 + item.GetBitmap().GetWidth(); + textX = bmpX + 3 + item.GetBitmap().GetScaledWidth(); textY = rect.y + (rect.height/2) - (textHeight/2); @@ -390,20 +391,20 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( dropBmpX = dropDownRect.x + (dropDownRect.width/2) - - (m_buttonDropDownBmp.GetWidth()/2); + (m_buttonDropDownBmp.GetScaledWidth()/2); dropBmpY = dropDownRect.y + (dropDownRect.height/2) - - (m_buttonDropDownBmp.GetHeight()/2); + (m_buttonDropDownBmp.GetScaledHeight()/2); if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) { bmpX = buttonRect.x + (buttonRect.width/2) - - (item.GetBitmap().GetWidth()/2); + (item.GetBitmap().GetScaledWidth()/2); bmpY = buttonRect.y + ((buttonRect.height-textHeight)/2) - - (item.GetBitmap().GetHeight()/2); + (item.GetBitmap().GetScaledHeight()/2); textX = rect.x + (rect.width/2) - (textWidth/2) + 1; textY = rect.y + rect.height - textHeight - 1; @@ -414,9 +415,9 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( bmpY = rect.y + (rect.height/2) - - (item.GetBitmap().GetHeight()/2); + (item.GetBitmap().GetScaledHeight()/2); - textX = bmpX + 3 + item.GetBitmap().GetWidth(); + textX = bmpX + 3 + item.GetBitmap().GetScaledWidth(); textY = rect.y + (rect.height/2) - (textHeight/2); @@ -553,8 +554,8 @@ wxSize wxAuiDefaultToolBarArt::GetToolSize( if (!item.GetBitmap().IsOk() && !(m_flags & wxAUI_TB_TEXT)) return wxSize(16,16); - int width = item.GetBitmap().GetWidth(); - int height = item.GetBitmap().GetHeight(); + int width = item.GetBitmap().GetScaledWidth(); + int height = item.GetBitmap().GetScaledHeight(); if (m_flags & wxAUI_TB_TEXT) { @@ -694,8 +695,8 @@ void wxAuiDefaultToolBarArt::DrawOverflowButton(wxDC& dc, } } - int x = rect.x+1+(rect.width-m_overflowBmp.GetWidth())/2; - int y = rect.y+1+(rect.height-m_overflowBmp.GetHeight())/2; + int x = rect.x+1+(rect.width-m_overflowBmp.GetScaledWidth())/2; + int y = rect.y+1+(rect.height-m_overflowBmp.GetScaledHeight())/2; dc.DrawBitmap(m_overflowBmp, x, y, true); } diff --git a/Externals/wxWidgets3/src/osx/core/bitmap.cpp b/Externals/wxWidgets3/src/osx/core/bitmap.cpp index 8ee6127b11..2edc5ed7ee 100644 --- a/Externals/wxWidgets3/src/osx/core/bitmap.cpp +++ b/Externals/wxWidgets3/src/osx/core/bitmap.cpp @@ -1225,6 +1225,8 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) { UnRef(); + // XXX comex: how exactly is this supposed to work!? @2x support isn't used in this case + /* wxBitmapHandler *handler = FindHandler(type); if ( handler ) @@ -1234,6 +1236,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return handler->LoadFile(this, filename, type, -1, -1); } else + */ { #if wxUSE_IMAGE double scale = 1.0;