Corrected references to bitmap size in AUI and Ribbon to take scaling into account

This commit is contained in:
JulianSmart 2017-05-12 15:50:15 +01:00
parent 11f79cda31
commit c07b14332b
10 changed files with 101 additions and 93 deletions

View File

@ -279,11 +279,11 @@ void wxAuiGenericToolBarArt::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 +294,9 @@ void wxAuiGenericToolBarArt::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 +390,20 @@ void wxAuiGenericToolBarArt::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 +414,9 @@ void wxAuiGenericToolBarArt::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 +553,8 @@ wxSize wxAuiGenericToolBarArt::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 +694,8 @@ void wxAuiGenericToolBarArt::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);
}

View File

@ -587,7 +587,7 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxWindow *WXUNUSED(window),
{
DrawIcon(dc, rect, pane);
caption_offset += pane.icon.GetWidth() + 3;
caption_offset += pane.icon.GetScaledWidth() + 3;
}
if (pane.state & wxAuiPaneInfo::optionActive)
@ -621,7 +621,7 @@ wxAuiDefaultDockArt::DrawIcon(wxDC& dc, const wxRect& rect, wxAuiPaneInfo& pane)
{
// Draw the icon centered vertically
dc.DrawBitmap(pane.icon,
rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2,
rect.x+2, rect.y+(rect.height-pane.icon.GetScaledHeight())/2,
true);
}
@ -720,7 +720,7 @@ void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
wxRect rect = _rect;
int old_y = rect.y;
rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2);
rect.y = rect.y + (rect.height/2) - (bmp.GetScaledHeight()/2);
rect.height = old_y + rect.height - rect.y - 1;

View File

