Use wxImageList in wxRibbonBar unconditionally
There shouldn't be any reason not to do it other than possible bugs in wxImageList itself, that should be fixed there.
This commit is contained in:
@@ -154,12 +154,9 @@ public:
|
|||||||
|
|
||||||
void HideIfExpanded();
|
void HideIfExpanded();
|
||||||
|
|
||||||
void UseImageList(bool useImageList = true) { m_useImageList = useImageList; }
|
|
||||||
bool UsesImageList() const { return m_useImageList; }
|
|
||||||
// Implementation only.
|
// Implementation only.
|
||||||
wxImageList* GetButtonImageList(wxSize* isize = NULL);
|
wxImageList* GetButtonImageList(wxSize size);
|
||||||
// Implementation only.
|
wxImageList* GetButtonSmallImageList(wxSize size);
|
||||||
wxImageList* GetButtonSmallImageList(wxSize* isize = NULL);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class wxRibbonPage;
|
friend class wxRibbonPage;
|
||||||
@@ -217,7 +214,6 @@ protected:
|
|||||||
|
|
||||||
wxRibbonDisplayMode m_ribbon_state;
|
wxRibbonDisplayMode m_ribbon_state;
|
||||||
|
|
||||||
bool m_useImageList;
|
|
||||||
wxImageList* m_buttonImageList;
|
wxImageList* m_buttonImageList;
|
||||||
wxImageList* m_buttonSmallImageList;
|
wxImageList* m_buttonSmallImageList;
|
||||||
|
|
||||||
|
@@ -453,26 +453,4 @@ public:
|
|||||||
Also calls wxRibbonPage::Realize() on each child page.
|
Also calls wxRibbonPage::Realize() on each child page.
|
||||||
*/
|
*/
|
||||||
virtual bool Realize();
|
virtual bool Realize();
|
||||||
|
|
||||||
/**
|
|
||||||
If the ribbon bar has many buttons, wxImageList can be used to reduce
|
|
||||||
bitmap resources. Call SetUseImageList after creating the ribbon bar,
|
|
||||||
and any subsequent AddButton or InsertButton calls will have their
|
|
||||||
images stored in an image list instead. Note that the conversion might
|
|
||||||
cause some images created from icons with alpha layers to have a black
|
|
||||||
background. Such images need to be edited before use.
|
|
||||||
|
|
||||||
@since 3.1.4
|
|
||||||
*/
|
|
||||||
void UseImageList(bool useImageList = true);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns whether a wxImageList is being used for buttons.
|
|
||||||
|
|
||||||
@see SetUseImageList()
|
|
||||||
|
|
||||||
@since 3.1.4
|
|
||||||
*/
|
|
||||||
bool UsesImageList() const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -736,7 +736,6 @@ wxRibbonBar::wxRibbonBar()
|
|||||||
m_tab_scroll_buttons_shown = false;
|
m_tab_scroll_buttons_shown = false;
|
||||||
m_arePanelsShown = true;
|
m_arePanelsShown = true;
|
||||||
m_help_button_hovered = false;
|
m_help_button_hovered = false;
|
||||||
m_useImageList = false;
|
|
||||||
m_buttonImageList = NULL;
|
m_buttonImageList = NULL;
|
||||||
m_buttonSmallImageList = NULL;
|
m_buttonSmallImageList = NULL;
|
||||||
|
|
||||||
@@ -755,14 +754,9 @@ wxRibbonBar::wxRibbonBar(wxWindow* parent,
|
|||||||
wxRibbonBar::~wxRibbonBar()
|
wxRibbonBar::~wxRibbonBar()
|
||||||
{
|
{
|
||||||
SetArtProvider(NULL);
|
SetArtProvider(NULL);
|
||||||
if (m_buttonImageList)
|
|
||||||
{
|
delete m_buttonImageList;
|
||||||
delete m_buttonImageList; m_buttonImageList = NULL;
|
delete m_buttonSmallImageList;
|
||||||
}
|
|
||||||
if (m_buttonSmallImageList)
|
|
||||||
{
|
|
||||||
delete m_buttonSmallImageList; m_buttonSmallImageList = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRibbonBar::Create(wxWindow* parent,
|
bool wxRibbonBar::Create(wxWindow* parent,
|
||||||
@@ -812,25 +806,26 @@ void wxRibbonBar::CommonInit(long style)
|
|||||||
|
|
||||||
m_ribbon_state = wxRIBBON_BAR_PINNED;
|
m_ribbon_state = wxRIBBON_BAR_PINNED;
|
||||||
|
|
||||||
m_useImageList = false;
|
|
||||||
m_buttonImageList = NULL;
|
m_buttonImageList = NULL;
|
||||||
m_buttonSmallImageList = NULL;
|
m_buttonSmallImageList = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxImageList* wxRibbonBar::GetButtonImageList(wxSize* isize)
|
wxImageList* wxRibbonBar::GetButtonImageList(wxSize size)
|
||||||
{
|
{
|
||||||
if (m_useImageList && m_buttonImageList == NULL)
|
if ( !m_buttonImageList )
|
||||||
{
|
{
|
||||||
m_buttonImageList = new wxImageList(isize->GetWidth(), isize->GetHeight(), /*mask*/false);
|
m_buttonImageList = new wxImageList(size.GetWidth(), size.GetHeight(),
|
||||||
|
/*mask*/false);
|
||||||
}
|
}
|
||||||
return m_buttonImageList;
|
return m_buttonImageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxImageList* wxRibbonBar::GetButtonSmallImageList(wxSize* isize)
|
wxImageList* wxRibbonBar::GetButtonSmallImageList(wxSize size)
|
||||||
{
|
{
|
||||||
if (m_useImageList && m_buttonSmallImageList == NULL)
|
if ( !m_buttonSmallImageList )
|
||||||
{
|
{
|
||||||
m_buttonSmallImageList = new wxImageList(isize->GetWidth(), isize->GetHeight(), /*mask*/false);
|
m_buttonSmallImageList = new wxImageList(size.GetWidth(), size.GetHeight(),
|
||||||
|
/*mask*/false);
|
||||||
}
|
}
|
||||||
return m_buttonSmallImageList;
|
return m_buttonSmallImageList;
|
||||||
}
|
}
|
||||||
|
@@ -352,8 +352,8 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
|||||||
wxImageList* buttonSmallImageList = NULL;
|
wxImageList* buttonSmallImageList = NULL;
|
||||||
if (m_ownerRibbonBar)
|
if (m_ownerRibbonBar)
|
||||||
{
|
{
|
||||||
buttonImageList = m_ownerRibbonBar->GetButtonImageList(&m_bitmap_size_large);
|
buttonImageList = m_ownerRibbonBar->GetButtonImageList(m_bitmap_size_large);
|
||||||
buttonSmallImageList = m_ownerRibbonBar->GetButtonSmallImageList(&m_bitmap_size_small);
|
buttonSmallImageList = m_ownerRibbonBar->GetButtonSmallImageList(m_bitmap_size_small);
|
||||||
}
|
}
|
||||||
if (base->bitmap_large.IsOk() && buttonImageList)
|
if (base->bitmap_large.IsOk() && buttonImageList)
|
||||||
{
|
{
|
||||||
@@ -882,8 +882,8 @@ void wxRibbonButtonBar::OnPaint(wxPaintEvent& WXUNUSED(evt))
|
|||||||
wxRect rect(button.position + m_layout_offset, base->sizes[button.size].size);
|
wxRect rect(button.position + m_layout_offset, base->sizes[button.size].size);
|
||||||
if (base->barButtonImageListPos != -1 && m_ownerRibbonBar)
|
if (base->barButtonImageListPos != -1 && m_ownerRibbonBar)
|
||||||
{
|
{
|
||||||
wxImageList* buttonImageList = m_ownerRibbonBar->GetButtonImageList();
|
wxImageList* buttonImageList = m_ownerRibbonBar->GetButtonImageList(m_bitmap_size_large);
|
||||||
wxImageList* buttonSmallImageList = m_ownerRibbonBar->GetButtonSmallImageList();
|
wxImageList* buttonSmallImageList = m_ownerRibbonBar->GetButtonSmallImageList(m_bitmap_size_small);
|
||||||
|
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
wxBitmap bitmap_small;
|
wxBitmap bitmap_small;
|
||||||
|
Reference in New Issue
Block a user