X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/530710322731ae53c2de235c04e529554cb70975..8fdd04f882cd54893dcf0aff4940faac64e2efb9:/samples/notebook/notebook.cpp diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index 5fdf6a136e..8e196ba498 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -5,7 +5,7 @@ // Modified by: Dimitri Schoolwerth // Created: 26/10/98 // RCS-ID: $Id$ -// Copyright: (c) 1998-2002 wxWindows team +// Copyright: (c) 1998-2002 wxWidgets team // License: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -33,15 +33,15 @@ bool MyApp::OnInit() // Problem with generic wxNotebook implementation whereby it doesn't size // properly unless you set the size again -#if defined(__WIN16__) || defined(__WXMOTIF__) +#if defined(__WXMOTIF__) int width, height; frame->GetSize(& width, & height); - frame->SetSize(-1, -1, width, height); + frame->SetSize(wxDefaultPosition.x, wxDefaultPosition.y, width, height); #endif frame->Show(); - return TRUE; + return true; } MyNotebook::MyNotebook(wxWindow *parent, wxWindowID id, @@ -92,8 +92,8 @@ wxPanel *MyNotebook::CreateUserCreatedPage() { wxPanel *panel = new wxPanel(this); - (void) new wxButton( panel, -1, wxT("Button"), - wxPoint(10, 10), wxSize(-1, -1) ); + (void) new wxButton( panel, wxID_ANY, wxT("Button"), + wxPoint(10, 10), wxDefaultSize ); return panel; } @@ -105,13 +105,13 @@ wxPanel *MyNotebook::CreateRadioButtonsPage() wxString animals[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"), wxT("Sabre-toothed tiger"), wxT("T Rex") }; - wxRadioBox *radiobox1 = new wxRadioBox(panel, -1, wxT("Choose one"), + wxRadioBox *radiobox1 = new wxRadioBox(panel, wxID_ANY, wxT("Choose one"), wxDefaultPosition, wxDefaultSize, 5, animals, 2, wxRA_SPECIFY_ROWS); wxString computers[] = { wxT("Amiga"), wxT("Commodore 64"), wxT("PET"), wxT("Another") }; - wxRadioBox *radiobox2 = new wxRadioBox(panel, -1, + wxRadioBox *radiobox2 = new wxRadioBox(panel, wxID_ANY, wxT("Choose your favourite"), wxDefaultPosition, wxDefaultSize, 4, computers, 0, wxRA_SPECIFY_COLS); @@ -127,7 +127,7 @@ wxPanel *MyNotebook::CreateVetoPage() { wxPanel *panel = new wxPanel(this); - (void) new wxStaticText( panel, -1, + (void) new wxStaticText( panel, wxID_ANY, wxT("This page intentionally left blank"), wxPoint(10, 10) ); return panel; @@ -137,8 +137,7 @@ wxPanel *MyNotebook::CreateBigButtonPage() { wxPanel *panel = new wxPanel(this); - wxButton *buttonBig = new wxButton( panel, -1, wxT("Maximized button"), - wxPoint(0, 0), wxSize(480, 360) ); + wxButton *buttonBig = new wxButton(panel, wxID_ANY, wxT("Maximized button")); wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); sizerPanel->Add(buttonBig, 1, wxEXPAND); @@ -153,7 +152,7 @@ wxPanel *MyNotebook::CreateInsertPage() wxPanel *panel = new wxPanel(this); panel->SetBackgroundColour( wxColour( wxT("MAROON") ) ); - (void) new wxStaticText( panel, -1, + (void) new wxStaticText( panel, wxID_ANY, wxT("This page has been inserted, not added."), wxPoint(10, 10) ); return panel; @@ -161,21 +160,19 @@ wxPanel *MyNotebook::CreateInsertPage() void MyNotebook::CreateInitialPages() { - wxPanel *panel = (wxPanel *) NULL; - // Create and add some panels to the notebook - panel = CreateRadioButtonsPage(); - AddPage( panel, RADIOBUTTONS_PAGE_NAME, FALSE, GetIconIndex() ); + wxPanel *panel = CreateRadioButtonsPage(); + AddPage( panel, RADIOBUTTONS_PAGE_NAME, false, GetIconIndex() ); panel = CreateVetoPage(); - AddPage( panel, VETO_PAGE_NAME, FALSE, GetIconIndex() ); + AddPage( panel, VETO_PAGE_NAME, false, GetIconIndex() ); panel = CreateBigButtonPage(); - AddPage( panel, MAXIMIZED_BUTTON_PAGE_NAME, FALSE, GetIconIndex() ); + AddPage( panel, MAXIMIZED_BUTTON_PAGE_NAME, false, GetIconIndex() ); panel = CreateInsertPage(); - InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, FALSE, GetIconIndex() ); + InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex() ); SetSelection(1); @@ -197,7 +194,7 @@ int MyNotebook::GetIconIndex() const MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) - : wxFrame((wxWindow *) NULL, -1, title, pos, size, style) + : wxFrame((wxWindow *) NULL, wxID_ANY, title, pos, size, style) { m_panel = (wxPanel *) NULL; m_notebook = (MyNotebook *) NULL; @@ -228,7 +225,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize) ); - m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, + m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE); // Create remaining controls @@ -246,16 +243,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,7 +275,7 @@ 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_text = new wxTextCtrl(m_panel, -1, wxEmptyString, + m_text = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); m_logTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(m_text) ); @@ -285,22 +286,23 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, 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); @@ -313,9 +315,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, m_panel->SetSizer(m_sizerFrame); - m_panel->SetAutoLayout(TRUE); - m_sizerFrame->Fit(this); + m_sizerFrame->SetSizeHints(this); Centre(wxBOTH); @@ -360,11 +361,16 @@ 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, wxDefaultPosition, wxDefaultSize, - flags|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); + flags); if ( m_chkShowImages->IsChecked() ) { @@ -380,8 +386,8 @@ void MyFrame::ReInitNotebook() { wxString str = notebook->GetPageText(n); - wxNotebookPage *page = m_notebook->CreatePage(str); - m_notebook->AddPage(page, str, FALSE, m_notebook->GetIconIndex() ); + wxWindow *page = m_notebook->CreatePage(str); + m_notebook->AddPage(page, str, false, m_notebook->GetIconIndex() ); } if (m_sizerNotebook) @@ -400,7 +406,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(); } @@ -408,6 +414,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) @@ -427,21 +436,21 @@ END_EVENT_TABLE() void MyFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { - ReInitNotebook(); + ReInitNotebook(); } void MyFrame::OnButtonAddPage( wxCommandEvent& WXUNUSED(event) ) { static unsigned s_pageAdded = 0; - wxPanel *panel = new wxPanel( m_notebook, -1 ); - (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) ); + wxPanel *panel = new wxPanel( m_notebook, wxID_ANY ); + (void) new wxButton( panel, wxID_ANY, wxT("First button"), + wxPoint(10, 10), wxDefaultSize ); + (void) new wxButton( panel, wxID_ANY, wxT("Second button"), + wxPoint(50, 100), wxDefaultSize ); m_notebook->AddPage(panel, wxString::Format(ADDED_PAGE_NAME wxT("%u"), - ++s_pageAdded), TRUE, m_notebook->GetIconIndex() ); + ++s_pageAdded), true, m_notebook->GetIconIndex() ); } void MyFrame::OnButtonInsertPage( wxCommandEvent& WXUNUSED(event) ) @@ -451,7 +460,7 @@ void MyFrame::OnButtonInsertPage( wxCommandEvent& WXUNUSED(event) ) wxPanel *panel = m_notebook->CreateUserCreatedPage(); m_notebook->InsertPage( 0, panel, - wxString::Format(INSERTED_PAGE_NAME wxT("%u"), ++s_pageIns), FALSE, + wxString::Format(INSERTED_PAGE_NAME wxT("%u"), ++s_pageIns), false, m_notebook->GetIconIndex() ); m_notebook->SetSelection(0);