]> git.saurik.com Git - wxWidgets.git/blame - src/generic/notebook.cpp
using new API (no visual difference)
[wxWidgets.git] / src / generic / notebook.cpp
CommitLineData
1e6d9499 1///////////////////////////////////////////////////////////////////////////////
7fc65a03
WS
2// Name: src/generic/notebook.cpp
3// Purpose: generic implementation of wxNotebook
1e6d9499
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
1e6d9499
JS
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
ffecfa5a 19
1cc4f822
JJ
20#ifdef __VMS
21#pragma message disable unscomzer
22#endif
23
1e6d9499
JS
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28#pragma hdrstop
29#endif
30
4055ed82
WS
31#ifndef __WXPALMOS__
32
ed58dbea
RR
33#include "wx/string.h"
34#include "wx/log.h"
35#include "wx/settings.h"
36#include "wx/generic/imaglist.h"
37#include "wx/notebook.h"
38#include "wx/dcclient.h"
00dd3b18 39#include "wx/generic/tabg.h"
1e6d9499
JS
40
41// ----------------------------------------------------------------------------
42// macros
43// ----------------------------------------------------------------------------
44
45// check that the page index is valid
0ea23391 46#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
1e6d9499
JS
47
48// ----------------------------------------------------------------------------
49// event table
50// ----------------------------------------------------------------------------
51
2e4df4bf
VZ
52DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
53DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
54
1e6d9499 55BEGIN_EVENT_TABLE(wxNotebook, wxControl)
ca65c044 56 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
1e6d9499
JS
57 EVT_SIZE(wxNotebook::OnSize)
58 EVT_PAINT(wxNotebook::OnPaint)
59 EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent)
60 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
61 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
1e6d9499
JS
62END_EVENT_TABLE()
63
64IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
65IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
1e6d9499
JS
66
67// ============================================================================
68// implementation
69// ============================================================================
70
00dd3b18
MB
71// ============================================================================
72// Private class
73// ============================================================================
74
75// This reuses wxTabView to draw the tabs.
76class WXDLLEXPORT wxNotebookTabView: public wxTabView
77{
78DECLARE_DYNAMIC_CLASS(wxNotebookTabView)
79public:
80 wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
81 ~wxNotebookTabView(void);
82
83 // Called when a tab is activated
84 virtual void OnTabActivate(int activateId, int deactivateId);
85 // Allows vetoing
86 virtual bool OnTabPreActivate(int activateId, int deactivateId);
87
88protected:
89 wxNotebook* m_notebook;
90};
91
1e6d9499
JS
92// ----------------------------------------------------------------------------
93// wxNotebook construction
94// ----------------------------------------------------------------------------
95
96// common part of all ctors
97void wxNotebook::Init()
98{
99 m_tabView = (wxNotebookTabView*) NULL;
1e6d9499
JS
100 m_nSelection = -1;
101}
102
103// default for dynamic class
104wxNotebook::wxNotebook()
105{
106 Init();
107}
108
109// the same arguments as for wxControl
110wxNotebook::wxNotebook(wxWindow *parent,
111 wxWindowID id,
112 const wxPoint& pos,
113 const wxSize& size,
114 long style,
115 const wxString& name)
116{
117 Init();
118
119 Create(parent, id, pos, size, style, name);
120}
121
122// Create() function
123bool wxNotebook::Create(wxWindow *parent,
124 wxWindowID id,
125 const wxPoint& pos,
126 const wxSize& size,
127 long style,
128 const wxString& name)
129{
130 // base init
131 SetName(name);
132
ca65c044 133 m_windowId = id == wxID_ANY ? NewControlId() : id;
1e6d9499 134
b4f8693c 135 if (!wxControl::Create(parent, id, pos, size, style|wxNO_BORDER, wxDefaultValidator, name))
ca65c044 136 return false;
1e6d9499 137
a756f210 138 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
f60d0f94 139
1e6d9499
JS
140 SetTabView(new wxNotebookTabView(this));
141
ca65c044 142 return true;
1e6d9499
JS
143}
144
145// dtor
146wxNotebook::~wxNotebook()
147{
148 delete m_tabView;
149}
150
151// ----------------------------------------------------------------------------
152// wxNotebook accessors
153// ----------------------------------------------------------------------------
1e6d9499
JS
154int wxNotebook::GetRowCount() const
155{
156 // TODO
157 return 0;
158}
159
15aad3b9 160int wxNotebook::SetSelection(size_t nPage)
1e6d9499 161{
1e6d9499
JS
162 wxASSERT( IS_VALID_PAGE(nPage) );
163
164 wxNotebookPage* pPage = GetPage(nPage);
165
166 m_tabView->SetTabSelection((int) (long) pPage);
3a5bcc4d 167
1e6d9499
JS
168 // TODO
169 return 0;
170}
171
45f22d48 172#if 0
1e6d9499
JS
173void wxNotebook::AdvanceSelection(bool bForward)
174{
175 int nSel = GetSelection();
176 int nMax = GetPageCount() - 1;
177 if ( bForward )
178 SetSelection(nSel == nMax ? 0 : nSel + 1);
179 else
180 SetSelection(nSel == 0 ? nMax : nSel - 1);
181}
45f22d48 182#endif
1e6d9499 183
15aad3b9 184bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
1e6d9499
JS
185{
186 wxASSERT( IS_VALID_PAGE(nPage) );
3a5bcc4d 187
1e6d9499
JS
188 wxNotebookPage* page = GetPage(nPage);
189 if (page)
190 {
191 m_tabView->SetTabText((int) (long) page, strText);
192 Refresh();
ca65c044 193 return true;
1e6d9499 194 }
3a5bcc4d 195
ca65c044 196 return false;
1e6d9499
JS
197}
198
15aad3b9 199wxString wxNotebook::GetPageText(size_t nPage) const
1e6d9499
JS
200{
201 wxASSERT( IS_VALID_PAGE(nPage) );
202
203 wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage);
204 if (page)
205 return m_tabView->GetTabText((int) (long) page);
206 else
207 return wxEmptyString;
208}
209
3f9ee1cd 210int wxNotebook::GetPageImage(size_t WXUNUSED_UNLESS_DEBUG(nPage)) const
1e6d9499
JS
211{
212 wxASSERT( IS_VALID_PAGE(nPage) );
213
214 // TODO
215 return 0;
216}
217
3f9ee1cd
VZ
218bool wxNotebook::SetPageImage(size_t WXUNUSED_UNLESS_DEBUG(nPage),
219 int WXUNUSED(nImage))
1e6d9499
JS
220{
221 wxASSERT( IS_VALID_PAGE(nPage) );
222
223 // TODO
ca65c044 224 return false;
1e6d9499
JS
225}
226
9806a47c 227// set the size (the same for all pages)
7fc65a03 228void wxNotebook::SetPageSize(const wxSize& WXUNUSED(size))
9806a47c
JS
229{
230 // TODO
231}
232
233// set the padding between tabs (in pixels)
7fc65a03 234void wxNotebook::SetPadding(const wxSize& WXUNUSED(padding))
9806a47c
JS
235{
236 // TODO
237}
238
239// set the size of the tabs for wxNB_FIXEDWIDTH controls
7fc65a03 240void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
9806a47c
JS
241{
242 // TODO
243}
244
1e6d9499
JS
245// ----------------------------------------------------------------------------
246// wxNotebook operations
247// ----------------------------------------------------------------------------
248
249// remove one page from the notebook and delete it
15aad3b9 250bool wxNotebook::DeletePage(size_t nPage)
1e6d9499 251{
ca65c044 252 wxCHECK( IS_VALID_PAGE(nPage), false );
1e6d9499
JS
253
254 if (m_nSelection != -1)
255 {
ca65c044 256 m_pages[m_nSelection]->Show(false);
45f22d48 257 m_pages[m_nSelection]->Lower();
1e6d9499
JS
258 }
259
260 wxNotebookPage* pPage = GetPage(nPage);
3a5bcc4d 261
1e6d9499
JS
262 m_tabView->RemoveTab((int) (long) pPage);
263
45f22d48
JS
264 m_pages.Remove(pPage);
265 delete pPage;
1e6d9499 266
45f22d48 267 if (m_pages.GetCount() == 0)
1e6d9499
JS
268 {
269 m_nSelection = -1;
ca65c044 270 m_tabView->SetTabSelection(-1, false);
1e6d9499
JS
271 }
272 else if (m_nSelection > -1)
273 {
274 m_nSelection = -1;
3a5bcc4d 275
ca65c044 276 m_tabView->SetTabSelection((int) (long) GetPage(0), false);
3a5bcc4d 277
1e6d9499
JS
278 if (m_nSelection != 0)
279 ChangePage(-1, 0);
280 }
281
ca65c044 282 RefreshLayout(false);
1e6d9499 283
ca65c044 284 return true;
1e6d9499
JS
285}
286
287bool wxNotebook::DeletePage(wxNotebookPage* page)
288{
289 int pagePos = FindPagePosition(page);
290 if (pagePos > -1)
291 return DeletePage(pagePos);
292 else
ca65c044 293 return false;
1e6d9499
JS
294}
295
15aad3b9 296bool wxNotebook::RemovePage(size_t nPage)
64b090c7
MB
297{
298 return DoRemovePage(nPage) != NULL;
299}
300
301// remove one page from the notebook
302wxWindow* wxNotebook::DoRemovePage(size_t nPage)
1e6d9499 303{
10f2222c 304 wxCHECK( IS_VALID_PAGE(nPage), NULL );
1e6d9499 305
ca65c044 306 m_pages[nPage]->Show(false);
45f22d48 307 // m_pages[nPage]->Lower();
1e6d9499
JS
308
309 wxNotebookPage* pPage = GetPage(nPage);
3a5bcc4d 310
1e6d9499
JS
311 m_tabView->RemoveTab((int) (long) pPage);
312
45f22d48 313 m_pages.Remove(pPage);
1e6d9499 314
45f22d48 315 if (m_pages.GetCount() == 0)
1e6d9499
JS
316 {
317 m_nSelection = -1;
ca65c044 318 m_tabView->SetTabSelection(-1, true);
1e6d9499
JS
319 }
320 else if (m_nSelection > -1)
321 {
322 // Only change the selection if the page we
323 // deleted was the selection.
30d2b71d 324 if (nPage == (size_t)m_nSelection)
1e6d9499
JS
325 {
326 m_nSelection = -1;
327 // Select the first tab. Generates a ChangePage.
ca65c044 328 m_tabView->SetTabSelection(0, true);
1e6d9499
JS
329 }
330 else
331 {
ca65c044 332 // We must adjust which tab we think is selected.
1e6d9499
JS
333 // If greater than the page we deleted, it must be moved down
334 // a notch.
30d2b71d 335 if (size_t(m_nSelection) > nPage)
1e6d9499
JS
336 m_nSelection -- ;
337 }
338 }
339
ca65c044 340 RefreshLayout(false);
1e6d9499 341
64b090c7 342 return pPage;
1e6d9499
JS
343}
344
345bool wxNotebook::RemovePage(wxNotebookPage* page)
346{
347 int pagePos = FindPagePosition(page);
348 if (pagePos > -1)
349 return RemovePage(pagePos);
350 else
ca65c044 351 return false;
1e6d9499
JS
352}
353
354// Find the position of the wxNotebookPage, -1 if not found.
355int wxNotebook::FindPagePosition(wxNotebookPage* page) const
356{
15aad3b9
VZ
357 size_t nPageCount = GetPageCount();
358 size_t nPage;
1e6d9499 359 for ( nPage = 0; nPage < nPageCount; nPage++ )
45f22d48 360 if (m_pages[nPage] == page)
1e6d9499
JS
361 return nPage;
362 return -1;
363}
364
365// remove all pages
366bool wxNotebook::DeleteAllPages()
367{
ca65c044 368 m_tabView->ClearTabs(true);
1e6d9499 369
15aad3b9
VZ
370 size_t nPageCount = GetPageCount();
371 size_t nPage;
1e6d9499 372 for ( nPage = 0; nPage < nPageCount; nPage++ )
45f22d48 373 delete m_pages[nPage];
1e6d9499 374
45f22d48 375 m_pages.Clear();
1e6d9499 376
ca65c044 377 return true;
1e6d9499
JS
378}
379
1e6d9499 380// same as AddPage() but does it at given position
15aad3b9 381bool wxNotebook::InsertPage(size_t nPage,
1e6d9499
JS
382 wxNotebookPage *pPage,
383 const wxString& strText,
384 bool bSelect,
7fc65a03 385 int WXUNUSED(imageId))
1e6d9499
JS
386{
387 wxASSERT( pPage != NULL );
ca65c044 388 wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );
1e6d9499
JS
389
390 m_tabView->AddTab((int) (long) pPage, strText);
3a5bcc4d 391
1e6d9499 392 if (!bSelect)
ca65c044 393 pPage->Show(false);
1e6d9499
JS
394
395 // save the pointer to the page
45f22d48 396 m_pages.Insert(pPage, nPage);
1e6d9499
JS
397
398 if (bSelect)
399 {
400 // This will cause ChangePage to be called, via OnSelPage
3a5bcc4d 401
ca65c044 402 m_tabView->SetTabSelection((int) (long) pPage, true);
1e6d9499
JS
403 }
404
405 // some page must be selected: either this one or the first one if there is
406 // still no selection
407 if ( m_nSelection == -1 )
408 ChangePage(-1, 0);
409
ca65c044 410 RefreshLayout(false);
1e6d9499 411
ca65c044 412 return true;
1e6d9499
JS
413}
414
415// ----------------------------------------------------------------------------
416// wxNotebook callbacks
417// ----------------------------------------------------------------------------
418
419// @@@ OnSize() is used for setting the font when it's called for the first
420// time because doing it in ::Create() doesn't work (for unknown reasons)
421void wxNotebook::OnSize(wxSizeEvent& event)
422{
ca65c044 423 static bool s_bFirstTime = true;
1e6d9499
JS
424 if ( s_bFirstTime ) {
425 // TODO: any first-time-size processing.
ca65c044 426 s_bFirstTime = false;
1e6d9499
JS
427 }
428
429 RefreshLayout();
430
431 // Processing continues to next OnSize
432 event.Skip();
433}
434
435// This was supposed to cure the non-display of the notebook
436// until the user resizes the window.
437// What's going on?
5180055b 438void wxNotebook::OnInternalIdle()
1e6d9499 439{
5180055b
JS
440 wxWindow::OnInternalIdle();
441
ca65c044
WS
442#if 0
443 static bool s_bFirstTime = true;
1e6d9499
JS
444 if ( s_bFirstTime ) {
445 /*
446 wxSize sz(GetSize());
447 sz.x ++;
448 SetSize(sz);
449 sz.x --;
450 SetSize(sz);
451 */
452
453 /*
454 wxSize sz(GetSize());
455 wxSizeEvent sizeEvent(sz, GetId());
456 sizeEvent.SetEventObject(this);
457 GetEventHandler()->ProcessEvent(sizeEvent);
458 Refresh();
459 */
ca65c044 460 s_bFirstTime = false;
1e6d9499 461 }
5180055b 462#endif
1e6d9499
JS
463}
464
465// Implementation: calculate the layout of the view rect
466// and resize the children if required
467bool wxNotebook::RefreshLayout(bool force)
468{
469 if (m_tabView)
470 {
471 wxRect oldRect = m_tabView->GetViewRect();
472
473 int cw, ch;
474 GetClientSize(& cw, & ch);
475
476 int tabHeight = m_tabView->GetTotalTabHeight();
477 wxRect rect;
478 rect.x = 4;
479 rect.y = tabHeight + 4;
480 rect.width = cw - 8;
481 rect.height = ch - 4 - rect.y ;
2e4df4bf 482
1e6d9499
JS
483 m_tabView->SetViewRect(rect);
484
25889d3c 485 m_tabView->LayoutTabs();
1e6d9499
JS
486
487 // Need to do it a 2nd time to get the tab height with
488 // the new view width, since changing the view width changes the
489 // tab layout.
490 tabHeight = m_tabView->GetTotalTabHeight();
491 rect.x = 4;
492 rect.y = tabHeight + 4;
493 rect.width = cw - 8;
494 rect.height = ch - 4 - rect.y ;
2e4df4bf 495
1e6d9499
JS
496 m_tabView->SetViewRect(rect);
497
25889d3c 498 m_tabView->LayoutTabs();
1e6d9499
JS
499
500 if (!force && (rect == oldRect))
ca65c044 501 return false;
1e6d9499
JS
502
503 // fit the notebook page to the tab control's display area
504
15aad3b9
VZ
505 size_t nCount = m_pages.Count();
506 for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
45f22d48 507 wxNotebookPage *pPage = m_pages[nPage];
10d1f413 508 wxRect clientRect = GetAvailableClientSize();
1e6d9499
JS
509 if (pPage->IsShown())
510 {
1e6d9499
JS
511 pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
512 if ( pPage->GetAutoLayout() )
513 pPage->Layout();
514 }
515 }
516 Refresh();
517 }
ca65c044 518 return true;
1e6d9499
JS
519}
520
521void wxNotebook::OnSelChange(wxNotebookEvent& event)
522{
523 // is it our tab control?
524 if ( event.GetEventObject() == this )
525 {
526 if (event.GetSelection() != m_nSelection)
527 ChangePage(event.GetOldSelection(), event.GetSelection());
528 }
529
530 // we want to give others a chance to process this message as well
531 event.Skip();
532}
533
534void wxNotebook::OnSetFocus(wxFocusEvent& event)
535{
536 // set focus to the currently selected page if any
537 if ( m_nSelection != -1 )
45f22d48 538 m_pages[m_nSelection]->SetFocus();
1e6d9499
JS
539
540 event.Skip();
541}
542
543void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
544{
545 if ( event.IsWindowChange() ) {
546 // change pages
547 AdvanceSelection(event.GetDirection());
548 }
549 else {
550 // pass to the parent
551 if ( GetParent() ) {
552 event.SetCurrentFocus(this);
553 GetParent()->ProcessEvent(event);
554 }
555 }
556}
557
558// ----------------------------------------------------------------------------
559// wxNotebook base class virtuals
560// ----------------------------------------------------------------------------
561
562// override these 2 functions to do nothing: everything is done in OnSize
563
564void wxNotebook::SetConstraintSizes(bool /* recurse */)
565{
566 // don't set the sizes of the pages - their correct size is not yet known
ca65c044 567 wxControl::SetConstraintSizes(false);
1e6d9499
JS
568}
569
570bool wxNotebook::DoPhase(int /* nPhase */)
571{
ca65c044 572 return true;
1e6d9499
JS
573}
574
af111fc3 575void wxNotebook::Command(wxCommandEvent& WXUNUSED(event))
1e6d9499 576{
b0c0a393 577 wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
1e6d9499
JS
578}
579
580// ----------------------------------------------------------------------------
581// wxNotebook helper functions
582// ----------------------------------------------------------------------------
583
584// hide the currently active panel and show the new one
585void wxNotebook::ChangePage(int nOldSel, int nSel)
586{
587 // cout << "ChangePage: " << nOldSel << ", " << nSel << "\n";
588 wxASSERT( nOldSel != nSel ); // impossible
589
590 if ( nOldSel != -1 ) {
ca65c044 591 m_pages[nOldSel]->Show(false);
45f22d48 592 m_pages[nOldSel]->Lower();
1e6d9499
JS
593 }
594
45f22d48 595 wxNotebookPage *pPage = m_pages[nSel];
1e6d9499
JS
596
597 wxRect clientRect = GetAvailableClientSize();
598 pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
599
f6bcfd97
BP
600 Refresh();
601
ca65c044 602 pPage->Show(true);
1e6d9499
JS
603 pPage->Raise();
604 pPage->SetFocus();
605
1e6d9499
JS
606 m_nSelection = nSel;
607}
608
609void wxNotebook::OnMouseEvent(wxMouseEvent& event)
610{
611 if (m_tabView)
612 m_tabView->OnEvent(event);
613}
614
615void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) )
616{
617 wxPaintDC dc(this);
618 if (m_tabView)
619 m_tabView->Draw(dc);
620}
621
6bae6726
MB
622wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
623{
624 // MBN: since the total tab height is really a function of the
625 // width, this should really call
626 // GetTotalTabHeightPretendingWidthIs(), but the current
627 // implementation will suffice, provided the wxNotebook has been
628 // created with a sensible initial width.
629 return wxSize( sizePage.x + 12,
630 sizePage.y + m_tabView->GetTotalTabHeight() + 6 + 4 );
631}
632
1e6d9499
JS
633wxRect wxNotebook::GetAvailableClientSize()
634{
635 int cw, ch;
636 GetClientSize(& cw, & ch);
637
638 int tabHeight = m_tabView->GetTotalTabHeight();
639
640 // TODO: these margins should be configurable.
641 wxRect rect;
642 rect.x = 6;
643 rect.y = tabHeight + 6;
644 rect.width = cw - 12;
645 rect.height = ch - 4 - rect.y ;
646
647 return rect;
648}
649
650/*
651 * wxNotebookTabView
652 */
2e4df4bf 653
1e6d9499
JS
654IMPLEMENT_CLASS(wxNotebookTabView, wxTabView)
655
656wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabView(style)
657{
658 m_notebook = notebook;
659
660 m_notebook->SetTabView(this);
661
662 SetWindow(m_notebook);
663}
664
665wxNotebookTabView::~wxNotebookTabView(void)
666{
667}
668
669// Called when a tab is activated
670void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
671{
672 if (!m_notebook)
673 return;
674
675 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
676
677 // Translate from wxTabView's ids (which aren't position-dependent)
678 // to wxNotebook's (which are).
679 wxNotebookPage* pActive = (wxNotebookPage*) activateId;
680 wxNotebookPage* pDeactive = (wxNotebookPage*) deactivateId;
681
682 int activatePos = m_notebook->FindPagePosition(pActive);
683 int deactivatePos = m_notebook->FindPagePosition(pDeactive);
684
685 event.SetEventObject(m_notebook);
686 event.SetSelection(activatePos);
687 event.SetOldSelection(deactivatePos);
688 m_notebook->GetEventHandler()->ProcessEvent(event);
689}
690
1c507b17
JS
691// Allows Vetoing
692bool wxNotebookTabView::OnTabPreActivate(int activateId, int deactivateId)
693{
ca65c044
WS
694 bool retval = true;
695
1c507b17
JS
696 if (m_notebook)
697 {
698 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId());
699
1c507b17
JS
700 // Translate from wxTabView's ids (which aren't position-dependent)
701 // to wxNotebook's (which are).
702 wxNotebookPage* pActive = (wxNotebookPage*) activateId;
703 wxNotebookPage* pDeactive = (wxNotebookPage*) deactivateId;
704
705 int activatePos = m_notebook->FindPagePosition(pActive);
706 int deactivatePos = m_notebook->FindPagePosition(pDeactive);
707
1c507b17
JS
708 event.SetEventObject(m_notebook);
709 event.SetSelection(activatePos);
710 event.SetOldSelection(deactivatePos);
711 if (m_notebook->GetEventHandler()->ProcessEvent(event))
712 {
713 retval = event.IsAllowed();
714 }
715 }
716 return retval;
ca65c044 717}
1e6d9499 718
4055ed82 719#endif // __WXPALMOS__