bool wxRibbonBar::Realize() { bool status = true; wxClientDC dcTemp(this); int sep = m_art->GetMetric(wxRIBBON_ART_TAB_SEPARATION_SIZE); size_t numtabs = m_pages.GetCount(); bool firstVisible = true; size_t i; for(i = 0; i < numtabs; ++i) { wxRibbonPageTabInfo& info = m_pages.Item(i); if (!info.shown) continue; RepositionPage(info.page); if(!info.page->Realize()) { status = false; } wxString label = wxEmptyString; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) label = info.page->GetLabel(); wxBitmap icon = wxNullBitmap; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) icon = info.page->GetIcon(); m_art->GetBarTabWidth(dcTemp, this, label, icon, &info.ideal_width, &info.small_begin_need_separator_width, &info.small_must_have_separator_width, &info.minimum_width); if ( firstVisible ) { firstVisible = false; m_tabs_total_width_ideal = info.ideal_width; m_tabs_total_width_minimum = info.minimum_width; } else { m_tabs_total_width_ideal += sep + info.ideal_width; m_tabs_total_width_minimum += sep + info.minimum_width; } } m_tab_height = m_art->GetTabCtrlHeight(dcTemp, this, m_pages); RecalculateMinSize(); RecalculateTabSizes(); Refresh(); return status; }
void wxRibbonBar::AddPage(wxRibbonPage *page) { wxRibbonPageTabInfo info; info.page = page; info.active = false; info.hovered = false; info.highlight = false; info.shown = true; // info.rect not set (intentional) wxClientDC dcTemp(this); wxString label = wxEmptyString; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) label = page->GetLabel(); wxBitmap icon = wxNullBitmap; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) icon = page->GetIcon(); m_art->GetBarTabWidth(dcTemp, this, label, icon, &info.ideal_width, &info.small_begin_need_separator_width, &info.small_must_have_separator_width, &info.minimum_width); if(m_pages.IsEmpty()) { m_tabs_total_width_ideal = info.ideal_width; m_tabs_total_width_minimum = info.minimum_width; } else { int sep = m_art->GetMetric(wxRIBBON_ART_TAB_SEPARATION_SIZE); m_tabs_total_width_ideal += sep + info.ideal_width; m_tabs_total_width_minimum += sep + info.minimum_width; } m_pages.Add(info); page->Hide(); // Most likely case is that this new page is not the active tab page->SetArtProvider(m_art); if(m_pages.GetCount() == 1) { SetActivePage((size_t)0); } }