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