From 9be821c71a4d0ee004b06faf5833bc53c699f026 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Apr 2022 20:01:23 +0100 Subject: [PATCH] Create a full page text, rather than a button, in notebook sample This is much more realistic and looks less weirdly. Also add the text directly as a page, without wrapping it in a panel, just to show that this is possible and works too. No real changes. --- samples/notebook/notebook.cpp | 38 ++++++++++++++++------------------- samples/notebook/notebook.h | 2 +- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index f5da371790..e4eb4c9bb3 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -122,21 +122,17 @@ wxPanel *CreateVetoPage(wxBookCtrlBase *parent) return panel; } -wxPanel *CreateBigButtonPage(wxBookCtrlBase *parent) +wxWindow *CreateFullPageText(wxBookCtrlBase *parent) { - wxPanel *panel = new wxPanel(parent); + wxTextCtrl *text = new wxTextCtrl(parent, wxID_ANY, "Full page text", + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE); #if wxUSE_HELP - panel->SetHelpText("Panel with a maximized button"); + text->SetHelpText("Page consisting of just a text control"); #endif - wxButton *buttonBig = new wxButton(panel, wxID_ANY, "Maximized button"); - - wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); - sizerPanel->Add(buttonBig, 1, wxEXPAND); - panel->SetSizer(sizerPanel); - - return panel; + return text; } wxPanel *CreateInsertPage(wxBookCtrlBase *parent) @@ -173,22 +169,22 @@ void CreateInitialPages(wxBookCtrlBase *parent) { // Create and add some panels to the notebook - wxPanel *panel = CreateRadioButtonsPage(parent); - parent->AddPage( panel, RADIOBUTTONS_PAGE_NAME, false, GetIconIndex(parent) ); + wxWindow *page = CreateRadioButtonsPage(parent); + parent->AddPage( page, RADIOBUTTONS_PAGE_NAME, false, GetIconIndex(parent) ); - panel = CreateVetoPage(parent); - parent->AddPage( panel, VETO_PAGE_NAME, false, GetIconIndex(parent) ); + page = CreateVetoPage(parent); + parent->AddPage( page, VETO_PAGE_NAME, false, GetIconIndex(parent) ); - panel = CreateBigButtonPage(parent); - parent->AddPage( panel, MAXIMIZED_BUTTON_PAGE_NAME, false, GetIconIndex(parent) ); + page = CreateFullPageText(parent); + parent->AddPage( page, TEXT_PAGE_NAME, false, GetIconIndex(parent) ); - panel = CreateInsertPage(parent); - parent->InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex(parent) ); + page = CreateInsertPage(parent); + parent->InsertPage( 0, page, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex(parent) ); parent->SetSelection(1); } -wxPanel *CreatePage(wxBookCtrlBase *parent, const wxString&pageName) +wxWindow *CreatePage(wxBookCtrlBase *parent, const wxString&pageName) { if ( pageName.Contains(INSERTED_PAGE_NAME) || pageName.Contains(ADDED_PAGE_NAME) || @@ -205,8 +201,8 @@ wxPanel *CreatePage(wxBookCtrlBase *parent, const wxString&pageName) if ( pageName == RADIOBUTTONS_PAGE_NAME ) return CreateRadioButtonsPage(parent); - if ( pageName == MAXIMIZED_BUTTON_PAGE_NAME ) - return CreateBigButtonPage(parent); + if ( pageName == TEXT_PAGE_NAME ) + return CreateFullPageText(parent); wxFAIL_MSG( "unknown page name" ); diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index ac7d13197c..acba301099 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -189,7 +189,7 @@ enum ID_COMMANDS #define I_WAS_INSERTED_PAGE_NAME "Inserted" #define RADIOBUTTONS_PAGE_NAME "Radiobuttons" #define VETO_PAGE_NAME "Veto" -#define MAXIMIZED_BUTTON_PAGE_NAME "Maximized button" +#define TEXT_PAGE_NAME "Text" // Pages that can be added by the user #define INSERTED_PAGE_NAME "Inserted "