]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/notebmac.cpp
Committing in .
[wxWidgets.git] / src / mac / carbon / notebmac.cpp
CommitLineData
ee6b1d97 1///////////////////////////////////////////////////////////////////////////////
90c0f5a9 2// Name: src/mac/carbon/notebmac.cpp
ee6b1d97 3// Purpose: implementation of wxNotebook
a31a5f85 4// Author: Stefan Csomor
5aed9d50 5// Modified by:
a31a5f85 6// Created: 1998-01-01
ee6b1d97 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
ee6b1d97
SC
10///////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
179e085f
RN
14#if wxUSE_NOTEBOOK
15
799690a0 16#include "wx/app.h"
d497dca4
GD
17#include "wx/string.h"
18#include "wx/log.h"
19#include "wx/imaglist.h"
061174e3 20#include "wx/image.h"
d497dca4
GD
21#include "wx/notebook.h"
22#include "wx/mac/uma.h"
5a7d70fe 23
ee6b1d97
SC
24
25// check that the page index is valid
19c43a77 26#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
ee6b1d97 27
ee6b1d97 28
5b781a67
SC
29DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
30DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
31
ee6b1d97 32BEGIN_EVENT_TABLE(wxNotebook, wxControl)
90c0f5a9 33 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
e40298d5 34
461fe6e2
SC
35 EVT_SIZE(wxNotebook::OnSize)
36 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
37 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
ee6b1d97
SC
38END_EVENT_TABLE()
39
40IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
41IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
ee6b1d97 42
5aed9d50
RD
43
44// common part of all ctors
45void wxNotebook::Init()
46{
ee6b1d97
SC
47 m_nSelection = -1;
48}
49
50// default for dynamic class
51wxNotebook::wxNotebook()
52{
53 Init();
54}
55
56// the same arguments as for wxControl
5a7d70fe
DS
57wxNotebook::wxNotebook( wxWindow *parent,
58 wxWindowID id,
59 const wxPoint& pos,
60 const wxSize& size,
61 long style,
62 const wxString& name )
ee6b1d97
SC
63{
64 Init();
5aed9d50 65
5a7d70fe 66 Create( parent, id, pos, size, style, name );
ee6b1d97
SC
67}
68
5a7d70fe
DS
69bool wxNotebook::Create( wxWindow *parent,
70 wxWindowID id,
71 const wxPoint& pos,
72 const wxSize& size,
73 long style,
74 const wxString& name )
ee6b1d97 75{
90c0f5a9
WS
76 m_macIsUserPane = false ;
77
5a7d70fe 78 if ( !wxNotebookBase::Create( parent, id, pos, size, style, name ) )
b45ed7a2
VZ
79 return false;
80
5a7d70fe 81 Rect bounds = wxMacGetBoundsForControl( this, pos, size );
5aed9d50 82
5a7d70fe
DS
83 if ( bounds.right <= bounds.left )
84 bounds.right = bounds.left + 100;
facd6764 85 if ( bounds.bottom <= bounds.top )
5a7d70fe 86 bounds.bottom = bounds.top + 100;
5aed9d50 87
5a7d70fe 88 UInt16 tabstyle = kControlTabDirectionNorth;
90c0f5a9 89 if ( HasFlag(wxBK_LEFT) )
5a7d70fe 90 tabstyle = kControlTabDirectionWest;
90c0f5a9 91 else if ( HasFlag( wxBK_RIGHT ) )
5a7d70fe 92 tabstyle = kControlTabDirectionEast;
90c0f5a9 93 else if ( HasFlag( wxBK_BOTTOM ) )
5a7d70fe 94 tabstyle = kControlTabDirectionSouth;
90c0f5a9 95
5a7d70fe
DS
96 ControlTabSize tabsize;
97 switch (GetWindowVariant())
facd6764 98 {
5a7d70fe
DS
99 case wxWINDOW_VARIANT_MINI:
100 if ( UMAGetSystemVersion() >= 0x1030 )
101 tabsize = 3 ;
102 else
103 tabsize = kControlSizeSmall;
104 break;
105
106 case wxWINDOW_VARIANT_SMALL:
107 tabsize = kControlTabSizeSmall;
108 break;
109
110 default:
111 tabsize = kControlTabSizeLarge;
112 break;
facd6764 113 }
5aed9d50 114
5a7d70fe
DS
115 m_peer = new wxMacControl( this );
116 OSStatus err = CreateTabsControl(
117 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
118 tabsize, tabstyle, 0, NULL, m_peer->GetControlRefAddr() );
119 verify_noerr( err );
90c0f5a9 120
5a7d70fe 121 MacPostControlCreate( pos, size );
90c0f5a9 122
90c0f5a9 123 return true ;
ee6b1d97
SC
124}
125
126// dtor
127wxNotebook::~wxNotebook()
128{
ee6b1d97
SC
129}
130
131// ----------------------------------------------------------------------------
132// wxNotebook accessors
133// ----------------------------------------------------------------------------
90b959ae
SC
134
135void wxNotebook::SetPadding(const wxSize& padding)
136{
63ff6f53 137 // unsupported by OS
90b959ae
SC
138}
139
140void wxNotebook::SetTabSize(const wxSize& sz)
ee6b1d97 141{
63ff6f53 142 // unsupported by OS
ee6b1d97
SC
143}
144
90b959ae 145void wxNotebook::SetPageSize(const wxSize& size)
ee6b1d97 146{
63ff6f53
SC
147 SetSize( CalcSizeFromPage( size ) );
148}
149
150wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
151{
5a7d70fe 152 return DoGetSizeFromClientSize( sizePage );
63ff6f53
SC
153}
154
8f83dfee 155int wxNotebook::SetSelection(size_t nPage)
ee6b1d97 156{
5a7d70fe 157 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("SetSelection: invalid notebook page") );
5aed9d50 158
461fe6e2
SC
159 if ( int(nPage) != m_nSelection )
160 {
161 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
162 event.SetSelection(nPage);
163 event.SetOldSelection(m_nSelection);
164 event.SetEventObject(this);
165 if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
166 {
167 // program allows the page change
168 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
169 (void)GetEventHandler()->ProcessEvent(event);
170
171 ChangePage(m_nSelection, nPage);
172 }
173 }
5aed9d50 174
ee6b1d97
SC
175 return m_nSelection;
176}
177
8f83dfee 178bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
ee6b1d97 179{
5a7d70fe 180 wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("SetPageText: invalid notebook page") );
5aed9d50 181
90b959ae 182 wxNotebookPage *page = m_pages[nPage];
c854c7d9
GD
183 page->SetLabel(strText);
184 MacSetupTabs();
5aed9d50 185
c854c7d9 186 return true;
ee6b1d97
SC
187}
188
8f83dfee 189wxString wxNotebook::GetPageText(size_t nPage) const
ee6b1d97 190{
5a7d70fe 191 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("GetPageText: invalid notebook page") );
5aed9d50 192
90b959ae 193 wxNotebookPage *page = m_pages[nPage];
5a7d70fe 194
c854c7d9 195 return page->GetLabel();
ee6b1d97
SC
196}
197
8f83dfee 198int wxNotebook::GetPageImage(size_t nPage) const
ee6b1d97 199{
5a7d70fe 200 wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("GetPageImage: invalid notebook page") );
5aed9d50 201
2b5f62a0 202 return m_images[nPage];
ee6b1d97
SC
203}
204
19c43a77 205bool wxNotebook::SetPageImage(size_t nPage, int nImage)
ee6b1d97 206{
5a7d70fe
DS
207 wxCHECK_MSG( IS_VALID_PAGE(nPage), false,
208 wxT("SetPageImage: invalid notebook page") );
90c0f5a9 209 wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false,
5a7d70fe 210 wxT("SetPageImage: invalid image index") );
5aed9d50 211
2b5f62a0
VZ
212 if ( nImage != m_images[nPage] )
213 {
214 // if the item didn't have an icon before or, on the contrary, did have
215 // it but has lost it now, its size will change - but if the icon just
216 // changes, it won't
217 m_images[nPage] = nImage;
5aed9d50 218
e40298d5 219 MacSetupTabs() ;
2b5f62a0 220 }
5aed9d50 221
90c0f5a9 222 return true;
ee6b1d97
SC
223}
224
ee6b1d97
SC
225// ----------------------------------------------------------------------------
226// wxNotebook operations
227// ----------------------------------------------------------------------------
228
90b959ae 229// remove one page from the notebook, without deleting the window
8f83dfee 230wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
ee6b1d97 231{
5a7d70fe
DS
232 wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL,
233 wxT("DoRemovePage: invalid notebook page") );
234
90b959ae 235 wxNotebookPage* page = m_pages[nPage] ;
3ef585df 236 m_pages.RemoveAt(nPage);
5aed9d50 237
c854c7d9 238 MacSetupTabs();
5aed9d50 239
5a7d70fe 240 if (m_nSelection >= (int)GetPageCount())
c854c7d9 241 m_nSelection = GetPageCount() - 1;
5a7d70fe
DS
242
243 if (m_nSelection >= 0)
90b959ae 244 m_pages[m_nSelection]->Show(true);
5a7d70fe 245
37144cf0 246 InvalidateBestSize();
5a7d70fe 247
90b959ae 248 return page;
ee6b1d97
SC
249}
250
251// remove all pages
252bool wxNotebook::DeleteAllPages()
253{
90b959ae 254 WX_CLEAR_ARRAY(m_pages) ;
c854c7d9 255 MacSetupTabs();
061174e3 256 m_nSelection = -1 ;
37144cf0 257 InvalidateBestSize();
5a7d70fe 258
90c0f5a9 259 return true;
ee6b1d97
SC
260}
261
ee6b1d97 262// same as AddPage() but does it at given position
8f83dfee 263bool wxNotebook::InsertPage(size_t nPage,
5a7d70fe
DS
264 wxNotebookPage *pPage,
265 const wxString& strText,
266 bool bSelect,
267 int imageId )
ee6b1d97 268{
5a7d70fe 269 if ( !wxNotebookBase::InsertPage( nPage, pPage, strText, bSelect, imageId ) )
19c43a77 270 return false;
5aed9d50 271
5a7d70fe 272 wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") );
461fe6e2
SC
273
274 // don't show pages by default (we'll need to adjust their size first)
275 pPage->Show( false ) ;
276
5a7d70fe 277 pPage->SetLabel( strText );
5aed9d50 278
5a7d70fe 279 m_images.Insert( imageId, nPage );
5aed9d50 280
c854c7d9 281 MacSetupTabs();
5aed9d50 282
63ff6f53 283 wxRect rect = GetPageRect() ;
5a7d70fe
DS
284 pPage->SetSize( rect );
285 if ( pPage->GetAutoLayout() )
c854c7d9 286 pPage->Layout();
461fe6e2
SC
287
288 // now deal with the selection
289 // ---------------------------
290
291 // if the inserted page is before the selected one, we must update the
292 // index of the selected page
293
90c0f5a9 294 if ( int(nPage) <= m_nSelection )
461fe6e2
SC
295 {
296 m_nSelection++;
5a7d70fe 297
461fe6e2 298 // while this still is the same page showing, we need to update the tabs
5ca0d812 299 m_peer->SetValue( m_nSelection + 1 ) ;
461fe6e2 300 }
90c0f5a9 301
461fe6e2
SC
302 // some page should be selected: either this one or the first one if there
303 // is still no selection
304 int selNew = -1;
305 if ( bSelect )
306 selNew = nPage;
307 else if ( m_nSelection == -1 )
308 selNew = 0;
309
310 if ( selNew != -1 )
5a7d70fe 311 SetSelection( selNew );
461fe6e2 312
37144cf0 313 InvalidateBestSize();
5a7d70fe 314
c854c7d9
GD
315 return true;
316}
317
3c3e6970
SC
318int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
319{
fe224552 320 int resultV = wxNOT_FOUND;
5a7d70fe 321
3c3e6970 322#if TARGET_API_MAC_OSX
5a7d70fe 323 const int countPages = GetPageCount();
fe224552 324
5a7d70fe 325 HIPoint hipoint = { pt.x , pt.y } ;
3c3e6970 326 HIViewPartCode outPart = 0 ;
5a7d70fe 327 OSStatus err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
fe224552 328
0df4335d 329 int max = m_peer->GetMaximum() ;
3c3e6970
SC
330 if ( outPart == 0 && max > 0 )
331 {
332 // this is a hack, as unfortunately a hit on an already selected tab returns 0,
fe224552 333 // so we have to go some extra miles to make sure we select something different
3c3e6970 334 // and try again ..
0df4335d 335 int val = m_peer->GetValue() ;
3c3e6970
SC
336 int maxval = max ;
337 if ( max == 1 )
338 {
0df4335d 339 m_peer->SetMaximum( 2 ) ;
3c3e6970
SC
340 maxval = 2 ;
341 }
342
343 if ( val == 1 )
0df4335d 344 m_peer->SetValue( maxval ) ;
3c3e6970 345 else
0df4335d 346 m_peer->SetValue( 1 ) ;
fe224552 347
5a7d70fe 348 err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
fe224552 349
0df4335d 350 m_peer->SetValue( val ) ;
3c3e6970 351 if ( max == 1 )
0df4335d 352 m_peer->SetMaximum( 1 ) ;
3c3e6970 353 }
fe224552
VZ
354
355 if ( outPart >= 1 && outPart <= countPages )
eb5d9594 356 resultV = outPart - 1 ;
f885b815
VZ
357#endif // TARGET_API_MAC_OSX
358
3c3e6970
SC
359 if (flags != NULL)
360 {
361 *flags = 0;
fe224552 362
3c3e6970 363 // we cannot differentiate better
eb5d9594 364 if (resultV >= 0)
3c3e6970
SC
365 *flags |= wxNB_HITTEST_ONLABEL;
366 else
367 *flags |= wxNB_HITTEST_NOWHERE;
368 }
5a7d70fe 369
3c3e6970
SC
370 return resultV;
371}
372
5a7d70fe
DS
373// Added by Mark Newsam
374// When a page is added or deleted to the notebook this function updates
375// information held in the control so that it matches the order
376// the user would expect.
377//
c854c7d9
GD
378void wxNotebook::MacSetupTabs()
379{
5ca0d812 380 m_peer->SetMaximum( GetPageCount() ) ;
5aed9d50 381
c854c7d9 382 wxNotebookPage *page;
5324268e 383 ControlTabInfoRecV1 info;
5aed9d50 384
19c43a77 385 const size_t countPages = GetPageCount();
5a7d70fe 386 for (size_t ii = 0; ii < countPages; ii++)
c854c7d9 387 {
90b959ae 388 page = m_pages[ii];
5324268e 389 info.version = kControlTabInfoVersionOne;
c854c7d9 390 info.iconSuiteID = 0;
5a7d70fe 391 wxMacCFStringHolder cflabel( page->GetLabel(), m_font.GetEncoding() ) ;
5324268e 392 info.name = cflabel ;
5a7d70fe 393 m_peer->SetData<ControlTabInfoRecV1>( ii + 1, kControlTabInfoTag, &info ) ;
20b69855 394
2b5f62a0
VZ
395 if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
396 {
5a7d70fe 397 const wxBitmap bmap = GetImageList()->GetBitmap( GetPageImage( ii ) ) ;
b337acd7 398 if ( bmap.Ok() )
061174e3 399 {
061174e3 400 ControlButtonContentInfo info ;
20b69855 401
5a7d70fe
DS
402 wxMacCreateBitmapButton( &info, bmap ) ;
403
404 OSStatus err = m_peer->SetData<ControlButtonContentInfo>( ii + 1, kControlTabImageContentTag, &info );
061174e3 405 wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
5a7d70fe 406
20b69855 407 wxMacReleaseBitmapButton( &info ) ;
061174e3 408 }
2b5f62a0 409 }
5a7d70fe
DS
410
411 m_peer->SetTabEnabled( ii + 1, true ) ;
c854c7d9 412 }
5a7d70fe 413
c854c7d9 414 Rect bounds;
5ca0d812 415 m_peer->GetRectInWindowCoords( &bounds ) ;
5a7d70fe 416 InvalWindowRect( (WindowRef)MacGetTopLevelWindowRef(), &bounds );
ee6b1d97
SC
417}
418
63ff6f53
SC
419wxRect wxNotebook::GetPageRect() const
420{
facd6764 421 wxSize size = GetClientSize() ;
5a7d70fe 422
facd6764 423 return wxRect( 0 , 0 , size.x , size.y ) ;
63ff6f53 424}
5a7d70fe 425
ee6b1d97
SC
426// ----------------------------------------------------------------------------
427// wxNotebook callbacks
428// ----------------------------------------------------------------------------
429
430// @@@ OnSize() is used for setting the font when it's called for the first
431// time because doing it in ::Create() doesn't work (for unknown reasons)
432void wxNotebook::OnSize(wxSizeEvent& event)
433{
90b959ae 434 unsigned int nCount = m_pages.Count();
63ff6f53 435 wxRect rect = GetPageRect() ;
5a7d70fe
DS
436
437 for ( unsigned int nPage = 0; nPage < nCount; nPage++ )
438 {
90b959ae 439 wxNotebookPage *pPage = m_pages[nPage];
63ff6f53 440 pPage->SetSize(rect);
5a7d70fe 441 if ( pPage->GetAutoLayout() )
ee6b1d97
SC
442 pPage->Layout();
443 }
5aed9d50 444
ee6b1d97
SC
445 // Processing continues to next OnSize
446 event.Skip();
447}
448
449void wxNotebook::OnSelChange(wxNotebookEvent& event)
450{
451 // is it our tab control?
452 if ( event.GetEventObject() == this )
453 ChangePage(event.GetOldSelection(), event.GetSelection());
5aed9d50 454
ee6b1d97
SC
455 // we want to give others a chance to process this message as well
456 event.Skip();
457}
458
459void wxNotebook::OnSetFocus(wxFocusEvent& event)
460{
461 // set focus to the currently selected page if any
462 if ( m_nSelection != -1 )
90b959ae 463 m_pages[m_nSelection]->SetFocus();
5aed9d50 464
ee6b1d97
SC
465 event.Skip();
466}
467
468void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
469{
5a7d70fe
DS
470 if ( event.IsWindowChange() )
471 {
ee6b1d97 472 // change pages
5a7d70fe 473 AdvanceSelection( event.GetDirection() );
ee6b1d97 474 }
5a7d70fe
DS
475 else
476 {
461fe6e2
SC
477 // we get this event in 2 cases
478 //
479 // a) one of our pages might have generated it because the user TABbed
480 // out from it in which case we should propagate the event upwards and
481 // our parent will take care of setting the focus to prev/next sibling
482 //
483 // or
484 //
485 // b) the parent panel wants to give the focus to us so that we
486 // forward it to our selected page. We can't deal with this in
487 // OnSetFocus() because we don't know which direction the focus came
488 // from in this case and so can't choose between setting the focus to
489 // first or last panel child
490 wxWindow *parent = GetParent();
5a7d70fe
DS
491
492 // the cast is here to fix a GCC ICE
461fe6e2
SC
493 if ( ((wxWindow*)event.GetEventObject()) == parent )
494 {
495 // no, it doesn't come from child, case (b): forward to a page
496 if ( m_nSelection != -1 )
497 {
498 // so that the page knows that the event comes from it's parent
499 // and is being propagated downwards
5a7d70fe 500 event.SetEventObject( this );
461fe6e2
SC
501
502 wxWindow *page = m_pages[m_nSelection];
5a7d70fe 503 if ( !page->GetEventHandler()->ProcessEvent( event ) )
461fe6e2
SC
504 {
505 page->SetFocus();
506 }
507 //else: page manages focus inside it itself
508 }
509 else
510 {
511 // we have no pages - still have to give focus to _something_
512 SetFocus();
513 }
514 }
515 else
516 {
517 // it comes from our child, case (a), pass to the parent
5a7d70fe
DS
518 if ( parent )
519 {
520 event.SetCurrentFocus( this );
521 parent->GetEventHandler()->ProcessEvent( event );
461fe6e2 522 }
ee6b1d97
SC
523 }
524 }
525}
526
527// ----------------------------------------------------------------------------
528// wxNotebook base class virtuals
529// ----------------------------------------------------------------------------
530
461fe6e2
SC
531#if wxUSE_CONSTRAINTS
532
ee6b1d97
SC
533// override these 2 functions to do nothing: everything is done in OnSize
534
461fe6e2 535void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
ee6b1d97 536{
90c0f5a9 537 // don't set the sizes of the pages - their correct size is not yet known
5a7d70fe 538 wxControl::SetConstraintSizes( false );
ee6b1d97
SC
539}
540
461fe6e2 541bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
ee6b1d97 542{
90c0f5a9 543 return true;
ee6b1d97
SC
544}
545
461fe6e2
SC
546#endif // wxUSE_CONSTRAINTS
547
ee6b1d97
SC
548void wxNotebook::Command(wxCommandEvent& event)
549{
427ff662 550 wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
ee6b1d97
SC
551}
552
553// ----------------------------------------------------------------------------
554// wxNotebook helper functions
555// ----------------------------------------------------------------------------
556
557// hide the currently active panel and show the new one
558void wxNotebook::ChangePage(int nOldSel, int nSel)
559{
5a7d70fe
DS
560 if (nOldSel == nSel)
561 return;
562
90c0f5a9 563 if ( nOldSel != -1 )
5a7d70fe 564 m_pages[nOldSel]->Show( false );
461fe6e2
SC
565
566 if ( nSel != -1 )
c854c7d9 567 {
90b959ae 568 wxNotebookPage *pPage = m_pages[nSel];
5a7d70fe 569 pPage->Show( true );
c854c7d9 570 pPage->SetFocus();
c854c7d9 571 }
90c0f5a9 572
ee6b1d97 573 m_nSelection = nSel;
5ca0d812 574 m_peer->SetValue( m_nSelection + 1 ) ;
ee6b1d97
SC
575}
576
90c0f5a9 577wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
799690a0 578{
4c37f124 579 OSStatus status = eventNotHandledErr ;
90c0f5a9 580
5ca0d812 581 SInt32 newSel = m_peer->GetValue() - 1 ;
4c37f124 582 if ( newSel != m_nSelection )
e40298d5 583 {
5a7d70fe
DS
584 wxNotebookEvent changing(
585 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
586 newSel , m_nSelection );
587 changing.SetEventObject( this );
588 GetEventHandler()->ProcessEvent( changing );
5aed9d50 589
5a7d70fe 590 if ( changing.IsAllowed() )
e40298d5 591 {
5a7d70fe
DS
592 wxNotebookEvent event(
593 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
594 newSel, m_nSelection );
595 event.SetEventObject( this );
596 GetEventHandler()->ProcessEvent( event );
4c37f124
SC
597 }
598 else
599 {
5ca0d812 600 m_peer->SetValue( m_nSelection + 1 ) ;
e40298d5 601 }
5a7d70fe 602
4c37f124 603 status = noErr ;
e40298d5 604 }
5a7d70fe
DS
605
606 return (wxInt32)status ;
ee6b1d97
SC
607}
608
179e085f 609#endif