Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wx/wx.h>
- #include <wx/ribbon/bar.h>
- #include <wx/ribbon/buttonbar.h>
- #include <wx/artprov.h>
- typedef enum {
- idRibbonOnlineConnect = wxID_HIGHEST + 1,
- idRibbon,
- idRibbonControlPage,
- idConnectDlg,
- } windowId;
- class cRibbon {
- public:
- cRibbon(wxWindow *pParent);
- wxRibbonBar *getRibbon(void);
- private:
- wxRibbonBar *m_pRibbon;
- };
- cRibbon::cRibbon(wxWindow *pParent)
- {
- m_pRibbon = new wxRibbonBar(
- pParent, idRibbon, wxDefaultPosition, wxDefaultSize,
- wxRIBBON_BAR_FLOW_HORIZONTAL | wxRIBBON_BAR_SHOW_PAGE_LABELS |
- wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
- );
- // 'Control' page general layout
- wxRibbonPage *pPageControl = new wxRibbonPage(m_pRibbon, idRibbonControlPage, "Control");
- wxRibbonPanel *pPanelOnline = new wxRibbonPanel(
- pPageControl, wxID_ANY, "On-line mode", wxNullBitmap,
- wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_NO_AUTO_MINIMISE
- );
- wxRibbonButtonBar *pOnlineBar = new wxRibbonButtonBar(pPanelOnline);
- pOnlineBar->AddButton(
- idRibbonOnlineConnect, "Connect",
- wxArtProvider::GetBitmap(wxART_QUESTION, wxART_TOOLBAR, wxSize(48,48))
- );
- m_pRibbon->Realize();
- }
- wxRibbonBar *cRibbon::getRibbon(void)
- {
- return m_pRibbon;
- }
- class MyApp: public wxApp
- {
- public:
- virtual bool OnInit();
- };
- extern class MyApp *g_pApp;
- class MyFrame: public wxFrame
- {
- public:
- MyFrame();
- wxPanel *m_pCont; ///< Main widget container.
- cRibbon *m_pRibbon;
- void onTestBtn(wxRibbonButtonBarEvent &evt);
- };
- class tExampleDlg: public wxDialog {
- public:
- tExampleDlg(wxWindow *pParent):
- wxDialog(pParent, idConnectDlg, "Select port", wxDefaultPosition, wxSize(400, 200))
- {
- new wxButton(this, wxID_ANY, "dupa");
- Centre();
- }
- };
- MyApp *g_pApp;
- wxIMPLEMENT_APP(MyApp);
- bool MyApp::OnInit()
- {
- g_pApp = this;
- MyFrame *frame = new MyFrame();
- frame->Show(true);
- return true;
- }
- MyFrame::MyFrame():
- wxFrame(NULL, wxID_ANY, "test", wxDefaultPosition, wxSize(800, 450))
- {
- m_pCont = new wxPanel(this, wxID_ANY);
- m_pRibbon = new cRibbon(m_pCont);
- wxBoxSizer *pMainSizer = new wxBoxSizer(wxVERTICAL);
- pMainSizer->Add(m_pRibbon->getRibbon(), 0, wxEXPAND);
- m_pCont->SetSizer(pMainSizer);
- Bind(wxEVT_RIBBONBUTTONBAR_CLICKED, onTestBtn, this, idRibbonOnlineConnect);
- this->Center();
- }
- void MyFrame::onTestBtn(wxRibbonButtonBarEvent &WXUNUSED(evt))
- {
- tExampleDlg *pDlg = new tExampleDlg(this);
- pDlg->ShowModal(); // Blocking, returns stuff
- pDlg->Destroy();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement