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
|
wxWindow* window; // page's associated window
|
||||||
wxString caption; // caption displayed on the tab
|
wxString caption; // caption displayed on the tab
|
||||||
wxString tooltip; // tooltip displayed when hovering over tab title
|
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
|
wxRect rect; // tab's hit rectangle
|
||||||
bool active; // true if the page is currently active
|
bool active; // true if the page is currently active
|
||||||
bool hover; // true if mouse hovering over tab
|
bool hover; // true if mouse hovering over tab
|
||||||
@@ -104,8 +104,8 @@ public:
|
|||||||
int id; // button's id
|
int id; // button's id
|
||||||
int curState; // current state (normal, hover, pressed, etc.)
|
int curState; // current state (normal, hover, pressed, etc.)
|
||||||
int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
||||||
wxBitmap bitmap; // button's hover bitmap
|
wxBitmapBundle bitmap; // button's hover bitmap
|
||||||
wxBitmap disBitmap; // button's disabled bitmap
|
wxBitmapBundle disBitmap; // button's disabled bitmap
|
||||||
wxRect rect; // button's hit rectangle
|
wxRect rect; // button's hit rectangle
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -156,8 +156,8 @@ public:
|
|||||||
void RemoveButton(int id);
|
void RemoveButton(int id);
|
||||||
void AddButton(int id,
|
void AddButton(int id,
|
||||||
int location,
|
int location,
|
||||||
const wxBitmap& normalBitmap = wxNullBitmap,
|
const wxBitmapBundle& normalBitmap = wxBitmapBundle(),
|
||||||
const wxBitmap& disabledBitmap = wxNullBitmap);
|
const wxBitmapBundle& disabledBitmap = wxBitmapBundle());
|
||||||
|
|
||||||
size_t GetTabOffset() const;
|
size_t GetTabOffset() const;
|
||||||
void SetTabOffset(size_t offset);
|
void SetTabOffset(size_t offset);
|
||||||
@@ -279,13 +279,13 @@ public:
|
|||||||
bool AddPage(wxWindow* page,
|
bool AddPage(wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
bool InsertPage(size_t pageIdx,
|
bool InsertPage(size_t pageIdx,
|
||||||
wxWindow* page,
|
wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
bool DeletePage(size_t page) wxOVERRIDE;
|
bool DeletePage(size_t page) wxOVERRIDE;
|
||||||
bool RemovePage(size_t page) wxOVERRIDE;
|
bool RemovePage(size_t page) wxOVERRIDE;
|
||||||
@@ -300,7 +300,7 @@ public:
|
|||||||
bool SetPageToolTip(size_t page, const wxString& text);
|
bool SetPageToolTip(size_t page, const wxString& text);
|
||||||
wxString GetPageToolTip(size_t pageIdx) const;
|
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;
|
wxBitmap GetPageBitmap(size_t pageIdx) const;
|
||||||
|
|
||||||
int SetSelection(size_t newPage) wxOVERRIDE;
|
int SetSelection(size_t newPage) wxOVERRIDE;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "wx/font.h"
|
#include "wx/font.h"
|
||||||
#include "wx/pen.h"
|
#include "wx/pen.h"
|
||||||
#include "wx/brush.h"
|
#include "wx/brush.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bmpbndl.h"
|
||||||
|
|
||||||
|
|
||||||
class wxAuiNotebookPage;
|
class wxAuiNotebookPage;
|
||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int closeButtonState,
|
int closeButtonState,
|
||||||
int* xExtent) = 0;
|
int* xExtent) = 0;
|
||||||
@@ -176,7 +176,7 @@ public:
|
|||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int closeButtonState,
|
int closeButtonState,
|
||||||
int* xExtent) wxOVERRIDE;
|
int* xExtent) wxOVERRIDE;
|
||||||
@@ -203,14 +203,14 @@ protected:
|
|||||||
wxPen m_borderPen;
|
wxPen m_borderPen;
|
||||||
wxBrush m_baseColourBrush;
|
wxBrush m_baseColourBrush;
|
||||||
wxColour m_activeColour;
|
wxColour m_activeColour;
|
||||||
wxBitmap m_activeCloseBmp;
|
wxBitmapBundle m_activeCloseBmp;
|
||||||
wxBitmap m_disabledCloseBmp;
|
wxBitmapBundle m_disabledCloseBmp;
|
||||||
wxBitmap m_activeLeftBmp;
|
wxBitmapBundle m_activeLeftBmp;
|
||||||
wxBitmap m_disabledLeftBmp;
|
wxBitmapBundle m_disabledLeftBmp;
|
||||||
wxBitmap m_activeRightBmp;
|
wxBitmapBundle m_activeRightBmp;
|
||||||
wxBitmap m_disabledRightBmp;
|
wxBitmapBundle m_disabledRightBmp;
|
||||||
wxBitmap m_activeWindowListBmp;
|
wxBitmapBundle m_activeWindowListBmp;
|
||||||
wxBitmap m_disabledWindowListBmp;
|
wxBitmapBundle m_disabledWindowListBmp;
|
||||||
|
|
||||||
int m_fixedTabWidth;
|
int m_fixedTabWidth;
|
||||||
int m_tabCtrlHeight;
|
int m_tabCtrlHeight;
|
||||||
@@ -279,7 +279,7 @@ public:
|
|||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int closeButtonState,
|
int closeButtonState,
|
||||||
int* xExtent) wxOVERRIDE;
|
int* xExtent) wxOVERRIDE;
|
||||||
@@ -303,14 +303,14 @@ protected:
|
|||||||
wxBrush m_normalBkBrush;
|
wxBrush m_normalBkBrush;
|
||||||
wxBrush m_selectedBkBrush;
|
wxBrush m_selectedBkBrush;
|
||||||
wxBrush m_bkBrush;
|
wxBrush m_bkBrush;
|
||||||
wxBitmap m_activeCloseBmp;
|
wxBitmapBundle m_activeCloseBmp;
|
||||||
wxBitmap m_disabledCloseBmp;
|
wxBitmapBundle m_disabledCloseBmp;
|
||||||
wxBitmap m_activeLeftBmp;
|
wxBitmapBundle m_activeLeftBmp;
|
||||||
wxBitmap m_disabledLeftBmp;
|
wxBitmapBundle m_disabledLeftBmp;
|
||||||
wxBitmap m_activeRightBmp;
|
wxBitmapBundle m_activeRightBmp;
|
||||||
wxBitmap m_disabledRightBmp;
|
wxBitmapBundle m_disabledRightBmp;
|
||||||
wxBitmap m_activeWindowListBmp;
|
wxBitmapBundle m_activeWindowListBmp;
|
||||||
wxBitmap m_disabledWindowListBmp;
|
wxBitmapBundle m_disabledWindowListBmp;
|
||||||
|
|
||||||
int m_fixedTabWidth;
|
int m_fixedTabWidth;
|
||||||
unsigned int m_flags;
|
unsigned int m_flags;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
int GetBorderWidth(wxWindow* wnd) wxOVERRIDE;
|
int GetBorderWidth(wxWindow* wnd) wxOVERRIDE;
|
||||||
int GetAdditionalBorderSpace(wxWindow* wnd) wxOVERRIDE;
|
int GetAdditionalBorderSpace(wxWindow* wnd) wxOVERRIDE;
|
||||||
virtual wxSize GetTabSize(wxDC& dc, wxWindow* wnd, const wxString& caption,
|
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;
|
int close_button_state, int* x_extent) wxOVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int closeButtonState,
|
int closeButtonState,
|
||||||
int* xExtent) wxOVERRIDE;
|
int* xExtent) wxOVERRIDE;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool AddPage(wxWindow* page, const wxString& caption,
|
bool AddPage(wxWindow* page, const wxString& caption,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a new page.
|
Adds a new page.
|
||||||
@@ -272,7 +272,7 @@ public:
|
|||||||
bool InsertPage(size_t page_idx, wxWindow* page,
|
bool InsertPage(size_t page_idx, wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
const wxBitmap& bitmap = wxNullBitmap);
|
const wxBitmapBundle& bitmap = wxBitmapBundle());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Inserts a new page at the specified position.
|
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
|
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
|
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
|
wxWindow* window; // page's associated window
|
||||||
wxString caption; // caption displayed on the tab
|
wxString caption; // caption displayed on the tab
|
||||||
wxString tooltip; // tooltip displayed when hovering over tab title
|
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
|
wxRect rect; // tab's hit rectangle
|
||||||
bool active; // true if the page is currently active
|
bool active; // true if the page is currently active
|
||||||
};
|
};
|
||||||
@@ -469,9 +469,9 @@ public:
|
|||||||
/// buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
/// buttons location (wxLEFT, wxRIGHT, or wxCENTER)
|
||||||
int location;
|
int location;
|
||||||
/// button's hover bitmap
|
/// button's hover bitmap
|
||||||
wxBitmap bitmap;
|
wxBitmapBundle bitmap;
|
||||||
/// button's disabled bitmap
|
/// button's disabled bitmap
|
||||||
wxBitmap disBitmap;
|
wxBitmapBundle disBitmap;
|
||||||
/// button's hit rectangle
|
/// button's hit rectangle
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
};
|
};
|
||||||
@@ -539,8 +539,8 @@ public:
|
|||||||
void RemoveButton(int id);
|
void RemoveButton(int id);
|
||||||
void AddButton(int id,
|
void AddButton(int id,
|
||||||
int location,
|
int location,
|
||||||
const wxBitmap& normalBitmap = wxNullBitmap,
|
const wxBitmapBundle& normalBitmap = wxBitmapBundle(),
|
||||||
const wxBitmap& disabledBitmap = wxNullBitmap);
|
const wxBitmapBundle& disabledBitmap = wxBitmapBundle());
|
||||||
|
|
||||||
size_t GetTabOffset() const;
|
size_t GetTabOffset() const;
|
||||||
void SetTabOffset(size_t offset);
|
void SetTabOffset(size_t offset);
|
||||||
|
|||||||
@@ -361,8 +361,8 @@ size_t wxAuiTabContainer::GetPageCount() const
|
|||||||
|
|
||||||
void wxAuiTabContainer::AddButton(int id,
|
void wxAuiTabContainer::AddButton(int id,
|
||||||
int location,
|
int location,
|
||||||
const wxBitmap& normalBitmap,
|
const wxBitmapBundle& normalBitmap,
|
||||||
const wxBitmap& disabledBitmap)
|
const wxBitmapBundle& disabledBitmap)
|
||||||
{
|
{
|
||||||
wxAuiTabContainerButton button;
|
wxAuiTabContainerButton button;
|
||||||
button.id = id;
|
button.id = id;
|
||||||
@@ -1963,7 +1963,7 @@ void wxAuiNotebook::SetWindowStyleFlag(long style)
|
|||||||
bool wxAuiNotebook::AddPage(wxWindow* page,
|
bool wxAuiNotebook::AddPage(wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select,
|
bool select,
|
||||||
const wxBitmap& bitmap)
|
const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
return InsertPage(GetPageCount(), page, caption, select, bitmap);
|
return InsertPage(GetPageCount(), page, caption, select, bitmap);
|
||||||
}
|
}
|
||||||
@@ -1972,7 +1972,7 @@ bool wxAuiNotebook::InsertPage(size_t page_idx,
|
|||||||
wxWindow* page,
|
wxWindow* page,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
bool select,
|
bool select,
|
||||||
const wxBitmap& bitmap)
|
const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(page, wxT("page pointer must be non-NULL"));
|
wxASSERT_MSG(page, wxT("page pointer must be non-NULL"));
|
||||||
if (!page)
|
if (!page)
|
||||||
@@ -2230,7 +2230,7 @@ wxString wxAuiNotebook::GetPageToolTip(size_t page_idx) const
|
|||||||
return page_info.tooltip;
|
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())
|
if (page_idx >= m_tabs.GetPageCount())
|
||||||
return false;
|
return false;
|
||||||
@@ -2264,7 +2264,7 @@ wxBitmap wxAuiNotebook::GetPageBitmap(size_t page_idx) const
|
|||||||
|
|
||||||
// update our own tab catalog
|
// update our own tab catalog
|
||||||
const wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx);
|
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
|
// 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)
|
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)
|
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,
|
bool wxAuiNotebook::AddPage(wxWindow *page, const wxString &text, bool select,
|
||||||
int imageId)
|
int imageId)
|
||||||
{
|
{
|
||||||
if(HasImageList())
|
return AddPage(page, text, select, GetBitmapBundle(imageId));
|
||||||
{
|
|
||||||
return AddPage(page, text, select, GetImageList()->GetBitmap(imageId));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return AddPage(page, text, select, wxNullBitmap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAuiNotebook::DeleteAllPages()
|
bool wxAuiNotebook::DeleteAllPages()
|
||||||
@@ -3432,15 +3425,7 @@ bool wxAuiNotebook::InsertPage(size_t index, wxWindow *page,
|
|||||||
const wxString &text, bool select,
|
const wxString &text, bool select,
|
||||||
int imageId)
|
int imageId)
|
||||||
{
|
{
|
||||||
if(HasImageList())
|
return InsertPage(index, page, text, select, GetBitmapBundle(imageId));
|
||||||
{
|
|
||||||
return InsertPage(index, page, text, select,
|
|
||||||
GetImageList()->GetBitmap(imageId));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return InsertPage(index, page, text, select, wxNullBitmap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|||||||
@@ -128,26 +128,6 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
|
|||||||
return wxBitmap(img);
|
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,
|
static void DrawGradientRectangle(wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
const wxColour& start_color,
|
const wxColour& start_color,
|
||||||
@@ -805,8 +785,6 @@ void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAuiScaleBitmap(bmp, window->GetDPIScaleFactor());
|
|
||||||
|
|
||||||
wxRect rect = _rect;
|
wxRect rect = _rect;
|
||||||
|
|
||||||
rect.y = rect.y + (rect.height/2) - (bmp.GetScaledHeight()/2);
|
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);
|
const wxColour& color);
|
||||||
|
|
||||||
// This function is defined in dockart.cpp.
|
// This function is defined in dockart.cpp.
|
||||||
void wxAuiScaleBitmap(wxBitmap& bmp, double scale);
|
|
||||||
float wxAuiGetColourContrast(const wxColour& c1, const wxColour& c2);
|
float wxAuiGetColourContrast(const wxColour& c1, const wxColour& c2);
|
||||||
|
|
||||||
wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size);
|
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);
|
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);
|
||||||
|
|
||||||
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
|
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)
|
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
|
||||||
tot_width -= m_activeWindowListBmp.GetScaledWidth();
|
tot_width -= m_activeWindowListBmp.GetPreferredSizeFor(wnd).x;
|
||||||
|
|
||||||
if (tab_count > 0)
|
if (tab_count > 0)
|
||||||
{
|
{
|
||||||
@@ -559,13 +558,15 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
|||||||
{
|
{
|
||||||
bitmap_offset = tab_x + wnd->FromDIP(8);
|
bitmap_offset = tab_x + wnd->FromDIP(8);
|
||||||
|
|
||||||
|
const wxBitmap bitmap = page.bitmap.GetBitmapFor(wnd);
|
||||||
|
|
||||||
// draw bitmap
|
// draw bitmap
|
||||||
dc.DrawBitmap(page.bitmap,
|
dc.DrawBitmap(bitmap,
|
||||||
bitmap_offset,
|
bitmap_offset,
|
||||||
drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetScaledHeight()/2),
|
drawn_tab_yoff + (drawn_tab_height/2) - (bitmap.GetScaledHeight()/2),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
text_offset = bitmap_offset + page.bitmap.GetScaledWidth();
|
text_offset = bitmap_offset + bitmap.GetScaledWidth();
|
||||||
text_offset += wnd->FromDIP(3); // bitmap padding
|
text_offset += wnd->FromDIP(3); // bitmap padding
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -577,15 +578,15 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
|||||||
int close_button_width = 0;
|
int close_button_width = 0;
|
||||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||||
{
|
{
|
||||||
wxBitmap bmp = m_disabledCloseBmp;
|
wxBitmapBundle bb = m_disabledCloseBmp;
|
||||||
|
|
||||||
if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
|
if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
|
||||||
close_button_state == wxAUI_BUTTON_STATE_PRESSED)
|
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;
|
int offsetY = tab_y-1;
|
||||||
if (m_flags & wxAUI_NB_BOTTOM)
|
if (m_flags & wxAUI_NB_BOTTOM)
|
||||||
@@ -627,8 +628,12 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
|
|||||||
wxRect focusRectBitmap;
|
wxRect focusRectBitmap;
|
||||||
|
|
||||||
if (page.bitmap.IsOk())
|
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())
|
if (page.bitmap.IsOk() && draw_text.IsEmpty())
|
||||||
focusRect = focusRectBitmap;
|
focusRect = focusRectBitmap;
|
||||||
@@ -672,7 +677,7 @@ int wxAuiGenericTabArt::GetAdditionalBorderSpace(wxWindow* WXUNUSED(wnd))
|
|||||||
wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
|
wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool WXUNUSED(active),
|
bool WXUNUSED(active),
|
||||||
int close_button_state,
|
int close_button_state,
|
||||||
int* x_extent)
|
int* x_extent)
|
||||||
@@ -692,15 +697,17 @@ wxSize wxAuiGenericTabArt::GetTabSize(wxDC& dc,
|
|||||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||||
{
|
{
|
||||||
// increase by button size plus the padding
|
// 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 there's a bitmap, add space for it
|
||||||
if (bitmap.IsOk())
|
if (bitmap.IsOk())
|
||||||
{
|
{
|
||||||
|
const wxSize bitmapSize = bitmap.GetPreferredSizeFor(wnd);
|
||||||
|
|
||||||
// increase by bitmap plus right side bitmap padding
|
// increase by bitmap plus right side bitmap padding
|
||||||
tab_width += bitmap.GetScaledWidth() + wnd->FromDIP(3);
|
tab_width += bitmapSize.x + wnd->FromDIP(3);
|
||||||
tab_height = wxMax(tab_height, bitmap.GetScaledHeight());
|
tab_height = wxMax(tab_height, bitmapSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add padding
|
// add padding
|
||||||
@@ -727,42 +734,42 @@ void wxAuiGenericTabArt::DrawButton(wxDC& dc,
|
|||||||
int orientation,
|
int orientation,
|
||||||
wxRect* out_rect)
|
wxRect* out_rect)
|
||||||
{
|
{
|
||||||
wxBitmap bmp;
|
wxBitmapBundle bb;
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
|
|
||||||
switch (bitmap_id)
|
switch (bitmap_id)
|
||||||
{
|
{
|
||||||
case wxAUI_BUTTON_CLOSE:
|
case wxAUI_BUTTON_CLOSE:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledCloseBmp;
|
bb = m_disabledCloseBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeCloseBmp;
|
bb = m_activeCloseBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_LEFT:
|
case wxAUI_BUTTON_LEFT:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledLeftBmp;
|
bb = m_disabledLeftBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeLeftBmp;
|
bb = m_activeLeftBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_RIGHT:
|
case wxAUI_BUTTON_RIGHT:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledRightBmp;
|
bb = m_disabledRightBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeRightBmp;
|
bb = m_activeRightBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_WINDOWLIST:
|
case wxAUI_BUTTON_WINDOWLIST:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledWindowListBmp;
|
bb = m_disabledWindowListBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeWindowListBmp;
|
bb = m_activeWindowListBmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!bmp.IsOk())
|
if (!bb.IsOk())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||||
|
|
||||||
rect = in_rect;
|
rect = in_rect;
|
||||||
|
|
||||||
@@ -808,7 +815,7 @@ int wxAuiGenericTabArt::ShowDropDown(wxWindow* wnd,
|
|||||||
|
|
||||||
wxMenuItem* item = new wxMenuItem(NULL, 1000+i, caption);
|
wxMenuItem* item = new wxMenuItem(NULL, 1000+i, caption);
|
||||||
if (page.bitmap.IsOk())
|
if (page.bitmap.IsOk())
|
||||||
item->SetBitmap(page.bitmap);
|
item->SetBitmap(page.bitmap.GetBitmapFor(wnd));
|
||||||
menuPopup.Append(item);
|
menuPopup.Append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +863,7 @@ int wxAuiGenericTabArt::GetBestTabCtrlSize(wxWindow* wnd,
|
|||||||
{
|
{
|
||||||
wxAuiNotebookPage& page = pages.Item(i);
|
wxAuiNotebookPage& page = pages.Item(i);
|
||||||
|
|
||||||
wxBitmap bmp;
|
wxBitmapBundle bmp;
|
||||||
if (measureBmp.IsOk())
|
if (measureBmp.IsOk())
|
||||||
bmp = measureBmp;
|
bmp = measureBmp;
|
||||||
else
|
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);
|
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);
|
||||||
|
|
||||||
if (m_flags & wxAUI_NB_CLOSE_BUTTON)
|
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)
|
if (m_flags & wxAUI_NB_WINDOWLIST_BUTTON)
|
||||||
tot_width -= m_activeWindowListBmp.GetScaledWidth();
|
tot_width -= m_activeWindowListBmp.GetBitmapFor(wnd).GetScaledWidth();
|
||||||
|
|
||||||
if (tab_count > 0)
|
if (tab_count > 0)
|
||||||
{
|
{
|
||||||
@@ -1133,13 +1140,10 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
|
|||||||
// draw close button if necessary
|
// draw close button if necessary
|
||||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||||
{
|
{
|
||||||
wxBitmap bmp;
|
const wxBitmapBundle bb(page.active ? m_activeCloseBmp
|
||||||
if (page.active)
|
: m_disabledCloseBmp);
|
||||||
bmp = m_activeCloseBmp;
|
|
||||||
else
|
|
||||||
bmp = m_disabledCloseBmp;
|
|
||||||
|
|
||||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||||
|
|
||||||
wxRect rect(tab_x + tab_width - bmp.GetScaledWidth() - 1,
|
wxRect rect(tab_x + tab_width - bmp.GetScaledWidth() - 1,
|
||||||
tab_y + (tab_height/2) - (bmp.GetScaledHeight()/2) + 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,
|
wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& WXUNUSED(bitmap),
|
const wxBitmapBundle& WXUNUSED(bitmap),
|
||||||
bool WXUNUSED(active),
|
bool WXUNUSED(active),
|
||||||
int close_button_state,
|
int close_button_state,
|
||||||
int* x_extent)
|
int* x_extent)
|
||||||
@@ -1231,7 +1235,7 @@ wxSize wxAuiSimpleTabArt::GetTabSize(wxDC& dc,
|
|||||||
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
|
||||||
{
|
{
|
||||||
// increase by button size plus the padding
|
// 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)
|
if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH)
|
||||||
@@ -1253,41 +1257,41 @@ void wxAuiSimpleTabArt::DrawButton(wxDC& dc,
|
|||||||
int orientation,
|
int orientation,
|
||||||
wxRect* out_rect)
|
wxRect* out_rect)
|
||||||
{
|
{
|
||||||
wxBitmap bmp;
|
wxBitmapBundle bb;
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
|
|
||||||
switch (bitmap_id)
|
switch (bitmap_id)
|
||||||
{
|
{
|
||||||
case wxAUI_BUTTON_CLOSE:
|
case wxAUI_BUTTON_CLOSE:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledCloseBmp;
|
bb = m_disabledCloseBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeCloseBmp;
|
bb = m_activeCloseBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_LEFT:
|
case wxAUI_BUTTON_LEFT:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledLeftBmp;
|
bb = m_disabledLeftBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeLeftBmp;
|
bb = m_activeLeftBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_RIGHT:
|
case wxAUI_BUTTON_RIGHT:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledRightBmp;
|
bb = m_disabledRightBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeRightBmp;
|
bb = m_activeRightBmp;
|
||||||
break;
|
break;
|
||||||
case wxAUI_BUTTON_WINDOWLIST:
|
case wxAUI_BUTTON_WINDOWLIST:
|
||||||
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
if (button_state & wxAUI_BUTTON_STATE_DISABLED)
|
||||||
bmp = m_disabledWindowListBmp;
|
bb = m_disabledWindowListBmp;
|
||||||
else
|
else
|
||||||
bmp = m_activeWindowListBmp;
|
bb = m_activeWindowListBmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bmp.IsOk())
|
if (!bb.IsOk())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxAuiScaleBitmap(bmp, wnd->GetDPIScaleFactor());
|
const wxBitmap bmp = bb.GetBitmapFor(wnd);
|
||||||
|
|
||||||
rect = in_rect;
|
rect = in_rect;
|
||||||
|
|
||||||
|
|||||||
@@ -310,8 +310,10 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
|
|||||||
int bitmap_offset;
|
int bitmap_offset;
|
||||||
bitmap_offset = textX;
|
bitmap_offset = textX;
|
||||||
|
|
||||||
|
const wxBitmap bitmap = page.bitmap.GetBitmapFor(wnd);
|
||||||
|
|
||||||
// draw bitmap
|
// 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(!page.active)
|
||||||
{
|
{
|
||||||
if (tab_pos == wxAUI_NB_TOP)
|
if (tab_pos == wxAUI_NB_TOP)
|
||||||
@@ -319,12 +321,12 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
|
|||||||
else
|
else
|
||||||
bitmapY -= style_notebook->ythickness / 2;
|
bitmapY -= style_notebook->ythickness / 2;
|
||||||
}
|
}
|
||||||
dc.DrawBitmap(page.bitmap,
|
dc.DrawBitmap(bitmap,
|
||||||
bitmap_offset,
|
bitmap_offset,
|
||||||
bitmapY,
|
bitmapY,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
textX += page.bitmap.GetScaledWidth() + padding;
|
textX += bitmap.GetScaledWidth() + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord textW, textH, textY;
|
wxCoord textW, textH, textY;
|
||||||
@@ -490,7 +492,7 @@ int wxAuiGtkTabArt::GetAdditionalBorderSpace(wxWindow* wnd)
|
|||||||
wxSize wxAuiGtkTabArt::GetTabSize(wxDC& dc,
|
wxSize wxAuiGtkTabArt::GetTabSize(wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int close_button_state,
|
int close_button_state,
|
||||||
int* x_extent)
|
int* x_extent)
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ void wxAuiMSWTabArt::DrawTab(wxDC& dc,
|
|||||||
|
|
||||||
dc.SetFont(wnd->GetFont());
|
dc.SetFont(wnd->GetFont());
|
||||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
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
|
// draw focus rectangle
|
||||||
if ( page.active && (wnd->FindFocus() == wnd) )
|
if ( page.active && (wnd->FindFocus() == wnd) )
|
||||||
@@ -276,7 +276,7 @@ int wxAuiMSWTabArt::GetAdditionalBorderSpace(wxWindow* wnd)
|
|||||||
wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc,
|
wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc,
|
||||||
wxWindow* wnd,
|
wxWindow* wnd,
|
||||||
const wxString& caption,
|
const wxString& caption,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
bool active,
|
bool active,
|
||||||
int close_button_state,
|
int close_button_state,
|
||||||
int* x_extent)
|
int* x_extent)
|
||||||
@@ -306,8 +306,10 @@ wxSize wxAuiMSWTabArt::GetTabSize(wxDC& dc,
|
|||||||
// if there's a bitmap, add space for it
|
// if there's a bitmap, add space for it
|
||||||
if ( bitmap.IsOk() )
|
if ( bitmap.IsOk() )
|
||||||
{
|
{
|
||||||
tabWidth += bitmap.GetWidth() + wnd->FromDIP(3); // bitmap padding
|
const wxSize bitmapSize = bitmap.GetPreferredSizeFor(wnd);
|
||||||
tabHeight = wxMax(tabHeight, bitmap.GetHeight() + wnd->FromDIP(2));
|
|
||||||
|
tabWidth += bitmapSize.x + wnd->FromDIP(3); // bitmap padding
|
||||||
|
tabHeight = wxMax(tabHeight, bitmapSize.y + wnd->FromDIP(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add padding
|
// add padding
|
||||||
|
|||||||
Reference in New Issue
Block a user