Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Hack up wx to support @2x images in the toolbar. Oh please let's swit…
…ch to Qt...
  • Loading branch information
comex committed Sep 25, 2013
1 parent 624c92f commit 693cee3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
8 changes: 7 additions & 1 deletion Externals/wxWidgets3/include/wx/bitmap.h
Expand Up @@ -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

Expand Down
29 changes: 15 additions & 14 deletions Externals/wxWidgets3/src/aui/auibar.cpp
@@ -1,3 +1,4 @@
// XXX comex: scale support
///////////////////////////////////////////////////////////////////////////////

// Name: src/aui/auibar.cpp
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions Externals/wxWidgets3/src/osx/core/bitmap.cpp
Expand Up @@ -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 )
Expand All @@ -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;
Expand Down

0 comments on commit 693cee3

Please sign in to comment.