1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/notebook/notebook.cpp
3 // Purpose: a sample demonstrating notebook usage
4 // Author: Julian Smart
5 // Modified by: Dimitri Schoolwerth
8 // Copyright: (c) 1998-2002 wxWidgets team
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/imaglist.h"
24 #include "wx/artprov.h"
27 #if !defined(__WXMSW__) && !defined(__WXPM__)
28 #include "../sample.xpm"
35 // Create the main window
36 MyFrame
*frame
= new MyFrame();
38 // Problem with generic wxNotebook implementation whereby it doesn't size
39 // properly unless you set the size again
40 #if defined(__WXMOTIF__)
42 frame
->GetSize(& width
, & height
);
43 frame
->SetSize(wxDefaultCoord
, wxDefaultCoord
, width
, height
);
51 wxPanel
*CreateUserCreatedPage(wxBookCtrlBase
*parent
)
53 wxPanel
*panel
= new wxPanel(parent
);
55 (void) new wxButton( panel
, wxID_ANY
, wxT("Button"),
56 wxPoint(10, 10), wxDefaultSize
);
61 wxPanel
*CreateRadioButtonsPage(wxBookCtrlBase
*parent
)
63 wxPanel
*panel
= new wxPanel(parent
);
65 wxString animals
[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"),
66 wxT("Sabre-toothed tiger"), wxT("T Rex") };
68 wxRadioBox
*radiobox1
= new wxRadioBox(panel
, wxID_ANY
, wxT("Choose one"),
69 wxDefaultPosition
, wxDefaultSize
, 5, animals
, 2, wxRA_SPECIFY_ROWS
);
71 wxString computers
[] = { wxT("Amiga"), wxT("Commodore 64"), wxT("PET"),
74 wxRadioBox
*radiobox2
= new wxRadioBox(panel
, wxID_ANY
,
75 wxT("Choose your favourite"), wxDefaultPosition
, wxDefaultSize
,
76 4, computers
, 0, wxRA_SPECIFY_COLS
);
78 wxBoxSizer
*sizerPanel
= new wxBoxSizer(wxVERTICAL
);
79 sizerPanel
->Add(radiobox1
, 2, wxEXPAND
);
80 sizerPanel
->Add(radiobox2
, 1, wxEXPAND
);
81 panel
->SetSizer(sizerPanel
);
86 wxPanel
*CreateVetoPage(wxBookCtrlBase
*parent
)
88 wxPanel
*panel
= new wxPanel(parent
);
90 (void) new wxStaticText( panel
, wxID_ANY
,
91 wxT("This page intentionally left blank"), wxPoint(10, 10) );
96 wxPanel
*CreateBigButtonPage(wxBookCtrlBase
*parent
)
98 wxPanel
*panel
= new wxPanel(parent
);
100 wxButton
*buttonBig
= new wxButton(panel
, wxID_ANY
, wxT("Maximized button"));
102 wxBoxSizer
*sizerPanel
= new wxBoxSizer(wxVERTICAL
);
103 sizerPanel
->Add(buttonBig
, 1, wxEXPAND
);
104 panel
->SetSizer(sizerPanel
);
110 wxPanel
*CreateInsertPage(wxBookCtrlBase
*parent
)
112 wxPanel
*panel
= new wxPanel(parent
);
114 panel
->SetBackgroundColour( wxColour( wxT("MAROON") ) );
115 (void) new wxStaticText( panel
, wxID_ANY
,
116 wxT("This page has been inserted, not added."), wxPoint(10, 10) );
121 int GetIconIndex(wxBookCtrlBase
* bookCtrl
)
123 if (bookCtrl
&& bookCtrl
->GetImageList())
125 int nImages
= bookCtrl
->GetImageList()->GetImageCount();
128 return bookCtrl
->GetPageCount() % nImages
;
135 void CreateInitialPages(wxBookCtrlBase
*parent
)
137 // Create and add some panels to the notebook
139 wxPanel
*panel
= CreateRadioButtonsPage(parent
);
140 parent
->AddPage( panel
, RADIOBUTTONS_PAGE_NAME
, false, GetIconIndex(parent
) );
142 panel
= CreateVetoPage(parent
);
143 parent
->AddPage( panel
, VETO_PAGE_NAME
, false, GetIconIndex(parent
) );
145 panel
= CreateBigButtonPage(parent
);
146 parent
->AddPage( panel
, MAXIMIZED_BUTTON_PAGE_NAME
, false, GetIconIndex(parent
) );
148 panel
= CreateInsertPage(parent
);
149 parent
->InsertPage( 0, panel
, I_WAS_INSERTED_PAGE_NAME
, false, GetIconIndex(parent
) );
151 parent
->SetSelection(1);
154 wxPanel
*CreatePage(wxBookCtrlBase
*parent
, const wxString
&pageName
)
156 if ( pageName
.Contains(INSERTED_PAGE_NAME
) ||
157 pageName
.Contains(ADDED_PAGE_NAME
) ||
158 pageName
.Contains(ADDED_SUB_PAGE_NAME
) ||
159 pageName
.Contains(ADDED_PAGE_NAME_BEFORE
) )
160 return CreateUserCreatedPage(parent
);
162 if ( pageName
== I_WAS_INSERTED_PAGE_NAME
)
163 return CreateInsertPage(parent
);
165 if ( pageName
== VETO_PAGE_NAME
)
166 return CreateVetoPage(parent
);
168 if ( pageName
== RADIOBUTTONS_PAGE_NAME
)
169 return CreateRadioButtonsPage(parent
);
171 if ( pageName
== MAXIMIZED_BUTTON_PAGE_NAME
)
172 return CreateBigButtonPage(parent
);
174 wxFAIL_MSG( _T("unknown page name") );
180 : wxFrame(NULL
, wxID_ANY
, wxString(wxT("wxWidgets book controls sample")))
183 m_type
= Type_Notebook
;
184 #elif wxUSE_CHOICEBOOK
185 m_type
= Type_Choicebook
;
187 m_type
= Type_Listbook
;
189 m_type
= Type_Treebook
;
191 #error "Don't use Notebook sample without any book enabled in wxWidgets build!"
194 m_orient
= ID_ORIENT_DEFAULT
;
195 m_chkShowImages
= true;
198 SetIcon(wxICON(sample
));
200 // menu of the sample
201 wxMenu
*menuType
= new wxMenu
;
203 menuType
->AppendRadioItem(ID_BOOK_NOTEBOOK
, wxT("&Notebook\tCtrl-1"));
206 menuType
->AppendRadioItem(ID_BOOK_LISTBOOK
, wxT("&Listbook\tCtrl-2"));
209 menuType
->AppendRadioItem(ID_BOOK_CHOICEBOOK
, wxT("&Choicebook\tCtrl-3"));
212 menuType
->AppendRadioItem(ID_BOOK_TREEBOOK
, wxT("&Treebook\tCtrl-4"));
215 menuType
->AppendRadioItem(ID_BOOK_TOOLBOOK
, wxT("T&oolbook\tCtrl-5"));
218 menuType
->Check(ID_BOOK_NOTEBOOK
+ m_type
, true);
220 wxMenu
*menuOrient
= new wxMenu
;
221 menuOrient
->AppendRadioItem(ID_ORIENT_DEFAULT
, wxT("&Default\tCtrl-5"));
222 menuOrient
->AppendRadioItem(ID_ORIENT_TOP
, wxT("&Top\tCtrl-6"));
223 menuOrient
->AppendRadioItem(ID_ORIENT_BOTTOM
, wxT("&Bottom\tCtrl-7"));
224 menuOrient
->AppendRadioItem(ID_ORIENT_LEFT
, wxT("&Left\tCtrl-8"));
225 menuOrient
->AppendRadioItem(ID_ORIENT_RIGHT
, wxT("&Right\tCtrl-9"));
227 wxMenu
*menuOperations
= new wxMenu
;
228 menuOperations
->Append(ID_ADD_PAGE
, wxT("&Add page\tAlt-A"));
229 menuOperations
->Append(ID_INSERT_PAGE
, wxT("&Insert page\tAlt-I"));
230 menuOperations
->Append(ID_DELETE_CUR_PAGE
, wxT("&Delete current page\tAlt-D"));
231 menuOperations
->Append(ID_DELETE_LAST_PAGE
, wxT("D&elete last page\tAlt-L"));
232 menuOperations
->Append(ID_NEXT_PAGE
, wxT("&Next page\tAlt-N"));
234 menuOperations
->AppendSeparator();
235 menuOperations
->Append(ID_ADD_PAGE_BEFORE
, wxT("Insert page &before\tAlt-B"));
236 menuOperations
->Append(ID_ADD_SUB_PAGE
, wxT("Add s&ub page\tAlt-U"));
239 wxMenu
*menuFile
= new wxMenu
;
240 menuFile
->Append(wxID_ANY
, wxT("&Type"), menuType
, wxT("Type of control"));
241 menuFile
->Append(wxID_ANY
, wxT("&Orientation"), menuOrient
, wxT("Orientation of control"));
242 menuFile
->AppendCheckItem(ID_SHOW_IMAGES
, wxT("&Show images\tAlt-S"));
243 menuFile
->AppendCheckItem(ID_MULTI
, wxT("&Multiple lines\tAlt-M"));
244 menuFile
->AppendSeparator();
245 menuFile
->Append(wxID_EXIT
, wxT("E&xit"), wxT("Quits the application"));
246 menuFile
->Check(ID_SHOW_IMAGES
, m_chkShowImages
);
247 menuFile
->Check(ID_MULTI
, m_multi
);
249 wxMenuBar
*menuBar
= new wxMenuBar
;
250 menuBar
->Append(menuFile
, wxT("&File"));
251 menuBar
->Append(menuOperations
, wxT("&Operations"));
258 // create a dummy image list with a few icons
259 const wxSize
imageSize(32, 32);
261 m_imageList
= new wxImageList(imageSize
.GetWidth(), imageSize
.GetHeight());
263 Add(wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
, imageSize
));
265 Add(wxArtProvider::GetIcon(wxART_QUESTION
, wxART_OTHER
, imageSize
));
267 Add(wxArtProvider::GetIcon(wxART_WARNING
, wxART_OTHER
, imageSize
));
269 Add(wxArtProvider::GetIcon(wxART_ERROR
, wxART_OTHER
, imageSize
));
271 m_panel
= new wxPanel(this);
274 m_text
= new wxTextCtrl(m_panel
, wxID_ANY
, wxEmptyString
,
275 wxDefaultPosition
, wxDefaultSize
,
276 wxTE_MULTILINE
| wxTE_READONLY
);
278 m_logTargetOld
= wxLog::SetActiveTarget( new wxLogTextCtrl(m_text
) );
282 m_sizerFrame
= new wxBoxSizer(wxVERTICAL
);
285 m_sizerFrame
->Add(m_text
, 1, wxEXPAND
);
290 m_panel
->SetSizer(m_sizerFrame
);
292 m_sizerFrame
->Fit(this);
293 m_sizerFrame
->SetSizeHints(this);
301 delete wxLog::SetActiveTarget(m_logTargetOld
);
307 // DISPATCH_ON_TYPE() macro is an ugly way to write the "same" code for
308 // different wxBookCtrlBase-derived classes without duplicating code and
309 // without using templates, it expands into "before <xxx> after" where "xxx"
310 // part is control class-specific
312 #define CASE_NOTEBOOK(x) case Type_Notebook: x; break;
314 #define CASE_NOTEBOOK(x)
318 #define CASE_LISTBOOK(x) case Type_Listbook: x; break;
320 #define CASE_LISTBOOK(x)
324 #define CASE_CHOICEBOOK(x) case Type_Choicebook: x; break;
326 #define CASE_CHOICEBOOK(x)
330 #define CASE_TREEBOOK(x) case Type_Treebook: x; break;
332 #define CASE_TREEBOOK(x)
336 #define CASE_TOOLBOOK(x) case Type_Toolbook: x; break;
338 #define CASE_TOOLBOOK(x)
341 #define DISPATCH_ON_TYPE(before, nb, lb, cb, tb, toolb, after) \
344 CASE_NOTEBOOK(before nb after) \
345 CASE_LISTBOOK(before lb after) \
346 CASE_CHOICEBOOK(before cb after) \
347 CASE_TREEBOOK(before tb after) \
348 CASE_TOOLBOOK(before toolb after) \
351 wxFAIL_MSG( _T("unknown book control type") ); \
354 int MyFrame::TranslateBookFlag(int nb
, int lb
, int chb
, int tbk
, int toolbk
) const
358 DISPATCH_ON_TYPE(flag
=, nb
, lb
, chb
, tbk
, toolbk
, + 0);
363 void MyFrame::RecreateBook()
372 case ID_ORIENT_BOTTOM
:
380 case ID_ORIENT_RIGHT
:
385 flags
= wxBK_DEFAULT
;
388 if ( m_multi
&& m_type
== Type_Notebook
)
389 flags
|= wxNB_MULTILINE
;
390 flags
|= wxDOUBLE_BORDER
;
392 wxBookCtrlBase
*oldBook
= m_bookCtrl
;
396 DISPATCH_ON_TYPE(m_bookCtrl
= new,
402 (m_panel
, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, flags
));
409 if ( m_chkShowImages
)
411 m_bookCtrl
->SetImageList(m_imageList
);
417 // we only need the old treebook if we're recreating another treebook
418 wxTreebook
*tbkOld
= m_type
== Type_Treebook
419 ? wxDynamicCast(oldBook
, wxTreebook
)
421 #endif // wxUSE_TREEBOOK
423 const int count
= oldBook
->GetPageCount();
424 for ( int n
= 0; n
< count
; n
++ )
426 const int image
= GetIconIndex(m_bookCtrl
);
427 const wxString str
= oldBook
->GetPageText(n
);
429 wxWindow
*page
= CreatePage(m_bookCtrl
, str
);
431 // treebook complication: need to account for possible parent page
435 const int parent
= tbkOld
->GetPageParent(n
);
436 if ( parent
!= wxNOT_FOUND
)
438 wxStaticCast(m_bookCtrl
, wxTreebook
)->
439 InsertSubPage(parent
, page
, str
, false, image
);
441 // skip adding it again below
445 #endif // wxUSE_TREEBOOK
447 m_bookCtrl
->AddPage(page
, str
, false, image
);
450 const int sel
= oldBook
->GetSelection();
451 if ( sel
!= wxNOT_FOUND
)
452 m_bookCtrl
->SetSelection(sel
);
455 m_sizerFrame
->Detach(oldBook
);
460 CreateInitialPages(m_bookCtrl
);
463 m_sizerFrame
->Insert(0, m_bookCtrl
, wxSizerFlags(5).Expand().Border());
465 m_sizerFrame
->Show(m_bookCtrl
);
466 m_sizerFrame
->Layout();
469 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
471 EVT_MENU_RANGE(ID_BOOK_NOTEBOOK
, ID_BOOK_MAX
, MyFrame::OnType
)
472 EVT_MENU_RANGE(ID_ORIENT_DEFAULT
, ID_ORIENT_MAX
, MyFrame::OnOrient
)
473 EVT_MENU(ID_SHOW_IMAGES
, MyFrame::OnShowImages
)
474 EVT_MENU(ID_MULTI
, MyFrame::OnMulti
)
475 EVT_MENU(wxID_EXIT
, MyFrame::OnExit
)
478 EVT_MENU(ID_ADD_PAGE
, MyFrame::OnAddPage
)
479 EVT_MENU(ID_INSERT_PAGE
, MyFrame::OnInsertPage
)
480 EVT_MENU(ID_DELETE_CUR_PAGE
, MyFrame::OnDeleteCurPage
)
481 EVT_MENU(ID_DELETE_LAST_PAGE
, MyFrame::OnDeleteLastPage
)
482 EVT_MENU(ID_NEXT_PAGE
, MyFrame::OnNextPage
)
486 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY
, MyFrame::OnNotebook
)
487 EVT_NOTEBOOK_PAGE_CHANGING(wxID_ANY
, MyFrame::OnNotebook
)
490 EVT_LISTBOOK_PAGE_CHANGED(wxID_ANY
, MyFrame::OnListbook
)
491 EVT_LISTBOOK_PAGE_CHANGING(wxID_ANY
, MyFrame::OnListbook
)
494 EVT_CHOICEBOOK_PAGE_CHANGED(wxID_ANY
, MyFrame::OnChoicebook
)
495 EVT_CHOICEBOOK_PAGE_CHANGING(wxID_ANY
, MyFrame::OnChoicebook
)
498 EVT_TREEBOOK_PAGE_CHANGED(wxID_ANY
, MyFrame::OnTreebook
)
499 EVT_TREEBOOK_PAGE_CHANGING(wxID_ANY
, MyFrame::OnTreebook
)
501 EVT_MENU(ID_ADD_SUB_PAGE
, MyFrame::OnAddSubPage
)
502 EVT_MENU(ID_ADD_PAGE_BEFORE
, MyFrame::OnAddPageBefore
)
503 EVT_UPDATE_UI_RANGE(ID_ADD_PAGE_BEFORE
, ID_ADD_SUB_PAGE
,
504 MyFrame::OnUpdateTreeMenu
)
507 EVT_TOOLBOOK_PAGE_CHANGED(wxID_ANY
, MyFrame::OnToolbook
)
508 EVT_TOOLBOOK_PAGE_CHANGING(wxID_ANY
, MyFrame::OnToolbook
)
511 // Update title in idle time
512 EVT_IDLE(MyFrame::OnIdle
)
515 void MyFrame::OnType(wxCommandEvent
& event
)
517 m_type
= wx_static_cast(BookType
, event
.GetId() - ID_BOOK_NOTEBOOK
);
520 m_sizerFrame
->Hide(m_bookCtrl
);
527 void MyFrame::OnUpdateTreeMenu(wxUpdateUIEvent
& event
)
529 event
.Enable(m_type
== Type_Treebook
);
532 #endif // wxUSE_TREEBOOK
535 void MyFrame::OnOrient(wxCommandEvent
& event
)
537 m_orient
= event
.GetId();
539 m_sizerFrame
->Layout();
542 void MyFrame::OnShowImages(wxCommandEvent
& event
)
544 m_chkShowImages
= event
.IsChecked();
546 m_sizerFrame
->Layout();
549 void MyFrame::OnMulti(wxCommandEvent
& event
)
551 m_multi
= event
.IsChecked();
553 m_sizerFrame
->Layout();
554 wxLogMessage(_T("Multiline setting works only in wxNotebook."));
557 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
562 wxPanel
*MyFrame::CreateNewPage() const
564 wxPanel
*panel
= new wxPanel(m_bookCtrl
, wxID_ANY
);
565 (void) new wxButton(panel
, wxID_ANY
, wxT("First button"), wxPoint(10, 10));
566 (void) new wxButton(panel
, wxID_ANY
, wxT("Second button"), wxPoint(50, 100));
571 void MyFrame::OnAddPage(wxCommandEvent
& WXUNUSED(event
))
573 wxBookCtrlBase
*currBook
= GetCurrentBook();
577 static unsigned s_pageAdded
= 0;
578 currBook
->AddPage(CreateNewPage(),
581 ADDED_PAGE_NAME
wxT("%u"),
585 GetIconIndex(currBook
));
590 void MyFrame::OnAddSubPage(wxCommandEvent
& WXUNUSED(event
))
592 wxTreebook
*currBook
= wxDynamicCast(GetCurrentBook(), wxTreebook
);
595 const int selPos
= currBook
->GetSelection();
596 if ( selPos
== wxNOT_FOUND
)
598 wxLogError(_T("Select the parent page first!"));
602 static unsigned s_subPageAdded
= 0;
603 currBook
->InsertSubPage
609 ADDED_SUB_PAGE_NAME
wxT("%u"),
613 GetIconIndex(currBook
)
618 void MyFrame::OnAddPageBefore(wxCommandEvent
& WXUNUSED(event
))
620 wxBookCtrlBase
*currBook
= GetCurrentBook();
623 const int selPos
= currBook
->GetSelection();
624 if ( selPos
== wxNOT_FOUND
)
626 wxLogError(_T("Select the parent page first!"));
630 static unsigned s_subPageAdded
= 0;
631 currBook
->InsertPage(selPos
,
635 ADDED_PAGE_NAME_BEFORE
wxT("%u"),
639 GetIconIndex(currBook
));
642 #endif // wxUSE_TREEBOOK
644 void MyFrame::OnInsertPage(wxCommandEvent
& WXUNUSED(event
))
646 static unsigned s_pageIns
= 0;
648 wxBookCtrlBase
*currBook
= GetCurrentBook();
652 wxPanel
*panel
= CreateUserCreatedPage( currBook
);
654 currBook
->InsertPage( 0, panel
,
655 wxString::Format(INSERTED_PAGE_NAME
wxT("%u"), ++s_pageIns
), false,
656 GetIconIndex(currBook
) );
658 currBook
->SetSelection(0);
662 void MyFrame::OnDeleteCurPage(wxCommandEvent
& WXUNUSED(event
))
664 wxBookCtrlBase
*currBook
= GetCurrentBook();
668 int sel
= currBook
->GetSelection();
670 if (sel
!= wxNOT_FOUND
)
672 currBook
->DeletePage(sel
);
677 void MyFrame::OnDeleteLastPage(wxCommandEvent
& WXUNUSED(event
))
679 wxBookCtrlBase
*currBook
= GetCurrentBook();
683 int page
= currBook
->GetPageCount();
687 currBook
->DeletePage(page
- 1);
692 void MyFrame::OnNextPage(wxCommandEvent
& WXUNUSED(event
))
694 wxBookCtrlBase
*currBook
= GetCurrentBook();
698 currBook
->AdvanceSelection();
702 void MyFrame::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
704 static int s_nPages
= wxNOT_FOUND
;
705 static int s_nSel
= wxNOT_FOUND
;
706 static wxBookCtrlBase
*s_currBook
= NULL
;
708 wxBookCtrlBase
*currBook
= GetCurrentBook();
710 int nPages
= currBook
? currBook
->GetPageCount() : 0;
711 int nSel
= currBook
? currBook
->GetSelection() : wxNOT_FOUND
;
713 if ( nPages
!= s_nPages
|| nSel
!= s_nSel
|| s_currBook
!= currBook
)
717 s_currBook
= currBook
;
720 if ( nSel
== wxNOT_FOUND
)
721 selection
<< wxT("not found");
726 title
.Printf(wxT("Notebook and friends (%d pages, selection: %s)"), nPages
, selection
.c_str());
732 void MyFrame::OnBookCtrl(wxBookCtrlBaseEvent
& event
)
734 static const struct EventInfo
736 wxEventType typeChanged
,
743 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
,
744 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,
747 #endif // wxUSE_NOTEBOOK
750 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
,
751 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
,
754 #endif // wxUSE_LISTBOOK
757 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
,
758 wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
,
761 #endif // wxUSE_CHOICEBOOK
764 wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED
,
765 wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING
,
768 #endif // wxUSE_TREEBOOK
771 wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
,
772 wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
,
775 #endif // wxUSE_TOOLBOOK
782 const wxEventType eventType
= event
.GetEventType();
783 for ( size_t n
= 0; n
< WXSIZEOF(events
); n
++ )
785 const EventInfo
& ei
= events
[n
];
786 if ( eventType
== ei
.typeChanged
)
788 nameEvent
= wxT("Changed");
790 else if ( eventType
== ei
.typeChanging
)
792 const int idx
= event
.GetOldSelection();
794 // NB: can't use wxStaticCast here as wxBookCtrlBase is not in
796 const wxBookCtrlBase
* const
797 book
= wx_static_cast(wxBookCtrlBase
*, event
.GetEventObject());
798 if ( idx
!= wxNOT_FOUND
&&
799 book
&& book
->GetPageText(idx
) == VETO_PAGE_NAME
)
803 wxT("Are you sure you want to leave this page?\n")
804 wxT("(This demonstrates veto-ing)"),
805 wxT("Notebook sample"),
806 wxICON_QUESTION
| wxYES_NO
,
811 veto
= _T(" (vetoed)");
815 nameEvent
= wxT("Changing");
817 else // skip end of the loop
822 nameControl
= ei
.name
;
826 static int s_num
= 0;
828 wxLogMessage(wxT("Event #%d: %s: %s (%d) new sel %d, old %d%s"),
833 event
.GetSelection(),
834 event
.GetOldSelection(),
838 m_text
->SetInsertionPointEnd();