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