Skip to content

Commit

Permalink
Handle high resolution displays in wxBitmapButtonBase::NewCloseButton().
Browse files Browse the repository at this point in the history
Bitmap for the close button is scaled based on GetContentScaleFactor(). On OS X the resulting bitmap has to use the correct scaling factor in order to be displayed correctly on the button when using a high resolution display.
  • Loading branch information
TcT2k committed Jan 4, 2016
1 parent 956052c commit b89910d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/common/bmpbtncmn.cpp
Expand Up @@ -103,13 +103,21 @@ GetCloseButtonBitmap(wxWindow *win,
const wxColour& colBg,
int flags = 0)
{
wxBitmap bmp(size);
wxSize drawSize = size * win->GetContentScaleFactor();

wxBitmap bmp(drawSize);
wxMemoryDC dc(bmp);
dc.SetBackground(colBg);
dc.Clear();


wxRendererNative::Get().
DrawTitleBarBitmap(win, dc, size, wxTITLEBAR_BUTTON_CLOSE, flags);
DrawTitleBarBitmap(win, dc, drawSize, wxTITLEBAR_BUTTON_CLOSE, flags);
#ifdef __WXOSX__
return wxBitmap(bmp.CreateCGImage(), win->GetContentScaleFactor());
#else
return bmp;
#endif
}

#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
Expand Down

0 comments on commit b89910d

Please sign in to comment.