wxRibbonToolBar就是工具栏,一下是实现的效果,界面只是功能展示,没有美化
实现代码如下所示:
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600))
{
wxRibbonBar* mainMenu = new wxRibbonBar(this, -1, wxDefaultPosition, wxDefaultSize, wxRIBBON_BAR_FLOW_HORIZONTAL
| wxRIBBON_BAR_SHOW_PAGE_LABELS
| wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS
| wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
| wxRIBBON_BAR_SHOW_HELP_BUTTON
);
wxRibbonPage* home = new wxRibbonPage(mainMenu, wxID_ANY, "Examples");
//添加toolbar
{
wxRibbonPanel *toolbar_panel = new wxRibbonPanel(home, wxID_ANY, "Toolbar",
wxNullBitmap, wxDefaultPosition, wxDefaultSize,
wxRIBBON_PANEL_NO_AUTO_MINIMISE |
wxRIBBON_PANEL_EXT_BUTTON);
wxRibbonToolBar *toolbar = new wxRibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR);
toolbar->AddToggleTool(wxID_JUSTIFY_LEFT, wxArtProvider::GetBitmap(wxART_COPY, wxART_OTHER, wxSize(32, 32)));
toolbar->AddToggleTool(wxID_JUSTIFY_CENTER, wxArtProvider::GetBitmap(wxART_COPY, wxART_OTHER, wxSize(32, 32)));
toolbar->AddToggleTool(wxID_JUSTIFY_RIGHT, wxArtProvider::GetBitmap(wxART_COPY, wxART_OTHER, wxSize(32, 32)));
toolbar->AddSeparator();
toolbar->AddHybridTool(wxID_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_OTHER, wxSize(16, 15)));
toolbar->AddTool(wxID_OPEN, wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_OTHER, wxSize(16, 15)), "Open something");
toolbar->AddTool(wxID_SAVE, wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_OTHER, wxSize(16, 15)), "Save something");
toolbar->AddTool(wxID_SAVEAS, wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_OTHER, wxSize(16, 15)), "Save something as ...");
toolbar->EnableTool(wxID_OPEN, false);
toolbar->EnableTool(wxID_SAVE, false);
toolbar->EnableTool(wxID_SAVEAS, false);
toolbar->AddSeparator();
toolbar->AddDropdownTool(wxID_UNDO, wxArtProvider::GetBitmap(wxART_UNDO, wxART_OTHER, wxSize(16, 15)));
toolbar->AddDropdownTool(wxID_REDO, wxArtProvider::GetBitmap(wxART_REDO, wxART_OTHER, wxSize(16, 15)));
toolbar->AddSeparator();
toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, wxSize(16, 15)));
toolbar->AddTool(wxID_ANY, wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_OTHER, wxSize(16, 15)));
toolbar->AddSeparator();
toolbar->AddHybridTool(wxID_PRINT, wxArtProvider::GetBitmap(wxART_PRINT, wxART_OTHER, wxSize(16, 15)),
"This is the Print button tooltip\ndemonstrating a tooltip");
//toolbar->SetRows(2, 3);
}
mainMenu->Realize();
wxSizer *s = new wxBoxSizer(wxVERTICAL);
s->Add(mainMenu, 0, wxEXPAND);
SetSizer(s);
Centre();
}