@ -222,9 +222,9 @@ void wxAuiGenericTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - 4;
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
tot_width -= m_activeCloseBmp.GetWidth();
tot_width -= m_activeCloseBmp.GetScaledWidth();
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
tot_width -= m_activeWindowListBmp.GetWidth();
tot_width -= m_activeWindowListBmp.GetScaledWidth();
if (tab_count > 0)
{
@ -503,7 +503,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
int close_button_width = 0;
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
{
close_button_width = m_activeCloseBmp.GetWidth();
close_button_width = m_activeCloseBmp.GetScaledWidth();
}
int bitmap_offset = 0;
@ -514,10 +514,10 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
// draw bitmap
dc.DrawBitmap(page.bitmap,
bitmap_offset,
drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetScaledHeight()/2),
true);
text_offset = bitmap_offset + page.bitmap.GetWidth();
text_offset = bitmap_offset + page.bitmap.GetScaledWidth();
text_offset += 3; // bitmap padding
}
@ -546,8 +546,8 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
wxRect focusRectBitmap;
if (page.bitmap.IsOk())
focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
page.bitmap.GetWidth(), page.bitmap.GetHeight());
focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetScaledHeight()/2),
page.bitmap.GetScaledWidth(), page.bitmap.GetScaledHeight());
if (page.bitmap.IsOk() && draw_text.IsEmpty())
focusRect = focusRectBitmap;
@ -577,7 +577,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
offsetY = 1;
wxRect rect(tab_x + tab_width - close_button_width - 1,
offsetY + (tab_height/2) - (bmp.GetHeight()/2),
offsetY + (tab_height/2) - (bmp.GetScaledHeight()/2),
close_button_width,
tab_height);
@ -635,14 +635,14 @@ wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
// if the close button is showing, add space for it
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
tab_width += m_activeCloseBmp.GetWidth() + 3;
tab_width += m_activeCloseBmp.GetScaledWidth() + 3;
// if there's a bitmap, add space for it
if (bitmap.IsOk())
{
tab_width += bitmap.GetWidth();
tab_width += bitmap.GetScaledWidth();
tab_width += 3; // right side bitmap padding
tab_height = wxMax(tab_height, bitmap.GetHeight());
tab_height = wxMax(tab_height, bitmap.GetScaledHeight());
}
// add padding
@ -708,15 +708,15 @@ void wxAuiGenericTabArt::DrawButton(wxDC& dc,
if (orientation == wxLEFT)
{
rect.SetX(in_rect.x);
rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2));
rect.SetWidth(bmp.GetWidth());
rect.SetHeight(bmp.GetHeight());
rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetScaledHeight()/2));
rect.SetWidth(bmp.GetScaledWidth());
rect.SetHeight(bmp.GetScaledHeight());
}
else
{
rect = wxRect(in_rect.x + in_rect.width - bmp.GetWidth(),
((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2),
bmp.GetWidth(), bmp.GetHeight());
rect = wxRect(in_rect.x + in_rect.width - bmp.GetScaledWidth(),
((in_rect.y + in_rect.height)/2) - (bmp.GetScaledHeight()/2),
bmp.GetScaledWidth(), bmp.GetScaledHeight());
}
IndentPressedBitmap(&rect, button_state);
@ -905,9 +905,9 @@ void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - 4;
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
tot_width -= m_activeCloseBmp.GetWidth();
tot_width -= m_activeCloseBmp.GetScaledWidth();
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
tot_width -= m_activeWindowListBmp.GetWidth();
tot_width -= m_activeWindowListBmp.GetScaledWidth();
if (tab_count > 0)
{
@ -1066,7 +1066,7 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
int close_button_width = 0;
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
{
close_button_width = m_activeCloseBmp.GetWidth();
close_button_width = m_activeCloseBmp.GetScaledWidth();
text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
}
else
@ -1110,7 +1110,7 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
bmp = m_disabledCloseBmp;
wxRect rect(tab_x + tab_width - close_button_width - 1,
tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1,
tab_y + (tab_height/2) - (bmp.GetScaledHeight()/2) + 1,
close_button_width,
tab_height - 1);
DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state);
@ -1163,7 +1163,7 @@ wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
wxCoord tab_width = measured_textx + tab_height + 5;
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
tab_width += m_activeCloseBmp.GetWidth();
tab_width += m_activeCloseBmp.GetScaledWidth();
if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH)
{
@ -1223,15 +1223,15 @@ void wxAuiSimpleTabArt::DrawButton(wxDC& dc,
if (orientation == wxLEFT)
{
rect.SetX(in_rect.x);
rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2));
rect.SetWidth(bmp.GetWidth());
rect.SetHeight(bmp.GetHeight());
rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetScaledHeight()/2));
rect.SetWidth(bmp.GetScaledWidth());
rect.SetHeight(bmp.GetScaledHeight());
}
else
{
rect = wxRect(in_rect.x + in_rect.width - bmp.GetWidth(),
((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2),
bmp.GetWidth(), bmp.GetHeight());
rect = wxRect(in_rect.x + in_rect.width - bmp.GetScaledWidth(),
((in_rect.y + in_rect.height)/2) - (bmp.GetScaledHeight()/2),
bmp.GetScaledWidth(), bmp.GetScaledHeight());
}

View File

@ -133,7 +133,7 @@ wxRect DrawCloseButton(wxDC& dc,
wxBitmap bmp(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
if(bmp.GetScaledWidth() != s_CloseIconSize || bmp.GetScaledHeight() != s_CloseIconSize)
{
wxImage img = bmp.ConvertToImage();
img.Rescale(s_CloseIconSize, s_CloseIconSize);
@ -316,7 +316,7 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
bitmap_offset = textX;
// draw bitmap
int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetHeight()) / 2;
int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetScaledHeight()) / 2;
if(!page.active)
{
if (tab_pos == wxAUI_NB_TOP)
@ -329,7 +329,7 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
bitmapY,
true);
textX += page.bitmap.GetWidth() + padding;
textX += page.bitmap.GetScaledWidth() + padding;
}
wxCoord textW, textH, textY;

View File

@ -349,7 +349,7 @@ int wxRibbonAUIArtProvider::GetTabCtrlHeight(
const wxRibbonPageTabInfo& info = pages.Item(i);
if(info.page->GetIcon().IsOk())
{
icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight());
icon_height = wxMax(icon_height, info.page->GetIcon().GetScaledHeight());
}
}
}
@ -436,9 +436,9 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
{
if(icon.IsOk())
{
int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
int x = tab.rect.x + (tab.rect.width - icon.GetScaledWidth()) / 2;
dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
icon.GetHeight()) / 2, true);
icon.GetScaledHeight()) / 2, true);
}
}
}
@ -452,7 +452,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
int offset = 0;
if(icon.IsOk())
offset += icon.GetWidth() + 2;
offset += icon.GetScaledWidth() + 2;
int text_height;
int text_width;
dc.GetTextExtent(label, &text_width, &text_height);
@ -467,7 +467,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
if(icon.IsOk())
{
dc.DrawBitmap(icon, x - offset, tab.rect.y + (tab.rect.height -
icon.GetHeight()) / 2, true);
icon.GetScaledHeight()) / 2, true);
}
dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height);
dc.DrawText(label, x, y);
@ -514,8 +514,8 @@ void wxRibbonAUIArtProvider::GetBarTabWidth(
}
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk())
{
width += bitmap.GetWidth();
min += bitmap.GetWidth();
width += bitmap.GetScaledWidth();
min += bitmap.GetScaledWidth();
}
if(ideal != NULL)
@ -852,8 +852,8 @@ void wxRibbonAUIArtProvider::DrawMinimisedPanel(
if(bitmap.IsOk())
{
dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
preview.y + (preview.height - bitmap.GetHeight()) / 2, true);
dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetScaledWidth()) / 2,
preview.y + (preview.height - bitmap.GetScaledHeight()) / 2, true);
}
}
@ -1061,7 +1061,7 @@ void wxRibbonAUIArtProvider::DrawButtonBarButton(
{
case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
{
int iYBorder = rect.y + bitmap_large.GetHeight() + 4;
int iYBorder = rect.y + bitmap_large.GetScaledHeight() + 4;
wxRect partial_bg(rect);
if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
{
@ -1224,8 +1224,8 @@ void wxRibbonAUIArtProvider::DrawTool(
dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
bg_rect.y + (bg_rect.height / 2) - 2, true);
}
dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2,
bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true);
dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetScaledWidth()) / 2,
bg_rect.y + (bg_rect.height - bitmap.GetScaledHeight()) / 2, true);
}
#endif // wxUSE_RIBBON

