]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/notebook/test.cpp
more new files
[wxWidgets.git] / samples / notebook / test.cpp
index 4070a935bd20c305ae892b16a087c189aad8b0ce..9a35002ed626895bd3fd3a05d90661137bcddd2e 100644 (file)
@@ -58,8 +58,8 @@ bool MyApp::OnInit(void)
 void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
 {
   m_okButton = new wxButton(window, wxID_OK, "Close", wxPoint(-1, -1), wxSize(80, 25));
-  m_cancelButton = new wxButton(window, wxID_CANCEL, "Cancel", wxPoint(-1, -1), wxSize(80, 25));
-  m_helpButton = new wxButton(window, wxID_HELP, "Help", wxPoint(-1, -1), wxSize(80, 25));
+  m_cancelButton = new wxButton(window, ID_DELETE_PAGE, "Delete page", wxPoint(-1, -1), wxSize(80, 25));
+  m_addPageButton = new wxButton(window, ID_ADD_PAGE, "Add page", wxPoint(-1, -1), wxSize(80, 25));
   m_okButton->SetDefault();
 
   wxLayoutConstraints* c = new wxLayoutConstraints;
@@ -67,10 +67,10 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
   c->bottom.SameAs(window, wxBottom, 4);
   c->height.AsIs();
   c->width.AsIs();
-  m_helpButton->SetConstraints(c);
+  m_addPageButton->SetConstraints(c);
 
   c = new wxLayoutConstraints;
-  c->right.SameAs(m_helpButton, wxLeft, 4);
+  c->right.SameAs(m_addPageButton, wxLeft, 4);
   c->bottom.SameAs(window, wxBottom, 4);
   c->height.AsIs();
   c->width.AsIs();
@@ -101,7 +101,6 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
     wxTE_MULTILINE);
 
   notebook->AddPage(panel2, "Dog");
-
   wxPanel *panel3 = new wxPanel(notebook, -1);
   panel3->SetBackgroundColour(wxColour("WHITE"));
   notebook->AddPage(panel3, "Goat");
@@ -109,6 +108,11 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
   wxPanel *panel4 = new wxPanel(notebook, -1);
   panel4->SetBackgroundColour(wxColour("YELLOW"));
   notebook->AddPage(panel4, "Sheep");
+  
+  wxPanel *panel5 = new wxPanel(notebook, -1);
+  panel5->SetBackgroundColour(wxColour("MAGENTA"));
+  (void)new wxStaticText(panel5, -1, "This page has been inserted, not added", wxPoint(10, 10) );
+  notebook->InsertPage(0, panel5, "Sheep");
 }
 
 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
@@ -155,7 +159,8 @@ void MyDialog::Init(void)
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_BUTTON(wxID_OK, MyFrame::OnOK)
-    EVT_BUTTON(wxID_CANCEL, MyFrame::OnOK)
+    EVT_BUTTON(ID_DELETE_PAGE, MyFrame::OnDeletePage)
+    EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
     EVT_SIZE(MyFrame::OnSize)
 END_EVENT_TABLE()
 
@@ -168,6 +173,19 @@ MyFrame::MyFrame(wxFrame* parent, const wxWindowID id, const wxString& title,
     Init();
 }
 
+void MyFrame::OnAddPage(wxCommandEvent& WXUNUSED(event))
+{
+  wxPanel *panel = new wxPanel( m_notebook, -1 );
+  (void)new wxButton( panel, -1, "Button", wxPoint( 10,10 ), wxSize(-1,-1) );
+  m_notebook->AddPage( panel, "Added" );
+//  m_notebook->SetSelection( m_notebook->GetPageCount()-1 );
+}
+
+void MyFrame::OnDeletePage(wxCommandEvent& WXUNUSED(event))
+{
+  m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
+}
+
 void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
 {
     this->Destroy();