Applied patch [ 581280 ] Revamped notebook sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16214 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -1,12 +1,12 @@
 | 
				
			|||||||
/////////////////////////////////////////////////////////////////////////////
 | 
					/////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Name:        notebook.cpp
 | 
					// Name:        samples/notebook/notebook.cpp
 | 
				
			||||||
// Purpose:     wxNotebook demo
 | 
					// Purpose:     a sample demonstrating notebook usage
 | 
				
			||||||
// Author:      Julian Smart
 | 
					// Author:      Julian Smart
 | 
				
			||||||
// Modified by:
 | 
					// Modified by: Dimitri Schoolwerth
 | 
				
			||||||
// Created:     26/10/98
 | 
					// Created:     26/10/98
 | 
				
			||||||
// RCS-ID:      $Id$
 | 
					// RCS-ID:      $Id$
 | 
				
			||||||
// Copyright:   (c)
 | 
					// Copyright:   (c) 1998-2002 wxWindows team
 | 
				
			||||||
// Licence:     wxWindows licence
 | 
					// License:     wxWindows license
 | 
				
			||||||
/////////////////////////////////////////////////////////////////////////////
 | 
					/////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// For compilers that support precompilation, includes "wx.h".
 | 
					// For compilers that support precompilation, includes "wx.h".
 | 
				
			||||||
@@ -20,294 +20,453 @@
 | 
				
			|||||||
    #include "wx/wx.h"
 | 
					    #include "wx/wx.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// If 1, use a dialog. Otherwise use a frame.
 | 
					#include "wx/imaglist.h"
 | 
				
			||||||
#define USE_TABBED_DIALOG 1
 | 
					#include "wx/artprov.h"
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "notebook.h"
 | 
					#include "notebook.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_TABBED_DIALOG
 | 
					// Name of the Veto page
 | 
				
			||||||
MyDialog* dialog = (MyDialog *) NULL;
 | 
					#define VETO_PAGE_NAME wxT("Veto")
 | 
				
			||||||
#else // !USE_TABBED_DIALOG
 | 
					 | 
				
			||||||
MyFrame*  frame = (MyFrame *) NULL;
 | 
					 | 
				
			||||||