View File

@ -1361,9 +1361,9 @@ void wxRibbonMSWArtProvider::DrawTab(
{
int x = tab.rect.x + 4;
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
x = tab.rect.x + (tab.rect.width - icon.GetScaledWidth()) / 2;
dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
icon.GetHeight()) / 2, true);
icon.GetScaledHeight()) / 2, true);
}
}
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
@ -1382,8 +1382,8 @@ void wxRibbonMSWArtProvider::DrawTab(
int x = tab.rect.x + 3;
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
{
x += 3 + tab.page->GetIcon().GetWidth();
width -= 3 + tab.page->GetIcon().GetWidth();
x += 3 + tab.page->GetIcon().GetScaledWidth();
width -= 3 + tab.page->GetIcon().GetScaledWidth();
}
int y = tab.rect.y + (tab.rect.height - text_height) / 2;
@ -1418,7 +1418,7 @@ void wxRibbonMSWArtProvider::DrawTabSeparator(
// The tab separator is relatively expensive to draw (for its size), and is
// usually drawn multiple times sequentially (in different positions), so it
// makes sense to draw it once and cache it.
if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize() || visibility != m_cached_tab_separator_visibility)
if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetScaledSize() != rect.GetSize() || visibility != m_cached_tab_separator_visibility)
{
wxRect size(rect.GetSize());
ReallyDrawTabSeparator(wnd, size, visibility);
@ -1428,7 +1428,7 @@ void wxRibbonMSWArtProvider::DrawTabSeparator(
void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect& rect, double visibility)
{
if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetSize() != rect.GetSize())
if(!m_cached_tab_separator.IsOk() || m_cached_tab_separator.GetScaledSize() != rect.GetSize())
{
m_cached_tab_separator = wxBitmap(rect.GetSize());
}
@ -2226,8 +2226,8 @@ void wxRibbonMSWArtProvider::DrawMinimisedPanel(
if(bitmap.IsOk())
{
dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true);
dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetScaledWidth()) / 2,
preview.y + (preview.height - 7 - bitmap.GetScaledHeight()) / 2, true);
}
DrawPanelBorder(dc, preview, m_panel_border_pen, m_panel_border_gradient_pen);
@ -2403,7 +2403,7 @@ void wxRibbonMSWArtProvider::DrawButtonBarButton(
{
case wxRIBBON_BUTTONBAR_BUTTON_LARGE:
{
int iYBorder = rect.y + bitmap_large.GetHeight() + 4;
int iYBorder = rect.y + bitmap_large.GetScaledHeight() + 4;
wxRect partial_bg(rect);
if(state & wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED)
{
@ -2509,9 +2509,9 @@ void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
{
const int padding = 2;
dc.DrawBitmap(bitmap_large,
rect.x + (rect.width - bitmap_large.GetWidth()) / 2,
rect.x + (rect.width - bitmap_large.GetScaledWidth()) / 2,
rect.y + padding, true);
int ypos = rect.y + padding + bitmap_large.GetHeight() + padding;
int ypos = rect.y + padding + bitmap_large.GetScaledHeight() + padding;
int arrow_width = kind == wxRIBBON_BUTTON_NORMAL ? 0 : 8;
wxCoord label_w, label_h;
dc.GetTextExtent(label, &label_w, &label_h);
@ -2563,8 +2563,8 @@ void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
{
int x_cursor = rect.x + 2;
dc.DrawBitmap(bitmap_small, x_cursor,
rect.y + (rect.height - bitmap_small.GetHeight())/2, true);
x_cursor += bitmap_small.GetWidth() + 2;
rect.y + (rect.height - bitmap_small.GetScaledHeight())/2, true);
x_cursor += bitmap_small.GetScaledWidth() + 2;
wxCoord label_w, label_h;
dc.GetTextExtent(label, &label_w, &label_h);
dc.DrawText(label, x_cursor,
@ -2705,8 +2705,8 @@ void wxRibbonMSWArtProvider::DrawTool(
dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
bg_rect.y + (bg_rect.height / 2) - 2, true);
}
dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetWidth()) / 2,
bg_rect.y + (bg_rect.height - bitmap.GetHeight()) / 2, true);
dc.DrawBitmap(bitmap, bg_rect.x + (avail_width - bitmap.GetScaledWidth()) / 2,
bg_rect.y + (bg_rect.height - bitmap.GetScaledHeight()) / 2, true);
}
void
@ -2791,8 +2791,8 @@ void wxRibbonMSWArtProvider::GetBarTabWidth(
}
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) && bitmap.IsOk())
{
width += bitmap.GetWidth();
min += bitmap.GetWidth();
width += bitmap.GetScaledWidth();
min += bitmap.GetScaledWidth();
}
if(ideal != NULL)
@ -2841,7 +2841,7 @@ int wxRibbonMSWArtProvider::GetTabCtrlHeight(
const wxRibbonPageTabInfo& info = pages.Item(i);
if(info.page->GetIcon().IsOk())
{
icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight() + 4);
icon_height = wxMax(icon_height, info.page->GetIcon().GetScaledHeight() + 4);
}
}
}

