X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/42d7394119d3d8117289c22ecb79d5a49d891648..43f4e852a1b2ac37c3db6a2b87315192ac549191:/src/ribbon/bar.cpp diff --git a/src/ribbon/bar.cpp b/src/ribbon/bar.cpp index 0970d3b43b..b2d008d734 100644 --- a/src/ribbon/bar.cpp +++ b/src/ribbon/bar.cpp @@ -21,6 +21,7 @@ #include "wx/ribbon/art.h" #include "wx/dcbuffer.h" #include "wx/app.h" +#include "wx/vector.h" #ifndef WX_PRECOMP #endif @@ -465,10 +466,21 @@ void wxRibbonBar::SetTabCtrlMargins(int left, int right) RecalculateTabSizes(); } -static int OrderPageTabInfoBySmallWidthAsc(wxRibbonPageTabInfo **first, wxRibbonPageTabInfo **second) +struct PageComparedBySmallWidthAsc { - return (**first).small_must_have_separator_width - (**second).small_must_have_separator_width; -} + wxEXPLICIT PageComparedBySmallWidthAsc(wxRibbonPageTabInfo* page) + : m_page(page) + { + } + + bool operator<(const PageComparedBySmallWidthAsc& other) const + { + return m_page->small_must_have_separator_width + < other.m_page->small_must_have_separator_width; + } + + wxRibbonPageTabInfo *m_page; +}; void wxRibbonBar::RecalculateTabSizes() { @@ -624,30 +636,27 @@ void wxRibbonBar::RecalculateTabSizes() if(width >= total_small_width) { // Do (2) - wxRibbonPageTabInfoArray sorted_pages; - for(i = 0; i < numtabs; ++i) - { - // Sneaky obj array trickery to not copy the tab descriptors - if (!m_pages.Item(i).shown) - continue; - sorted_pages.Add(&m_pages.Item(i)); - } - sorted_pages.Sort(OrderPageTabInfoBySmallWidthAsc); + wxVector sorted_pages; + sorted_pages.reserve(numtabs); + for ( i = 0; i < numtabs; ++i ) + sorted_pages.push_back(PageComparedBySmallWidthAsc(&m_pages.Item(i))); + + wxVectorSort(sorted_pages); width -= tabsep * (numtabs - 1); for(i = 0; i < numtabs; ++i) { - wxRibbonPageTabInfo& info = sorted_pages.Item(i); - if (!info.shown) + wxRibbonPageTabInfo* info = sorted_pages[i].m_page; + if (!info->shown) continue; - if(info.small_must_have_separator_width * (int)(numtabs - i) <= width) + if(info->small_must_have_separator_width * (int)(numtabs - i) <= width) { - info.rect.width = info.small_must_have_separator_width;; + info->rect.width = info->small_must_have_separator_width;; } else { - info.rect.width = width / (numtabs - i); + info->rect.width = width / (numtabs - i); } - width -= info.rect.width; + width -= info->rect.width; } for(i = 0; i < numtabs; ++i) { @@ -658,7 +667,6 @@ void wxRibbonBar::RecalculateTabSizes() info.rect.y = y; info.rect.height = m_tab_height; x += info.rect.width + tabsep; - sorted_pages.Detach(numtabs - (i + 1)); } } else @@ -704,6 +712,7 @@ wxRibbonBar::wxRibbonBar() m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL; m_tab_scroll_buttons_shown = false; m_arePanelsShown = true; + m_help_button_hovered = false; } wxRibbonBar::wxRibbonBar(wxWindow* parent,