]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/notebmac.cpp
use wxDIB object instead of static ConvertFromBitmap() in CF_DIB case
[wxWidgets.git] / src / mac / carbon / notebmac.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: notebook.cpp
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
ee6b1d97
SC
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
eb22f2a6 12#ifdef __GNUG__
e40298d5 13#pragma implementation "notebook.h"
eb22f2a6
GD
14#endif
15
ee6b1d97
SC
16// ============================================================================
17// declarations
18// ============================================================================
19
20// ----------------------------------------------------------------------------
21// headers
22// ----------------------------------------------------------------------------
799690a0 23#include "wx/app.h"
d497dca4
GD
24#include "wx/string.h"
25#include "wx/log.h"
26#include "wx/imaglist.h"
061174e3 27#include "wx/image.h"
d497dca4
GD
28#include "wx/notebook.h"
29#include "wx/mac/uma.h"
ee6b1d97
SC
30// ----------------------------------------------------------------------------
31// macros
32// ----------------------------------------------------------------------------
33
34// check that the page index is valid
19c43a77 35#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
ee6b1d97 36
ee6b1d97
SC
37
38// ----------------------------------------------------------------------------
39// event table
40// ----------------------------------------------------------------------------
41
5b781a67
SC
42DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
43DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
44
ee6b1d97 45BEGIN_EVENT_TABLE(wxNotebook, wxControl)
461fe6e2
SC
46 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
47 EVT_MOUSE_EVENTS(wxNotebook::OnMouse)
e40298d5 48
461fe6e2
SC
49 EVT_SIZE(wxNotebook::OnSize)
50 EVT_SET_FOCUS(wxNotebook::OnSetFocus)
51 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
ee6b1d97
SC
52END_EVENT_TABLE()
53
54IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
55IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
ee6b1d97
SC
56
57// ============================================================================
58// implementation
59// ============================================================================
60
5aed9d50
RD
61// ----------------------------------------------------------------------------
62// wxNotebook construction
63// ----------------------------------------------------------------------------
64
65// common part of all ctors
66void wxNotebook::Init()
67{
ee6b1d97
SC
68 m_nSelection = -1;
69}
70
71// default for dynamic class
72wxNotebook::wxNotebook()
73{
74 Init();
75}
76
77// the same arguments as for wxControl
78wxNotebook::wxNotebook(wxWindow *parent,
79 wxWindowID id,
80 const wxPoint& pos,
81 const wxSize& size,
82 long style,
83 const wxString& name)
84{
85 Init();
5aed9d50 86
ee6b1d97
SC
87 Create(parent, id, pos, size, style, name);
88}
89
90// Create() function
91bool wxNotebook::Create(wxWindow *parent,
92 wxWindowID id,
93 const wxPoint& pos,
94 const wxSize& size,
95 long style,
96 const wxString& name)
97{
facd6764
SC
98 m_macIsUserPane = FALSE ;
99
b45ed7a2
VZ
100 if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
101 return false;
102
facd6764 103 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
5aed9d50 104
facd6764
SC
105 if( bounds.right <= bounds.left )
106 bounds.right = bounds.left + 100 ;
107 if ( bounds.bottom <= bounds.top )
108 bounds.bottom = bounds.top + 100 ;
5aed9d50 109
facd6764 110 UInt16 tabstyle = kControlTabDirectionNorth ;
e40298d5 111 if ( HasFlag(wxNB_LEFT) )
facd6764 112 tabstyle = kControlTabDirectionWest ;
e40298d5 113 else if ( HasFlag( wxNB_RIGHT ) )
facd6764 114 tabstyle = kControlTabDirectionEast ;
e40298d5 115 else if ( HasFlag( wxNB_BOTTOM ) )
facd6764
SC
116 tabstyle = kControlTabDirectionSouth ;
117
118 ControlTabSize tabsize = kControlTabSizeLarge ;
119 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
120 tabsize = kControlTabSizeSmall ;
121 else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
122 {
123 if (UMAGetSystemVersion() >= 0x1030 )
124 tabsize = 3 ;
125 else
126 tabsize = kControlSizeSmall;
127 }
5aed9d50 128
facd6764
SC
129 ::CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl);
130
131 MacPostControlCreate(pos,size) ;
e40298d5 132 return TRUE ;
ee6b1d97
SC
133}
134
135// dtor
136wxNotebook::~wxNotebook()
137{
ee6b1d97
SC
138}
139
140// ----------------------------------------------------------------------------
141// wxNotebook accessors
142// ----------------------------------------------------------------------------
90b959ae
SC
143
144void wxNotebook::SetPadding(const wxSize& padding)
145{
63ff6f53 146 // unsupported by OS
90b959ae
SC
147}
148
149void wxNotebook::SetTabSize(const wxSize& sz)
ee6b1d97 150{
63ff6f53 151 // unsupported by OS
ee6b1d97
SC
152}
153
90b959ae 154void wxNotebook::SetPageSize(const wxSize& size)
ee6b1d97 155{
63ff6f53
SC
156 SetSize( CalcSizeFromPage( size ) );
157}
158
159wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
160{
facd6764 161 return DoGetSizeFromClientSize( sizePage ) ;
63ff6f53
SC
162}
163
164wxSize wxNotebook::DoGetBestSize() const
165{
166 // calculate the max page size
167 wxSize size(0, 0);
168
169 size_t count = GetPageCount();
170 if ( count )
171 {
172 for ( size_t n = 0; n < count; n++ )
173 {
174 wxSize sizePage = m_pages[n]->GetSize();
175
176 if ( size.x < sizePage.x )
177 size.x = sizePage.x;
178 if ( size.y < sizePage.y )
179 size.y = sizePage.y;
180 }
181 }
182 else // no pages
183 {
184 // use some arbitrary default size
185 size.x =
186 size.y = 100;
187 }
188
189 return CalcSizeFromPage(size);
ee6b1d97
SC
190}
191
8f83dfee 192int wxNotebook::SetSelection(size_t nPage)
ee6b1d97 193{
461fe6e2 194 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
5aed9d50 195
461fe6e2
SC
196 if ( int(nPage) != m_nSelection )
197 {
198 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
199 event.SetSelection(nPage);
200 event.SetOldSelection(m_nSelection);
201 event.SetEventObject(this);
202 if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
203 {
204 // program allows the page change
205 event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
206 (void)GetEventHandler()->ProcessEvent(event);
207
208 ChangePage(m_nSelection, nPage);
209 }
210 }
5aed9d50 211
ee6b1d97
SC
212 return m_nSelection;
213}
214
8f83dfee 215bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
ee6b1d97
SC
216{
217 wxASSERT( IS_VALID_PAGE(nPage) );
5aed9d50 218
90b959ae 219 wxNotebookPage *page = m_pages[nPage];
c854c7d9
GD
220 page->SetLabel(strText);
221 MacSetupTabs();
5aed9d50 222
c854c7d9 223 return true;
ee6b1d97
SC
224}
225
8f83dfee 226wxString wxNotebook::GetPageText(size_t nPage) const
ee6b1d97
SC
227{
228 wxASSERT( IS_VALID_PAGE(nPage) );
5aed9d50 229
90b959ae 230 wxNotebookPage *page = m_pages[nPage];
c854c7d9 231 return page->GetLabel();
ee6b1d97
SC
232}
233
8f83dfee 234int wxNotebook::GetPageImage(size_t nPage) const
ee6b1d97 235{
fc0daf84 236 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") );
5aed9d50 237
2b5f62a0 238 return m_images[nPage];
ee6b1d97
SC
239}
240
19c43a77 241bool wxNotebook::SetPageImage(size_t nPage, int nImage)
ee6b1d97 242{
fc0daf84 243 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") );
5aed9d50 244
fc0daf84 245 wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE,
e40298d5 246 _T("invalid image index in SetPageImage()") );
5aed9d50 247
2b5f62a0
VZ
248 if ( nImage != m_images[nPage] )
249 {
250 // if the item didn't have an icon before or, on the contrary, did have
251 // it but has lost it now, its size will change - but if the icon just
252 // changes, it won't
253 m_images[nPage] = nImage;
5aed9d50 254
e40298d5 255 MacSetupTabs() ;
2b5f62a0 256 }
5aed9d50 257
2b5f62a0 258 return TRUE;
ee6b1d97
SC
259}
260
ee6b1d97
SC
261// ----------------------------------------------------------------------------
262// wxNotebook operations
263// ----------------------------------------------------------------------------
264
90b959ae 265// remove one page from the notebook, without deleting the window
8f83dfee 266wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
ee6b1d97 267{
90b959ae
SC
268 wxCHECK( IS_VALID_PAGE(nPage), NULL );
269 wxNotebookPage* page = m_pages[nPage] ;
3ef585df 270 m_pages.RemoveAt(nPage);
5aed9d50 271
c854c7d9 272 MacSetupTabs();
5aed9d50 273
19c43a77 274 if(m_nSelection >= (int)GetPageCount()) {
c854c7d9
GD
275 m_nSelection = GetPageCount() - 1;
276 }
277 if(m_nSelection >= 0) {
90b959ae 278 m_pages[m_nSelection]->Show(true);
c854c7d9 279 }
90b959ae 280 return page;
ee6b1d97
SC
281}
282
283// remove all pages
284bool wxNotebook::DeleteAllPages()
285{
90b959ae 286 WX_CLEAR_ARRAY(m_pages) ;
c854c7d9 287 MacSetupTabs();
061174e3 288 m_nSelection = -1 ;
ee6b1d97
SC
289 return TRUE;
290}
291
ee6b1d97
SC
292
293// same as AddPage() but does it at given position
8f83dfee 294bool wxNotebook::InsertPage(size_t nPage,
ee6b1d97
SC
295 wxNotebookPage *pPage,
296 const wxString& strText,
297 bool bSelect,
298 int imageId)
299{
19c43a77
VZ
300 if ( !wxNotebookBase::InsertPage(nPage, pPage, strText, bSelect, imageId) )
301 return false;
5aed9d50 302
461fe6e2
SC
303 wxASSERT_MSG( pPage->GetParent() == this,
304 _T("notebook pages must have notebook as parent") );
305
306 // don't show pages by default (we'll need to adjust their size first)
307 pPage->Show( false ) ;
308
c854c7d9 309 pPage->SetLabel(strText);
5aed9d50 310
2b5f62a0 311 m_images.Insert(imageId, nPage);
5aed9d50 312
c854c7d9 313 MacSetupTabs();
5aed9d50 314
63ff6f53
SC
315 wxRect rect = GetPageRect() ;
316 pPage->SetSize(rect);
c854c7d9
GD
317 if ( pPage->GetAutoLayout() ) {
318 pPage->Layout();
319 }
5aed9d50 320
461fe6e2
SC
321
322 // now deal with the selection
323 // ---------------------------
324
325 // if the inserted page is before the selected one, we must update the
326 // index of the selected page
327
328 if ( int(nPage) <= m_nSelection )
329 {
330 m_nSelection++;
331 // while this still is the same page showing, we need to update the tabs
facd6764 332 SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
461fe6e2
SC
333 }
334
335 // some page should be selected: either this one or the first one if there
336 // is still no selection
337 int selNew = -1;
338 if ( bSelect )
339 selNew = nPage;
340 else if ( m_nSelection == -1 )
341 selNew = 0;
342
343 if ( selNew != -1 )
344 SetSelection(selNew);
345
c854c7d9
GD
346 return true;
347}
348
349/* Added by Mark Newsam
e40298d5
JS
350* When a page is added or deleted to the notebook this function updates
351* information held in the m_macControl so that it matches the order
352* the user would expect.
353*/
c854c7d9
GD
354void wxNotebook::MacSetupTabs()
355{
facd6764 356 SetControl32BitMaximum( (ControlRef) m_macControl , GetPageCount() ) ;
5aed9d50 357
c854c7d9
GD
358 wxNotebookPage *page;
359 ControlTabInfoRec info;
5aed9d50 360
19c43a77
VZ
361 const size_t countPages = GetPageCount();
362 for(size_t ii = 0; ii < countPages; ii++)
c854c7d9 363 {
90b959ae 364 page = m_pages[ii];
c854c7d9
GD
365 info.version = 0;
366 info.iconSuiteID = 0;
427ff662
SC
367 wxMacStringToPascal( page->GetLabel() , info.name ) ;
368
facd6764 369 SetControlData( (ControlRef) m_macControl, ii+1, kControlTabInfoTag,
e40298d5 370 sizeof( ControlTabInfoRec) , (char*) &info ) ;
facd6764 371 SetTabEnabled( (ControlRef) m_macControl , ii+1 , true ) ;
22026088 372#if TARGET_CARBON
2b5f62a0
VZ
373 if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
374 {
e40298d5
JS
375 // tab controls only support very specific types of images, therefore we are doing an odyssee
376 // accross the icon worlds (even Apple DTS did not find a shorter path)
377 // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately
5aed9d50 378 // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we
e40298d5 379 // unregister it) in case this will ever lead to having the same icon everywhere add some kind
5aed9d50 380 // of static counter
69efd83d 381 const wxBitmap* bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ;
061174e3
SC
382 if ( bmap )
383 {
384 wxBitmap scaledBitmap ;
385 if ( bmap->GetWidth() != 16 || bmap->GetHeight() != 16 )
386 {
387 scaledBitmap = wxBitmap( bmap->ConvertToImage().Scale(16,16) ) ;
388 bmap = &scaledBitmap ;
389 }
390 ControlButtonContentInfo info ;
391 wxMacCreateBitmapButton( &info , *bmap , kControlContentPictHandle) ;
392 IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
393 OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
394 wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
395 IconRef iconRef ;
d5f7923b 396 err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1, iconFamily, &iconRef ) ;
061174e3
SC
397 wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
398 info.contentType = kControlContentIconRef ;
399 info.u.iconRef = iconRef ;
facd6764 400 SetControlData( (ControlRef) m_macControl, ii+1,kControlTabImageContentTag,
061174e3
SC
401 sizeof( info ), (Ptr)&info );
402 wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
d8c59747 403 if ( UMAGetSystemVersion() < 0x1030 )
d5f7923b
SC
404 {
405 UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
406 }
407
061174e3
SC
408 ReleaseIconRef( iconRef ) ;
409 DisposeHandle( (Handle) iconFamily ) ;
410 }
2b5f62a0
VZ
411 }
412#endif
c854c7d9
GD
413 }
414 Rect bounds;
facd6764
SC
415 UMAGetControlBoundsInWindowCoords((ControlRef)m_macControl, &bounds);
416 InvalWindowRect((WindowRef)MacGetTopLevelWindowRef(), &bounds);
ee6b1d97
SC
417}
418
63ff6f53
SC
419wxRect wxNotebook::GetPageRect() const
420{
facd6764
SC
421 wxSize size = GetClientSize() ;
422 return wxRect( 0 , 0 , size.x , size.y ) ;
63ff6f53 423}
ee6b1d97
SC
424// ----------------------------------------------------------------------------
425// wxNotebook callbacks
426// ----------------------------------------------------------------------------
427
428// @@@ OnSize() is used for setting the font when it's called for the first
429// time because doing it in ::Create() doesn't work (for unknown reasons)
430void wxNotebook::OnSize(wxSizeEvent& event)
431{
5aed9d50 432
90b959ae 433 unsigned int nCount = m_pages.Count();
63ff6f53 434 wxRect rect = GetPageRect() ;
ee6b1d97 435 for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
90b959ae 436 wxNotebookPage *pPage = m_pages[nPage];
63ff6f53 437 pPage->SetSize(rect);
c854c7d9 438 if ( pPage->GetAutoLayout() ) {
ee6b1d97 439 pPage->Layout();
c854c7d9 440 }
ee6b1d97 441 }
5aed9d50 442
ee6b1d97
SC
443 // Processing continues to next OnSize
444 event.Skip();
445}
446
447void wxNotebook::OnSelChange(wxNotebookEvent& event)
448{
449 // is it our tab control?
450 if ( event.GetEventObject() == this )
451 ChangePage(event.GetOldSelection(), event.GetSelection());
5aed9d50 452
ee6b1d97
SC
453 // we want to give others a chance to process this message as well
454 event.Skip();
455}
456
457void wxNotebook::OnSetFocus(wxFocusEvent& event)
458{
459 // set focus to the currently selected page if any
460 if ( m_nSelection != -1 )
90b959ae 461 m_pages[m_nSelection]->SetFocus();
5aed9d50 462
ee6b1d97
SC
463 event.Skip();
464}
465
466void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
467{
468 if ( event.IsWindowChange() ) {
469 // change pages
470 AdvanceSelection(event.GetDirection());
471 }
472 else {
461fe6e2
SC
473 // we get this event in 2 cases
474 //
475 // a) one of our pages might have generated it because the user TABbed
476 // out from it in which case we should propagate the event upwards and
477 // our parent will take care of setting the focus to prev/next sibling
478 //
479 // or
480 //
481 // b) the parent panel wants to give the focus to us so that we
482 // forward it to our selected page. We can't deal with this in
483 // OnSetFocus() because we don't know which direction the focus came
484 // from in this case and so can't choose between setting the focus to
485 // first or last panel child
486 wxWindow *parent = GetParent();
487 // the cast is here to fic a GCC ICE
488 if ( ((wxWindow*)event.GetEventObject()) == parent )
489 {
490 // no, it doesn't come from child, case (b): forward to a page
491 if ( m_nSelection != -1 )
492 {
493 // so that the page knows that the event comes from it's parent
494 // and is being propagated downwards
495 event.SetEventObject(this);
496
497 wxWindow *page = m_pages[m_nSelection];
498 if ( !page->GetEventHandler()->ProcessEvent(event) )
499 {
500 page->SetFocus();
501 }
502 //else: page manages focus inside it itself
503 }
504 else
505 {
506 // we have no pages - still have to give focus to _something_
507 SetFocus();
508 }
509 }
510 else
511 {
512 // it comes from our child, case (a), pass to the parent
513 if ( parent ) {
514 event.SetCurrentFocus(this);
515 parent->GetEventHandler()->ProcessEvent(event);
516 }
ee6b1d97
SC
517 }
518 }
519}
520
521// ----------------------------------------------------------------------------
522// wxNotebook base class virtuals
523// ----------------------------------------------------------------------------
524
461fe6e2
SC
525#if wxUSE_CONSTRAINTS
526
ee6b1d97
SC
527// override these 2 functions to do nothing: everything is done in OnSize
528
461fe6e2 529void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
ee6b1d97 530{
461fe6e2
SC
531 // don't set the sizes of the pages - their correct size is not yet known
532 wxControl::SetConstraintSizes(FALSE);
ee6b1d97
SC
533}
534
461fe6e2 535bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
ee6b1d97 536{
461fe6e2 537 return TRUE;
ee6b1d97
SC
538}
539
461fe6e2
SC
540#endif // wxUSE_CONSTRAINTS
541
ee6b1d97
SC
542void wxNotebook::Command(wxCommandEvent& event)
543{
427ff662 544 wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
ee6b1d97
SC
545}
546
547// ----------------------------------------------------------------------------
548// wxNotebook helper functions
549// ----------------------------------------------------------------------------
550
551// hide the currently active panel and show the new one
552void wxNotebook::ChangePage(int nOldSel, int nSel)
553{
461fe6e2
SC
554 if ( nOldSel != -1 )
555 {
556 m_pages[nOldSel]->Show(FALSE);
557 }
558
559 if ( nSel != -1 )
c854c7d9 560 {
90b959ae 561 wxNotebookPage *pPage = m_pages[nSel];
c854c7d9
GD
562 pPage->Show(TRUE);
563 pPage->SetFocus();
c854c7d9 564 }
461fe6e2 565
ee6b1d97 566 m_nSelection = nSel;
facd6764 567 SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
ee6b1d97
SC
568}
569
799690a0
SC
570
571void wxNotebook::OnMouse( wxMouseEvent &event )
572{
facd6764 573 if ( (ControlRef) m_macControl == NULL )
e40298d5
JS
574 {
575 event.Skip() ;
576 return ;
577 }
5aed9d50 578
e40298d5
JS
579 if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
580 {
581 int x = event.m_x ;
582 int y = event.m_y ;
5aed9d50 583
e40f15ab 584#if TARGET_API_MAC_OSX
facd6764
SC
585 // OS Needs it in window not client coordinates
586 wxPoint origin = GetClientAreaOrigin() ;
587 x += origin.x ;
588 y += origin.y ;
589#else
590 // OS Needs it in tlw content area coordinates
591 MacClientToRootWindow( &x , &y ) ;
592#endif
5aed9d50 593
facd6764 594 ControlRef control ;
e40298d5
JS
595 Point localwhere ;
596 SInt16 controlpart ;
5aed9d50 597
e40298d5
JS
598 localwhere.h = x ;
599 localwhere.v = y ;
5aed9d50 600
e40298d5 601 short modifiers = 0;
5aed9d50 602
e40298d5
JS
603 if ( !event.m_leftDown && !event.m_rightDown )
604 modifiers |= btnState ;
5aed9d50 605
e40298d5
JS
606 if ( event.m_shiftDown )
607 modifiers |= shiftKey ;
5aed9d50 608
e40298d5
JS
609 if ( event.m_controlDown )
610 modifiers |= controlKey ;
5aed9d50 611
e40298d5
JS
612 if ( event.m_altDown )
613 modifiers |= optionKey ;
5aed9d50 614
e40298d5
JS
615 if ( event.m_metaDown )
616 modifiers |= cmdKey ;
5aed9d50 617
facd6764 618 control = (ControlRef) m_macControl ;
e40298d5
JS
619 if ( control && ::IsControlActive( control ) )
620 {
621 {
622 wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
623 ::GetControl32BitValue(control) - 1, m_nSelection);
624 changing.SetEventObject(this);
55da8bd1 625 GetEventHandler()->ProcessEvent(changing);
5aed9d50 626
e40298d5
JS
627 if(changing.IsAllowed())
628 {
629 controlpart = ::HandleControlClick(control, localwhere, modifiers,
630 (ControlActionUPP) -1);
631 wxTheApp->s_lastMouseDown = 0 ;
5aed9d50 632
e40298d5
JS
633 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
634 ::GetControl32BitValue(control) - 1, m_nSelection);
635 event.SetEventObject(this);
5aed9d50 636
55da8bd1 637 GetEventHandler()->ProcessEvent(event);
e40298d5
JS
638 }
639 }
640 }
641 }
799690a0 642}
e40298d5 643
799690a0 644
4b26b60f 645void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
ee6b1d97 646{
799690a0 647#if 0
facd6764 648 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlRef)m_macControl) - 1, m_nSelection);
e40298d5 649 event.SetEventObject(this);
5aed9d50 650
e40298d5 651 ProcessEvent(event);
799690a0 652#endif
ee6b1d97
SC
653}
654