Continuation of 'widgets' sample improvements.
[wxWidgets.git] / samples / widgets / notebook.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWidgets Widgets Sample
3 // Name: notebook.cpp
4 // Purpose: Part of the widgets sample showing book controls
5 // Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
6 // Created: 06.04.01
7 // Id: $Id$
8 // Copyright: (c) 2001 Vadim Zeitlin, 2006 Wlodzimierz Skiba
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_BOOKCTRL
28
29 // for all others, include the necessary headers
30 #ifndef WX_PRECOMP
31 #include "wx/app.h"
32 #include "wx/log.h"
33
34 #include "wx/button.h"
35 #include "wx/checkbox.h"
36 #include "wx/combobox.h"
37 #include "wx/radiobox.h"
38 #include "wx/statbox.h"
39 #include "wx/textctrl.h"
40
41 #include "wx/dynarray.h"
42 #endif
43
44 #include "wx/sizer.h"
45 #include "wx/bookctrl.h"
46 #include "wx/artprov.h"
47
48 #include "widgets.h"
49
50 // ----------------------------------------------------------------------------
51 // constants
52 // ----------------------------------------------------------------------------
53
54 // control ids
55 enum
56 {
57 BookPage_Reset = wxID_HIGHEST,
58 BookPage_SelectPage,
59 BookPage_AddPage,
60 BookPage_InsertPage,
61 BookPage_RemovePage,
62 BookPage_DeleteAll,
63 BookPage_InsertText,
64 BookPage_RemoveText,
65 BookPage_SelectText,
66 BookPage_NumPagesText,
67 BookPage_CurSelectText,
68 BookPage_Book
69 };
70
71 // book orientations
72 enum Orient
73 {
74 Orient_Top,
75 Orient_Bottom,
76 Orient_Left,
77 Orient_Right,
78 Orient_Max
79 };
80
81 // ----------------------------------------------------------------------------
82 // BookWidgetsPage
83 // ----------------------------------------------------------------------------
84
85 class BookWidgetsPage : public WidgetsPage
86 {
87 public:
88 BookWidgetsPage(WidgetsBookCtrl *book);
89 virtual ~BookWidgetsPage();
90
91 virtual wxControl *GetWidget() const { return m_book; }
92 virtual void RecreateWidget() { RecreateBook(); }
93
94 protected:
95 // event handlers
96 void OnButtonReset(wxCommandEvent& event);
97 void OnButtonDeleteAll(wxCommandEvent& event);
98 void OnButtonSelectPage(wxCommandEvent& event);
99 void OnButtonAddPage(wxCommandEvent& event);
100 void OnButtonInsertPage(wxCommandEvent& event);
101 void OnButtonRemovePage(wxCommandEvent& event);
102
103 void OnCheckOrRadioBox(wxCommandEvent& event);
104
105 void OnUpdateUINumPagesText(wxUpdateUIEvent& event);
106 void OnUpdateUICurSelectText(wxUpdateUIEvent& event);
107
108 void OnUpdateUISelectButton(wxUpdateUIEvent& event);
109 void OnUpdateUIInsertButton(wxUpdateUIEvent& event);
110 void OnUpdateUIRemoveButton(wxUpdateUIEvent& event);
111
112 void OnUpdateUIResetButton(wxUpdateUIEvent& event);
113
114 // reset book parameters
115 void Reset();
116
117 // (re)create book
118 void RecreateBook();
119 virtual wxBookCtrlBase *CreateBook(long flags) = 0;
120
121 // create or destroy the image list
122 void CreateImageList();
123
124 // create a new page
125 wxWindow *CreateNewPage();
126
127 // get the image index for the new page
128 int GetIconIndex() const;
129
130 // get the numeric value of text ctrl
131 int GetTextValue(wxTextCtrl *text) const;
132
133 // is the value in range?
134 bool IsValidValue(int val) const
135 { return (val >= 0) && (val < (int) m_book->GetPageCount()); }
136
137 // the controls
138 // ------------
139
140 // the check/radio boxes for styles
141 wxCheckBox *m_chkImages;
142 wxRadioBox *m_radioOrient;
143
144 // the text controls containing input for various commands
145 wxTextCtrl *m_textInsert,
146 *m_textRemove,
147 *m_textSelect;
148
149 // the book itself and the sizer it is in
150 wxBookCtrlBase *m_book;
151 wxSizer *m_sizerBook;
152
153 // thei mage list for our book
154 wxImageList *m_imageList;
155
156 private:
157 DECLARE_EVENT_TABLE()
158 };
159
160 // ----------------------------------------------------------------------------
161 // event tables
162 // ----------------------------------------------------------------------------
163
164 BEGIN_EVENT_TABLE(BookWidgetsPage, WidgetsPage)
165 EVT_BUTTON(BookPage_Reset, BookWidgetsPage::OnButtonReset)
166 EVT_BUTTON(BookPage_SelectPage, BookWidgetsPage::OnButtonSelectPage)
167 EVT_BUTTON(BookPage_AddPage, BookWidgetsPage::OnButtonAddPage)
168 EVT_BUTTON(BookPage_InsertPage, BookWidgetsPage::OnButtonInsertPage)
169 EVT_BUTTON(BookPage_RemovePage, BookWidgetsPage::OnButtonRemovePage)
170 EVT_BUTTON(BookPage_DeleteAll, BookWidgetsPage::OnButtonDeleteAll)
171
172 EVT_UPDATE_UI(BookPage_NumPagesText, BookWidgetsPage::OnUpdateUINumPagesText)
173 EVT_UPDATE_UI(BookPage_CurSelectText, BookWidgetsPage::OnUpdateUICurSelectText)
174
175 EVT_UPDATE_UI(BookPage_SelectPage, BookWidgetsPage::OnUpdateUISelectButton)
176 EVT_UPDATE_UI(BookPage_InsertPage, BookWidgetsPage::OnUpdateUIInsertButton)
177 EVT_UPDATE_UI(BookPage_RemovePage, BookWidgetsPage::OnUpdateUIRemoveButton)
178
179 EVT_CHECKBOX(wxID_ANY, BookWidgetsPage::OnCheckOrRadioBox)
180 EVT_RADIOBOX(wxID_ANY, BookWidgetsPage::OnCheckOrRadioBox)
181 END_EVENT_TABLE()
182
183 // ============================================================================
184 // implementation
185 // ============================================================================
186
187 BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book)
188 :WidgetsPage(book)
189 {
190 // init everything
191 m_chkImages = NULL;
192 m_imageList = NULL;
193
194 m_book = NULL;
195 m_sizerBook = (wxSizer *)NULL;
196
197 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
198
199 // left pane
200 wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
201
202 // must be in sync with Orient enum
203 wxArrayString orientations;
204 orientations.Add(_T("&top"));
205 orientations.Add(_T("&bottom"));
206 orientations.Add(_T("&left"));
207 orientations.Add(_T("&right"));
208
209 wxASSERT_MSG( orientations.GetCount() == Orient_Max,
210 _T("forgot to update something") );
211
212 m_chkImages = new wxCheckBox(this, wxID_ANY, _T("Show &images"));
213 m_radioOrient = new wxRadioBox(this, wxID_ANY, _T("&Tab orientation"),
214 wxDefaultPosition, wxDefaultSize,
215 orientations, 1, wxRA_SPECIFY_COLS);
216
217 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
218
219 sizerLeft->Add(m_chkImages, 0, wxALL, 5);
220 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
221 sizerLeft->Add(m_radioOrient, 0, wxALL, 5);
222
223 wxButton *btn = new wxButton(this, BookPage_Reset, _T("&Reset"));
224 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
225
226 // middle pane
227 wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, _T("&Contents"));
228 wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
229
230 wxTextCtrl *text;
231 wxSizer *sizerRow = CreateSizerWithTextAndLabel(_T("Number of pages: "),
232 BookPage_NumPagesText,
233 &text);
234 text->SetEditable(false);
235 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
236
237 sizerRow = CreateSizerWithTextAndLabel(_T("Current selection: "),
238 BookPage_CurSelectText,
239 &text);
240 text->SetEditable(false);
241 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
242
243 sizerRow = CreateSizerWithTextAndButton(BookPage_SelectPage,
244 _T("&Select page"),
245 BookPage_SelectText,
246 &m_textSelect);
247 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
248
249 btn = new wxButton(this, BookPage_AddPage, _T("&Add page"));
250 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
251
252 sizerRow = CreateSizerWithTextAndButton(BookPage_InsertPage,
253 _T("&Insert page at"),
254 BookPage_InsertText,
255 &m_textInsert);
256 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
257
258 sizerRow = CreateSizerWithTextAndButton(BookPage_RemovePage,
259 _T("&Remove page"),
260 BookPage_RemoveText,
261 &m_textRemove);
262 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
263
264 btn = new wxButton(this, BookPage_DeleteAll, _T("&Delete All"));
265 sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
266
267 // right pane
268 m_sizerBook = new wxBoxSizer(wxHORIZONTAL);
269
270 // the 3 panes compose the window
271 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
272 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
273 sizerTop->Add(m_sizerBook, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
274
275 // final initializations
276 Reset();
277 CreateImageList();
278
279 SetSizer(sizerTop);
280
281 sizerTop->Fit(this);
282 }
283
284 BookWidgetsPage::~BookWidgetsPage()
285 {
286 delete m_imageList;
287 }
288
289 // ----------------------------------------------------------------------------
290 // operations
291 // ----------------------------------------------------------------------------
292
293 void BookWidgetsPage::Reset()
294 {
295 m_chkImages->SetValue(true);
296 m_radioOrient->SetSelection(Orient_Top);
297 }
298
299 void BookWidgetsPage::CreateImageList()
300 {
301 if ( m_chkImages->GetValue() )
302 {
303 if ( !m_imageList )
304 {
305 // create a dummy image list with a few icons
306 m_imageList = new wxImageList(32, 32);
307 wxSize size(32, 32);
308 m_imageList->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size));
309 m_imageList->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size));
310 m_imageList->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size));
311 m_imageList->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size));
312 }
313
314 if ( m_book )
315 m_book->SetImageList(m_imageList);
316 }
317 else // no images
318 {
319 if ( m_imageList )
320 {
321 delete m_imageList;
322 m_imageList = NULL;
323 }
324 }
325
326 // because of the bug in wxMSW we can't use SetImageList(NULL) - although
327 // it would be logical if this removed the image list from book, under
328 // MSW it crashes instead - FIXME
329 }
330
331 void BookWidgetsPage::RecreateBook()
332 {
333 int flags = ms_defaultFlags;
334 switch ( m_radioOrient->GetSelection() )
335 {
336 default:
337 wxFAIL_MSG( _T("unknown orientation") );
338 // fall through
339
340 case Orient_Top:
341 flags |= wxBK_TOP;
342 break;
343
344 case Orient_Bottom:
345 flags |= wxBK_BOTTOM;
346 break;
347
348 case Orient_Left:
349 flags |= wxBK_LEFT;
350 break;
351
352 case Orient_Right:
353 flags |= wxBK_RIGHT;
354 break;
355 }
356
357 wxBookCtrlBase *oldBook = m_book;
358
359 m_book = CreateBook(flags);
360
361 CreateImageList();
362
363 if ( oldBook )
364 {
365 const int sel = oldBook->GetSelection();
366
367 const int count = oldBook->GetPageCount();
368
369 // recreate the pages
370 for ( int n = 0; n < count; n++ )
371 {
372 m_book->AddPage(CreateNewPage(),
373 oldBook->GetPageText(n),
374 false,
375 m_chkImages->GetValue() ?
376 GetIconIndex() : -1);
377 }
378
379 m_sizerBook->Detach( oldBook );
380 delete oldBook;
381
382 // restore selection
383 if ( sel != -1 )
384 {
385 m_book->SetSelection(sel);
386 }
387 }
388
389 m_sizerBook->Add(m_book, 1, wxGROW | wxALL, 5);
390 m_sizerBook->SetMinSize(150, 0);
391 m_sizerBook->Layout();
392 }
393
394 // ----------------------------------------------------------------------------
395 // helpers
396 // ----------------------------------------------------------------------------
397
398 int BookWidgetsPage::GetTextValue(wxTextCtrl *text) const
399 {
400 long pos;
401 if ( !text->GetValue().ToLong(&pos) )
402 pos = -1;
403
404 return (int)pos;
405 }
406
407 int BookWidgetsPage::GetIconIndex() const
408 {
409 if ( m_imageList )
410 {
411 int nImages = m_imageList->GetImageCount();
412 if ( nImages > 0 )
413 {
414 return m_book->GetPageCount() % nImages;
415 }
416 }
417
418 return -1;
419 }
420
421 wxWindow *BookWidgetsPage::CreateNewPage()
422 {
423 return new wxTextCtrl(m_book, wxID_ANY, _T("I'm a book page"));
424 }
425
426 // ----------------------------------------------------------------------------
427 // event handlers
428 // ----------------------------------------------------------------------------
429
430 void BookWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
431 {
432 Reset();
433
434 RecreateBook();
435 }
436
437 void BookWidgetsPage::OnButtonDeleteAll(wxCommandEvent& WXUNUSED(event))
438 {
439 m_book->DeleteAllPages();
440 }
441
442 void BookWidgetsPage::OnButtonSelectPage(wxCommandEvent& WXUNUSED(event))
443 {
444 int pos = GetTextValue(m_textSelect);
445 wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
446
447 m_book->SetSelection(pos);
448 }
449
450 void BookWidgetsPage::OnButtonAddPage(wxCommandEvent& WXUNUSED(event))
451 {
452 m_book->AddPage(CreateNewPage(), _T("Added page"), false,
453 GetIconIndex());
454 }
455
456 void BookWidgetsPage::OnButtonInsertPage(wxCommandEvent& WXUNUSED(event))
457 {
458 int pos = GetTextValue(m_textInsert);
459 wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
460
461 m_book->InsertPage(pos, CreateNewPage(), _T("Inserted page"), false,
462 GetIconIndex());
463 }
464
465 void BookWidgetsPage::OnButtonRemovePage(wxCommandEvent& WXUNUSED(event))
466 {
467 int pos = GetTextValue(m_textRemove);
468 wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
469
470 m_book->DeletePage(pos);
471 }
472
473 void BookWidgetsPage::OnUpdateUISelectButton(wxUpdateUIEvent& event)
474 {
475 event.Enable( IsValidValue(GetTextValue(m_textSelect)) );
476 }
477
478 void BookWidgetsPage::OnUpdateUIInsertButton(wxUpdateUIEvent& event)
479 {
480 event.Enable( IsValidValue(GetTextValue(m_textInsert)) );
481 }
482
483 void BookWidgetsPage::OnUpdateUIRemoveButton(wxUpdateUIEvent& event)
484 {
485 event.Enable( IsValidValue(GetTextValue(m_textRemove)) );
486 }
487
488 void BookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
489 {
490 event.Enable( !m_chkImages->GetValue() ||
491 m_radioOrient->GetSelection() != wxBK_TOP );
492 }
493
494 void BookWidgetsPage::OnUpdateUINumPagesText(wxUpdateUIEvent& event)
495 {
496 event.SetText( wxString::Format(_T("%d"), m_book->GetPageCount()) );
497 }
498
499 void BookWidgetsPage::OnUpdateUICurSelectText(wxUpdateUIEvent& event)
500 {
501 event.SetText( wxString::Format(_T("%d"), m_book->GetSelection()) );
502 }
503
504 void BookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
505 {
506 RecreateBook();
507 }
508
509 #if wxUSE_NOTEBOOK
510
511 #include "icons/notebook.xpm"
512 #include "wx/notebook.h"
513
514 // ----------------------------------------------------------------------------
515 // NotebookWidgetsPage
516 // ----------------------------------------------------------------------------
517
518 class NotebookWidgetsPage : public BookWidgetsPage
519 {
520 public:
521 NotebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
522 : BookWidgetsPage(book)
523 {
524 imaglist->Add(wxBitmap(notebook_xpm));
525 RecreateBook();
526 }
527 virtual ~NotebookWidgetsPage() {}
528
529 protected:
530
531 // event handlers
532 void OnPageChanging(wxNotebookEvent& event);
533 void OnPageChanged(wxNotebookEvent& event);
534
535 // (re)create book
536 virtual wxBookCtrlBase *CreateBook(long flags)
537 {
538 return new wxNotebook(this, BookPage_Book,
539 wxDefaultPosition, wxDefaultSize,
540 flags);
541
542 }
543
544 private:
545 DECLARE_EVENT_TABLE()
546 DECLARE_WIDGETS_PAGE(NotebookWidgetsPage)
547 };
548
549 // ----------------------------------------------------------------------------
550 // event table
551 // ----------------------------------------------------------------------------
552
553 BEGIN_EVENT_TABLE(NotebookWidgetsPage, BookWidgetsPage)
554 EVT_NOTEBOOK_PAGE_CHANGING(wxID_ANY, NotebookWidgetsPage::OnPageChanging)
555 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, NotebookWidgetsPage::OnPageChanged)
556 END_EVENT_TABLE()
557
558 #if defined(__WXUNIVERSAL__)
559 #define FAMILY_CTRLS UNIVERSAL_CTRLS
560 #elif defined(__WXMOTIF__)
561 #define FAMILY_CTRLS GENERIC_CTRLS
562 #else
563 #define FAMILY_CTRLS NATIVE_CTRLS
564 #endif
565
566 IMPLEMENT_WIDGETS_PAGE(NotebookWidgetsPage, _T("Notebook"),
567 FAMILY_CTRLS | BOOK_CTRLS
568 );
569
570 void NotebookWidgetsPage::OnPageChanging(wxNotebookEvent& event)
571 {
572 wxLogMessage(_T("Notebook page changing from %d to %d (currently %d)."),
573 event.GetOldSelection(),
574 event.GetSelection(),
575 m_book->GetSelection());
576
577 event.Skip();
578 }
579
580 void NotebookWidgetsPage::OnPageChanged(wxNotebookEvent& event)
581 {
582 wxLogMessage(_T("Notebook page changed from %d to %d (currently %d)."),
583 event.GetOldSelection(),
584 event.GetSelection(),
585 m_book->GetSelection());
586
587 event.Skip();
588 }
589
590 #endif // wxUSE_NOTEBOOK
591
592 #if wxUSE_LISTBOOK
593
594 #include "icons/listbook.xpm"
595 #include "wx/listbook.h"
596
597 // ----------------------------------------------------------------------------
598 // ListbookWidgetsPage
599 // ----------------------------------------------------------------------------
600
601 class ListbookWidgetsPage : public BookWidgetsPage
602 {
603 public:
604 ListbookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
605 : BookWidgetsPage(book)
606 {
607 imaglist->Add(wxBitmap(listbook_xpm));
608 RecreateBook();
609 }
610 virtual ~ListbookWidgetsPage() {}
611
612 protected:
613
614 // event handlers
615 void OnPageChanging(wxListbookEvent& event);
616 void OnPageChanged(wxListbookEvent& event);
617
618 // (re)create book
619 virtual wxBookCtrlBase *CreateBook(long flags)
620 {
621 return new wxListbook(this, BookPage_Book,
622 wxDefaultPosition, wxDefaultSize,
623 flags);
624
625 }
626
627 private:
628 DECLARE_EVENT_TABLE()
629 DECLARE_WIDGETS_PAGE(ListbookWidgetsPage)
630 };
631
632 // ----------------------------------------------------------------------------
633 // event table
634 // ----------------------------------------------------------------------------
635
636 BEGIN_EVENT_TABLE(ListbookWidgetsPage, BookWidgetsPage)
637 EVT_LISTBOOK_PAGE_CHANGING(wxID_ANY, ListbookWidgetsPage::OnPageChanging)
638 EVT_LISTBOOK_PAGE_CHANGED(wxID_ANY, ListbookWidgetsPage::OnPageChanged)
639 END_EVENT_TABLE()
640
641 IMPLEMENT_WIDGETS_PAGE(ListbookWidgetsPage, _T("Listbook"),
642 GENERIC_CTRLS | BOOK_CTRLS
643 );
644
645 void ListbookWidgetsPage::OnPageChanging(wxListbookEvent& event)
646 {
647 wxLogMessage(_T("Listbook page changing from %d to %d (currently %d)."),
648 event.GetOldSelection(),
649 event.GetSelection(),
650 m_book->GetSelection());
651
652 event.Skip();
653 }
654
655 void ListbookWidgetsPage::OnPageChanged(wxListbookEvent& event)
656 {
657 wxLogMessage(_T("Listbook page changed from %d to %d (currently %d)."),
658 event.GetOldSelection(),
659 event.GetSelection(),
660 m_book->GetSelection());
661
662 event.Skip();
663 }
664
665 #endif // wxUSE_LISTBOOK
666
667 #if wxUSE_CHOICEBOOK
668
669 #include "icons/choicebk.xpm"
670 #include "wx/choicebk.h"
671
672 // ----------------------------------------------------------------------------
673 // ChoicebookWidgetsPage
674 // ----------------------------------------------------------------------------
675
676 class ChoicebookWidgetsPage : public BookWidgetsPage
677 {
678 public:
679 ChoicebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
680 : BookWidgetsPage(book)
681 {
682 imaglist->Add(wxBitmap(choicebk_xpm));
683 RecreateBook();
684 }
685 virtual ~ChoicebookWidgetsPage() {}
686
687 protected:
688
689 // event handlers
690 void OnPageChanging(wxChoicebookEvent& event);
691 void OnPageChanged(wxChoicebookEvent& event);
692
693 // (re)create book
694 virtual wxBookCtrlBase *CreateBook(long flags)
695 {
696 return new wxChoicebook(this, BookPage_Book,
697 wxDefaultPosition, wxDefaultSize,
698 flags);
699
700 }
701
702 private:
703 DECLARE_EVENT_TABLE()
704 DECLARE_WIDGETS_PAGE(ChoicebookWidgetsPage)
705 };
706
707 // ----------------------------------------------------------------------------
708 // event table
709 // ----------------------------------------------------------------------------
710
711 BEGIN_EVENT_TABLE(ChoicebookWidgetsPage, BookWidgetsPage)
712 EVT_CHOICEBOOK_PAGE_CHANGING(wxID_ANY, ChoicebookWidgetsPage::OnPageChanging)
713 EVT_CHOICEBOOK_PAGE_CHANGED(wxID_ANY, ChoicebookWidgetsPage::OnPageChanged)
714 END_EVENT_TABLE()
715
716 IMPLEMENT_WIDGETS_PAGE(ChoicebookWidgetsPage, _T("Choicebook"),
717 GENERIC_CTRLS | BOOK_CTRLS
718 );
719
720 void ChoicebookWidgetsPage::OnPageChanging(wxChoicebookEvent& event)
721 {
722 wxLogMessage(_T("Choicebook page changing from %d to %d (currently %d)."),
723 event.GetOldSelection(),
724 event.GetSelection(),
725 m_book->GetSelection());
726
727 event.Skip();
728 }
729
730 void ChoicebookWidgetsPage::OnPageChanged(wxChoicebookEvent& event)
731 {
732 wxLogMessage(_T("Choicebook page changed from %d to %d (currently %d)."),
733 event.GetOldSelection(),
734 event.GetSelection(),
735 m_book->GetSelection());
736
737 event.Skip();
738 }
739
740 #endif // wxUSE_CHOICEBOOK
741
742 #endif // wxUSE_BOOKCTRL