]> git.saurik.com Git - wxWidgets.git/blame - src/mac/toolbar.cpp
don't include windows.h unless neccessary
[wxWidgets.git] / src / mac / toolbar.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: toolbar.cpp
3// Purpose: wxToolBar
4// Author: AUTHOR
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
2f1ae414 8// Copyright: (c) AUTHORy
e9576ca5
SC
9/////////////////////////////////////////////////////////////////////////////
10
11#ifdef __GNUG__
12#pragma implementation "toolbar.h"
13#endif
14
15#include "wx/wx.h"
519cb848
SC
16
17#if wxUSE_TOOLBAR
18
e9576ca5 19#include "wx/toolbar.h"
2f1ae414
SC
20#include "wx/notebook.h"
21#include "wx/tabctrl.h"
72055702 22#include "wx/bitmap.h"
e9576ca5 23
2f1ae414 24#if !USE_SHARED_LIBRARY
12ed316d 25IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
e9576ca5
SC
26
27BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
2f1ae414
SC
28 EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
29 EVT_PAINT( wxToolBar::OnPaint )
e9576ca5 30END_EVENT_TABLE()
2f1ae414 31#endif
e9576ca5 32
d497dca4 33#include "wx/mac/uma.h"
519cb848 34
37e2cb08
SC
35// ----------------------------------------------------------------------------
36// private classes
37// ----------------------------------------------------------------------------
38
39class wxToolBarTool : public wxToolBarToolBase
40{
41public:
42 wxToolBarTool(wxToolBar *tbar,
43 int id,
44 const wxBitmap& bitmap1,
45 const wxBitmap& bitmap2,
46 bool toggle,
47 wxObject *clientData,
48 const wxString& shortHelpString,
49 const wxString& longHelpString)
50 : wxToolBarToolBase(tbar, id, bitmap1, bitmap2, toggle,
51 clientData, shortHelpString, longHelpString)
52 {
53 m_nSepCount = 0;
2f1ae414 54 m_index = -1 ;
37e2cb08
SC
55 }
56
57 wxToolBarTool(wxToolBar *tbar, wxControl *control)
58 : wxToolBarToolBase(tbar, control)
59 {
60 m_nSepCount = 1;
2f1ae414 61 m_index = -1 ;
37e2cb08
SC
62 }
63
64 // set/get the number of separators which we use to cover the space used by
65 // a control in the toolbar
66 void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
67 size_t GetSeparatorsCount() const { return m_nSepCount; }
68
69 int m_index ;
70private:
71 size_t m_nSepCount;
72};
73
74
75// ============================================================================
76// implementation
77// ============================================================================
78
79// ----------------------------------------------------------------------------
80// wxToolBarTool
81// ----------------------------------------------------------------------------
82
895f5af7
SC
83const short kwxMacToolBarToolDefaultWidth = 24 ;
84const short kwxMacToolBarToolDefaultHeight = 22 ;
85const short kwxMacToolBarTopMargin = 2 ;
86const short kwxMacToolBarLeftMargin = 2 ;
87
2f1ae414 88
37e2cb08
SC
89wxToolBarToolBase *wxToolBar::CreateTool(int id,
90 const wxBitmap& bitmap1,
91 const wxBitmap& bitmap2,
92 bool toggle,
93 wxObject *clientData,
94 const wxString& shortHelpString,
95 const wxString& longHelpString)
96{
97 return new wxToolBarTool(this, id, bitmap1, bitmap2, toggle,
98 clientData, shortHelpString, longHelpString);
99}
100
101wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
102{
103 return new wxToolBarTool(this, control);
104}
105
37e2cb08 106void wxToolBar::Init()
e9576ca5
SC
107{
108 m_maxWidth = -1;
109 m_maxHeight = -1;
895f5af7
SC
110 m_defaultWidth = kwxMacToolBarToolDefaultWidth;
111 m_defaultHeight = kwxMacToolBarToolDefaultHeight;
e9576ca5
SC
112}
113
114bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
115 long style, const wxString& name)
116{
e9576ca5 117
519cb848
SC
118 int x = pos.x;
119 int y = pos.y;
120 int width = size.x;
121 int height = size.y;
e9576ca5 122
519cb848
SC
123 if (width <= 0)
124 width = 100;
125 if (height <= 0)
126 height = 30;
127 if (x < 0)
128 x = 0;
129 if (y < 0)
130 y = 0;
e9576ca5 131
895f5af7
SC
132 SetName(name);
133
134 m_windowStyle = style;
135 parent->AddChild(this);
136
137 m_backgroundColour = parent->GetBackgroundColour() ;
138 m_foregroundColour = parent->GetForegroundColour() ;
139
140 if (id == -1)
141 m_windowId = NewControlId();
142 else
143 m_windowId = id;
144
145 {
146 m_width = size.x ;
147 m_height = size.y ;
148 int x = pos.x ;
149 int y = pos.y ;
150 AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
151 m_x = x ;
152 m_y = y ;
153 }
a90c95aa
RR
154
155 return TRUE;
e9576ca5
SC
156}
157
158wxToolBar::~wxToolBar()
159{
7810c95b
SC
160 // we must refresh the frame size when the toolbar is deleted but the frame
161 // is not - otherwise toolbar leaves a hole in the place it used to occupy
e9576ca5
SC
162}
163
37e2cb08 164bool wxToolBar::Realize()
e9576ca5 165{
0b7a8cd3
GD
166 if (m_tools.Number() == 0)
167 return FALSE;
168
169 Point localOrigin ;
170 Rect clipRect ;
171 WindowRef window ;
172 wxWindow *win ;
173
174 GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
175
176 Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
177 m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
178 ControlFontStyleRec controlstyle ;
179
180 controlstyle.flags = kControlUseFontMask ;
181 controlstyle.font = kControlFontSmallSystemFont ;
182
183 wxNode *node = m_tools.First();
184 int noButtons = 0;
185 int x = 0 ;
186 int y = 0 ;
187 wxSize toolSize = GetToolSize() ;
7c551d95
SC
188 int tw, th;
189 GetSize(& tw, & th);
895f5af7
SC
190
191 int maxWidth = 0 ;
192 int maxHeight = 0 ;
193
0b7a8cd3 194 while (node)
7810c95b 195 {
0b7a8cd3
GD
196 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
197 wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
198
199 if( !tool->IsSeparator() )
200 {
201 Rect toolrect = { toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin,
202 toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
203 toolrect.right = toolrect.left + toolSize.x ;
204 toolrect.bottom = toolrect.top + toolSize.y ;
205
206 ControlButtonContentInfo info ;
207 if ( bmap )
208 {
209 if ( bmap->m_bitmapType == kMacBitmapTypePict )
210 {
211 info.contentType = kControlContentPictHandle ;
212 info.u.picture = bmap->m_hPict ;
213 }
214 else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
215 {
216 if ( tool->GetBitmap1().GetMask() )
217 {
218 info.contentType = kControlContentCIconHandle ;
219 info.u.cIconHandle = wxMacCreateCIcon( bmap->m_hBitmap , tool->GetBitmap1().GetMask()->GetMaskBitmap() ,
220 8 , 16 ) ;
221 }
222 else
223 {
224 info.contentType = kControlContentCIconHandle ;
225 info.u.cIconHandle = wxMacCreateCIcon( bmap->m_hBitmap , NULL ,
226 8 , 16 ) ;
227 }
228 }
229 }
230
231 ControlHandle m_macToolHandle ;
232
233 SInt16 behaviour = kControlBehaviorOffsetContents ;
234 if ( tool->CanBeToggled() )
235 behaviour += kControlBehaviorToggles ;
236
237 if ( info.u.cIconHandle ) // since it is a handle we can use one of them
238 {
239 m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
240 behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
241
242 ::SetControlData( m_macToolHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
243 }
244 else
245 {
246 m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
247 behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
248 }
249 UMAShowControl( m_macToolHandle ) ;
250 m_macToolHandles.Add( m_macToolHandle ) ;
251 tool->m_index = m_macToolHandles.Count() -1 ;
252 if ( !tool->IsEnabled() )
253 {
254 UMADeactivateControl( m_macToolHandle ) ;
255 }
256 if ( tool->CanBeToggled() && tool->IsToggled() )
257 {
258 ::SetControlValue( m_macToolHandle , 1 ) ;
259 }
260 else
261 {
262 ::SetControlValue( m_macToolHandle , 0 ) ;
263 }
264 /*
265 ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ;
266 */
267 ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
268 wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
269 ::EmbedControl( m_macToolHandle , container ) ;
270
271 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
272 {
273 x += (int)toolSize.x;
274 }
275 else
276 {
277 y += (int)toolSize.y;
278 }
279 noButtons ++;
280 }
281 else
282 {
283 m_macToolHandles.Add( NULL ) ;
284 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
285 {
286 x += (int)toolSize.x / 4;
287 }
288 else
289 {
290 y += (int)toolSize.y / 4;
291 }
292 }
293 if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h > maxWidth) {
294 maxWidth = toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h;
295 }
296 if (toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) {
297 maxHeight = toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v ;
298 }
299 node = node->Next();
7810c95b 300 }
0b7a8cd3
GD
301
302 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
7810c95b 303 {
0b7a8cd3
GD
304 if ( m_maxRows == 0 )
305 {
306 // if not set yet, only one row
307 SetRows(1);
308 }
309 maxWidth = tw ;
310 maxHeight += toolSize.y;
311 maxHeight += m_yMargin + kwxMacToolBarTopMargin;
312 m_maxHeight = maxHeight ;
7810c95b 313 }
0b7a8cd3
GD
314 else
315 {
316 if ( noButtons > 0 && m_maxRows == 0 )
317 {
318 // if not set yet, have one column
319 SetRows(noButtons);
320 }
321 maxHeight = th ;
322 maxWidth += toolSize.x;
323 maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
324 m_maxWidth = maxWidth ;
325 }
326
327 SetSize(maxWidth, maxHeight);
328
329 return TRUE;
e9576ca5
SC
330}
331
332void wxToolBar::SetToolBitmapSize(const wxSize& size)
333{
9aad97fd 334 m_defaultWidth = size.x+4; m_defaultHeight = size.y+4;
e9576ca5
SC
335}
336
e9576ca5
SC
337// The button size is bigger than the bitmap size
338wxSize wxToolBar::GetToolSize() const
339{
2f1ae414 340 return wxSize(m_defaultWidth + 4, m_defaultHeight + 4);
e9576ca5
SC
341}
342
519cb848
SC
343void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
344{
345 int index = 0 ;
346 for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
347 {
348 if ( m_macToolHandles[index] == (void*) control )
349 {
2f1ae414
SC
350 wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data();
351 if ( tool->CanBeToggled() )
352 {
353 tool->Toggle( GetControlValue( control ) ) ;
354 }
355 OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
356 break ;
519cb848
SC
357 }
358 }
359}
360
37e2cb08 361void wxToolBar::SetRows(int nRows)
e9576ca5 362{
37e2cb08 363 if ( nRows == m_maxRows )
e9576ca5 364 {
37e2cb08
SC
365 // avoid resizing the frame uselessly
366 return;
e9576ca5 367 }
37e2cb08
SC
368
369 m_maxRows = nRows;
e9576ca5
SC
370}
371
c257d44d
SC
372void wxToolBar::MacSuperChangedPosition()
373{
374 if (m_tools.Number() > 0)
375 {
376
377 Point localOrigin ;
378 Rect clipRect ;
379 WindowRef window ;
380 wxWindow *win ;
381
382 GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
383
384 Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
385 m_y + m_height + localOrigin.v , m_x + m_width + localOrigin.h} ;
386 ControlFontStyleRec controlstyle ;
387
388 controlstyle.flags = kControlUseFontMask ;
389 controlstyle.font = kControlFontSmallSystemFont ;
390
391 wxNode *node = m_tools.First();
392 int noButtons = 0;
393 int x = 0 ;
394 wxSize toolSize = GetToolSize() ;
395 int tw, th;
396 GetSize(& tw, & th);
397
398 int maxWidth = 0 ;
399 int maxHeight = 0 ;
400 int toolcount = 0 ;
401 {
402 WindowRef rootwindow = GetMacRootWindow() ;
403 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
72055702 404 ::SetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
c257d44d
SC
405 wxMacDrawingHelper focus( wxrootwindow ) ;
406 while (node)
407 {
408 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
409 wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
410
411 if( !tool->IsSeparator() )
412 {
413 Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
414 toolrect.right = toolrect.left + toolSize.x ;
415 toolrect.bottom = toolrect.top + toolSize.y ;
416
417 ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ;
418
419 {
420 Rect contrlRect ;
421 GetControlBounds( m_macToolHandle , &contrlRect ) ;
422 int former_mac_x = contrlRect.left ;
423 int former_mac_y = contrlRect.top ;
424 int mac_x = toolrect.left ;
425 int mac_y = toolrect.top ;
426
427 if ( mac_x != former_mac_x || mac_y != former_mac_y )
428 {
429 {
430 Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ;
431 InvalWindowRect( rootwindow , &inval ) ;
432 }
433 UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ;
434 {
435 Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ;
436 InvalWindowRect( rootwindow , &inval ) ;
437 }
438 }
439 }
440
441 x += (int)toolSize.x;
442 noButtons ++;
443 }
444 else
445 {
446 toolcount++ ;
447 x += (int)toolSize.x / 4;
448 }
449 if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth)
450 maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h;
451 if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight)
452 maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ;
453
454 node = node->Next();
455 }
456 if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
457 {
458 }
459 else
460 {
72055702 461 ::SetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
c257d44d
SC
462 }
463 }
464
465 if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
466 {
467 if ( m_maxRows == 0 )
468 {
469 // if not set yet, only one row
470 SetRows(1);
471 }
472 maxWidth = tw ;
473 maxHeight += toolSize.y;
474 maxHeight += m_yMargin + kwxMacToolBarTopMargin;
475 m_maxHeight = maxHeight ;
476 }
477 else
478 {
479 if ( noButtons > 0 && m_maxRows == 0 )
480 {
481 // if not set yet, have one column
482 SetRows(noButtons);
483 }
484 maxHeight = th ;
485 maxWidth += toolSize.x;
486 maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
487 m_maxWidth = maxWidth ;
488 }
489
490 SetSize(maxWidth, maxHeight);
491 }
492
493 wxWindow::MacSuperChangedPosition() ;
494}
495
37e2cb08 496wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
e9576ca5 497{
37e2cb08 498 MacClientToRootWindow( &x , &y ) ;
2f1ae414 499 Point pt = { y ,x } ;
37e2cb08
SC
500
501 int index = 0 ;
502 for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
503 {
2f1ae414 504 if ( m_macToolHandles[index] )
37e2cb08 505 {
2f1ae414
SC
506 Rect bounds ;
507 GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ;
508 if ( PtInRect( pt , &bounds ) )
509 {
510 return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ;
511 }
37e2cb08
SC
512 }
513 }
514
515 return (wxToolBarToolBase *)NULL;
e9576ca5
SC
516}
517
2f1ae414
SC
518wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
519{
520 wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
521 if ( tool )
522 {
523 return tool->GetShortHelp() ;
524 }
525 return "" ;
526}
527
37e2cb08 528void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
e9576ca5 529{
37e2cb08 530 wxToolBarTool *tool = (wxToolBarTool *)t;
2f1ae414
SC
531 if ( tool->m_index < 0 )
532 return ;
533
8208e181 534 ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
2f1ae414
SC
535
536 if ( enable )
537 UMAActivateControl( control ) ;
8208e181 538 else
2f1ae414 539 UMADeactivateControl( control ) ;
e9576ca5
SC
540}
541
37e2cb08 542void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
e9576ca5 543{
37e2cb08 544 wxToolBarTool *tool = (wxToolBarTool *)t;
2f1ae414
SC
545 if ( tool->m_index < 0 )
546 return ;
8208e181
SC
547
548 ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
549 ::SetControlValue( control , toggle ) ;
37e2cb08 550}
7c551d95 551
37e2cb08
SC
552bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
553 wxToolBarToolBase *tool)
554{
555 // nothing special to do here - we really create the toolbar buttons in
556 // Realize() later
557 tool->Attach(this);
7c551d95 558
37e2cb08
SC
559 return TRUE;
560}
e9576ca5 561
37e2cb08
SC
562void wxToolBar::DoSetToggle(wxToolBarToolBase *t, bool toggle)
563{
564 wxToolBarTool *tool = (wxToolBarTool *)t;
565 // TODO: set toggle state
e9576ca5
SC
566}
567
37e2cb08
SC
568bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
569{
570 return TRUE ;
571}
2f1ae414
SC
572
573void wxToolBar::OnPaint(wxPaintEvent& event)
574{
80645074
SC
575 Point localOrigin ;
576 Rect clipRect ;
577 WindowRef window ;
578 wxWindow *win ;
579
7810c95b 580 GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
80645074
SC
581 if ( window && win )
582 {
583 wxMacDrawingHelper help( win ) ;
584 // the mac control manager always assumes to have the origin at 0,0
585 SetOrigin( 0 , 0 ) ;
586
587 bool hasTabBehind = false ;
588 wxWindow* parent = GetParent() ;
589 while ( parent )
590 {
591 if( parent->MacGetWindowData() )
592 {
72055702 593 ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
80645074
SC
594 break ;
595 }
596
597 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
598 {
599 if ( ((wxControl*)parent)->GetMacControl() )
600 SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
601 break ;
602 }
603
604 parent = parent->GetParent() ;
605 }
895f5af7 606
80645074 607 Rect toolbarrect = { m_y + localOrigin.v , m_x + localOrigin.h ,
895f5af7 608 m_y + localOrigin.v + m_height , m_x + localOrigin.h + m_width } ;
80645074
SC
609
610 UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
611 {
612 int index = 0 ;
613 for ( index = 0 ; index < m_macToolHandles.Count() ; ++index )
614 {
615 if ( m_macToolHandles[index] )
616 {
617 UMADrawControl( (ControlHandle) m_macToolHandles[index] ) ;
618 }
619 }
620 }
72055702 621 ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
80645074 622 }
2f1ae414 623}
895f5af7 624
2f1ae414
SC
625void wxToolBar::OnMouse( wxMouseEvent &event )
626{
627
628 if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
629 {
630
631 int x = event.m_x ;
632 int y = event.m_y ;
633
634 MacClientToRootWindow( &x , &y ) ;
635
636 ControlHandle control ;
637 Point localwhere ;
638 GrafPtr port ;
639 SInt16 controlpart ;
640 WindowRef window = GetMacRootWindow() ;
641
642 localwhere.h = x ;
643 localwhere.v = y ;
644
645 short modifiers = 0;
646
647 if ( !event.m_leftDown && !event.m_rightDown )
648 modifiers |= btnState ;
649
650 if ( event.m_shiftDown )
651 modifiers |= shiftKey ;
652
653 if ( event.m_controlDown )
654 modifiers |= controlKey ;
655
656 if ( event.m_altDown )
657 modifiers |= optionKey ;
658
659 if ( event.m_metaDown )
660 modifiers |= cmdKey ;
661
662 controlpart = FindControl( localwhere , window , &control ) ;
663 {
72055702 664 if ( control && ::IsControlActive( control ) )
2f1ae414
SC
665 {
666 {
667 if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
72055702 668 controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
2f1ae414 669 else
72055702 670 controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
2f1ae414
SC
671 wxTheApp->s_lastMouseDown = 0 ;
672 if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
673 && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
674 {
675 MacHandleControlClick( control , controlpart ) ;
676 }
677 }
678 }
679 }
680 }
681}
682
519cb848
SC
683#endif // wxUSE_TOOLBAR
684