#include "wx/ribbon/toolbar.h"
#include "wx/sizer.h"
#include "wx/menu.h"
+#include "wx/msgdlg.h"
#include "wx/dcbuffer.h"
#include "wx/colordlg.h"
#include "wx/artprov.h"
ID_UI_CHECK_UPDATED,
ID_CHANGE_TEXT1,
ID_CHANGE_TEXT2,
- ID_UI_CHANGE_TEXT_UPDATED
+ ID_UI_CHANGE_TEXT_UPDATED,
+ ID_REMOVE_PAGE,
+ ID_HIDE_PAGES,
+ ID_SHOW_PAGES
};
void OnEnableUpdateUI(wxUpdateUIEvent& evt);
void OnPositionLeftIcons(wxCommandEvent& 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 OnRibbonBarToggled(wxRibbonBarEvent& evt);
+
+ void OnExtButton(wxRibbonPanelEvent& evt);
protected:
wxRibbonGallery* PopulateColoursPanel(wxWindow* panel, wxColour def,
EVT_MENU(ID_POSITION_TOP_ICONS, MyFrame::OnPositionTopIcons)
EVT_MENU(ID_POSITION_TOP_BOTH, MyFrame::OnPositionTopBoth)
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)
+EVT_RIBBONBAR_TOGGLED(wxID_ANY, MyFrame::OnRibbonBarToggled)
END_EVENT_TABLE()
#include "align_center.xpm"
MyFrame::MyFrame()
: wxFrame(NULL, wxID_ANY, wxT("wxRibbon Sample Application"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE)
{
- m_ribbon = new wxRibbonBar(this, wxID_ANY);
+ m_ribbon = new wxRibbonBar(this);
{
wxRibbonPage* home = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Examples"), ribbon_xpm);
wxRibbonPanel *toolbar_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Toolbar"),
wxNullBitmap, wxDefaultPosition, wxDefaultSize,
- wxRIBBON_PANEL_NO_AUTO_MINIMISE);
+ wxRIBBON_PANEL_NO_AUTO_MINIMISE |
+ wxRIBBON_PANEL_EXT_BUTTON);
wxRibbonToolBar *toolbar = new wxRibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR);
toolbar->AddToggleTool(wxID_JUSTIFY_LEFT, align_left_xpm);
toolbar->AddToggleTool(wxID_JUSTIFY_CENTER , align_center_xpm);
bar->AddButton(ID_UI_CHANGE_TEXT_UPDATED, wxT("Zero"), ribbon_xpm);
}
new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Empty Page"), empty_xpm);
- new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Another Page"), empty_xpm);
+ {
+ wxRibbonPage* page = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Another Page"), empty_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);
+ }
+ new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Highlight Page"), empty_xpm);
+ m_ribbon->AddPageHighlight(m_ribbon->GetPageCount()-1);
m_ribbon->Realize();
m_ribbon->ShowPanels(m_togglePanels->GetValue());
}
+void MyFrame::OnExtButton(wxRibbonPanelEvent& WXUNUSED(evt))
+{
+ wxMessageBox("Extension button clicked");
+}
+
void MyFrame::AddText(wxString msg)
{
m_logwindow->AppendText(msg);
m_ribbon->Thaw();
GetSizer()->Layout();
}
+
+void MyFrame::OnRemovePage(wxRibbonButtonBarEvent& WXUNUSED(evt))
+{
+ size_t n = m_ribbon->GetPageCount();
+ if(n > 0)
+ {
+ m_ribbon->DeletePage(n-1);
+ 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();
+}
+
+void MyFrame::OnRibbonBarToggled(wxRibbonBarEvent& WXUNUSED(evt))
+{
+ AddText(wxString::Format("Ribbon bar %s.",
+ m_ribbon->ArePanelsShown()
+ ? "expanded"
+ : "collapsed"));
+}