]> git.saurik.com Git - wxWidgets.git/blame - src/msw/notebook.cpp
Add some new files for interface additions
[wxWidgets.git] / src / msw / notebook.cpp
CommitLineData
88310e2e
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/notebook.cpp
3// Purpose: implementation of wxNotebook
4// Author: Vadim Zeitlin
907f37b3 5// Modified by:
88310e2e
VZ
6// Created: 11.06.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
88310e2e 12#ifdef __GNUG__
a3b46648 13#pragma implementation "notebook.h"
88310e2e
VZ
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
a3b46648 20#pragma hdrstop
88310e2e
VZ
21#endif
22
23// wxWindows
24#ifndef WX_PRECOMP
3096bd2f 25 #include "wx/string.h"
88310e2e
VZ
26#endif // WX_PRECOMP
27
3096bd2f
VZ
28#include "wx/log.h"
29#include "wx/imaglist.h"
30#include "wx/event.h"
31#include "wx/control.h"
32#include "wx/notebook.h"
88310e2e 33
3096bd2f 34#include "wx/msw/private.h"
88310e2e
VZ
35
36// Windows standard headers
37#ifndef __WIN95__
2432b92d 38 #error "wxNotebook is only supported Windows 95 and above"
88310e2e
VZ
39#endif //Win95
40
aaab7c01
VZ
41#include <windowsx.h> // for SetWindowFont
42
57c208c5 43#ifndef __TWIN32__
c42404a5
VZ
44 #ifdef __GNUWIN32_OLD__
45 #include "wx/msw/gnuwin32/extra.h"
46 #endif
65fd5cb0 47#endif
57c208c5 48
c42404a5
VZ
49#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) || defined(__TWIN32__))
50 #include <commctrl.h>
88310e2e
VZ
51#endif
52
53// ----------------------------------------------------------------------------
54// macros
55// ----------------------------------------------------------------------------
56
57// check that the page index is valid
58#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
59
60// hide the ugly cast
61#define m_hwnd (HWND)GetHWND()
62
74b31181
VZ
63// ----------------------------------------------------------------------------
64// constants
65// ----------------------------------------------------------------------------
66
67// This is a work-around for missing defines in gcc-2.95 headers
68#ifndef TCS_RIGHT
69 #define TCS_RIGHT 0x0002
70#endif
71
72#ifndef TCS_VERTICAL
73 #define TCS_VERTICAL 0x0080
74#endif
75
76#ifndef TCS_BOTTOM
77 #define TCS_BOTTOM TCS_RIGHT
78#endif
79
88310e2e
VZ
80// ----------------------------------------------------------------------------
81// event table
82// ----------------------------------------------------------------------------
83
d9317fd4 84BEGIN_EVENT_TABLE(wxNotebook, wxControl)
88310e2e
VZ
85 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
86
9026ad85 87 EVT_SIZE(wxNotebook::OnSize)
42e69d6b 88
88310e2e 89 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
42e69d6b 90
88310e2e 91 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
d9317fd4 92END_EVENT_TABLE()
88310e2e 93
d9317fd4
VZ
94IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
95IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
88310e2e
VZ
96
97// ============================================================================
98// implementation
99// ============================================================================
100
101// ----------------------------------------------------------------------------
102// wxNotebook construction
103// ----------------------------------------------------------------------------
104
105// common part of all ctors
106void wxNotebook::Init()
107{
108 m_pImageList = NULL;
b656febd 109 m_bOwnsImageList = FALSE;
88310e2e
VZ
110 m_nSelection = -1;
111}
112
113// default for dynamic class
114wxNotebook::wxNotebook()
115{
116 Init();
117}
118
119// the same arguments as for wxControl
120wxNotebook::wxNotebook(wxWindow *parent,
8b9518ee 121 wxWindowID id,
88310e2e
VZ
122 const wxPoint& pos,
123 const wxSize& size,
8b9518ee 124 long style,
88310e2e
VZ
125 const wxString& name)
126{
127 Init();
128
129 Create(parent, id, pos, size, style, name);
130}
131
132// Create() function
133bool wxNotebook::Create(wxWindow *parent,
8b9518ee 134 wxWindowID id,
88310e2e
VZ
135 const wxPoint& pos,
136 const wxSize& size,
8b9518ee 137 long style,
88310e2e
VZ
138 const wxString& name)
139{
140 // base init
8d99be5f
VZ
141 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
142 return FALSE;
88310e2e
VZ
143
144 // colors and font
145 m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
4b7f2165 146 m_foregroundColour = *wxBLACK;
88310e2e 147
88310e2e 148 // style
fd2daa68 149 m_windowStyle = style | wxTAB_TRAVERSAL;
88310e2e 150
d13c32e9
JS
151 long tabStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TABS;
152
153 if (m_windowStyle & wxCLIP_CHILDREN)
154 tabStyle |= WS_CLIPCHILDREN;
88310e2e
VZ
155 if ( m_windowStyle & wxTC_MULTILINE )
156 tabStyle |= TCS_MULTILINE;
157 if ( m_windowStyle & wxBORDER )
158 tabStyle &= WS_BORDER;
58a8ab88
JS
159 if (m_windowStyle & wxNB_FIXEDWIDTH)
160 tabStyle |= TCS_FIXEDWIDTH ;
7a3ac804
RS
161 if (m_windowStyle & wxNB_BOTTOM)
162 tabStyle |= TCS_RIGHT;
163 if (m_windowStyle & wxNB_LEFT)
164 tabStyle |= TCS_VERTICAL;
165 if (m_windowStyle & wxNB_RIGHT)
166 tabStyle |= TCS_VERTICAL|TCS_RIGHT;
0398b1d6 167
88310e2e 168
789295bf
VZ
169 if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
170 this, NULL, pos.x, pos.y, size.x, size.y,
171 tabStyle, NULL, 0) )
172 {
88310e2e
VZ
173 return FALSE;
174 }
175
27529614 176 // Not all compilers recognise SetWindowFont
789295bf
VZ
177 ::SendMessage(GetHwnd(), WM_SETFONT,
178 (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), TRUE);
27529614 179
aaab7c01 180
907f37b3 181 if ( parent != NULL )
88310e2e 182 parent->AddChild(this);
907f37b3 183
88310e2e
VZ
184 SubclassWin(m_hWnd);
185
186 return TRUE;
187}
188
189// dtor
190wxNotebook::~wxNotebook()
191{
b656febd 192 if (m_bOwnsImageList) delete m_pImageList;
88310e2e
VZ
193}
194
195// ----------------------------------------------------------------------------
196// wxNotebook accessors
197// ----------------------------------------------------------------------------
198int wxNotebook::GetPageCount() const
199{
200 // consistency check
201 wxASSERT( (int)m_aPages.Count() == TabCtrl_GetItemCount(m_hwnd) );
202
203 return m_aPages.Count();
204}
205
206int wxNotebook::GetRowCount() const
207{
208 return TabCtrl_GetRowCount(m_hwnd);
209}
210
211int wxNotebook::SetSelection(int nPage)
212{
223d09f6 213 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
214
215 ChangePage(m_nSelection, nPage);
216
217 return TabCtrl_SetCurSel(m_hwnd, nPage);
218}
219
220void wxNotebook::AdvanceSelection(bool bForward)
221{
222 int nSel = GetSelection();
223 int nMax = GetPageCount() - 1;
224 if ( bForward )
225 SetSelection(nSel == nMax ? 0 : nSel + 1);
226 else
227 SetSelection(nSel == 0 ? nMax : nSel - 1);
228}
229
230bool wxNotebook::SetPageText(int nPage, const wxString& strText)
231{
223d09f6 232 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
233
234 TC_ITEM tcItem;
235 tcItem.mask = TCIF_TEXT;
837e5743 236 tcItem.pszText = (wxChar *)strText.c_str();
88310e2e
VZ
237
238 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
239}
240
241wxString wxNotebook::GetPageText(int nPage) const
242{
223d09f6 243 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
88310e2e 244
837e5743 245 wxChar buf[256];
88310e2e
VZ
246 TC_ITEM tcItem;
247 tcItem.mask = TCIF_TEXT;
248 tcItem.pszText = buf;
249 tcItem.cchTextMax = WXSIZEOF(buf);
250
251 wxString str;
252 if ( TabCtrl_GetItem(m_hwnd, nPage, &tcItem) )
253 str = tcItem.pszText;
254
255 return str;
256}
257
258int wxNotebook::GetPageImage(int nPage) const
259{
223d09f6 260 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
261
262 TC_ITEM tcItem;
263 tcItem.mask = TCIF_IMAGE;
264
265 return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1;
266}
267
268bool wxNotebook::SetPageImage(int nPage, int nImage)
269{
223d09f6 270 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
271
272 TC_ITEM tcItem;
273 tcItem.mask = TCIF_IMAGE;
274 tcItem.iImage = nImage;
275
276 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
277}
278
279void wxNotebook::SetImageList(wxImageList* imageList)
907f37b3 280{
b656febd 281 if (m_bOwnsImageList) delete m_pImageList;
88310e2e 282 m_pImageList = imageList;
b656febd 283 m_bOwnsImageList = FALSE;
88310e2e
VZ
284 TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST());
285}
286
b656febd
VS
287void wxNotebook::AssignImageList(wxImageList* imageList)
288{
289 SetImageList(imageList);
290 m_bOwnsImageList = TRUE;
291}
292
d9506e77
VZ
293// ----------------------------------------------------------------------------
294// wxNotebook size settings
295// ----------------------------------------------------------------------------
296
297void wxNotebook::SetPageSize(const wxSize& size)
298{
299 // transform the page size into the notebook size
300 RECT rc;
301 rc.left =
302 rc.top = 0;
303 rc.right = size.x;
304 rc.bottom = size.y;
305
306 TabCtrl_AdjustRect(GetHwnd(), TRUE, &rc);
307
308 // and now set it
309 SetSize(rc.right - rc.left, rc.bottom - rc.top);
310}
311
312void wxNotebook::SetPadding(const wxSize& padding)
313{
314 TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y);
315}
42e69d6b
VZ
316
317// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
318// style.
319void wxNotebook::SetTabSize(const wxSize& sz)
320{
321 ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
322}
323
88310e2e
VZ
324// ----------------------------------------------------------------------------
325// wxNotebook operations
326// ----------------------------------------------------------------------------
327
328// remove one page from the notebook
329bool wxNotebook::DeletePage(int nPage)
330{
223d09f6 331 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e 332
96d37807
VZ
333 if ( m_nSelection == nPage ) {
334 // advance selection backwards - the page being deleted shouldn't be left
335 // selected
336 AdvanceSelection(FALSE);
337 }
338
88310e2e
VZ
339 TabCtrl_DeleteItem(m_hwnd, nPage);
340
341 delete m_aPages[nPage];
342 m_aPages.Remove(nPage);
343
96d37807
VZ
344 if ( m_aPages.IsEmpty() ) {
345 // no selection if the notebook became empty
346 m_nSelection = -1;
347 }
9b6b5750
JS
348 else
349 m_nSelection = TabCtrl_GetCurSel(m_hwnd);
350
96d37807 351
88310e2e
VZ
352 return TRUE;
353}
354
621793f4
JS
355// remove one page from the notebook, without deleting
356bool wxNotebook::RemovePage(int nPage)
357{
223d09f6 358 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
621793f4
JS
359
360 TabCtrl_DeleteItem(m_hwnd, nPage);
361
362 m_aPages.Remove(nPage);
363
47f12f58
JS
364 if ( m_aPages.IsEmpty() )
365 m_nSelection = -1;
9b6b5750
JS
366 else
367 m_nSelection = TabCtrl_GetCurSel(m_hwnd);
47f12f58 368
621793f4
JS
369 return TRUE;
370}
371
88310e2e
VZ
372// remove all pages
373bool wxNotebook::DeleteAllPages()
374{
88310e2e
VZ
375 int nPageCount = GetPageCount();
376 int nPage;
377 for ( nPage = 0; nPage < nPageCount; nPage++ )
378 delete m_aPages[nPage];
379
380 m_aPages.Clear();
381
907f37b3
VZ
382 TabCtrl_DeleteAllItems(m_hwnd);
383
47f12f58
JS
384 m_nSelection = -1;
385
88310e2e
VZ
386 return TRUE;
387}
388
389// add a page to the notebook
390bool wxNotebook::AddPage(wxNotebookPage *pPage,
391 const wxString& strText,
392 bool bSelect,
393 int imageId)
394{
395 return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
396}
397
398// same as AddPage() but does it at given position
399bool wxNotebook::InsertPage(int nPage,
400 wxNotebookPage *pPage,
401 const wxString& strText,
402 bool bSelect,
403 int imageId)
404{
405 wxASSERT( pPage != NULL );
406 wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
407
43427087
VZ
408 // do add the tab to the control
409
410 // init all fields to 0
88310e2e 411 TC_ITEM tcItem;
43427087 412 memset(&tcItem, 0, sizeof(tcItem));
58a8ab88 413
43427087 414 if ( imageId != -1 )
58a8ab88
JS
415 {
416 tcItem.mask |= TCIF_IMAGE;
417 tcItem.iImage = imageId;
418 }
58a8ab88 419
43427087 420 if ( !strText.IsEmpty() )
58a8ab88 421 {
43427087
VZ
422 tcItem.mask |= TCIF_TEXT;
423 tcItem.pszText = (wxChar *)strText.c_str(); // const_cast
58a8ab88 424 }
88310e2e
VZ
425
426 if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
223d09f6 427 wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
43427087 428
88310e2e
VZ
429 return FALSE;
430 }
431
43427087
VZ
432 // if the inserted page is before the selected one, we must update the
433 // index of the selected page
434 if ( nPage <= m_nSelection )
435 {
436 // one extra page added
437 m_nSelection++;
438 }
439
88310e2e
VZ
440 // save the pointer to the page
441 m_aPages.Insert(pPage, nPage);
442
88310e2e 443 // don't show pages by default (we'll need to adjust their size first)
42e69d6b 444 HWND hwnd = GetWinHwnd(pPage);
88310e2e
VZ
445 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
446
42e69d6b
VZ
447 // this updates internal flag too - otherwise it will get out of sync
448 pPage->Show(FALSE);
449
0398b1d6
RD
450 // fit the notebook page to the tab control's display area
451 RECT rc;
452 rc.left = rc.top = 0;
453 GetSize((int *)&rc.right, (int *)&rc.bottom);
454 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
455 pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
0398b1d6 456
43427087
VZ
457 // some page should be selected: either this one or the first one if there is
458 // still no selection
459 int selNew = -1;
460 if ( bSelect )
461 selNew = nPage;
462 else if ( m_nSelection == -1 )
463 selNew = 0;
464
465 if ( selNew != -1 )
466 SetSelection(selNew);
96d37807 467
88310e2e
VZ
468 return TRUE;
469}
470
471// ----------------------------------------------------------------------------
472// wxNotebook callbacks
473// ----------------------------------------------------------------------------
474
9026ad85 475void wxNotebook::OnSize(wxSizeEvent& event)
88310e2e 476{
b5c3b538
VZ
477 // fit the notebook page to the tab control's display area
478 RECT rc;
479 rc.left = rc.top = 0;
480 GetSize((int *)&rc.right, (int *)&rc.bottom);
481
482 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
4b7f2165
VZ
483
484 int width = rc.right - rc.left,
485 height = rc.bottom - rc.top;
c86f1403
VZ
486 size_t nCount = m_aPages.Count();
487 for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
b5c3b538 488 wxNotebookPage *pPage = m_aPages[nPage];
4b7f2165 489 pPage->SetSize(rc.left, rc.top, width, height);
b5c3b538
VZ
490 }
491
88310e2e
VZ
492 event.Skip();
493}
494
495void wxNotebook::OnSelChange(wxNotebookEvent& event)
496{
497 // is it our tab control?
498 if ( event.GetEventObject() == this )
5d1d2d46 499 {
5d1d2d46
VZ
500 int sel = event.GetOldSelection();
501 if ( sel != -1 )
502 m_aPages[sel]->Show(FALSE);
0398b1d6 503
5d1d2d46
VZ
504 sel = event.GetSelection();
505 if ( sel != -1 )
506 {
507 wxNotebookPage *pPage = m_aPages[sel];
508 pPage->Show(TRUE);
509 pPage->SetFocus();
510 }
0398b1d6 511
5d1d2d46
VZ
512 m_nSelection = sel;
513 }
88310e2e
VZ
514
515 // we want to give others a chance to process this message as well
516 event.Skip();
517}
518
519void wxNotebook::OnSetFocus(wxFocusEvent& event)
520{
d9506e77
VZ
521 // this function is only called when the focus is explicitly set (i.e. from
522 // the program) to the notebook - in this case we don't need the
523 // complicated OnNavigationKey() logic because the programmer knows better
524 // what [s]he wants
88310e2e 525
d9506e77
VZ
526 // set focus to the currently selected page if any
527 if ( m_nSelection != -1 )
528 m_aPages[m_nSelection]->SetFocus();
529
530 event.Skip();
88310e2e
VZ
531}
532
533void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
534{
d9506e77
VZ
535 if ( event.IsWindowChange() ) {
536 // change pages
537 AdvanceSelection(event.GetDirection());
538 }
539 else {
540 // we get this event in 2 cases
541 //
542 // a) one of our pages might have generated it because the user TABbed
543 // out from it in which case we should propagate the event upwards and
544 // our parent will take care of setting the focus to prev/next sibling
545 //
546 // or
547 //
548 // b) the parent panel wants to give the focus to us so that we
549 // forward it to our selected page. We can't deal with this in
550 // OnSetFocus() because we don't know which direction the focus came
551 // from in this case and so can't choose between setting the focus to
552 // first or last panel child
553
554 wxWindow *parent = GetParent();
555 if ( event.GetEventObject() == parent )
556 {
557 // no, it doesn't come from child, case (b): forward to a page
558 if ( m_nSelection != -1 )
559 {
560 // so that the page knows that the event comes from it's parent
561 // and is being propagated downwards
562 event.SetEventObject(this);
563
564 wxWindow *page = m_aPages[m_nSelection];
565 if ( !page->GetEventHandler()->ProcessEvent(event) )
566 {
567 page->SetFocus();
568 }
569 //else: page manages focus inside it itself
570 }
571 else
572 {
573 // we have no pages - still have to give focus to _something_
574 SetFocus();
575 }
576 }
577 else
578 {
579 // it comes from our child, case (a), pass to the parent
580 if ( parent ) {
581 event.SetCurrentFocus(this);
582 parent->GetEventHandler()->ProcessEvent(event);
583 }
584 }
88310e2e 585 }
88310e2e
VZ
586}
587
588// ----------------------------------------------------------------------------
589// wxNotebook base class virtuals
590// ----------------------------------------------------------------------------
b5c3b538
VZ
591
592// override these 2 functions to do nothing: everything is done in OnSize
593
4b7f2165 594void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
b5c3b538
VZ
595{
596 // don't set the sizes of the pages - their correct size is not yet known
597 wxControl::SetConstraintSizes(FALSE);
598}
599
4b7f2165 600bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
b5c3b538
VZ
601{
602 return TRUE;
603}
604
a23fd0e1 605bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
88310e2e 606{
93a19f17 607 wxNotebookEvent event(wxEVT_NULL, m_windowId);
88310e2e
VZ
608
609 NMHDR* hdr = (NMHDR *)lParam;
610 switch ( hdr->code ) {
611 case TCN_SELCHANGE:
612 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
613 break;
614
615 case TCN_SELCHANGING:
616 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
617 break;
618
fd3f686c 619 default:
a23fd0e1 620 return wxControl::MSWOnNotify(idCtrl, lParam, result);
88310e2e
VZ
621 }
622
93a19f17
VZ
623 event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
624 event.SetOldSelection(m_nSelection);
88310e2e 625 event.SetEventObject(this);
a23fd0e1 626 event.SetInt(idCtrl);
88310e2e 627
fd3f686c
VZ
628 bool processed = GetEventHandler()->ProcessEvent(event);
629 *result = !event.IsAllowed();
630 return processed;
88310e2e
VZ
631}
632
633// ----------------------------------------------------------------------------
634// wxNotebook helper functions
635// ----------------------------------------------------------------------------
636
43427087
VZ
637// generate the page changing and changed events, hide the currently active
638// panel and show the new one
88310e2e
VZ
639void wxNotebook::ChangePage(int nOldSel, int nSel)
640{
fd3f686c
VZ
641 // MT-FIXME should use a real semaphore
642 static bool s_bInsideChangePage = FALSE;
643
644 // when we call ProcessEvent(), our own OnSelChange() is called which calls
645 // this function - break the infinite loop
646 if ( s_bInsideChangePage )
647 return;
648
aaab7c01
VZ
649 // it's not an error (the message may be generated by the tab control itself)
650 // and it may happen - just do nothing
651 if ( nSel == nOldSel )
652 return;
88310e2e 653
fd3f686c
VZ
654 s_bInsideChangePage = TRUE;
655
656 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
657 event.SetSelection(nSel);
658 event.SetOldSelection(nOldSel);
659 event.SetEventObject(this);
660 if ( ProcessEvent(event) && !event.IsAllowed() )
661 {
662 // program doesn't allow the page change
663 s_bInsideChangePage = FALSE;
664 return;
665 }
666
fd3f686c
VZ
667 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
668 ProcessEvent(event);
669
fd3f686c 670 s_bInsideChangePage = FALSE;
88310e2e 671}