Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.51 KB | None | 0 0
  1. #include <wx/wx.h>
  2. #include <wx/ribbon/bar.h>
  3. #include <wx/ribbon/buttonbar.h>
  4. #include <wx/artprov.h>
  5.  
  6. typedef enum {
  7.     idRibbonOnlineConnect = wxID_HIGHEST + 1,
  8.     idRibbon,
  9.     idRibbonControlPage,
  10.     idConnectDlg,
  11. } windowId;
  12.  
  13.  
  14. class cRibbon {
  15.     public:
  16.         cRibbon(wxWindow *pParent);
  17.         wxRibbonBar *getRibbon(void);
  18.  
  19.     private:
  20.         wxRibbonBar *m_pRibbon;
  21. };
  22.  
  23. cRibbon::cRibbon(wxWindow *pParent)
  24. {
  25.     m_pRibbon = new wxRibbonBar(
  26.         pParent, idRibbon, wxDefaultPosition, wxDefaultSize,
  27.         wxRIBBON_BAR_FLOW_HORIZONTAL | wxRIBBON_BAR_SHOW_PAGE_LABELS |
  28.         wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
  29.     );
  30.  
  31.     // 'Control'  page general layout
  32.     wxRibbonPage *pPageControl = new wxRibbonPage(m_pRibbon, idRibbonControlPage, "Control");
  33.     wxRibbonPanel *pPanelOnline = new wxRibbonPanel(
  34.         pPageControl, wxID_ANY, "On-line mode", wxNullBitmap,
  35.         wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_NO_AUTO_MINIMISE
  36.     );
  37.     wxRibbonButtonBar *pOnlineBar = new wxRibbonButtonBar(pPanelOnline);
  38.     pOnlineBar->AddButton(
  39.         idRibbonOnlineConnect, "Connect",
  40.         wxArtProvider::GetBitmap(wxART_QUESTION, wxART_TOOLBAR, wxSize(48,48))
  41.     );
  42.     m_pRibbon->Realize();
  43. }
  44.  
  45. wxRibbonBar *cRibbon::getRibbon(void)
  46. {
  47.     return m_pRibbon;
  48. }
  49.  
  50. class MyApp: public wxApp
  51. {
  52.   public:
  53.       virtual bool OnInit();
  54. };
  55.  
  56. extern class MyApp *g_pApp;
  57.  
  58. class MyFrame: public wxFrame
  59. {
  60.   public:
  61.     MyFrame();
  62.  
  63.     wxPanel *m_pCont; ///< Main widget container.
  64.         cRibbon *m_pRibbon;
  65.         void onTestBtn(wxRibbonButtonBarEvent &evt);
  66. };
  67.  
  68. class tExampleDlg: public wxDialog {
  69.     public:
  70.         tExampleDlg(wxWindow *pParent):
  71.             wxDialog(pParent, idConnectDlg, "Select port", wxDefaultPosition, wxSize(400, 200))
  72.         {
  73.             new wxButton(this, wxID_ANY, "dupa");
  74.             Centre();
  75.         }
  76. };
  77.  
  78. MyApp *g_pApp;
  79.  
  80. wxIMPLEMENT_APP(MyApp);
  81.  
  82. bool MyApp::OnInit()
  83. {
  84.     g_pApp = this;
  85.     MyFrame *frame = new MyFrame();
  86.     frame->Show(true);
  87.     return true;
  88. }
  89.  
  90. MyFrame::MyFrame():
  91.     wxFrame(NULL, wxID_ANY, "test", wxDefaultPosition, wxSize(800, 450))
  92. {
  93.     m_pCont = new wxPanel(this, wxID_ANY);
  94.     m_pRibbon = new cRibbon(m_pCont);
  95.     wxBoxSizer *pMainSizer = new wxBoxSizer(wxVERTICAL);
  96.     pMainSizer->Add(m_pRibbon->getRibbon(), 0, wxEXPAND);
  97.     m_pCont->SetSizer(pMainSizer);
  98.    
  99.     Bind(wxEVT_RIBBONBUTTONBAR_CLICKED, onTestBtn, this, idRibbonOnlineConnect);
  100.  
  101.     this->Center();
  102. }
  103.  
  104. void MyFrame::onTestBtn(wxRibbonButtonBarEvent &WXUNUSED(evt))
  105. {
  106.     tExampleDlg *pDlg = new tExampleDlg(this);
  107.     pDlg->ShowModal(); // Blocking, returns stuff
  108.     pDlg->Destroy();
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement