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