X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..abf07807b4d32740999df7a09c3c17758c325ea0:/samples/notebook/notebook.cpp?ds=sidebyside diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index 940c084d5f..c2f40aa6d6 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -161,11 +161,9 @@ wxPanel *MyNotebook::CreateInsertPage() void MyNotebook::CreateInitialPages() { - wxPanel *panel = (wxPanel *) NULL; - // Create and add some panels to the notebook - panel = CreateRadioButtonsPage(); + wxPanel *panel = CreateRadioButtonsPage(); AddPage( panel, RADIOBUTTONS_PAGE_NAME, FALSE, GetIconIndex() ); panel = CreateVetoPage(); @@ -229,7 +227,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, ); m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, - wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER); + wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE); // Create remaining controls @@ -246,16 +244,20 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, wxT("Forgot to update something") ); m_radioOrient = new wxRadioBox - ( - m_panel, ID_RADIO_ORIENT, - wxT("&Tab orientation"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(strOrientations), strOrientations, - 1, wxRA_SPECIFY_COLS - ); + ( + m_panel, ID_RADIO_ORIENT, + wxT("&Tab orientation"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(strOrientations), strOrientations, + 1, wxRA_SPECIFY_COLS + ); m_chkShowImages = new wxCheckBox( m_panel, ID_CHK_SHOWIMAGES, wxT("&Show images") ); +#ifndef TEST_LISTBOOK + m_chkMultiLine = new wxCheckBox( m_panel, ID_CHK_MULTILINE, + wxT("&Multiple lines") ); +#endif // !TEST_LISTBOOK m_btnAddPage = new wxButton( m_panel, ID_BTN_ADD_PAGE, wxT("&Add page") ); @@ -274,38 +276,34 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, m_btnExit = new wxButton( m_panel, wxID_OK, wxT("&Exit") ); m_btnExit->SetDefault(); - m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK); - m_text = new wxTextCtrl(m_panel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); m_logTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(m_text) ); - // Create the notebook's panels - m_notebook->CreateInitialPages(); - // Set sizers m_sizerFrame = new wxBoxSizer(wxVERTICAL); m_sizerTop = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *sizerLeft = new wxBoxSizer(wxVERTICAL); - { - sizerLeft->Add(m_radioOrient, 0, wxEXPAND); - sizerLeft->Add(m_chkShowImages, 0, wxEXPAND | wxTOP, 4); + sizerLeft->Add(m_radioOrient, 0, wxEXPAND); + sizerLeft->Add(m_chkShowImages, 0, wxEXPAND | wxTOP, 4); +#ifndef TEST_LISTBOOK + sizerLeft->Add(m_chkMultiLine, 0, wxEXPAND | wxTOP, 4); +#endif // !TEST_LISTBOOK - sizerLeft->Add(0, 0, 1); // Spacer + sizerLeft->Add(0, 0, 1); // Spacer - sizerLeft->Add(m_btnAddPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); - sizerLeft->Add(m_btnInsertPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); - sizerLeft->Add(m_btnDeleteCurPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); - sizerLeft->Add(m_btnDeleteLastPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); - sizerLeft->Add(m_btnNextPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); + sizerLeft->Add(m_btnAddPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); + sizerLeft->Add(m_btnInsertPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); + sizerLeft->Add(m_btnDeleteCurPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); + sizerLeft->Add(m_btnDeleteLastPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); + sizerLeft->Add(m_btnNextPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4); - sizerLeft->Add(0, 0, 1); // Spacer + sizerLeft->Add(0, 0, 1); // Spacer - sizerLeft->Add(m_btnExit, 0, wxEXPAND); - } + sizerLeft->Add(m_btnExit, 0, wxEXPAND); m_sizerTop->Add(sizerLeft, 0, wxEXPAND | wxALL, 4); @@ -314,6 +312,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, m_sizerFrame->Add(m_text, 0, wxEXPAND); ReInitNotebook(); + m_notebook->CreateInitialPages(); m_panel->SetSizer(m_sizerFrame); @@ -364,6 +363,11 @@ void MyFrame::ReInitNotebook() break; } +#ifndef TEST_LISTBOOK + if ( m_chkMultiLine->IsChecked() ) + flags |= wxNB_MULTILINE; +#endif // !TEST_LISTBOOK + MyNotebook *notebook = m_notebook; m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK, @@ -384,7 +388,7 @@ void MyFrame::ReInitNotebook() { wxString str = notebook->GetPageText(n); - wxNotebookPage *page = m_notebook->CreatePage(str); + wxWindow *page = m_notebook->CreatePage(str); m_notebook->AddPage(page, str, FALSE, m_notebook->GetIconIndex() ); } @@ -404,7 +408,7 @@ void MyFrame::ReInitNotebook() } - m_sizerNotebook = new wxNotebookSizer(m_notebook); + m_sizerNotebook = new wxBookCtrlSizer(m_notebook); m_sizerTop->Add(m_sizerNotebook, 1, wxEXPAND | wxALL, 4); m_sizerTop->Layout(); } @@ -412,6 +416,9 @@ void MyFrame::ReInitNotebook() BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_RADIOBOX(ID_RADIO_ORIENT, MyFrame::OnCheckOrRadioBox) EVT_CHECKBOX(ID_CHK_SHOWIMAGES, MyFrame::OnCheckOrRadioBox) +#ifndef TEST_LISTBOOK + EVT_CHECKBOX(ID_CHK_MULTILINE, MyFrame::OnCheckOrRadioBox) +#endif // !TEST_LISTBOOK EVT_BUTTON(ID_BTN_ADD_PAGE, MyFrame::OnButtonAddPage) EVT_BUTTON(ID_BTN_INSERT_PAGE, MyFrame::OnButtonInsertPage) @@ -429,17 +436,17 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_IDLE(MyFrame::OnIdle) END_EVENT_TABLE() -void MyFrame::OnCheckOrRadioBox(wxCommandEvent& event) +void MyFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { - ReInitNotebook(); + ReInitNotebook(); } void MyFrame::OnButtonAddPage( wxCommandEvent& WXUNUSED(event) ) { - static size_t s_pageAdded = 0; + static unsigned s_pageAdded = 0; wxPanel *panel = new wxPanel( m_notebook, -1 ); - (void) new wxButton( panel, -1, wxT("Frist button"), + (void) new wxButton( panel, -1, wxT("First button"), wxPoint(10, 10), wxSize(-1, -1) ); (void) new wxButton( panel, -1, wxT("Second button"), wxPoint(50, 100), wxSize(-1, -1) ); @@ -450,7 +457,7 @@ void MyFrame::OnButtonAddPage( wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnButtonInsertPage( wxCommandEvent& WXUNUSED(event) ) { - static size_t s_pageIns = 0; + static unsigned s_pageIns = 0; wxPanel *panel = m_notebook->CreateUserCreatedPage();