#endif // USE_TABBED_DIALOG
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
IMPLEMENT_APP(MyApp)
 | 
					IMPLEMENT_APP(MyApp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool MyApp::OnInit()
 | 
					bool MyApp::OnInit()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // Create the main window
 | 
					    // Create the main window
 | 
				
			||||||
#if USE_TABBED_DIALOG
 | 
					    MyFrame *frame = new MyFrame( wxT("Notebook sample") );
 | 
				
			||||||
  dialog = new MyDialog((wxFrame *) NULL, -1, "Notebook", wxPoint(-1, -1), wxSize(365, 390),
 | 
					 | 
				
			||||||
                        wxRESIZE_BORDER);
 | 
					 | 
				
			||||||
  dialog->ShowModal();
 | 
					 | 
				
			||||||
  delete dialog;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Quit immediately the dialog has been dismissed
 | 
					    // Problem with generic wxNotebook implementation whereby it doesn't size
 | 
				
			||||||
  return FALSE;
 | 
					    // properly unless you set the size again
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  frame = new MyFrame((wxFrame*) NULL, -1, "Notebook", wxPoint(-1, -1), wxSize(465, 390) );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Problem with generic wxNotebook implementation whereby it doesn't size properly unless
 | 
					 | 
				
			||||||
  // you set the size again
 | 
					 | 
				
			||||||
#if defined(__WIN16__) || defined(__WXMOTIF__)
 | 
					#if defined(__WIN16__) || defined(__WXMOTIF__)
 | 
				
			||||||
    int width, height;
 | 
					    int width, height;
 | 
				
			||||||
    frame->GetSize(& width, & height);
 | 
					    frame->GetSize(& width, & height);
 | 
				
			||||||
    frame->SetSize(-1, -1, width, height);
 | 
					    frame->SetSize(-1, -1, width, height);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    frame->Show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return TRUE;
 | 
					    return TRUE;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
 | 
					MyNotebook::MyNotebook(wxWindow *parent, wxWindowID id,
 | 
				
			||||||
 | 
					    const wxPoint& pos, const wxSize& size, long style)
 | 
				
			||||||
 | 
					    : wxNotebook(parent, id, pos, size, style)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  m_okButton = new wxButton(window, wxID_OK, "Close", wxPoint(-1, -1), wxSize(80, 25));
 | 
					    // Empty
 | 
				
			||||||
  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_insertPageButton = new wxButton(window, ID_INSERT_PAGE, "&Insert page", wxPoint(-1, -1), wxSize(80, 25));
 | 
					 | 
				
			||||||
  m_nextPageButton = new wxButton(window, ID_NEXT_PAGE, "&Next page", wxPoint(-1, -1), wxSize(80, 25));
 | 
					 | 
				
			||||||
  m_okButton->SetDefault();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxLayoutConstraints *c;
 | 
					void MyNotebook::CreateInitialPages()
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					{
 | 
				
			||||||
  c->right.SameAs(window, wxRight, 4);
 | 
					    wxPanel *panel = (wxPanel *) NULL;
 | 
				
			||||||
  c->bottom.SameAs(window, wxBottom, 4);
 | 
					    wxBoxSizer *sizerPanel = (wxBoxSizer *) NULL;
 | 
				
			||||||
  c->height.AsIs();
 | 
					 | 
				
			||||||
  c->width.AsIs();
 | 
					 | 
				
			||||||
  m_addPageButton->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    // Create and add some panels to the notebook
 | 
				
			||||||
  c->right.SameAs(m_addPageButton, wxLeft, 4);
 | 
					 | 
				
			||||||
  c->bottom.SameAs(window, wxBottom, 4);
 | 
					 | 
				
			||||||
  c->height.AsIs();
 | 
					 | 
				
			||||||
  c->width.AsIs();
 | 
					 | 
				
			||||||
  m_insertPageButton->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					 | 
				
			||||||
  c->right.SameAs(m_insertPageButton, wxLeft, 4);
 | 
					 | 
				
			||||||
  c->bottom.SameAs(window, wxBottom, 4);
 | 
					 | 
				
			||||||
  c->height.AsIs();
 | 
					 | 
				
			||||||
  c->width.AsIs();
 | 
					 | 
				
			||||||
  m_nextPageButton->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    // Panel 1
 | 
				
			||||||
  c->right.SameAs(m_nextPageButton, wxLeft, 4);
 | 
					    panel = new wxPanel(this);
 | 
				
			||||||
  c->bottom.SameAs(window, wxBottom, 4);
 | 
					 | 
				
			||||||
  c->height.AsIs();
 | 
					 | 
				
			||||||
  c->width.AsIs();
 | 
					 | 
				
			||||||
  m_cancelButton->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    sizerPanel = new wxBoxSizer(wxVERTICAL);
 | 
				
			||||||
  c->right.SameAs(m_cancelButton, wxLeft, 4);
 | 
					    sizerPanel->Add( new wxButton( panel, -1, wxT("Button") ) );
 | 
				
			||||||
  c->bottom.SameAs(window, wxBottom, 4);
 | 
					    sizerPanel->Add( new wxTextCtrl(panel, -1, wxT("1234"),
 | 
				
			||||||
  c->height.AsIs();
 | 
					        wxDefaultPosition, wxSize(120, 150) ) );
 | 
				
			||||||
  c->width.AsIs();
 | 
					    panel->SetSizer(sizerPanel);
 | 
				
			||||||
  m_okButton->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Add some panels
 | 
					    AddPage( panel, wxT("Controls without sizer"), TRUE, GetIconIndex() );
 | 
				
			||||||
  wxPanel *panel1 = new wxPanel(notebook, -1);
 | 
					 | 
				
			||||||
  //  panel1->SetBackgroundColour(wxColour("RED"));
 | 
					 | 
				
			||||||
  (void)new wxButton(panel1, -1, "Press me", wxPoint(10, 10));
 | 
					 | 
				
			||||||
  (void)new wxTextCtrl(panel1, -1, "1234", wxPoint(10, 40), wxSize(120, 150));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notebook->AddPage(panel1, "Cat", TRUE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxPanel *panel2 = new wxPanel(notebook, -1);
 | 
					    // Panel 2
 | 
				
			||||||
  panel2->SetAutoLayout(TRUE);
 | 
					    panel = new wxPanel(this);
 | 
				
			||||||
  panel2->SetBackgroundColour(wxColour("BLUE"));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" };
 | 
					    wxString animals[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"),
 | 
				
			||||||
  wxRadioBox *radiobox = new wxRadioBox(panel2, -1, "Choose one",
 | 
					        wxT("Sabre-toothed tiger"), wxT("T Rex") };
 | 
				
			||||||
                                        wxDefaultPosition, wxDefaultSize, 5, animals,
 | 
					    wxRadioBox *radiobox1 = new wxRadioBox(panel, -1, wxT("Choose one"),
 | 
				
			||||||
                                        2, wxRA_SPECIFY_ROWS);
 | 
					        wxDefaultPosition, wxDefaultSize, 5, animals, 2, wxRA_SPECIFY_ROWS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    wxString computers[] = { wxT("Amiga"), wxT("Commodore 64"), wxT("PET"),
 | 
				
			||||||
  c->left.SameAs(panel2, wxLeft, 10);
 | 
					        wxT("Another") };
 | 
				
			||||||
  c->top.SameAs(panel2, wxTop, 5);
 | 
					    wxRadioBox *radiobox2 = new wxRadioBox(panel, -1,
 | 
				
			||||||
  c->height.PercentOf(panel2, wxHeight, 50);
 | 
					        wxT("Choose your favourite"), wxDefaultPosition, wxDefaultSize,
 | 
				
			||||||
  c->right.SameAs(panel2, wxRight, 10);
 | 
					        4, computers, 0, wxRA_SPECIFY_COLS);
 | 
				
			||||||
  radiobox->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxRadioBox *radiobox2 = new wxRadioBox(panel2, -1, "Choose one",
 | 
					    sizerPanel = new wxBoxSizer(wxVERTICAL);
 | 
				
			||||||
 | 
					    sizerPanel->Add(radiobox1, 2, wxEXPAND);
 | 
				
			||||||
 | 
					    sizerPanel->Add(radiobox2, 1, wxEXPAND);
 | 
				
			||||||
 | 
					    panel->SetSizer(sizerPanel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AddPage( panel, wxT("Radiobuttons"), FALSE, GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Panel 3
 | 
				
			||||||
 | 
					    panel = new wxPanel(this);
 | 
				
			||||||
 | 
					    (void) new wxStaticText( panel, -1,
 | 
				
			||||||
 | 
					        wxT("This page intentionally left blank"), wxPoint(10, 10) );
 | 
				
			||||||
 | 
					    AddPage( panel, VETO_PAGE_NAME, FALSE, GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Panel 4
 | 
				
			||||||
 | 
					    panel = new wxPanel(this);
 | 
				
			||||||
 | 
					    wxButton *buttonBig = new wxButton( panel, -1, wxT("Big button"),
 | 
				
			||||||
 | 
					        wxPoint(0, 0), wxSize(480, 360) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    sizerPanel = new wxBoxSizer(wxVERTICAL);
 | 
				
			||||||
 | 
					    sizerPanel->Add(buttonBig, 1, wxEXPAND);
 | 
				
			||||||
 | 
					    panel->SetSizer(sizerPanel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    AddPage( panel, wxT("Big button"), FALSE, GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Panel 5
 | 
				
			||||||
 | 
					    panel = new wxPanel(this);
 | 
				
			||||||
 | 
					    panel->SetBackgroundColour( wxColour( wxT("MAROON") ) );
 | 
				
			||||||
 | 
					    (void) new wxStaticText( panel, -1,
 | 
				
			||||||
 | 
					        wxT("This page has been inserted, not added."), wxPoint(10, 10) );
 | 
				
			||||||
 | 
					    InsertPage( 0, panel, wxT("Inserted"), FALSE, GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetSelection(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int MyNotebook::GetIconIndex() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_imageList)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					       int nImages = m_imageList->GetImageCount();
 | 
				
			||||||
 | 
					       if (nImages > 0)
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					           return GetPageCount() % nImages;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
 | 
				
			||||||
 | 
					                 long style)
 | 
				
			||||||
 | 
					    : wxFrame((wxWindow *) NULL, -1, title, pos, size, style)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_panel = (wxPanel *) NULL;
 | 
				
			||||||
 | 
					    m_notebook = (MyNotebook *) NULL;
 | 
				
			||||||
 | 
					    m_imageList = (wxImageList *) NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
 | 
				
			||||||
 | 
					        wxTAB_TRAVERSAL|wxCLIP_CHILDREN|wxNO_BORDER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Create remaining controls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // must be in sync with Orient enum
 | 
				
			||||||
 | 
					    wxString strOrientations[] =
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        wxT("&Top"),
 | 
				
			||||||
 | 
					        wxT("&Bottom"),
 | 
				
			||||||
 | 
					        wxT("&Left"),
 | 
				
			||||||
 | 
					        wxT("&Right"),
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxASSERT_MSG( WXSIZEOF(strOrientations) == ORIENT_MAX,
 | 
				
			||||||
 | 
					                  wxT("forgot to update something") );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_radioOrient = new wxRadioBox
 | 
				
			||||||
 | 
					        (
 | 
				
			||||||
 | 
					            m_panel, ID_RADIO_ORIENT,
 | 
				
			||||||
 | 
					            wxT("&Tab orientation"),
 | 
				
			||||||
            wxDefaultPosition, wxDefaultSize,
 | 
					            wxDefaultPosition, wxDefaultSize,
 | 
				
			||||||
                                         5, animals,
 | 
					            WXSIZEOF(strOrientations), strOrientations,
 | 
				
			||||||
                                         2, wxRA_SPECIFY_ROWS);
 | 
					            1, wxRA_SPECIFY_COLS
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    m_chkShowImages = new wxCheckBox( m_panel, ID_CHK_SHOWIMAGES,
 | 
				
			||||||
  c->left.SameAs(radiobox, wxLeft);
 | 
					        wxT("&Show images") );
 | 
				
			||||||
  c->height.AsIs();
 | 
					 | 
				
			||||||
  c->top.Below(radiobox, 5);
 | 
					 | 
				
			||||||
  c->right.SameAs(radiobox, wxRight);
 | 
					 | 
				
			||||||
  radiobox2->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notebook->AddPage(panel2, "Dog");
 | 
					    m_btnAddPage = new wxButton( m_panel, ID_BTN_ADD_PAGE, wxT("&Add page") );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxPanel *panel3 = new wxPanel(notebook, -1);
 | 
					    m_btnInsertPage = new wxButton( m_panel, ID_BTN_INSERT_PAGE,
 | 
				
			||||||
  panel3->SetBackgroundColour(wxColour("WHITE"));
 | 
					        wxT("&Insert page") );
 | 
				
			||||||
  notebook->AddPage(panel3, "Goat");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxPanel *panel4 = new wxPanel(notebook, -1);
 | 
					    m_btnDeletePage = new wxButton( m_panel, ID_BTN_DELETE_PAGE,
 | 
				
			||||||
  panel4->SetBackgroundColour(wxColour("YELLOW"));
 | 
					        wxT("&Delete page") );
 | 
				
			||||||
  notebook->AddPage(panel4, "Sheep");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxPanel *panel5 = new wxPanel(notebook, -1);
 | 
					    m_btnNextPage = new wxButton( m_panel, ID_BTN_NEXT_PAGE,
 | 
				
			||||||
  panel5->SetBackgroundColour(wxColour("MAGENTA"));
 | 
					        wxT("&Next page") );
 | 
				
			||||||
  (void)new wxStaticText(panel5, -1, "This page has been inserted, not added", wxPoint(10, 10) );
 | 
					 | 
				
			||||||
  notebook->InsertPage(0, panel5, "Sheep");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notebook->SetSelection(2);
 | 
					    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(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_btnDeletePage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
 | 
				
			||||||
 | 
					        sizerLeft->Add(m_btnNextPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sizerLeft->Add(0, 0, 1); // Spacer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sizerLeft->Add(m_btnExit, 0, wxEXPAND);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_TABBED_DIALOG
 | 
					    m_sizerTop->Add(sizerLeft, 0, wxEXPAND | wxALL, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
 | 
					 | 
				
			||||||
    EVT_BUTTON(wxID_OK, MyDialog::OnOK)
 | 
					 | 
				
			||||||
    EVT_BUTTON(wxID_CANCEL, MyDialog::OnOK)
 | 
					 | 
				
			||||||
END_EVENT_TABLE()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
MyDialog::MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
 | 
					    m_sizerFrame->Add(m_sizerTop, 1, wxEXPAND);
 | 
				
			||||||
    const wxPoint& pos, const wxSize& size, const long windowStyle):
 | 
					    m_sizerFrame->Add(m_text, 0, wxEXPAND);
 | 
				
			||||||
  wxDialog(parent, id, title, pos, size, windowStyle)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    Init();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
 | 
					    ReInitNotebook();
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    EndModal(wxID_OK);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
 | 
					    m_panel->SetSizer(m_sizerFrame);
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    EndModal(wxID_CANCEL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyDialog::Init()
 | 
					    m_panel->SetAutoLayout(TRUE);
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  m_notebook = new wxNotebook(this, ID_NOTEBOOK);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxLayoutConstraints* c = new wxLayoutConstraints;
 | 
					    m_sizerFrame->Fit(this);
 | 
				
			||||||
  c->left.SameAs(this, wxLeft, 4);
 | 
					 | 
				
			||||||
  c->right.SameAs(this, wxRight, 4);
 | 
					 | 
				
			||||||
  c->top.SameAs(this, wxTop, 4);
 | 
					 | 
				
			||||||
  c->bottom.SameAs(this, wxBottom, 40);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  m_notebook->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  wxGetApp().InitTabView(m_notebook, this);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  SetAutoLayout(TRUE);
 | 
					 | 
				
			||||||
  Layout();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Centre(wxBOTH);
 | 
					    Centre(wxBOTH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MyFrame::~MyFrame()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    delete wxLog::SetActiveTarget(m_logTargetOld);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MyFrame::ReInitNotebook()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    switch ( m_radioOrient->GetSelection() )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            wxFAIL_MSG( wxT("unknown notebook orientation") );
 | 
				
			||||||
 | 
					            // fall through
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case ORIENT_TOP:
 | 
				
			||||||
 | 
					            flags = wxNB_TOP;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case ORIENT_BOTTOM:
 | 
				
			||||||
 | 
					            flags = wxNB_BOTTOM;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case ORIENT_LEFT:
 | 
				
			||||||
 | 
					            flags = wxNB_LEFT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case ORIENT_RIGHT:
 | 
				
			||||||
 | 
					            flags = wxNB_RIGHT;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MyNotebook *notebook = m_notebook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK,
 | 
				
			||||||
 | 
					                                wxDefaultPosition, wxDefaultSize,
 | 
				
			||||||
 | 
					                                flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CreateImageList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ( notebook )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int sel = notebook->GetSelection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int count = notebook->GetPageCount();
 | 
				
			||||||
 | 
					        for ( int n = 0; n < count; n++ )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            wxNotebookPage *page = notebook->GetPage(0);
 | 
				
			||||||
 | 
					            page->Reparent(m_notebook);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            m_notebook->AddPage( page, notebook->GetPageText(0), FALSE,
 | 
				
			||||||
 | 
					                m_notebook->GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            notebook->RemovePage(0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (m_sizerNotebook)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_sizerTop->Remove(m_sizerNotebook);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        delete notebook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // restore selection
 | 
				
			||||||
 | 
					        if ( sel != -1 )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_notebook->SetSelection(sel);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_sizerNotebook = new wxNotebookSizer(m_notebook);
 | 
				
			||||||
 | 
					    m_sizerTop->Add(m_sizerNotebook, 1, wxEXPAND | wxALL, 4);
 | 
				
			||||||
 | 
					    m_sizerTop->Layout();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MyFrame::CreateImageList()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_imageList)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        delete m_imageList;
 | 
				
			||||||
 | 
					        m_imageList = (wxImageList *) NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ( m_chkShowImages->IsChecked() )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // create a dummy image list with a few icons
 | 
				
			||||||
 | 
					        wxSize size(32, 32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_imageList = new wxImageList( size.GetWidth(), size.GetHeight() );
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        m_imageList->Add
 | 
				
			||||||
 | 
					            (
 | 
				
			||||||
 | 
					                wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size)
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_imageList->Add
 | 
				
			||||||
 | 
					            (
 | 
				
			||||||
 | 
					                wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_imageList->Add
 | 
				
			||||||
 | 
					            (
 | 
				
			||||||
 | 
					                wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size)
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_imageList->Add
 | 
				
			||||||
 | 
					            (
 | 
				
			||||||
 | 
					                wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size)
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        m_notebook->SetImageList(m_imageList);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else // USE_TABBED_DIALOG
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 | 
					BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 | 
				
			||||||
    EVT_BUTTON(wxID_OK, MyFrame::OnOK)
 | 
					    EVT_RADIOBOX(ID_RADIO_ORIENT, MyFrame::OnCheckOrRadioBox)
 | 
				
			||||||
    EVT_BUTTON(ID_DELETE_PAGE, MyFrame::OnDeletePage)
 | 
					    EVT_CHECKBOX(ID_CHK_SHOWIMAGES, MyFrame::OnCheckOrRadioBox)
 | 
				
			||||||
    EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
 | 
					
 | 
				
			||||||
    EVT_BUTTON(ID_INSERT_PAGE, MyFrame::OnInsertPage)
 | 
					    EVT_BUTTON(ID_BTN_ADD_PAGE, MyFrame::OnButtonAddPage)
 | 
				
			||||||
    EVT_BUTTON(ID_NEXT_PAGE, MyFrame::OnNextPage)
 | 
					    EVT_BUTTON(ID_BTN_INSERT_PAGE, MyFrame::OnButtonInsertPage)
 | 
				
			||||||
 | 
					    EVT_BUTTON(ID_BTN_DELETE_PAGE, MyFrame::OnButtonDeletePage)
 | 
				
			||||||
 | 
					    EVT_BUTTON(ID_BTN_NEXT_PAGE, MyFrame::OnButtonNextPage)
 | 
				
			||||||
 | 
					    EVT_BUTTON(wxID_OK, MyFrame::OnButtonExit)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyFrame::OnNotebook)
 | 
				
			||||||
 | 
					    EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyFrame::OnNotebook)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    EVT_IDLE(MyFrame::OnIdle)
 | 
					    EVT_IDLE(MyFrame::OnIdle)
 | 
				
			||||||
END_EVENT_TABLE()
 | 
					END_EVENT_TABLE()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MyFrame::MyFrame(wxFrame* parent, const wxWindowID id, const wxString& title,
 | 
					void MyFrame::OnCheckOrRadioBox(wxCommandEvent& event)
 | 
				
			||||||
    const wxPoint& pos, const wxSize& size, const long windowStyle):
 | 
					 | 
				
			||||||
  wxFrame(parent, id, title, pos, size, windowStyle)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_panel = (wxPanel*) NULL;
 | 
					        ReInitNotebook();
 | 
				
			||||||
    m_notebook = (wxNotebook*) NULL;
 | 
					 | 
				
			||||||
    Init();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnAddPage(wxCommandEvent& WXUNUSED(event))
 | 
					void MyFrame::OnButtonAddPage( wxCommandEvent& WXUNUSED(event) )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static size_t s_pageAdded = 0;
 | 
					    static size_t s_pageAdded = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wxPanel *panel = new wxPanel( m_notebook, -1 );
 | 
					    wxPanel *panel = new wxPanel( m_notebook, -1 );
 | 
				
			||||||
    (void)new wxButton( panel, -1, "Button", wxPoint( 10,10 ), wxSize(-1,-1) );
 | 
					    (void) new wxButton( panel, -1, wxT("Button"),
 | 
				
			||||||
 | 
					        wxPoint(10, 10), wxSize(-1, -1) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_notebook->AddPage( panel, wxString::Format("Added %u", ++s_pageAdded) );
 | 
					    m_notebook->AddPage(panel, wxString::Format(wxT("Added %u"),
 | 
				
			||||||
 | 
					        ++s_pageAdded), FALSE, m_notebook->GetIconIndex() );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnInsertPage(wxCommandEvent& WXUNUSED(event))
 | 
					void MyFrame::OnButtonInsertPage( wxCommandEvent& WXUNUSED(event) )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static size_t s_pageIns = 0;
 | 
					    static size_t s_pageIns = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wxPanel *panel = new wxPanel( m_notebook, -1 );
 | 
					    wxPanel *panel = new wxPanel( m_notebook, -1 );
 | 
				
			||||||
    (void)new wxButton( panel, -1, "Button", wxPoint( 10,10 ), wxSize(-1,-1) );
 | 
					    (void) new wxButton( panel, -1, wxT("Button"),
 | 
				
			||||||
 | 
					        wxPoint(10, 10), wxSize(-1, -1) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_notebook->InsertPage( 0, panel,
 | 
				
			||||||
 | 
					        wxString::Format(wxT("Inserted %u"), ++s_pageIns), FALSE,
 | 
				
			||||||
 | 
					        m_notebook->GetIconIndex() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_notebook->InsertPage(0, panel, wxString::Format("Inserted %u", ++s_pageIns) );
 | 
					 | 
				
			||||||
    m_notebook->SetSelection(0);
 | 
					    m_notebook->SetSelection(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wxWindow *test = NULL;
 | 
					void MyFrame::OnButtonDeletePage( wxCommandEvent& WXUNUSED(event) )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int sel = m_notebook->GetSelection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnDeletePage(wxCommandEvent& WXUNUSED(event))
 | 
					    if (sel != -1)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    if (m_notebook->GetPageCount() > 0)
 | 
					        m_notebook->DeletePage(sel);
 | 
				
			||||||
        m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
    if (test)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
       m_notebook->AddPage( test, "Readded" );
 | 
					 | 
				
			||||||
       test = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
       test = m_notebook->GetPage( m_notebook->GetPageCount()-1 );
 | 
					 | 
				
			||||||
       m_notebook->RemovePage( m_notebook->GetPageCount()-1 );
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnNextPage(wxCommandEvent& WXUNUSED(event))
 | 
					void MyFrame::OnButtonNextPage( wxCommandEvent& WXUNUSED(event) )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_notebook->AdvanceSelection();
 | 
					    m_notebook->AdvanceSelection();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
 | 
					void MyFrame::OnButtonExit( wxCommandEvent& WXUNUSED(event) )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Destroy();
 | 
					    Close();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
 | 
					void MyFrame::OnNotebook(wxNotebookEvent& event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Destroy();
 | 
					    wxString str = wxT("Unknown notebook event");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxEventType eventType = event.GetEventType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (eventType == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        str = wxT("Notebook changed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (eventType == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int idx = event.GetOldSelection();
 | 
				
			||||||
 | 
					        if ( idx != -1 && m_notebook->GetPageText(idx) == VETO_PAGE_NAME )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if
 | 
				
			||||||
 | 
					            (
 | 
				
			||||||
 | 
					                wxMessageBox(
 | 
				
			||||||
 | 
					                wxT("Are you sure you want to leave this notebook page?\n")
 | 
				
			||||||
 | 
					                wxT("(This demonstrates veto-ing)"),
 | 
				
			||||||
 | 
					                          wxT("Notebook sample"),
 | 
				
			||||||
 | 
					                          wxICON_QUESTION | wxYES_NO, this) != wxYES )
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                event.Veto();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::Init()
 | 
					        }
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxCLIP_CHILDREN);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxLayoutConstraints* c = new wxLayoutConstraints;
 | 
					        str = wxT("Notebook changing");
 | 
				
			||||||
  c->left.SameAs(this, wxLeft);
 | 
					    }
 | 
				
			||||||
  c->right.SameAs(this, wxRight);
 | 
					 | 
				
			||||||
  c->top.SameAs(this, wxTop);
 | 
					 | 
				
			||||||
  c->bottom.SameAs(this, wxBottom);
 | 
					 | 
				
			||||||
  m_panel->SetConstraints(c);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m_notebook = new wxNotebook(m_panel, ID_NOTEBOOK);
 | 
					    static int s_numNotebookEvents = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  c = new wxLayoutConstraints;
 | 
					    wxLogMessage(wxT("Notebook event #%d: %s (%d)"),
 | 
				
			||||||
  c->left.SameAs(m_panel, wxLeft, 4);
 | 
					        s_numNotebookEvents++, str, eventType);
 | 
				
			||||||
  c->right.SameAs(m_panel, wxRight, 4);
 | 
					 | 
				
			||||||
  c->top.SameAs(m_panel, wxTop, 4);
 | 
					 | 
				
			||||||
  c->bottom.SameAs(m_panel, wxBottom, 40);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m_notebook->SetConstraints(c);
 | 
					    m_text->SetInsertionPointEnd();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wxGetApp().InitTabView(m_notebook, m_panel);
 | 
					    event.Skip();
 | 
				
			||||||
 | 
					 | 
				
			||||||
  m_panel->SetAutoLayout(TRUE);
 | 
					 | 
				
			||||||
  SetAutoLayout(TRUE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Centre(wxBOTH);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Show(TRUE);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
 | 
					void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
 | 
				
			||||||
@@ -323,10 +482,8 @@ void MyFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
 | 
				
			|||||||
        s_nSel = nSel;
 | 
					        s_nSel = nSel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        wxString title;
 | 
					        wxString title;
 | 
				
			||||||
        title.Printf("Notebook (%d pages, selection: %d)", nPages, nSel);
 | 
					        title.Printf(wxT("Notebook (%d pages, selection: %d)"), nPages, nSel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SetTitle(title);
 | 
					        SetTitle(title);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // USE_TABBED_DIALOG
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,12 @@
 | 
				
			|||||||
/////////////////////////////////////////////////////////////////////////////
 | 
					/////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Name:        notebook.h
 | 
					// Name:        samples/notebook/notebook.h
 | 
				
			||||||
// Purpose:     wxNotebook demo
 | 
					// Purpose:     a sample demonstrating notebook usage
 | 
				
			||||||
// Author:      Julian Smart
 | 
					// Author:      Julian Smart
 | 
				
			||||||
// Modified by:
 | 
					// Modified by: Dimitri Schoolwerth
 | 
				
			||||||
// Created:     25/10/98
 | 
					// Created:     25/10/98
 | 
				
			||||||
// RCS-ID:      $Id$
 | 
					// RCS-ID:      $Id$
 | 
				
			||||||
// Copyright:   (c)
 | 
					// Copyright:   (c) 1998-2002 wxWindows team
 | 
				
			||||||
// Licence:     wxWindows licence
 | 
					// License:     wxWindows license
 | 
				
			||||||
/////////////////////////////////////////////////////////////////////////////
 | 
					/////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "wx/notebook.h"
 | 
					#include "wx/notebook.h"
 | 
				
			||||||
@@ -16,81 +16,109 @@ class MyApp: public wxApp
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    bool OnInit();
 | 
					    bool OnInit();
 | 
				
			||||||
    void InitTabView(wxNotebook* notebook, wxWindow* window);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    wxButton*   m_okButton;
 | 
					 | 
				
			||||||
    wxButton*   m_cancelButton;
 | 
					 | 
				
			||||||
    wxButton*   m_addPageButton, *m_insertPageButton;
 | 
					 | 
				
			||||||
    wxButton*   m_nextPageButton;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DECLARE_APP(MyApp)
 | 
					DECLARE_APP(MyApp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_TABBED_DIALOG
 | 
					//
 | 
				
			||||||
 | 
					class MyNotebook : public wxNotebook
 | 
				
			||||||
class MyDialog: public wxDialog
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
 | 
					    MyNotebook(wxWindow *parent, wxWindowID id = -1,
 | 
				
			||||||
        const wxPoint& pos, const wxSize& size, const long windowStyle = wxDEFAULT_DIALOG_STYLE);
 | 
					        const wxPoint& pos = wxDefaultPosition,
 | 
				
			||||||
 | 
					        const wxSize& size = wxDefaultSize, long style = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void OnOK(wxCommandEvent& event);
 | 
					    void CreateInitialPages();
 | 
				
			||||||
    void OnCloseWindow(wxCloseEvent& event);
 | 
					 | 
				
			||||||
    void Init();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					    int GetIconIndex() const;
 | 
				
			||||||
    wxNotebook* m_notebook;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    DECLARE_EVENT_TABLE()
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else // USE_TABBED_DIALOG
 | 
					//
 | 
				
			||||||
 | 
					 | 
				
			||||||
class MyFrame : public wxFrame
 | 
					class MyFrame : public wxFrame
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    MyFrame(wxFrame* parent, const wxWindowID id, const wxString& title,
 | 
					    MyFrame(const wxString& title, const wxPoint& pos = wxDefaultPosition,
 | 
				
			||||||
        const wxPoint& pos, const wxSize& size, const long windowStyle = wxDEFAULT_FRAME_STYLE);
 | 
					        const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    virtual ~MyFrame();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Recreates the notebook with the same pages, but with possibly
 | 
				
			||||||
 | 
					    // a different orientation and optionally with images.
 | 
				
			||||||
 | 
					    void ReInitNotebook();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void CreateImageList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void OnCheckOrRadioBox(wxCommandEvent& event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void OnButtonAddPage(wxCommandEvent& event);
 | 
				
			||||||
 | 
					    void OnButtonInsertPage(wxCommandEvent& event);
 | 
				
			||||||
 | 
					    void OnButtonDeletePage(wxCommandEvent& event);
 | 
				
			||||||
 | 
					    void OnButtonNextPage(wxCommandEvent& event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void OnButtonExit(wxCommandEvent& event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void OnNotebook(wxNotebookEvent& event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void OnOK(wxCommandEvent& event);
 | 
					 | 
				
			||||||
    void OnCloseWindow(wxCloseEvent& event);
 | 
					 | 
				
			||||||
    void OnAddPage(wxCommandEvent& event);
 | 
					 | 
				
			||||||
    void OnInsertPage(wxCommandEvent& event);
 | 
					 | 
				
			||||||
    void OnNextPage(wxCommandEvent& event);
 | 
					 | 
				
			||||||
    void OnDeletePage(wxCommandEvent& event);
 | 
					 | 
				
			||||||
    void OnIdle(wxIdleEvent& event);
 | 
					    void OnIdle(wxIdleEvent& event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Init();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					private:
 | 
				
			||||||
    wxNotebook*     m_notebook;
 | 
					    wxLog *m_logTargetOld;
 | 
				
			||||||
    wxPanel*        m_panel; // Panel containing notebook and OK/Cancel/Help
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Controls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxPanel *m_panel; // Panel containing notebook and other controls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxRadioBox *m_radioOrient;
 | 
				
			||||||
 | 
					    wxCheckBox *m_chkShowImages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxButton *m_btnAddPage;
 | 
				
			||||||
 | 
					    wxButton *m_btnInsertPage;
 | 
				
			||||||
 | 
					    wxButton *m_btnDeletePage;
 | 
				
			||||||
 | 
					    wxButton *m_btnNextPage;
 | 
				
			||||||
 | 
					    wxButton *m_btnExit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MyNotebook *m_notebook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Log window
 | 
				
			||||||
 | 
					    wxTextCtrl *m_text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Sizers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // The frame's sizer. Consists of m_sizerTop and the log window
 | 
				
			||||||
 | 
					    // at the bottom.
 | 
				
			||||||
 | 
					    wxBoxSizer *m_sizerFrame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Sizer that contains the notebook and controls on the left
 | 
				
			||||||
 | 
					    wxBoxSizer *m_sizerTop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Sizer for m_notebook
 | 
				
			||||||
 | 
					    wxNotebookSizer *m_sizerNotebook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    wxImageList *m_imageList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DECLARE_EVENT_TABLE()
 | 
					    DECLARE_EVENT_TABLE()
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // USE_TABBED_DIALOG
 | 
					enum ID_CONTROLS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
// File ids
 | 
					    ID_RADIO_ORIENT = wxID_HIGHEST,
 | 
				
			||||||
#define TEST_ABOUT          2
 | 
					    ID_CHK_SHOWIMAGES,
 | 
				
			||||||
 | 
					    ID_BTN_ADD_PAGE,
 | 
				
			||||||
// Tab ids
 | 
					    ID_BTN_INSERT_PAGE,
 | 
				
			||||||
#define TEST_TAB_DOG        1
 | 
					    ID_BTN_DELETE_PAGE,
 | 
				
			||||||
#define TEST_TAB_CAT        2
 | 
					    ID_BTN_NEXT_PAGE,
 | 
				
			||||||
#define TEST_TAB_GOAT       3
 | 
					    ID_NOTEBOOK
 | 
				
			||||||
#define TEST_TAB_GUINEAPIG  4
 | 
					};
 | 
				
			||||||
#define TEST_TAB_ANTEATER   5
 | 
					 | 
				
			||||||
#define TEST_TAB_HUMMINGBIRD 6
 | 
					 | 
				
			||||||
#define TEST_TAB_SHEEP      7
 | 
					 | 
				
			||||||
#define TEST_TAB_COW        8
 | 
					 | 
				
			||||||
#define TEST_TAB_HORSE      9
 | 
					 | 
				
			||||||
#define TEST_TAB_PIG        10
 | 
					 | 
				
			||||||
#define TEST_TAB_OSTRICH    11
 | 
					 | 
				
			||||||
#define TEST_TAB_AARDVARK   12
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define ID_NOTEBOOK         1000
 | 
					 | 
				
			||||||
#define ID_ADD_PAGE         1200
 | 
					 | 
				
			||||||
#define ID_DELETE_PAGE      1201
 | 
					 | 
				
			||||||
#define ID_NEXT_PAGE        1202
 | 
					 | 
				
			||||||
#define ID_INSERT_PAGE      1203
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// notebook orientations
 | 
				
			||||||
 | 
					enum ORIENT
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ORIENT_TOP,
 | 
				
			||||||
 | 
					    ORIENT_BOTTOM,
 | 
				
			||||||
 | 
					    ORIENT_LEFT,
 | 
				
			||||||
 | 
					    ORIENT_RIGHT,
 | 
				
			||||||
 | 
					    ORIENT_MAX
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user