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