Use wxBitmapBundle for AUI tab pages bitmaps
Take wxBitmapBundle instead of just wxBitmap in various public functions and select the bitmap appropriate for the current DPI scaling when we need to use it. Note that this removes wxAuiScaleBitmap() which used custom scaling logic that might be better than the generic approach used by wxBitmapBundle, and so could result in a temporary regression in the icons appearance in high DPI, but they will hopefully be replaced with SVG versions soon, so that this shouldn't matter.
This commit is contained in:
@@ -91,7 +91,7 @@ public:
|
||||
wxWindow* window; // page's associated window
|
||||
wxString caption; // caption displayed on the tab
|
||||
wxString tooltip; // tooltip displayed when hovering over tab title
|
||||
wxBitmap bitmap; // tab's bitmap
|
||||
wxBitmapBundle bitmap;// tab's bitmap
|
||||
wxRect rect; // tab's hit rectangle
|
||||
bool active; // true if the page is currently active
|
||||
bool hover; // true if mouse hovering over tab
|
||||
@@ -104,8 +104,8 @@ public:
|
||||
int id; // button's id
|
||||
int curState; // current state (normal, hover, pressed, etc.)
|
||||
int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
||||
wxBitmap bitmap; // button's hover bitmap
|
||||
wxBitmap disBitmap; // button's disabled bitmap
|
||||
wxBitmapBundle bitmap; // button's hover bitmap
|
||||
wxBitmapBundle disBitmap; // button's disabled bitmap
|
||||
wxRect rect; // button's hit rectangle
|
||||
};
|
||||
|
||||
@@ -156,8 +156,8 @@ public:
|
||||
void RemoveButton(int id);
|
||||
void AddButton(int id,
|
||||
int location,
|
||||
const wxBitmap& normalBitmap = wxNullBitmap,
|
||||
const wxBitmap& disabledBitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& normalBitmap = wxBitmapBundle(),
|
||||
const wxBitmapBundle& disabledBitmap = wxBitmapBundle());
|
||||
|
||||
size_t GetTabOffset() const;
|
||||
void SetTabOffset(size_t offset);
|
||||
@@ -279,13 +279,13 @@ public:
|
||||
bool AddPage(wxWindow* page,
|
||||
const wxString& caption,
|
||||
bool select = false,
|
||||
const wxBitmap& bitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||
|
||||
bool InsertPage(size_t pageIdx,
|
||||
wxWindow* page,
|
||||
const wxString& caption,
|
||||
bool select = false,
|
||||
const wxBitmap& bitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||
|
||||
bool DeletePage(size_t page) wxOVERRIDE;
|
||||
bool RemovePage(size_t page) wxOVERRIDE;
|
||||
@@ -300,7 +300,7 @@ public:
|
||||
bool SetPageToolTip(size_t page, const wxString& text);
|
||||
wxString GetPageToolTip(size_t pageIdx) const;
|
||||
|
||||
bool SetPageBitmap(size_t page, const wxBitmap& bitmap);
|
||||
bool SetPageBitmap(size_t page, const wxBitmapBundle& bitmap);
|
||||
wxBitmap GetPageBitmap(size_t pageIdx) const;
|
||||
|
||||
int SetSelection(size_t newPage) wxOVERRIDE;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "wx/font.h"
|
||||
#include "wx/pen.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/bmpbndl.h"
|
||||
|
||||
|
||||
class wxAuiNotebookPage;
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int closeButtonState,
|
||||
int* xExtent) = 0;
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int closeButtonState,
|
||||
int* xExtent) wxOVERRIDE;
|
||||
@@ -203,14 +203,14 @@ protected:
|
||||
wxPen m_borderPen;
|
||||
wxBrush m_baseColourBrush;
|
||||
wxColour m_activeColour;
|
||||
wxBitmap m_activeCloseBmp;
|
||||
wxBitmap m_disabledCloseBmp;
|
||||
wxBitmap m_activeLeftBmp;
|
||||
wxBitmap m_disabledLeftBmp;
|
||||
wxBitmap m_activeRightBmp;
|
||||
wxBitmap m_disabledRightBmp;
|
||||
wxBitmap m_activeWindowListBmp;
|
||||
wxBitmap m_disabledWindowListBmp;
|
||||
wxBitmapBundle m_activeCloseBmp;
|
||||
wxBitmapBundle m_disabledCloseBmp;
|
||||
wxBitmapBundle m_activeLeftBmp;
|
||||
wxBitmapBundle m_disabledLeftBmp;
|
||||
wxBitmapBundle m_activeRightBmp;
|
||||
wxBitmapBundle m_disabledRightBmp;
|
||||
wxBitmapBundle m_activeWindowListBmp;
|
||||
wxBitmapBundle m_disabledWindowListBmp;
|
||||
|
||||
int m_fixedTabWidth;
|
||||
int m_tabCtrlHeight;
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int closeButtonState,
|
||||
int* xExtent) wxOVERRIDE;
|
||||
@@ -303,14 +303,14 @@ protected:
|
||||
wxBrush m_normalBkBrush;
|
||||
wxBrush m_selectedBkBrush;
|
||||
wxBrush m_bkBrush;
|
||||
wxBitmap m_activeCloseBmp;
|
||||
wxBitmap m_disabledCloseBmp;
|
||||
wxBitmap m_activeLeftBmp;
|
||||
wxBitmap m_disabledLeftBmp;
|
||||
wxBitmap m_activeRightBmp;
|
||||
wxBitmap m_disabledRightBmp;
|
||||
wxBitmap m_activeWindowListBmp;
|
||||
wxBitmap m_disabledWindowListBmp;
|
||||
wxBitmapBundle m_activeCloseBmp;
|
||||
wxBitmapBundle m_disabledCloseBmp;
|
||||
wxBitmapBundle m_activeLeftBmp;
|
||||
wxBitmapBundle m_disabledLeftBmp;
|
||||
wxBitmapBundle m_activeRightBmp;
|
||||
wxBitmapBundle m_disabledRightBmp;
|
||||
wxBitmapBundle m_activeWindowListBmp;
|
||||
wxBitmapBundle m_disabledWindowListBmp;
|
||||
|
||||
int m_fixedTabWidth;
|
||||
unsigned int m_flags;
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
int GetBorderWidth(wxWindow* wnd) wxOVERRIDE;
|
||||
int GetAdditionalBorderSpace(wxWindow* wnd) wxOVERRIDE;
|
||||
virtual wxSize GetTabSize(wxDC& dc, wxWindow* wnd, const wxString& caption,
|
||||
const wxBitmap& bitmap, bool active,
|
||||
const wxBitmapBundle& bitmap, bool active,
|
||||
int close_button_state, int* x_extent) wxOVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int closeButtonState,
|
||||
int* xExtent) wxOVERRIDE;
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
*/
|
||||
bool AddPage(wxWindow* page, const wxString& caption,
|
||||
bool select = false,
|
||||
const wxBitmap& bitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||
|
||||
/**
|
||||
Adds a new page.
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
bool InsertPage(size_t page_idx, wxWindow* page,
|
||||
const wxString& caption,
|
||||
bool select = false,
|
||||
const wxBitmap& bitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||
|
||||
/**
|
||||
Inserts a new page at the specified position.
|
||||
@@ -326,9 +326,9 @@ public:
|
||||
|
||||
/**
|
||||
Sets the bitmap for the page. To remove a bitmap from the tab caption, pass
|
||||
wxNullBitmap.
|
||||
an empty wxBitmapBundle.
|
||||
*/
|
||||
bool SetPageBitmap(size_t page, const wxBitmap& bitmap);
|
||||
bool SetPageBitmap(size_t page, const wxBitmapBundle& bitmap);
|
||||
|
||||
/**
|
||||
Sets the image index for the given page. @a image is an index into
|
||||
@@ -445,7 +445,7 @@ public:
|
||||
wxWindow* window; // page's associated window
|
||||
wxString caption; // caption displayed on the tab
|
||||
wxString tooltip; // tooltip displayed when hovering over tab title
|
||||
wxBitmap bitmap; // tab's bitmap
|
||||
wxBitmapBundle bitmap;// tab's bitmap
|
||||
wxRect rect; // tab's hit rectangle
|
||||
bool active; // true if the page is currently active
|
||||
};
|
||||
@@ -469,9 +469,9 @@ public:
|
||||
/// buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
||||
int location;
|
||||
/// button's hover bitmap
|
||||
wxBitmap bitmap;
|
||||
wxBitmapBundle bitmap;
|
||||
/// button's disabled bitmap
|
||||
wxBitmap disBitmap;
|
||||
wxBitmapBundle disBitmap;
|
||||
/// button's hit rectangle
|
||||
wxRect rect;
|
||||
};
|
||||
@@ -539,8 +539,8 @@ public:
|
||||
void RemoveButton(int id);
|
||||
void AddButton(int id,
|
||||
int location,
|
||||
const wxBitmap& normalBitmap = wxNullBitmap,
|
||||
const wxBitmap& disabledBitmap = wxNullBitmap);
|
||||
const wxBitmapBundle& normalBitmap = wxBitmapBundle(),
|
||||
const wxBitmapBundle& disabledBitmap = wxBitmapBundle());
|
||||
|
||||
size_t GetTabOffset() const;
|
||||
void SetTabOffset(size_t offset);
|
||||
|
||||
@@ -361,8 +361,8 @@ size_t wxAuiTabContainer::GetPageCount() const
|
||||
|
||||
void wxAuiTabContainer::AddButton(int id,
|
||||
int location,
|
||||
const wxBitmap& normalBitmap,
|
||||
const wxBitmap& disabledBitmap)
|
||||
const wxBitmapBundle& normalBitmap,
|
||||
const wxBitmapBundle& disabledBitmap)
|
||||
{
|
||||
wxAuiTabContainerButton button;
|
||||
button.id = id;
|
||||
@@ -1963,7 +1963,7 @@ void wxAuiNotebook::SetWindowStyleFlag(long style)
|
||||
bool wxAuiNotebook::AddPage(wxWindow* page,
|
||||
const wxString& caption,
|
||||
bool select,
|
||||
const wxBitmap& bitmap)
|
||||
const wxBitmapBundle& bitmap)
|
||||
{
|
||||
return InsertPage(GetPageCount(), page, caption, select, bitmap);
|
||||
}
|
||||
@@ -1972,7 +1972,7 @@ bool wxAuiNotebook::InsertPage(size_t page_idx,
|
||||
wxWindow* page,
|
||||
const wxString& caption,
|
||||
bool select,
|
||||
const wxBitmap& bitmap)
|
||||
const wxBitmapBundle& bitmap)
|
||||
{
|
||||
wxASSERT_MSG(page, wxT("page pointer must be non-NULL"));
|
||||
if (!page)
|
||||
@@ -2230,7 +2230,7 @@ wxString wxAuiNotebook::GetPageToolTip(size_t page_idx) const
|
||||
return page_info.tooltip;
|
||||
}
|
||||
|
||||
bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmap& bitmap)
|
||||
bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmapBundle& bitmap)
|
||||
{
|
||||
if (page_idx >= m_tabs.GetPageCount())
|
||||
return false;
|
||||
@@ -2264,7 +2264,7 @@ wxBitmap wxAuiNotebook::GetPageBitmap(size_t page_idx) const
|
||||
|
||||
// update our own tab catalog
|
||||
const wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx);
|
||||
return page_info.bitmap;
|
||||
return page_info.bitmap.GetBitmap(page_info.bitmap.GetDefaultSize());
|
||||
}
|
||||
|
||||
// GetSelection() returns the index of the currently active page
|
||||
@@ -3397,7 +3397,7 @@ int wxAuiNotebook::GetPageImage(size_t WXUNUSED(n)) const
|
||||
|
||||
bool wxAuiNotebook::SetPageImage(size_t n, int imageId)
|
||||
{
|
||||
return SetPageBitmap(n, GetImageList()->GetBitmap(imageId));
|
||||
return SetPageBitmap(n, GetBitmapBundle(imageId));
|
||||
}
|
||||
|
||||
int wxAuiNotebook::ChangeSelection(size_t n)
|
||||
@@ -3408,14 +3408,7 @@ int wxAuiNotebook::ChangeSelection(size_t n)
|
||||
bool wxAuiNotebook::AddPage(wxWindow *page, const wxString &text, bool select,
|
||||
int imageId)
|
||||
{
|
||||
if(HasImageList())
|
||||
{
|
||||
return AddPage(page, text, select, GetImageList()->GetBitmap(imageId));
|
||||
}
|
||||
else
|
||||
{
|
||||
return AddPage(page, text, select, wxNullBitmap);
|
||||
}
|
||||
return AddPage(page, text, select, GetBitmapBundle(imageId));
|
||||
}
|
||||
|
||||
bool wxAuiNotebook::DeleteAllPages()
|
||||
@@ -3432,15 +3425,7 @@ bool wxAuiNotebook::InsertPage(size_t index, wxWindow *page,
|
||||
const wxString &text, bool select,
|
||||
int imageId)
|
||||
{
|
||||
if(HasImageList())
|
||||
{
|
||||
return InsertPage(index, page, text, select,
|
||||
GetImageList()->GetBitmap(imageId));
|
||||
}
|
||||
else
|
||||
{
|
||||
return InsertPage(index, page, text, select, wxNullBitmap);
|
||||
}
|
||||
return InsertPage(index, page, text, select, GetBitmapBundle(imageId));
|
||||
}
|
||||
|
||||
namespace
|
||||
|
||||
@@ -128,26 +128,6 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
|
||||
return wxBitmap(img);
|
||||
}
|
||||
|
||||
// A utility function to scales a bitmap in place for use at the given scale
|
||||
// factor.
|
||||
void wxAuiScaleBitmap(wxBitmap& bmp, double scale)
|
||||
{
|
||||
#if wxUSE_IMAGE && !defined(__WXGTK3__) && !defined(__WXMAC__)
|
||||
// scale to a close round number to improve quality
|
||||
scale = floor(scale + 0.25);
|
||||
if (scale > 1.0 && !(bmp.GetScaleFactor() > 1.0))
|
||||
{
|
||||
wxImage img = bmp.ConvertToImage();
|
||||
img.Rescale(bmp.GetWidth()*scale, bmp.GetHeight()*scale,
|
||||
wxIMAGE_QUALITY_BOX_AVERAGE);
|
||||
bmp = wxBitmap(img);
|
||||
}
|
||||
#else
|
||||
wxUnusedVar(bmp);
|
||||
wxUnusedVar(scale);
|
||||
#endif // wxUSE_IMAGE
|
||||
}
|
||||
|
||||
static void DrawGradientRectangle(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxColour& start_color,
|
||||
@@ -805,8 +785,6 @@ void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc,
|
||||
break;
|
||||
}
|
||||
|
||||
wxAuiScaleBitmap(bmp, window->GetDPIScaleFactor());
|
||||
|
||||
wxRect rect = _rect;
|
||||
|
||||
rect.y = rect.y + (rect.height/2) - (bmp.GetScaledHeight()/2);
|
||||
|
||||
@@ -71,7 +71,6 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
|
||||
const wxColour& color);
|
||||
|
||||
// This function is defined in dockart.cpp.
|
||||
void wxAuiScaleBitmap(wxBitmap& bmp, double scale);
|
||||
float wxAuiGetColourContrast(const wxColour& c1, const wxColour& c2);
|
||||
|
||||
wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size);
|
||||
@@ -249,9 +248,9 @@ void wxAuiGenericTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
|
||||
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);
|
||||
|
||||
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
|
||||
tot_width -= m_activeCloseBmp.GetScaledWidth();
|
||||
tot_width -= m_activeCloseBmp.GetPreferredSizeFor(wnd).x;
|
||||
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
|
||||
tot_width -= m_activeWindowListBmp.GetScaledWidth();
|
||||
tot_width -= m_activeWindowListBmp.GetPreferredSizeFor(wnd).x;
|
||||
|
||||
if (tab_count > 0)
|
||||
{
|
||||
@@ -559,13 +558,15 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
||||
{
|
||||
bitmap_offset = tab_x + wnd->FromDIP(8);
|
||||
|
||||
const wxBitmap bitmap = page.bitmap.GetBitmapFor(wnd);
|
||||
|
||||
// draw bitmap
|
||||
dc.DrawBitmap(page.bitmap,
|
||||
dc.DrawBitmap(bitmap,
|
||||
bitmap_offset,
|
||||
drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetScaledHeight()/2),
|
||||
drawn_tab_yoff + (drawn_tab_height/2) - (bitmap.GetScaledHeight()/2),
|
||||
true);
|
||||
|
||||
text_offset = bitmap_offset + page.bitmap.GetScaledWidth();
|
||||
text_offset = bitmap_offset + bitmap.GetScaledWidth();
|
||||
text_offset += wnd->FromDIP(3); // bitmap padding
|
||||
}
|
||||
else
|
||||
@@ -577,15 +578,15 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
||||
int close_button_width = 0;
|
||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||
{
|
||||
wxBitmap bmp = m_disabledCloseBmp;
|
||||
wxBitmapBundle bb = m_disabledCloseBmp;
|
||||
|
||||
if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
|
||||
close_button_state == wxAUI_BUTTON_STATE_PRESSED)
|
||||
{
|
||||
bmp = m_activeCloseBmp;
|
||||
bb = m_activeCloseBmp;
|
||||
}
|
||||
|
||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
||||
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||
|
||||
int offsetY = tab_y-1;
|
||||
if (m_flags & wxAUI_NB_BOTTOM)
|
||||
@@ -627,8 +628,12 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
||||
wxRect focusRectBitmap;
|
||||
|
||||
if (page.bitmap.IsOk())
|
||||
focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetScaledHeight()/2),
|
||||
page.bitmap.GetScaledWidth(), page.bitmap.GetScaledHeight());
|
||||
{
|
||||
const wxBitmap bitmap = page.bitmap.GetBitmapFor(wnd);
|
||||
|
||||
focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (bitmap.GetScaledHeight()/2),
|
||||
bitmap.GetScaledWidth(), bitmap.GetScaledHeight());
|
||||
}
|
||||
|
||||
if (page.bitmap.IsOk() && draw_text.IsEmpty())
|
||||
focusRect = focusRectBitmap;
|
||||
@@ -672,7 +677,7 @@ int wxAuiGenericTabArt::GetAdditionalBorderSpace(wxWindow* WXUNUSED(wnd))
|
||||
wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool WXUNUSED(active),
|
||||
int close_button_state,
|
||||
int* x_extent)
|
||||
@@ -692,15 +697,17 @@ wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
|
||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||
{
|
||||
// increase by button size plus the padding
|
||||
tab_width += m_activeCloseBmp.GetScaledWidth() + wnd->FromDIP(3);
|
||||
tab_width += m_activeCloseBmp.GetBitmapFor(wnd).GetScaledWidth() + wnd->FromDIP(3);
|
||||
}
|
||||
|
||||
// if there's a bitmap, add space for it
|
||||
if (bitmap.IsOk())
|
||||
{
|
||||
const wxSize bitmapSize = bitmap.GetPreferredSizeFor(wnd);
|
||||
|
||||
// increase by bitmap plus right side bitmap padding
|
||||
tab_width += bitmap.GetScaledWidth() + wnd->FromDIP(3);
|
||||
tab_height = wxMax(tab_height, bitmap.GetScaledHeight());
|
||||
tab_width += bitmapSize.x + wnd->FromDIP(3);
|
||||
tab_height = wxMax(tab_height, bitmapSize.y);
|
||||
}
|
||||
|
||||
// add padding
|
||||
@@ -727,42 +734,42 @@ void wxAuiGenericTabArt::DrawButton(wxDC& dc,
|
||||
int orientation,
|
||||
wxRect* out_rect)
|
||||
{
|
||||
wxBitmap bmp;
|
||||
wxBitmapBundle bb;
|
||||
wxRect rect;
|
||||
|
||||
switch (bitmap_id)
|
||||
{
|
||||
case wxAUI_BUTTON_CLOSE:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledCloseBmp;
|
||||
bb = m_disabledCloseBmp;
|
||||
else
|
||||
bmp = m_activeCloseBmp;
|
||||
bb = m_activeCloseBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_LEFT:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledLeftBmp;
|
||||
bb = m_disabledLeftBmp;
|
||||
else
|
||||
bmp = m_activeLeftBmp;
|
||||
bb = m_activeLeftBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_RIGHT:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledRightBmp;
|
||||
bb = m_disabledRightBmp;
|
||||
else
|
||||
bmp = m_activeRightBmp;
|
||||
bb = m_activeRightBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_WINDOWLIST:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledWindowListBmp;
|
||||
bb = m_disabledWindowListBmp;
|
||||
else
|
||||
bmp = m_activeWindowListBmp;
|
||||
bb = m_activeWindowListBmp;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!bmp.IsOk())
|
||||
if (!bb.IsOk())
|
||||
return;
|
||||
|
||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
||||
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||
|
||||
rect = in_rect;
|
||||
|
||||
@@ -808,7 +815,7 @@ int wxAuiGenericTabArt::ShowDropDown(wxWindow* wnd,
|
||||
|
||||
wxMenuItem* item = new wxMenuItem(NULL, 1000+i, caption);
|
||||
if (page.bitmap.IsOk())
|
||||
item->SetBitmap(page.bitmap);
|
||||
item->SetBitmap(page.bitmap.GetBitmapFor(wnd));
|
||||
menuPopup.Append(item);
|
||||
}
|
||||
|
||||
@@ -856,7 +863,7 @@ int wxAuiGenericTabArt::GetBestTabCtrlSize(wxWindow* wnd,
|
||||
{
|
||||
wxAuiNotebookPage& page = pages.Item(i);
|
||||
|
||||
wxBitmap bmp;
|
||||
wxBitmapBundle bmp;
|
||||
if (measureBmp.IsOk())
|
||||
bmp = measureBmp;
|
||||
else
|
||||
@@ -972,9 +979,9 @@ void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
|
||||
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);
|
||||
|
||||
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
|
||||
tot_width -= m_activeCloseBmp.GetScaledWidth();
|
||||
tot_width -= m_activeCloseBmp.GetBitmapFor(wnd).GetScaledWidth();
|
||||
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
|
||||
tot_width -= m_activeWindowListBmp.GetScaledWidth();
|
||||
tot_width -= m_activeWindowListBmp.GetBitmapFor(wnd).GetScaledWidth();
|
||||
|
||||
if (tab_count > 0)
|
||||
{
|
||||
@@ -1133,13 +1140,10 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
|
||||
// draw close button if necessary
|
||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||
{
|
||||
wxBitmap bmp;
|
||||
if (page.active)
|
||||
bmp = m_activeCloseBmp;
|
||||
else
|
||||
bmp = m_disabledCloseBmp;
|
||||
const wxBitmapBundle bb(page.active ? m_activeCloseBmp
|
||||
: m_disabledCloseBmp);
|
||||
|
||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
||||
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||
|
||||
wxRect rect(tab_x + tab_width - bmp.GetScaledWidth() - 1,
|
||||
tab_y + (tab_height/2) - (bmp.GetScaledHeight()/2) + 1,
|
||||
@@ -1215,7 +1219,7 @@ int wxAuiSimpleTabArt::GetAdditionalBorderSpace(wxWindow* WXUNUSED(wnd))
|
||||
wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& WXUNUSED(bitmap),
|
||||
const wxBitmapBundle& WXUNUSED(bitmap),
|
||||
bool WXUNUSED(active),
|
||||
int close_button_state,
|
||||
int* x_extent)
|
||||
@@ -1231,7 +1235,7 @@ wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
|
||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||
{
|
||||
// increase by button size plus the padding
|
||||
tab_width += m_activeCloseBmp.GetScaledWidth() + wnd->FromDIP(3);
|
||||
tab_width += m_activeCloseBmp.GetBitmapFor(wnd).GetScaledWidth() + wnd->FromDIP(3);
|
||||
}
|
||||
|
||||
if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH)
|
||||
@@ -1253,41 +1257,41 @@ void wxAuiSimpleTabArt::DrawButton(wxDC& dc,
|
||||
int orientation,
|
||||
wxRect* out_rect)
|
||||
{
|
||||
wxBitmap bmp;
|
||||
wxBitmapBundle bb;
|
||||
wxRect rect;
|
||||
|
||||
switch (bitmap_id)
|
||||
{
|
||||
case wxAUI_BUTTON_CLOSE:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledCloseBmp;
|
||||
bb = m_disabledCloseBmp;
|
||||
else
|
||||
bmp = m_activeCloseBmp;
|
||||
bb = m_activeCloseBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_LEFT:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledLeftBmp;
|
||||
bb = m_disabledLeftBmp;
|
||||
else
|
||||
bmp = m_activeLeftBmp;
|
||||
bb = m_activeLeftBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_RIGHT:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledRightBmp;
|
||||
bb = m_disabledRightBmp;
|
||||
else
|
||||
bmp = m_activeRightBmp;
|
||||
bb = m_activeRightBmp;
|
||||
break;
|
||||
case wxAUI_BUTTON_WINDOWLIST:
|
||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||
bmp = m_disabledWindowListBmp;
|
||||
bb = m_disabledWindowListBmp;
|
||||
else
|
||||
bmp = m_activeWindowListBmp;
|
||||
bb = m_activeWindowListBmp;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bmp.IsOk())
|
||||
if (!bb.IsOk())
|
||||
return;
|
||||
|
||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
||||
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||
|
||||
rect = in_rect;
|
||||
|
||||
|
||||
@@ -310,8 +310,10 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
|
||||
int bitmap_offset;
|
||||
bitmap_offset = textX;
|
||||
|
||||
const wxBitmap bitmap = page.bitmap.GetBitmapFor(wnd);
|
||||
|
||||
// draw bitmap
|
||||
int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetScaledHeight()) / 2;
|
||||
int bitmapY = tab_rect.y +(tab_rect.height - bitmap.GetScaledHeight()) / 2;
|
||||
if(!page.active)
|
||||
{
|
||||
if (tab_pos == wxAUI_NB_TOP)
|
||||
@@ -319,12 +321,12 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
|
||||
else
|
||||
bitmapY -= style_notebook->ythickness / 2;
|
||||
}
|
||||
dc.DrawBitmap(page.bitmap,
|
||||
dc.DrawBitmap(bitmap,
|
||||
bitmap_offset,
|
||||
bitmapY,
|
||||
true);
|
||||
|
||||
textX += page.bitmap.GetScaledWidth() + padding;
|
||||
textX += bitmap.GetScaledWidth() + padding;
|
||||
}
|
||||
|
||||
wxCoord textW, textH, textY;
|
||||
@@ -490,7 +492,7 @@ int wxAuiGtkTabArt::GetAdditionalBorderSpace(wxWindow* wnd)
|
||||
wxSize wxAuiGtkTabArt::GetTabSize(wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int close_button_state,
|
||||
int* x_extent)
|
||||
|
||||
@@ -204,7 +204,7 @@ void wxAuiMSWTabArt::DrawTab(wxDC& dc,
|
||||
|
||||
dc.SetFont(wnd->GetFont());
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
dc.DrawLabel(page.caption, page.bitmap, textRect, wxALIGN_CENTRE);
|
||||
dc.DrawLabel(page.caption, page.bitmap.GetBitmapFor(wnd), textRect, wxALIGN_CENTRE);
|
||||
|
||||
// draw focus rectangle
|
||||
if ( page.active && (wnd->FindFocus() == wnd) )
|
||||
@@ -276,7 +276,7 @@ int wxAuiMSWTabArt::GetAdditionalBorderSpace(wxWindow* wnd)
|
||||
wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc,
|
||||
wxWindow* wnd,
|
||||
const wxString& caption,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmapBundle& bitmap,
|
||||
bool active,
|
||||
int close_button_state,
|
||||
int* x_extent)
|
||||
@@ -306,8 +306,10 @@ wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc,
|
||||
// if there's a bitmap, add space for it
|
||||
if ( bitmap.IsOk() )
|
||||
{
|
||||
tabWidth += bitmap.GetWidth() + wnd->FromDIP(3); // bitmap padding
|
||||
tabHeight = wxMax(tabHeight, bitmap.GetHeight() + wnd->FromDIP(2));
|
||||
const wxSize bitmapSize = bitmap.GetPreferredSizeFor(wnd);
|
||||
|
||||
tabWidth += bitmapSize.x + wnd->FromDIP(3); // bitmap padding
|
||||
tabHeight = wxMax(tabHeight, bitmapSize.y + wnd->FromDIP(2));
|
||||
}
|
||||
|
||||
// add padding
|
||||
|
||||
Reference in New Issue
Block a user