]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/toolbar.cpp
cleanup in toplevel activation, and switching to native carbon event notification...
[wxWidgets.git] / src / mac / carbon / toolbar.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: toolbar.cpp
3// Purpose: wxToolBar
a31a5f85 4// Author: Stefan Csomor
e9576ca5
SC
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
84969af7
JS
8// Copyright: (c) Stefan Csomor
9// Licence: The wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "toolbar.h"
14#endif
15
16#include "wx/wx.h"
519cb848
SC
17
18#if wxUSE_TOOLBAR
19
e9576ca5 20#include "wx/toolbar.h"
2f1ae414
SC
21#include "wx/notebook.h"
22#include "wx/tabctrl.h"
72055702 23#include "wx/bitmap.h"
e9576ca5 24
2f1ae414 25#if !USE_SHARED_LIBRARY
2eb10e2a 26IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
e9576ca5
SC
27
28BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
e044f600
RR
29 EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
30 EVT_PAINT( wxToolBar::OnPaint )
e9576ca5 31END_EVENT_TABLE()
2f1ae414 32#endif
e9576ca5 33
d497dca4 34#include "wx/mac/uma.h"
bfe9ffbc 35#include "wx/geometry.h"
37e2cb08
SC
36// ----------------------------------------------------------------------------
37// private classes
38// ----------------------------------------------------------------------------
39
40class wxToolBarTool : public wxToolBarToolBase
41{
42public:
43 wxToolBarTool(wxToolBar *tbar,
44 int id,
27e2d606
GD
45 const wxString& label,
46 const wxBitmap& bmpNormal,
47 const wxBitmap& bmpDisabled,
48 wxItemKind kind,
37e2cb08 49 wxObject *clientData,
27e2d606 50 const wxString& shortHelp,
bfe9ffbc
SC
51 const wxString& longHelp) ;
52
37e2cb08
SC
53 wxToolBarTool(wxToolBar *tbar, wxControl *control)
54 : wxToolBarToolBase(tbar, control)
55 {
bfe9ffbc 56 Init() ;
37e2cb08 57 }
bfe9ffbc
SC
58
59 ~wxToolBarTool()
60 {
61 if ( m_controlHandle )
62 DisposeControl( m_controlHandle ) ;
63 }
64
facd6764
SC
65 WXWidget GetControlHandle() { return (WXWidget) m_controlHandle ; }
66 void SetControlHandle( ControlRef handle ) { m_controlHandle = handle ; }
37e2cb08 67
bfe9ffbc
SC
68 void SetSize(const wxSize& size) ;
69 void SetPosition( const wxPoint& position ) ;
70 wxSize GetSize() const
71 {
72 if ( IsControl() )
73 {
74 return GetControl()->GetSize() ;
75 }
76 else if ( IsButton() )
77 {
78 return GetToolBar()->GetToolSize() ;
79 }
80 else
81 {
82 wxSize sz = GetToolBar()->GetToolSize() ;
83 sz.x /= 4 ;
84 sz.y /= 4 ;
85 return sz ;
86 }
87 }
88 wxPoint GetPosition() const
89 {
90 return wxPoint(m_x, m_y);
91 }
92private :
93 void Init()
94 {
95 m_controlHandle = NULL ;
96 }
facd6764 97 ControlRef m_controlHandle ;
37e2cb08 98
bfe9ffbc
SC
99 wxCoord m_x;
100 wxCoord m_y;
37e2cb08
SC
101};
102
facd6764
SC
103static const EventTypeSpec eventList[] =
104{
105 { kEventClassControl , kEventControlHit } ,
106} ;
107
108static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
109{
110 OSStatus result = eventNotHandledErr ;
111
112 wxMacCarbonEvent cEvent( event ) ;
113
114 ControlRef controlRef ;
115
116 cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
117
118 switch( GetEventKind( event ) )
119 {
120 case kEventControlHit :
121 {
122 wxToolBarTool* tbartool = (wxToolBarTool*)data ;
123 if ( tbartool->CanBeToggled() )
124 {
125 tbartool->Toggle( GetControl32BitValue( (ControlRef) tbartool->GetControlHandle() ) ) ;
126 }
127 ((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ;
128
129 result = noErr;
130 }
131 break ;
132 default :
133 break ;
134 }
135 return result ;
136}
137
138pascal OSStatus wxMacToolBarToolEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
139{
140 OSStatus result = eventNotHandledErr ;
141
142 switch ( GetEventClass( event ) )
143 {
144 case kEventClassControl :
145 result = wxMacToolBarToolControlEventHandler( handler, event, data ) ;
146 break ;
147 default :
148 break ;
149 }
150 return result ;
151}
152
153DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler )
154
37e2cb08
SC
155// ============================================================================
156// implementation
157// ============================================================================
158
159// ----------------------------------------------------------------------------
160// wxToolBarTool
161// ----------------------------------------------------------------------------
162
bfe9ffbc
SC
163void wxToolBarTool::SetSize(const wxSize& size)
164{
165 if ( IsControl() )
166 {
167 GetControl()->SetSize( size ) ;
168 }
169}
170
171void wxToolBarTool::SetPosition(const wxPoint& position)
172{
173 m_x = position.x;
174 m_y = position.y;
175
176 if ( IsButton() )
177 {
178 int x , y ;
179 x = y = 0 ;
facd6764
SC
180 int mac_x = position.x ;
181 int mac_y = position.y ;
182#if !TARGET_API_MAC_OSX
183 WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetTopLevelWindowRef() ;
bfe9ffbc 184 GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
facd6764
SC
185 mac_x += x;
186 mac_y += y;
187#endif
bfe9ffbc
SC
188 Rect contrlRect ;
189 GetControlBounds( m_controlHandle , &contrlRect ) ;
190 int former_mac_x = contrlRect.left ;
191 int former_mac_y = contrlRect.top ;
192 wxSize sz = GetToolBar()->GetToolSize() ;
193
194 if ( mac_x != former_mac_x || mac_y != former_mac_y )
195 {
bfe9ffbc 196 UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
bfe9ffbc
SC
197 }
198 }
199 else if ( IsControl() )
200 {
201 GetControl()->Move( position ) ;
202 }
203}
204
895f5af7
SC
205const short kwxMacToolBarToolDefaultWidth = 24 ;
206const short kwxMacToolBarToolDefaultHeight = 22 ;
207const short kwxMacToolBarTopMargin = 2 ;
208const short kwxMacToolBarLeftMargin = 2 ;
209
bfe9ffbc
SC
210wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
211 int id,
212 const wxString& label,
213 const wxBitmap& bmpNormal,
214 const wxBitmap& bmpDisabled,
215 wxItemKind kind,
216 wxObject *clientData,
217 const wxString& shortHelp,
218 const wxString& longHelp)
219 : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
220 clientData, shortHelp, longHelp)
221{
f4e0be4f
RR
222 Init();
223
224 if (id == wxID_SEPARATOR) return;
bfe9ffbc 225
facd6764 226 WindowRef window = (WindowRef) tbar->MacGetTopLevelWindowRef() ;
bfe9ffbc
SC
227 wxSize toolSize = tbar->GetToolSize() ;
228 Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ;
229
230 ControlButtonContentInfo info ;
231 wxMacCreateBitmapButton( &info , GetNormalBitmap() ) ;
232
233 SInt16 behaviour = kControlBehaviorOffsetContents ;
234 if ( CanBeToggled() )
235 behaviour += kControlBehaviorToggles ;
236
237 if ( info.contentType != kControlNoContent )
238 {
facd6764 239 m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
bfe9ffbc
SC
240 behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
241
242 ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
243 }
244 else
245 {
facd6764 246 m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
bfe9ffbc
SC
247 behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
248 }
facd6764
SC
249 InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
250 GetEventTypeCount(eventList), eventList, this,NULL);
bfe9ffbc
SC
251 UMAShowControl( m_controlHandle ) ;
252 if ( !IsEnabled() )
253 {
254 UMADeactivateControl( m_controlHandle ) ;
255 }
256 if ( CanBeToggled() && IsToggled() )
257 {
258 ::SetControl32BitValue( m_controlHandle , 1 ) ;
259 }
260 else
261 {
262 ::SetControl32BitValue( m_controlHandle , 0 ) ;
263 }
264
facd6764 265 ControlRef container = (ControlRef) tbar->GetHandle() ;
bfe9ffbc
SC
266 wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
267 ::EmbedControl( m_controlHandle , container ) ;
268}
269
2f1ae414 270
37e2cb08 271wxToolBarToolBase *wxToolBar::CreateTool(int id,
27e2d606
GD
272 const wxString& label,
273 const wxBitmap& bmpNormal,
274 const wxBitmap& bmpDisabled,
275 wxItemKind kind,
37e2cb08 276 wxObject *clientData,
27e2d606
GD
277 const wxString& shortHelp,
278 const wxString& longHelp)
37e2cb08 279{
27e2d606
GD
280 return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
281 clientData, shortHelp, longHelp);
37e2cb08
SC
282}
283
284wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
285{
286 return new wxToolBarTool(this, control);
287}
288
37e2cb08 289void wxToolBar::Init()
e9576ca5 290{
e40298d5
JS
291 m_maxWidth = -1;
292 m_maxHeight = -1;
293 m_defaultWidth = kwxMacToolBarToolDefaultWidth;
294 m_defaultHeight = kwxMacToolBarToolDefaultHeight;
e9576ca5
SC
295}
296
297bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
298 long style, const wxString& name)
e40298d5 299{
facd6764
SC
300 if ( !wxToolBarBase::Create( parent , id , pos , size , style ) )
301 return FALSE ;
e40298d5
JS
302
303 return TRUE;
e9576ca5
SC
304}
305
306wxToolBar::~wxToolBar()
bfe9ffbc 307{
7810c95b
SC
308 // we must refresh the frame size when the toolbar is deleted but the frame
309 // is not - otherwise toolbar leaves a hole in the place it used to occupy
e9576ca5
SC
310}
311
37e2cb08 312bool wxToolBar::Realize()
e9576ca5 313{
eb22f2a6 314 if (m_tools.GetCount() == 0)
0b7a8cd3
GD
315 return FALSE;
316
bfe9ffbc
SC
317 int x = m_xMargin + kwxMacToolBarLeftMargin ;
318 int y = m_yMargin + kwxMacToolBarTopMargin ;
0b7a8cd3 319
7c551d95
SC
320 int tw, th;
321 GetSize(& tw, & th);
895f5af7
SC
322
323 int maxWidth = 0 ;
324 int maxHeight = 0 ;
325
bfe9ffbc
SC
326 int maxToolWidth = 0;
327 int maxToolHeight = 0;
328
329 // Find the maximum tool width and height
330 wxToolBarToolsList::Node *node = m_tools.GetFirst();
331 while ( node )
332 {
333 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
334 wxSize sz = tool->GetSize() ;
335
336 if ( sz.x > maxToolWidth )
337 maxToolWidth = sz.x ;
338 if (sz.y> maxToolHeight)
339 maxToolHeight = sz.y;
340
341 node = node->GetNext();
342 }
343
bfe9ffbc 344 node = m_tools.GetFirst();
0b7a8cd3 345 while (node)
7810c95b 346 {
eb22f2a6 347 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
bfe9ffbc 348 wxSize cursize = tool->GetSize() ;
0b7a8cd3 349
bfe9ffbc
SC
350 // for the moment we just do a single row/column alignement
351 if ( x + cursize.x > maxWidth )
352 maxWidth = x + cursize.x ;
353 if ( y + cursize.y > maxHeight )
354 maxHeight = y + cursize.y ;
0b7a8cd3 355
bfe9ffbc
SC
356 tool->SetPosition( wxPoint( x , y ) ) ;
357
358 if ( GetWindowStyleFlag() & wxTB_VERTICAL )
359 {
360 y += cursize.y ;
0b7a8cd3
GD
361 }
362 else
363 {
bfe9ffbc 364 x += cursize.x ;
0b7a8cd3 365 }
bfe9ffbc 366
eb22f2a6 367 node = node->GetNext();
7810c95b 368 }
0b7a8cd3
GD
369
370 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
7810c95b 371 {
0b7a8cd3
GD
372 if ( m_maxRows == 0 )
373 {
374 // if not set yet, only one row
375 SetRows(1);
376 }
377 maxWidth = tw ;
0b7a8cd3
GD
378 maxHeight += m_yMargin + kwxMacToolBarTopMargin;
379 m_maxHeight = maxHeight ;
7810c95b 380 }
0b7a8cd3
GD
381 else
382 {
bfe9ffbc 383 if ( GetToolsCount() > 0 && m_maxRows == 0 )
0b7a8cd3
GD
384 {
385 // if not set yet, have one column
bfe9ffbc 386 SetRows(GetToolsCount());
0b7a8cd3
GD
387 }
388 maxHeight = th ;
0b7a8cd3
GD
389 maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
390 m_maxWidth = maxWidth ;
391 }
392
facd6764 393 SetSize( maxWidth, maxHeight );
0b7a8cd3
GD
394
395 return TRUE;
e9576ca5
SC
396}
397
398void wxToolBar::SetToolBitmapSize(const wxSize& size)
399{
9aad97fd 400 m_defaultWidth = size.x+4; m_defaultHeight = size.y+4;
e9576ca5
SC
401}
402
e9576ca5
SC
403// The button size is bigger than the bitmap size
404wxSize wxToolBar::GetToolSize() const
405{
2f1ae414 406 return wxSize(m_defaultWidth + 4, m_defaultHeight + 4);
e9576ca5
SC
407}
408
4b26b60f 409void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
519cb848 410{
bfe9ffbc
SC
411 wxToolBarToolsList::Node *node;
412 for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
e044f600 413 {
bfe9ffbc
SC
414 wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
415 if ( tool->IsButton() )
e044f600 416 {
bfe9ffbc
SC
417 if( tool->GetControlHandle() == control )
418 {
419 if ( tool->CanBeToggled() )
420 {
facd6764 421 tool->Toggle( GetControl32BitValue( (ControlRef) control ) ) ;
bfe9ffbc
SC
422 }
423 OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
424 break ;
425 }
e044f600
RR
426 }
427 }
519cb848
SC
428}
429
37e2cb08 430void wxToolBar::SetRows(int nRows)
e9576ca5 431{
37e2cb08 432 if ( nRows == m_maxRows )
e9576ca5 433 {
37e2cb08
SC
434 // avoid resizing the frame uselessly
435 return;
e9576ca5 436 }
37e2cb08
SC
437
438 m_maxRows = nRows;
e9576ca5
SC
439}
440
c257d44d
SC
441void wxToolBar::MacSuperChangedPosition()
442{
c257d44d 443 wxWindow::MacSuperChangedPosition() ;
bfe9ffbc 444 Realize() ;
c257d44d
SC
445}
446
37e2cb08 447wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
e9576ca5 448{
bfe9ffbc
SC
449 wxToolBarToolsList::Node *node = m_tools.GetFirst();
450 while (node)
e044f600 451 {
bfe9ffbc
SC
452 wxToolBarTool *tool = (wxToolBarTool *)node->GetData() ;
453 wxRect2DInt r( tool->GetPosition() , tool->GetSize() ) ;
454 if ( r.Contains( wxPoint( x , y ) ) )
e044f600 455 {
bfe9ffbc 456 return tool;
e044f600 457 }
bfe9ffbc
SC
458
459 node = node->GetNext();
e044f600 460 }
37e2cb08
SC
461
462 return (wxToolBarToolBase *)NULL;
e9576ca5
SC
463}
464
2f1ae414
SC
465wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
466{
e044f600
RR
467 wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
468 if ( tool )
469 {
470 return tool->GetShortHelp() ;
471 }
427ff662 472 return wxEmptyString ;
2f1ae414
SC
473}
474
37e2cb08 475void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
e9576ca5 476{
e044f600
RR
477 if (!IsShown())
478 return ;
479
480 wxToolBarTool *tool = (wxToolBarTool *)t;
bfe9ffbc
SC
481 if ( tool->IsControl() )
482 {
483 tool->GetControl()->Enable( enable ) ;
484 }
485 else if ( tool->IsButton() )
486 {
487 if ( enable )
facd6764 488 UMAActivateControl( (ControlRef) tool->GetControlHandle() ) ;
bfe9ffbc 489 else
facd6764 490 UMADeactivateControl( (ControlRef) tool->GetControlHandle() ) ;
bfe9ffbc 491 }
e9576ca5
SC
492}
493
37e2cb08 494void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
e9576ca5 495{
e044f600
RR
496 if (!IsShown())
497 return ;
498
499 wxToolBarTool *tool = (wxToolBarTool *)t;
bfe9ffbc
SC
500 if ( tool->IsButton() )
501 {
facd6764 502 ::SetControl32BitValue( (ControlRef) tool->GetControlHandle() , toggle ) ;
bfe9ffbc 503 }
37e2cb08 504}
7c551d95 505
37e2cb08
SC
506bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
507 wxToolBarToolBase *tool)
508{
bfe9ffbc 509 // nothing special to do here - we relayout in Realize() later
37e2cb08 510 tool->Attach(this);
7c551d95 511
37e2cb08
SC
512 return TRUE;
513}
e9576ca5 514
5115c51a 515void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
37e2cb08 516{
5115c51a 517 wxFAIL_MSG( _T("not implemented") );
e9576ca5
SC
518}
519
bfe9ffbc 520bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
37e2cb08 521{
bfe9ffbc
SC
522 wxToolBarToolsList::Node *node;
523 for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
524 {
525 wxToolBarToolBase *tool2 = node->GetData();
526 if ( tool2 == tool )
527 {
528 // let node point to the next node in the list
529 node = node->GetNext();
530
531 break;
532 }
533 }
534
535 wxSize sz = ((wxToolBarTool*)tool)->GetSize() ;
536
537 tool->Detach();
538
539 // and finally reposition all the controls after this one
540
541 for ( /* node -> first after deleted */ ; node; node = node->GetNext() )
542 {
543 wxToolBarTool *tool2 = (wxToolBarTool*) node->GetData();
544 wxPoint pt = tool2->GetPosition() ;
545
546 if ( GetWindowStyleFlag() & wxTB_VERTICAL )
547 {
548 pt.y -= sz.y ;
549 }
550 else
551 {
552 pt.x -= sz.x ;
553 }
554 tool2->SetPosition( pt ) ;
555 }
556
5115c51a 557 return TRUE ;
37e2cb08 558}
2f1ae414
SC
559
560void wxToolBar::OnPaint(wxPaintEvent& event)
561{
e40298d5
JS
562 wxPaintDC dc(this) ;
563 wxMacPortSetter helper(&dc) ;
facd6764
SC
564 int w, h ;
565 GetSize( &w , &h ) ;
e40298d5 566
1fd1922a 567 Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
facd6764
SC
568 dc.YLOG2DEVMAC(h) , dc.XLOG2DEVMAC(w) } ;
569/*
570 if( toolbarrect.left < 0 )
571 toolbarrect.left = 0 ;
572 if ( toolbarrect.top < 0 )
573 toolbarrect.top = 0 ;
574*/
1fd1922a 575 UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
facd6764 576/*
1fd1922a 577 {
bfe9ffbc
SC
578 wxToolBarToolsList::Node *node;
579 for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
1fd1922a 580 {
bfe9ffbc
SC
581 wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
582 if ( tool->IsButton() )
1fd1922a 583 {
facd6764 584 UMADrawControl( (ControlRef) tool->GetControlHandle() ) ;
1fd1922a
RR
585 }
586 }
587 }
facd6764
SC
588*/
589 event.Skip() ;
2f1ae414 590}
895f5af7 591
2f1ae414
SC
592void wxToolBar::OnMouse( wxMouseEvent &event )
593{
1fd1922a
RR
594 if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
595 {
596
597 int x = event.m_x ;
598 int y = event.m_y ;
599
600 MacClientToRootWindow( &x , &y ) ;
601
facd6764 602 ControlRef control ;
1fd1922a
RR
603 Point localwhere ;
604 SInt16 controlpart ;
facd6764 605 WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
1fd1922a
RR
606
607 localwhere.h = x ;
608 localwhere.v = y ;
609
610 short modifiers = 0;
611
612 if ( !event.m_leftDown && !event.m_rightDown )
613 modifiers |= btnState ;
614
615 if ( event.m_shiftDown )
616 modifiers |= shiftKey ;
617
618 if ( event.m_controlDown )
619 modifiers |= controlKey ;
620
621 if ( event.m_altDown )
622 modifiers |= optionKey ;
623
624 if ( event.m_metaDown )
625 modifiers |= cmdKey ;
626
627 controlpart = ::FindControl( localwhere , window , &control ) ;
628 {
629 if ( control && ::IsControlActive( control ) )
630 {
631 {
4b26b60f 632 controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
1fd1922a 633 wxTheApp->s_lastMouseDown = 0 ;
4b26b60f 634 if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice
1fd1922a 635 {
facd6764 636 MacHandleControlClick((WXWidget) control , controlpart , false /* not down anymore */ ) ;
1fd1922a
RR
637 }
638 }
639 }
640 }
641 }
2f1ae414
SC
642}
643
519cb848
SC
644#endif // wxUSE_TOOLBAR
645