*/
bool DismissExpandedPanel();
+ /**
+ Returns the number for a given ribbon bar page.
+
+ The number can be used in other ribbon bar calls.
+
+ @since 2.9.5
+ */
+ int GetPageNumber(wxRibbonPage* page) const;
+
/**
Delete a single page from this ribbon bar.
*/
void ClearPages();
+ /**
+ Indicates whether the tab for the given page is shown to the user or
+ not.
+
+ By default all page tabs are shown.
+
+ @since 2.9.5
+ */
+ bool IsPageShown(size_t page) const;
+
+ /**
+ Show or hide the tab for a given page.
+
+ After showing or hiding a tab, you need to call wxRibbonBar::Realize().
+ If you hide the tab for the currently active page (GetActivePage) then
+ you should call SetActivePage to activate a different page.
+
+ @since 2.9.5
+ */
+ void ShowPage(size_t page, bool show_tab=true);
+
+ /**
+ Hides the tab for a given page.
+
+ Equivalent to @c ShowPage(page, false).
+
+ @since 2.9.5
+ */
+ void HidePage(size_t page);
+
/**
Shows or hides the panel area of the ribbon bar.
ID_CHANGE_TEXT1,
ID_CHANGE_TEXT2,
ID_UI_CHANGE_TEXT_UPDATED,
- ID_REMOVE_PAGE
+ ID_REMOVE_PAGE,
+ ID_HIDE_PAGES,
+ ID_SHOW_PAGES
};
void OnEnableUpdateUI(wxUpdateUIEvent& evt);
void OnPositionLeftBoth(wxCommandEvent& evt);
void OnPositionLeftDropdown(wxRibbonToolBarEvent& evt);
void OnRemovePage(wxRibbonButtonBarEvent& evt);
+ void OnHidePages(wxRibbonButtonBarEvent& evt);
+ void OnShowPages(wxRibbonButtonBarEvent& evt);
void OnTogglePanels(wxCommandEvent& evt);
void OnExtButton(wxRibbonPanelEvent& evt);
EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS, MyFrame::OnTogglePanels)
EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED(wxID_ANY, MyFrame::OnExtButton)
EVT_RIBBONBUTTONBAR_CLICKED(ID_REMOVE_PAGE, MyFrame::OnRemovePage)
+EVT_RIBBONBUTTONBAR_CLICKED(ID_HIDE_PAGES, MyFrame::OnHidePages)
+EVT_RIBBONBUTTONBAR_CLICKED(ID_SHOW_PAGES, MyFrame::OnShowPages)
END_EVENT_TABLE()
#include "align_center.xpm"
wxRibbonPanel *panel = new wxRibbonPanel(page, wxID_ANY, wxT("Page manipulation"), ribbon_xpm);
wxRibbonButtonBar *bar = new wxRibbonButtonBar(panel, wxID_ANY);
bar->AddButton(ID_REMOVE_PAGE, wxT("Remove"), wxArtProvider::GetBitmap(wxART_DELETE, wxART_OTHER, wxSize(24, 24)));
+ bar->AddButton(ID_HIDE_PAGES, wxT("Hide Pages"), ribbon_xpm);
+ bar->AddButton(ID_SHOW_PAGES, wxT("Show Pages"), ribbon_xpm);
}
m_ribbon->Realize();
m_ribbon->Realize();
}
}
+
+void MyFrame::OnHidePages(wxRibbonButtonBarEvent& WXUNUSED(evt))
+{
+ m_ribbon->HidePage(1);
+ m_ribbon->HidePage(2);
+ m_ribbon->HidePage(3);
+ m_ribbon->Realize();
+}
+
+void MyFrame::OnShowPages(wxRibbonButtonBarEvent& WXUNUSED(evt))
+{
+ m_ribbon->ShowPage(1);
+ m_ribbon->ShowPage(2);
+ m_ribbon->ShowPage(3);
+ m_ribbon->Realize();
+}
info.page = page;
info.active = false;
info.hovered = false;
+ info.shown = true;
// info.rect not set (intentional)
wxClientDC dcTemp(this);
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
RepositionPage(info.page);
if(!info.page->Realize())
{
return m_pages.GetCount();
}
+bool wxRibbonBar::IsPageShown(size_t page) const
+{
+ if (page >= m_pages.GetCount())
+ return false;
+ return m_pages.Item(page).shown;
+}
+
+void wxRibbonBar::ShowPage(size_t page, bool show)
+{
+ if(page >= m_pages.GetCount())
+ return;
+ m_pages.Item(page).shown = show;
+}
+
void wxRibbonBar::DeletePage(size_t n)
{
if(n < m_pages.GetCount())
}
m_current_page = (int)page;
m_pages.Item(page).active = true;
+ m_pages.Item(page).shown = true;
{
wxRibbonPage* wnd = m_pages.Item(page).page;
RepositionPage(wnd);
return false;
}
+int wxRibbonBar::GetPageNumber(wxRibbonPage* page) const
+{
+ size_t numpages = m_pages.GetCount();
+ for(size_t i = 0; i < numpages; ++i)
+ {
+ if(m_pages.Item(i).page == page)
+ {
+ return i;
+ }
+ }
+ return wxNOT_FOUND;
+}
+
+
int wxRibbonBar::GetActivePage() const
{
return m_current_page;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
info.rect.x = x;
info.rect.y = y;
info.rect.width = info.ideal_width;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
info.rect.x = x;
info.rect.y = y;
info.rect.width = info.minimum_width;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
info.rect.x -= m_tab_scroll_amount;
}
}
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
if(info.small_must_have_separator_width < smallest_tab_width)
{
smallest_tab_width = info.small_must_have_separator_width;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
int delta = info.ideal_width - info.small_must_have_separator_width;
info.rect.x = x;
info.rect.y = y;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
if(info.minimum_width < smallest_tab_width)
{
total_small_width += smallest_tab_width;
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);
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = sorted_pages.Item(i);
+ if (!info.shown)
+ continue;
if(info.small_must_have_separator_width * (int)(numtabs - i) <= width)
{
info.rect.width = info.small_must_have_separator_width;;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
info.rect.x = x;
info.rect.y = y;
info.rect.height = m_tab_height;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
int delta = smallest_tab_width - info.minimum_width;
info.rect.x = x;
info.rect.y = y;
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
dc.DestroyClippingRegion();
if(m_tab_scroll_buttons_shown)
for(i = 0; i < numtabs - 1; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
rect.x = info.rect.x + info.rect.width;
if(m_tab_scroll_buttons_shown && !tabs_rect.Intersects(rect))
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
if(info.rect.Contains(position))
{
if(index != NULL)
for(i = 0; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
info.rect.SetX(info.rect.GetX() - amount);
}
if(show_right != (m_tab_scroll_right_button_rect.GetWidth() != 0) ||
for(i = 1; i < numtabs; ++i)
{
wxRibbonPageTabInfo& info = m_pages.Item(i);
+ if (!info.shown)
+ continue;
wxSize page_min = info.page->GetMinSize();
min_size.x = wxMax(min_size.x, page_min.x);