]> git.saurik.com Git - wxWidgets.git/blame - src/msw/notebook.cpp
compilation fix (wxUniv/MSW)
[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{
0df3fbd7
VZ
144 // base init
145 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
146 return FALSE;
88310e2e 147
0df3fbd7
VZ
148 // notebook, so explicitly specify 0 as last parameter
149 if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size,
150 style | wxTAB_TRAVERSAL) )
151 return FALSE;
907f37b3 152
0df3fbd7
VZ
153 SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE)));
154
155 return TRUE;
156}
157
158WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const
159{
160 WXDWORD tabStyle = wxControl::MSWGetStyle(style, exstyle);
161
162 tabStyle |= WS_TABSTOP | TCS_TABS;
163
164 if ( style & wxTC_MULTILINE )
165 tabStyle |= TCS_MULTILINE;
166 if ( style & wxNB_FIXEDWIDTH )
167 tabStyle |= TCS_FIXEDWIDTH;
168
169 if ( style & wxNB_BOTTOM )
170 tabStyle |= TCS_RIGHT;
171 else if ( style & wxNB_LEFT )
172 tabStyle |= TCS_VERTICAL;
173 else if ( style & wxNB_RIGHT )
174 tabStyle |= TCS_VERTICAL | TCS_RIGHT;
175
176 // ex style
177 if ( exstyle )
178 {
179 // note that we never want to have the default WS_EX_CLIENTEDGE style
180 // as it looks too ugly for the notebooks
181 *exstyle = 0;
182 }
183
184 return tabStyle;
88310e2e
VZ
185}
186
88310e2e
VZ
187// ----------------------------------------------------------------------------
188// wxNotebook accessors
189// ----------------------------------------------------------------------------
07b8d7ec 190
88310e2e
VZ
191int wxNotebook::GetPageCount() const
192{
193 // consistency check
1e6feb95 194 wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(m_hwnd) );
88310e2e 195
1e6feb95 196 return m_pages.Count();
88310e2e
VZ
197}
198
199int wxNotebook::GetRowCount() const
200{
201 return TabCtrl_GetRowCount(m_hwnd);
202}
203
204int wxNotebook::SetSelection(int nPage)
205{
223d09f6 206 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
207
208 ChangePage(m_nSelection, nPage);
209
210 return TabCtrl_SetCurSel(m_hwnd, nPage);
211}
212
88310e2e
VZ
213bool wxNotebook::SetPageText(int nPage, const wxString& strText)
214{
223d09f6 215 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
216
217 TC_ITEM tcItem;
218 tcItem.mask = TCIF_TEXT;
837e5743 219 tcItem.pszText = (wxChar *)strText.c_str();
88310e2e
VZ
220
221 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
222}
223
224wxString wxNotebook::GetPageText(int nPage) const
225{
223d09f6 226 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
88310e2e 227
837e5743 228 wxChar buf[256];
88310e2e
VZ
229 TC_ITEM tcItem;
230 tcItem.mask = TCIF_TEXT;
231 tcItem.pszText = buf;
232 tcItem.cchTextMax = WXSIZEOF(buf);
233
234 wxString str;
235 if ( TabCtrl_GetItem(m_hwnd, nPage, &tcItem) )
236 str = tcItem.pszText;
237
238 return str;
239}
240
241int wxNotebook::GetPageImage(int nPage) const
242{
223d09f6 243 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
88310e2e
VZ
244
245 TC_ITEM tcItem;
246 tcItem.mask = TCIF_IMAGE;
247
248 return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1;
249}
250
251bool wxNotebook::SetPageImage(int nPage, int nImage)
252{
223d09f6 253 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e
VZ
254
255 TC_ITEM tcItem;
256 tcItem.mask = TCIF_IMAGE;
257 tcItem.iImage = nImage;
258
259 return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0;
260}
261
262void wxNotebook::SetImageList(wxImageList* imageList)
907f37b3 263{
07b8d7ec
VZ
264 wxNotebookBase::SetImageList(imageList);
265
266 if ( imageList )
1e6feb95 267 {
07b8d7ec 268 TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST());
1e6feb95 269 }
b656febd
VS
270}
271
d9506e77
VZ
272// ----------------------------------------------------------------------------
273// wxNotebook size settings
274// ----------------------------------------------------------------------------
275
276void wxNotebook::SetPageSize(const wxSize& size)
277{
278 // transform the page size into the notebook size
279 RECT rc;
280 rc.left =
281 rc.top = 0;
282 rc.right = size.x;
283 rc.bottom = size.y;
284
285 TabCtrl_AdjustRect(GetHwnd(), TRUE, &rc);
286
287 // and now set it
288 SetSize(rc.right - rc.left, rc.bottom - rc.top);
289}
290
291void wxNotebook::SetPadding(const wxSize& padding)
292{
293 TabCtrl_SetPadding(GetHwnd(), padding.x, padding.y);
294}
42e69d6b
VZ
295
296// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
297// style.
298void wxNotebook::SetTabSize(const wxSize& sz)
299{
300 ::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
301}
302
88310e2e
VZ
303// ----------------------------------------------------------------------------
304// wxNotebook operations
305// ----------------------------------------------------------------------------
306
307// remove one page from the notebook
308bool wxNotebook::DeletePage(int nPage)
309{
223d09f6 310 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
88310e2e 311
96d37807
VZ
312 if ( m_nSelection == nPage ) {
313 // advance selection backwards - the page being deleted shouldn't be left
314 // selected
315 AdvanceSelection(FALSE);
316 }
317
88310e2e
VZ
318 TabCtrl_DeleteItem(m_hwnd, nPage);
319
1e6feb95 320 delete m_pages[nPage];
b54e41c5 321 m_pages.RemoveAt(nPage);
88310e2e 322
1e6feb95 323 if ( m_pages.IsEmpty() ) {
96d37807
VZ
324 // no selection if the notebook became empty
325 m_nSelection = -1;
326 }
9b6b5750
JS
327 else
328 m_nSelection = TabCtrl_GetCurSel(m_hwnd);
329
96d37807 330
88310e2e
VZ
331 return TRUE;
332}
333
621793f4 334// remove one page from the notebook, without deleting
1e6feb95 335wxNotebookPage *wxNotebook::DoRemovePage(int nPage)
621793f4 336{
10199e27
VZ
337 wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage);
338 if ( !pageRemoved )
339 return NULL;
621793f4
JS
340
341 TabCtrl_DeleteItem(m_hwnd, nPage);
342
1e6feb95
VZ
343 if ( m_pages.IsEmpty() )
344 m_nSelection = -1;
345 else
346 m_nSelection = TabCtrl_GetCurSel(m_hwnd);
47f12f58 347
1e6feb95 348 return pageRemoved;
621793f4
JS
349}
350
88310e2e
VZ
351// remove all pages
352bool wxNotebook::DeleteAllPages()
353{
88310e2e
VZ
354 int nPageCount = GetPageCount();
355 int nPage;
356 for ( nPage = 0; nPage < nPageCount; nPage++ )
1e6feb95 357 delete m_pages[nPage];
88310e2e 358
1e6feb95 359 m_pages.Clear();
88310e2e 360
907f37b3
VZ
361 TabCtrl_DeleteAllItems(m_hwnd);
362
47f12f58
JS
363 m_nSelection = -1;
364
88310e2e
VZ
365 return TRUE;
366}
367
368// add a page to the notebook
369bool wxNotebook::AddPage(wxNotebookPage *pPage,
370 const wxString& strText,
371 bool bSelect,
372 int imageId)
373{
374 return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
375}
376
377// same as AddPage() but does it at given position
378bool wxNotebook::InsertPage(int nPage,
379 wxNotebookPage *pPage,
380 const wxString& strText,
381 bool bSelect,
382 int imageId)
383{
384 wxASSERT( pPage != NULL );
385 wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
386
43427087
VZ
387 // do add the tab to the control
388
389 // init all fields to 0
88310e2e 390 TC_ITEM tcItem;
43427087 391 memset(&tcItem, 0, sizeof(tcItem));
58a8ab88 392
43427087 393 if ( imageId != -1 )
58a8ab88
JS
394 {
395 tcItem.mask |= TCIF_IMAGE;
396 tcItem.iImage = imageId;
397 }
58a8ab88 398
43427087 399 if ( !strText.IsEmpty() )
58a8ab88 400 {
43427087
VZ
401 tcItem.mask |= TCIF_TEXT;
402 tcItem.pszText = (wxChar *)strText.c_str(); // const_cast
58a8ab88 403 }
88310e2e
VZ
404
405 if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
223d09f6 406 wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
43427087 407
88310e2e
VZ
408 return FALSE;
409 }
410
43427087
VZ
411 // if the inserted page is before the selected one, we must update the
412 // index of the selected page
413 if ( nPage <= m_nSelection )
414 {
415 // one extra page added
416 m_nSelection++;
417 }
418
88310e2e 419 // save the pointer to the page
1e6feb95 420 m_pages.Insert(pPage, nPage);
88310e2e 421
88310e2e 422 // don't show pages by default (we'll need to adjust their size first)
42e69d6b 423 HWND hwnd = GetWinHwnd(pPage);
88310e2e
VZ
424 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
425
42e69d6b
VZ
426 // this updates internal flag too - otherwise it will get out of sync
427 pPage->Show(FALSE);
428
0398b1d6
RD
429 // fit the notebook page to the tab control's display area
430 RECT rc;
431 rc.left = rc.top = 0;
432 GetSize((int *)&rc.right, (int *)&rc.bottom);
433 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
434 pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
0398b1d6 435
43427087
VZ
436 // some page should be selected: either this one or the first one if there is
437 // still no selection
438 int selNew = -1;
439 if ( bSelect )
440 selNew = nPage;
441 else if ( m_nSelection == -1 )
442 selNew = 0;
443
444 if ( selNew != -1 )
445 SetSelection(selNew);
96d37807 446
88310e2e
VZ
447 return TRUE;
448}
449
450// ----------------------------------------------------------------------------
451// wxNotebook callbacks
452// ----------------------------------------------------------------------------
453
9026ad85 454void wxNotebook::OnSize(wxSizeEvent& event)
88310e2e 455{
b5c3b538
VZ
456 // fit the notebook page to the tab control's display area
457 RECT rc;
458 rc.left = rc.top = 0;
459 GetSize((int *)&rc.right, (int *)&rc.bottom);
460
461 TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
4b7f2165
VZ
462
463 int width = rc.right - rc.left,
464 height = rc.bottom - rc.top;
1e6feb95 465 size_t nCount = m_pages.Count();
c86f1403 466 for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
1e6feb95 467 wxNotebookPage *pPage = m_pages[nPage];
4b7f2165 468 pPage->SetSize(rc.left, rc.top, width, height);
b5c3b538
VZ
469 }
470
88310e2e
VZ
471 event.Skip();
472}
473
474void wxNotebook::OnSelChange(wxNotebookEvent& event)
475{
476 // is it our tab control?
477 if ( event.GetEventObject() == this )
5d1d2d46 478 {
5d1d2d46
VZ
479 int sel = event.GetOldSelection();
480 if ( sel != -1 )
1e6feb95 481 m_pages[sel]->Show(FALSE);
0398b1d6 482
5d1d2d46
VZ
483 sel = event.GetSelection();
484 if ( sel != -1 )
485 {
1e6feb95 486 wxNotebookPage *pPage = m_pages[sel];
5d1d2d46
VZ
487 pPage->Show(TRUE);
488 pPage->SetFocus();
489 }
0398b1d6 490
5d1d2d46
VZ
491 m_nSelection = sel;
492 }
88310e2e
VZ
493
494 // we want to give others a chance to process this message as well
495 event.Skip();
496}
497
498void wxNotebook::OnSetFocus(wxFocusEvent& event)
499{
d9506e77
VZ
500 // this function is only called when the focus is explicitly set (i.e. from
501 // the program) to the notebook - in this case we don't need the
502 // complicated OnNavigationKey() logic because the programmer knows better
503 // what [s]he wants
88310e2e 504
d9506e77
VZ
505 // set focus to the currently selected page if any
506 if ( m_nSelection != -1 )
1e6feb95 507 m_pages[m_nSelection]->SetFocus();
d9506e77
VZ
508
509 event.Skip();
88310e2e
VZ
510}
511
512void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
513{
d9506e77
VZ
514 if ( event.IsWindowChange() ) {
515 // change pages
516 AdvanceSelection(event.GetDirection());
517 }
518 else {
519 // we get this event in 2 cases
520 //
521 // a) one of our pages might have generated it because the user TABbed
522 // out from it in which case we should propagate the event upwards and
523 // our parent will take care of setting the focus to prev/next sibling
524 //
525 // or
526 //
527 // b) the parent panel wants to give the focus to us so that we
528 // forward it to our selected page. We can't deal with this in
529 // OnSetFocus() because we don't know which direction the focus came
530 // from in this case and so can't choose between setting the focus to
531 // first or last panel child
532
533 wxWindow *parent = GetParent();
534 if ( event.GetEventObject() == parent )
535 {
536 // no, it doesn't come from child, case (b): forward to a page
537 if ( m_nSelection != -1 )
538 {
539 // so that the page knows that the event comes from it's parent
540 // and is being propagated downwards
541 event.SetEventObject(this);
542
1e6feb95 543 wxWindow *page = m_pages[m_nSelection];
d9506e77
VZ
544 if ( !page->GetEventHandler()->ProcessEvent(event) )
545 {
546 page->SetFocus();
547 }
548 //else: page manages focus inside it itself
549 }
550 else
551 {
552 // we have no pages - still have to give focus to _something_
553 SetFocus();
554 }
555 }
556 else
557 {
558 // it comes from our child, case (a), pass to the parent
559 if ( parent ) {
560 event.SetCurrentFocus(this);
561 parent->GetEventHandler()->ProcessEvent(event);
562 }
563 }
88310e2e 564 }
88310e2e
VZ
565}
566
567// ----------------------------------------------------------------------------
568// wxNotebook base class virtuals
569// ----------------------------------------------------------------------------
b5c3b538
VZ
570
571// override these 2 functions to do nothing: everything is done in OnSize
572
4b7f2165 573void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
b5c3b538
VZ
574{
575 // don't set the sizes of the pages - their correct size is not yet known
576 wxControl::SetConstraintSizes(FALSE);
577}
578
4b7f2165 579bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
b5c3b538
VZ
580{
581 return TRUE;
582}
583
0df3fbd7
VZ
584// ----------------------------------------------------------------------------
585// wxNotebook Windows message handlers
586// ----------------------------------------------------------------------------
587
588bool wxNotebook::MSWOnScroll(int orientation, WXWORD nSBCode,
589 WXWORD pos, WXHWND control)
590{
591 // don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
592 // up-down control
593 if ( control )
594 return FALSE;
595
596 return wxNotebookBase::MSWOnScroll(orientation, nSBCode, pos, control);
597}
598
a23fd0e1 599bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
88310e2e 600{
93a19f17 601 wxNotebookEvent event(wxEVT_NULL, m_windowId);
88310e2e
VZ
602
603 NMHDR* hdr = (NMHDR *)lParam;
604 switch ( hdr->code ) {
605 case TCN_SELCHANGE:
606 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
607 break;
608
609 case TCN_SELCHANGING:
610 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
611 break;
612
fd3f686c 613 default:
a23fd0e1 614 return wxControl::MSWOnNotify(idCtrl, lParam, result);
88310e2e
VZ
615 }
616
93a19f17
VZ
617 event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
618 event.SetOldSelection(m_nSelection);
88310e2e 619 event.SetEventObject(this);
a23fd0e1 620 event.SetInt(idCtrl);
88310e2e 621
fd3f686c
VZ
622 bool processed = GetEventHandler()->ProcessEvent(event);
623 *result = !event.IsAllowed();
624 return processed;
88310e2e
VZ
625}
626
627// ----------------------------------------------------------------------------
628// wxNotebook helper functions
629// ----------------------------------------------------------------------------
630
43427087
VZ
631// generate the page changing and changed events, hide the currently active
632// panel and show the new one
88310e2e
VZ
633void wxNotebook::ChangePage(int nOldSel, int nSel)
634{
fd3f686c
VZ
635 // MT-FIXME should use a real semaphore
636 static bool s_bInsideChangePage = FALSE;
637
638 // when we call ProcessEvent(), our own OnSelChange() is called which calls
639 // this function - break the infinite loop
640 if ( s_bInsideChangePage )
641 return;
642
aaab7c01
VZ
643 // it's not an error (the message may be generated by the tab control itself)
644 // and it may happen - just do nothing
645 if ( nSel == nOldSel )
646 return;
88310e2e 647
fd3f686c
VZ
648 s_bInsideChangePage = TRUE;
649
650 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
651 event.SetSelection(nSel);
652 event.SetOldSelection(nOldSel);
653 event.SetEventObject(this);
1e6feb95 654 if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
fd3f686c
VZ
655 {
656 // program doesn't allow the page change
657 s_bInsideChangePage = FALSE;
658 return;
659 }
660
fd3f686c 661 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
1e6feb95 662 GetEventHandler()->ProcessEvent(event);
fd3f686c 663
fd3f686c 664 s_bInsideChangePage = FALSE;
88310e2e 665}
1e6feb95
VZ
666
667#endif // wxUSE_NOTEBOOK