View File

@ -302,7 +302,7 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
{
if(bitmap.IsOk())
{
m_bitmap_size_large = bitmap.GetSize();
m_bitmap_size_large = bitmap.GetScaledSize();
if(!bitmap_small.IsOk())
{
m_bitmap_size_small = m_bitmap_size_large;
@ -311,7 +311,7 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
}
if(bitmap_small.IsOk())
{
m_bitmap_size_small = bitmap_small.GetSize();
m_bitmap_size_small = bitmap_small.GetScaledSize();
if(!bitmap.IsOk())
{
m_bitmap_size_large = m_bitmap_size_small;
@ -329,7 +329,7 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
base->bitmap_large = MakeResizedBitmap(base->bitmap_small,
m_bitmap_size_large);
}
else if(base->bitmap_large.GetSize() != m_bitmap_size_large)
else if(base->bitmap_large.GetScaledSize() != m_bitmap_size_large)
{
base->bitmap_large = MakeResizedBitmap(base->bitmap_large,
m_bitmap_size_large);
@ -340,7 +340,7 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
base->bitmap_small = MakeResizedBitmap(base->bitmap_large,
m_bitmap_size_small);
}
else if(base->bitmap_small.GetSize() != m_bitmap_size_small)
else if(base->bitmap_small.GetScaledSize() != m_bitmap_size_small)
{
base->bitmap_small = MakeResizedBitmap(base->bitmap_small,
m_bitmap_size_small);
@ -467,15 +467,19 @@ void wxRibbonButtonBar::FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
wxBitmap wxRibbonButtonBar::MakeResizedBitmap(const wxBitmap& original, wxSize size)
{
double scale = original.GetScaleFactor();
if (scale > 1.0)
scale = 2.0;
wxImage img(original.ConvertToImage());
img.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH);
return wxBitmap(img);
img.Rescale(scale * size.GetWidth(), scale * size.GetHeight(), wxIMAGE_QUALITY_HIGH);
return wxBitmap(img, -1, scale);
}
wxBitmap wxRibbonButtonBar::MakeDisabledBitmap(const wxBitmap& original)
{
wxImage img(original.ConvertToImage());
return wxBitmap(img.ConvertToGreyscale());
return wxBitmap(img.ConvertToGreyscale(), -1, original.GetScaleFactor());
}
size_t wxRibbonButtonBar::GetButtonCount() const

View File

@ -541,12 +541,12 @@ wxRibbonGalleryItem* wxRibbonGallery::Append(const wxBitmap& bitmap, int id)
wxASSERT(bitmap.IsOk());
if(m_items.IsEmpty())
{
m_bitmap_size = bitmap.GetSize();
m_bitmap_size = bitmap.GetScaledSize();
CalculateMinSize();
}
else
{
wxASSERT(bitmap.GetSize() == m_bitmap_size);
wxASSERT(bitmap.GetScaledSize() == m_bitmap_size);
}
wxRibbonGalleryItem *item = new wxRibbonGalleryItem;

View File

@ -692,11 +692,15 @@ bool wxRibbonPanel::Realize()
wxSize panel_min_size = GetMinNotMinimisedSize();
m_minimised_size = m_art->GetMinimisedPanelMinimumSize(temp_dc, this,
&bitmap_size, &m_preferred_expand_direction);
if(m_minimised_icon.IsOk() && m_minimised_icon.GetSize() != bitmap_size)
if(m_minimised_icon.IsOk() && m_minimised_icon.GetScaledSize() != bitmap_size)
{
double scale = m_minimised_icon.GetScaleFactor();
if (scale > 1.0)
scale = 2.0;
wxImage img(m_minimised_icon.ConvertToImage());
img.Rescale(bitmap_size.GetWidth(), bitmap_size.GetHeight(), wxIMAGE_QUALITY_HIGH);
m_minimised_icon_resized = wxBitmap(img);
img.Rescale(scale * bitmap_size.GetWidth(), scale * bitmap_size.GetHeight(), wxIMAGE_QUALITY_HIGH);
m_minimised_icon_resized = wxBitmap(img, -1, scale);
}
else
{

View File

@ -251,7 +251,7 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::InsertTool(
tool->bitmap = bitmap;
if(bitmap_disabled.IsOk())
{
wxASSERT(bitmap.GetSize() == bitmap_disabled.GetSize());
wxASSERT(bitmap.GetScaledSize() == bitmap_disabled.GetScaledSize());
tool->bitmap_disabled = bitmap_disabled;
}
else
@ -519,7 +519,7 @@ bool wxRibbonToolBar::GetToolState(int tool_id)const
wxBitmap wxRibbonToolBar::MakeDisabledBitmap(const wxBitmap& original)
{
wxImage img(original.ConvertToImage());
return wxBitmap(img.ConvertToGreyscale());
return wxBitmap(img.ConvertToGreyscale(), -1, original.GetScaleFactor());
}
void wxRibbonToolBar::AppendGroup()
@ -748,7 +748,7 @@ bool wxRibbonToolBar::Realize()
{
wxRibbonToolBarToolBase* tool = group->tools.Item(t);
tool->size = m_art->GetToolSize(temp_dc, this,
tool->bitmap.GetSize(), tool->kind, t == 0,
tool->bitmap.GetScaledSize(), tool->kind, t == 0,
t == (tool_count - 1), &tool->dropdown);
if(t == 0)
tool->state |= wxRIBBON_TOOLBAR_TOOL_FIRST;