]> git.saurik.com Git - wxWidgets.git/blame - src/mac/notebmac.cpp
unicode and linkage corrections
[wxWidgets.git] / src / mac / 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"
27#include "wx/notebook.h"
28#include "wx/mac/uma.h"
ee6b1d97
SC
29// ----------------------------------------------------------------------------
30// macros
31// ----------------------------------------------------------------------------
32
33// check that the page index is valid
19c43a77 34#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
ee6b1d97 35
ee6b1d97
SC
36
37// ----------------------------------------------------------------------------
38// event table
39// ----------------------------------------------------------------------------
40
41#if !USE_SHARED_LIBRARIES
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)
e40298d5
JS
46EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
47EVT_MOUSE_EVENTS(wxNotebook::OnMouse)
48
49EVT_SIZE(wxNotebook::OnSize)
50EVT_SET_FOCUS(wxNotebook::OnSetFocus)
51EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
ee6b1d97
SC
52END_EVENT_TABLE()
53
54IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
55IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
56#endif
57
58// ============================================================================
59// implementation
60// ============================================================================
61
5aed9d50
RD
62// The Appearance Manager docs show using tab controls in either edge to edge
63// mode, or inset. I think edge to edge conforms better to the other ports,
64// and inset mode is better accomplished with space around the wxNotebook rather
65// than within it. --Robin
66#define wxMAC_EDGE_TO_EDGE 1
ee6b1d97 67
5aed9d50 68static inline int wxMacTabMargin(long nbStyle, long side)
ee6b1d97 69{
5aed9d50
RD
70 static int tabMargin = -1;
71 static int otherMargin = -1;
72
73 if ( tabMargin == -1)
dd47b3d3
SC
74 {
75 if ( UMAHasAquaLayout() )
76 {
5aed9d50
RD
77 tabMargin = 26; // From Appearance Manager docs for small tab control dimensions
78#if wxMAC_EDGE_TO_EDGE
79 otherMargin = 0;
80#else
81 otherMargin = 20;
82#endif
dd47b3d3
SC
83 }
84 else
85 {
5aed9d50
RD
86 tabMargin = 30;
87#if wxMAC_EDGE_TO_EDGE
88 otherMargin = 0;
89#else
90 otherMargin = 16;
91#endif
dd47b3d3 92 }
dd47b3d3 93 }
5aed9d50
RD
94
95 // If the style matches the side asked for then return the tab margin,
96 // but we have to special case wxNB_TOP since it is zero...
97 if ( side == wxNB_TOP)
98 {
feddd867 99 if ( nbStyle != 0 && nbStyle & (wxNB_LEFT|wxNB_RIGHT|wxNB_BOTTOM))
5aed9d50
RD
100 {
101 return otherMargin;
102 }
103 else
104 {
105 return tabMargin;
106 }
107 }
108 else if ( nbStyle & side)
109 return tabMargin;
110 else
111 return otherMargin;
112}
113
114static inline int wxMacTabLeftMargin(long style)
115{
116 return wxMacTabMargin(style, wxNB_LEFT);
117}
118
119static inline int wxMacTabTopMargin(long style)
120{
121 return wxMacTabMargin(style, wxNB_TOP);
122}
123
124static inline int wxMacTabRightMargin(long style)
125{
126 return wxMacTabMargin(style, wxNB_RIGHT);
127}
128
129static inline int wxMacTabBottomMargin(long style)
130{
131 return wxMacTabMargin(style, wxNB_BOTTOM);
132}
133
134// ----------------------------------------------------------------------------
135// wxNotebook construction
136// ----------------------------------------------------------------------------
137
138// common part of all ctors
139void wxNotebook::Init()
140{
dd47b3d3
SC
141 if ( UMAHasAquaLayout() )
142 {
5aed9d50 143 // Should these depend on wxMAC_EDGE_TO_EDGE too?
dd47b3d3
SC
144 m_macHorizontalBorder = 7;
145 m_macVerticalBorder = 8;
146 }
5aed9d50 147
ee6b1d97
SC
148 m_nSelection = -1;
149}
150
151// default for dynamic class
152wxNotebook::wxNotebook()
153{
154 Init();
155}
156
157// the same arguments as for wxControl
158wxNotebook::wxNotebook(wxWindow *parent,
159 wxWindowID id,
160 const wxPoint& pos,
161 const wxSize& size,
162 long style,
163 const wxString& name)
164{
165 Init();
5aed9d50 166
ee6b1d97
SC
167 Create(parent, id, pos, size, style, name);
168}
169
170// Create() function
171bool wxNotebook::Create(wxWindow *parent,
172 wxWindowID id,
173 const wxPoint& pos,
174 const wxSize& size,
175 long style,
176 const wxString& name)
177{
b45ed7a2
VZ
178 if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
179 return false;
180
e40298d5
JS
181 Rect bounds ;
182 Str255 title ;
5aed9d50 183
427ff662 184 MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
5aed9d50 185
e40298d5
JS
186 int tabstyle = kControlTabSmallNorthProc ;
187 if ( HasFlag(wxNB_LEFT) )
188 tabstyle = kControlTabSmallWestProc ;
189 else if ( HasFlag( wxNB_RIGHT ) )
190 tabstyle = kControlTabSmallEastProc ;
191 else if ( HasFlag( wxNB_BOTTOM ) )
192 tabstyle = kControlTabSmallSouthProc ;
5aed9d50
RD
193
194
195 m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
e40298d5 196 tabstyle , (long) this ) ;
5aed9d50 197
e40298d5
JS
198 MacPostControlCreate() ;
199 return TRUE ;
ee6b1d97
SC
200}
201
202// dtor
203wxNotebook::~wxNotebook()
204{
ee6b1d97
SC
205}
206
2ce7af35 207wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
60ec3e58
RR
208{
209 wxSize sizeTotal = sizePage;
5aed9d50 210
60ec3e58
RR
211 int major,minor;
212 wxGetOsVersion( &major, &minor );
5aed9d50 213
60ec3e58 214 // Mac has large notebook borders. Aqua even more so.
5aed9d50 215
60ec3e58
RR
216 if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
217 {
218 sizeTotal.x += 90;
5aed9d50 219
60ec3e58
RR
220 if (major >= 10)
221 sizeTotal.y += 28;
222 else
223 sizeTotal.y += 20;
224 }
225 else
226 {
227 if (major >= 10)
228 {
229 sizeTotal.x += 34;
230 sizeTotal.y += 46;
231 }
232 else
233 {
234 sizeTotal.x += 22;
235 sizeTotal.y += 44;
236 }
237 }
5aed9d50 238
60ec3e58
RR
239 return sizeTotal;
240}
241
ee6b1d97
SC
242// ----------------------------------------------------------------------------
243// wxNotebook accessors
244// ----------------------------------------------------------------------------
90b959ae
SC
245
246void wxNotebook::SetPadding(const wxSize& padding)
247{
e40298d5 248 wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") );
90b959ae
SC
249}
250
251void wxNotebook::SetTabSize(const wxSize& sz)
ee6b1d97 252{
fc0daf84 253 wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") );
ee6b1d97
SC
254}
255
90b959ae 256void wxNotebook::SetPageSize(const wxSize& size)
ee6b1d97 257{
fc0daf84 258 wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") );
ee6b1d97
SC
259}
260
8f83dfee 261int wxNotebook::SetSelection(size_t nPage)
ee6b1d97 262{
5aed9d50 263 if( !IS_VALID_PAGE(nPage) )
e40298d5 264 return m_nSelection ;
5aed9d50 265
ee6b1d97 266 ChangePage(m_nSelection, nPage);
e40298d5 267 SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ;
5aed9d50 268
2b5f62a0 269 Refresh();
ee6b1d97
SC
270 return m_nSelection;
271}
272
8f83dfee 273bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
ee6b1d97
SC
274{
275 wxASSERT( IS_VALID_PAGE(nPage) );
5aed9d50 276
90b959ae 277 wxNotebookPage *page = m_pages[nPage];
c854c7d9
GD
278 page->SetLabel(strText);
279 MacSetupTabs();
5aed9d50 280
c854c7d9 281 return true;
ee6b1d97
SC
282}
283
8f83dfee 284wxString wxNotebook::GetPageText(size_t nPage) const
ee6b1d97
SC
285{
286 wxASSERT( IS_VALID_PAGE(nPage) );
5aed9d50 287
90b959ae 288 wxNotebookPage *page = m_pages[nPage];
c854c7d9 289 return page->GetLabel();
ee6b1d97
SC
290}
291
8f83dfee 292int wxNotebook::GetPageImage(size_t nPage) const
ee6b1d97 293{
fc0daf84 294 wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") );
5aed9d50 295
2b5f62a0 296 return m_images[nPage];
ee6b1d97
SC
297}
298
19c43a77 299bool wxNotebook::SetPageImage(size_t nPage, int nImage)
ee6b1d97 300{
fc0daf84 301 wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") );
5aed9d50 302
fc0daf84 303 wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE,
e40298d5 304 _T("invalid image index in SetPageImage()") );
5aed9d50 305
2b5f62a0
VZ
306 if ( nImage != m_images[nPage] )
307 {
308 // if the item didn't have an icon before or, on the contrary, did have
309 // it but has lost it now, its size will change - but if the icon just
310 // changes, it won't
311 m_images[nPage] = nImage;
5aed9d50 312
e40298d5 313 MacSetupTabs() ;
2b5f62a0 314 }
5aed9d50 315
2b5f62a0 316 return TRUE;
ee6b1d97
SC
317}
318
ee6b1d97
SC
319// ----------------------------------------------------------------------------
320// wxNotebook operations
321// ----------------------------------------------------------------------------
322
90b959ae 323// remove one page from the notebook, without deleting the window
8f83dfee 324wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
ee6b1d97 325{
90b959ae
SC
326 wxCHECK( IS_VALID_PAGE(nPage), NULL );
327 wxNotebookPage* page = m_pages[nPage] ;
3ef585df 328 m_pages.RemoveAt(nPage);
5aed9d50 329
c854c7d9 330 MacSetupTabs();
5aed9d50 331
19c43a77 332 if(m_nSelection >= (int)GetPageCount()) {
c854c7d9
GD
333 m_nSelection = GetPageCount() - 1;
334 }
335 if(m_nSelection >= 0) {
90b959ae 336 m_pages[m_nSelection]->Show(true);
c854c7d9 337 }
90b959ae 338 return page;
ee6b1d97
SC
339}
340
341// remove all pages
342bool wxNotebook::DeleteAllPages()
343{
344 // TODO: delete native widget pages
5aed9d50 345
90b959ae 346 WX_CLEAR_ARRAY(m_pages) ;
c854c7d9 347 MacSetupTabs();
5aed9d50 348
ee6b1d97
SC
349 return TRUE;
350}
351
ee6b1d97
SC
352
353// same as AddPage() but does it at given position
8f83dfee 354bool wxNotebook::InsertPage(size_t nPage,
ee6b1d97
SC
355 wxNotebookPage *pPage,
356 const wxString& strText,
357 bool bSelect,
358 int imageId)
359{
19c43a77
VZ
360 if ( !wxNotebookBase::InsertPage(nPage, pPage, strText, bSelect, imageId) )
361 return false;
5aed9d50 362
c854c7d9 363 pPage->SetLabel(strText);
5aed9d50 364
2b5f62a0 365 m_images.Insert(imageId, nPage);
5aed9d50 366
c854c7d9 367 MacSetupTabs();
5aed9d50 368
c854c7d9 369 if ( bSelect ) {
ee6b1d97 370 m_nSelection = nPage;
c854c7d9
GD
371 }
372 else if ( m_nSelection == -1 ) {
ee6b1d97 373 m_nSelection = 0;
c854c7d9 374 }
19c43a77 375 else if ((size_t)m_nSelection >= nPage) {
c854c7d9
GD
376 m_nSelection++;
377 }
378 // don't show pages by default (we'll need to adjust their size first)
379 pPage->Show( false ) ;
5aed9d50 380
c854c7d9
GD
381 int h, w;
382 GetSize(&w, &h);
5aed9d50
RD
383 pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
384 wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
385 w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
386 h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
c854c7d9
GD
387 if ( pPage->GetAutoLayout() ) {
388 pPage->Layout();
389 }
5aed9d50 390
c854c7d9
GD
391 return true;
392}
393
394/* Added by Mark Newsam
e40298d5
JS
395* When a page is added or deleted to the notebook this function updates
396* information held in the m_macControl so that it matches the order
397* the user would expect.
398*/
c854c7d9
GD
399void wxNotebook::MacSetupTabs()
400{
467e3168 401 SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ;
5aed9d50 402
c854c7d9
GD
403 wxNotebookPage *page;
404 ControlTabInfoRec info;
5aed9d50 405
19c43a77
VZ
406 const size_t countPages = GetPageCount();
407 for(size_t ii = 0; ii < countPages; ii++)
c854c7d9 408 {
90b959ae 409 page = m_pages[ii];
c854c7d9
GD
410 info.version = 0;
411 info.iconSuiteID = 0;
427ff662
SC
412 wxMacStringToPascal( page->GetLabel() , info.name ) ;
413
76a5e5d2 414 SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag,
e40298d5 415 sizeof( ControlTabInfoRec) , (char*) &info ) ;
2b5f62a0 416 SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ;
22026088 417#if TARGET_CARBON
2b5f62a0
VZ
418 if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
419 {
e40298d5
JS
420 // tab controls only support very specific types of images, therefore we are doing an odyssee
421 // accross the icon worlds (even Apple DTS did not find a shorter path)
422 // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately
5aed9d50 423 // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we
e40298d5 424 // unregister it) in case this will ever lead to having the same icon everywhere add some kind
5aed9d50 425 // of static counter
e40298d5
JS
426 ControlButtonContentInfo info ;
427 wxMacCreateBitmapButton( &info , *GetImageList()->GetBitmap( GetPageImage(ii ) ) , kControlContentPictHandle) ;
428 IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
429 OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
22026088 430 wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
e40298d5
JS
431 IconRef iconRef ;
432 err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1 , iconFamily, &iconRef ) ;
22026088 433 wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
e40298d5
JS
434 info.contentType = kControlContentIconRef ;
435 info.u.iconRef = iconRef ;
436 SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag,
437 sizeof( info ), (Ptr)&info );
22026088 438 wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
e40298d5 439 UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
2b5f62a0
VZ
440 ReleaseIconRef( iconRef ) ;
441 DisposeHandle( (Handle) iconFamily ) ;
442 }
443#endif
c854c7d9
GD
444 }
445 Rect bounds;
76a5e5d2
SC
446 GetControlBounds((ControlHandle)m_macControl, &bounds);
447 InvalWindowRect((WindowRef)MacGetRootWindow(), &bounds);
ee6b1d97
SC
448}
449
450// ----------------------------------------------------------------------------
451// wxNotebook callbacks
452// ----------------------------------------------------------------------------
453
454// @@@ OnSize() is used for setting the font when it's called for the first
455// time because doing it in ::Create() doesn't work (for unknown reasons)
456void wxNotebook::OnSize(wxSizeEvent& event)
457{
ee6b1d97
SC
458 // emulate page change (it's esp. important to do it first time because
459 // otherwise our page would stay invisible)
460 int nSel = m_nSelection;
461 m_nSelection = -1;
462 SetSelection(nSel);
5aed9d50 463
ee6b1d97
SC
464 // fit the notebook page to the tab control's display area
465 int w, h;
466 GetSize(&w, &h);
5aed9d50 467
90b959ae 468 unsigned int nCount = m_pages.Count();
ee6b1d97 469 for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
90b959ae 470 wxNotebookPage *pPage = m_pages[nPage];
5aed9d50
RD
471 pPage->SetSize(wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
472 wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
473 w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
474 h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
c854c7d9 475 if ( pPage->GetAutoLayout() ) {
ee6b1d97 476 pPage->Layout();
c854c7d9 477 }
ee6b1d97 478 }
5aed9d50 479
ee6b1d97
SC
480 // Processing continues to next OnSize
481 event.Skip();
482}
483
484void wxNotebook::OnSelChange(wxNotebookEvent& event)
485{
486 // is it our tab control?
487 if ( event.GetEventObject() == this )
488 ChangePage(event.GetOldSelection(), event.GetSelection());
5aed9d50 489
ee6b1d97
SC
490 // we want to give others a chance to process this message as well
491 event.Skip();
492}
493
494void wxNotebook::OnSetFocus(wxFocusEvent& event)
495{
496 // set focus to the currently selected page if any
497 if ( m_nSelection != -1 )
90b959ae 498 m_pages[m_nSelection]->SetFocus();
5aed9d50 499
ee6b1d97
SC
500 event.Skip();
501}
502
503void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
504{
505 if ( event.IsWindowChange() ) {
506 // change pages
507 AdvanceSelection(event.GetDirection());
508 }
509 else {
510 // pass to the parent
511 if ( GetParent() ) {
512 event.SetCurrentFocus(this);
513 GetParent()->ProcessEvent(event);
514 }
515 }
516}
517
518// ----------------------------------------------------------------------------
519// wxNotebook base class virtuals
520// ----------------------------------------------------------------------------
521
522// override these 2 functions to do nothing: everything is done in OnSize
523
524void wxNotebook::SetConstraintSizes(bool /* recurse */)
525{
526 // don't set the sizes of the pages - their correct size is not yet known
527 wxControl::SetConstraintSizes(FALSE);
528}
529
530bool wxNotebook::DoPhase(int /* nPhase */)
531{
532 return TRUE;
533}
534
535void wxNotebook::Command(wxCommandEvent& event)
536{
427ff662 537 wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
ee6b1d97
SC
538}
539
540// ----------------------------------------------------------------------------
541// wxNotebook helper functions
542// ----------------------------------------------------------------------------
543
544// hide the currently active panel and show the new one
545void wxNotebook::ChangePage(int nOldSel, int nSel)
546{
c854c7d9
GD
547 // it's not an error (the message may be generated by the tab control itself)
548 // and it may happen - just do nothing
549 if ( nSel == nOldSel )
550 {
90b959ae 551 wxNotebookPage *pPage = m_pages[nSel];
c854c7d9
GD
552 pPage->Show(FALSE);
553 pPage->Show(TRUE);
554 pPage->SetFocus();
555 return;
556 }
5aed9d50 557
c854c7d9 558 // Hide previous page
ee6b1d97 559 if ( nOldSel != -1 ) {
90b959ae 560 m_pages[nOldSel]->Show(FALSE);
ee6b1d97 561 }
5aed9d50 562
90b959ae 563 wxNotebookPage *pPage = m_pages[nSel];
ee6b1d97
SC
564 pPage->Show(TRUE);
565 pPage->SetFocus();
5aed9d50 566
ee6b1d97
SC
567 m_nSelection = nSel;
568}
569
799690a0
SC
570
571void wxNotebook::OnMouse( wxMouseEvent &event )
572{
e40298d5
JS
573 if ( (ControlHandle) m_macControl == NULL )
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
e40298d5 584 MacClientToRootWindow( &x , &y ) ;
5aed9d50 585
e40298d5
JS
586 ControlHandle control ;
587 Point localwhere ;
588 SInt16 controlpart ;
5aed9d50 589
e40298d5
JS
590 localwhere.h = x ;
591 localwhere.v = y ;
5aed9d50 592
e40298d5 593 short modifiers = 0;
5aed9d50 594
e40298d5
JS
595 if ( !event.m_leftDown && !event.m_rightDown )
596 modifiers |= btnState ;
5aed9d50 597
e40298d5
JS
598 if ( event.m_shiftDown )
599 modifiers |= shiftKey ;
5aed9d50 600
e40298d5
JS
601 if ( event.m_controlDown )
602 modifiers |= controlKey ;
5aed9d50 603
e40298d5
JS
604 if ( event.m_altDown )
605 modifiers |= optionKey ;
5aed9d50 606
e40298d5
JS
607 if ( event.m_metaDown )
608 modifiers |= cmdKey ;
5aed9d50 609
e40298d5
JS
610 control = (ControlHandle) m_macControl ;
611 if ( control && ::IsControlActive( control ) )
612 {
613 {
614 wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
615 ::GetControl32BitValue(control) - 1, m_nSelection);
616 changing.SetEventObject(this);
55da8bd1 617 GetEventHandler()->ProcessEvent(changing);
5aed9d50 618
e40298d5
JS
619 if(changing.IsAllowed())
620 {
621 controlpart = ::HandleControlClick(control, localwhere, modifiers,
622 (ControlActionUPP) -1);
623 wxTheApp->s_lastMouseDown = 0 ;
5aed9d50 624
e40298d5
JS
625 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
626 ::GetControl32BitValue(control) - 1, m_nSelection);
627 event.SetEventObject(this);
5aed9d50 628
55da8bd1 629 GetEventHandler()->ProcessEvent(event);
e40298d5
JS
630 }
631 }
632 }
633 }
799690a0 634}
e40298d5 635
799690a0 636
4b26b60f 637void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
ee6b1d97 638{
799690a0 639#if 0
e40298d5
JS
640 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection);
641 event.SetEventObject(this);
5aed9d50 642
e40298d5 643 ProcessEvent(event);
799690a0 644#endif
ee6b1d97
SC
645}
646