]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/control.cpp
63610676a06912f12de959f129bd651bd5ebeceb
[wxWidgets.git] / src / mac / carbon / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.cpp
3 // Purpose: wxControl class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "control.h"
14 #endif
15
16 #include "wx/control.h"
17 #include "wx/panel.h"
18 #include "wx/app.h"
19 #include "wx/dc.h"
20 #include "wx/notebook.h"
21 #include "wx/tabctrl.h"
22 #include "wx/radiobox.h"
23 #include "wx/spinbutt.h"
24 #include "wx/scrolbar.h"
25 #include "wx/button.h"
26 #include "wx/dialog.h"
27 #include "wx/statbox.h"
28 #include "wx/sizer.h"
29 #include "wx/stattext.h"
30
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
33
34 BEGIN_EVENT_TABLE(wxControl, wxWindow)
35 EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
36 EVT_CHAR( wxControl::OnKeyDown )
37 EVT_PAINT( wxControl::OnPaint )
38 END_EVENT_TABLE()
39 #endif
40
41 #include <wx/mac/uma.h>
42
43 // Item members
44
45 ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
46
47 pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
48 pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
49 {
50 if ( partCode != 0)
51 {
52 wxControl* wx = (wxControl*) GetControlReference( control ) ;
53 if ( wx )
54 {
55 wx->MacHandleControlClick( control , partCode ) ;
56 }
57 }
58 }
59
60 wxControl::wxControl()
61 {
62 m_macControl = NULL ;
63 m_macHorizontalBorder = 0 ; // additional pixels around the real control
64 m_macVerticalBorder = 0 ;
65 m_backgroundColour = *wxWHITE;
66 m_foregroundColour = *wxBLACK;
67 #if WXWIN_COMPATIBILITY
68 m_callback = 0;
69 #endif // WXWIN_COMPATIBILITY
70
71 if ( wxMacLiveScrollbarActionUPP == NULL )
72 {
73 #ifdef __UNIX__
74 wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
75 #else
76 wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
77 #endif
78 }
79 }
80
81 bool wxControl::Create(wxWindow *parent, wxWindowID id,
82 const wxPoint& pos,
83 const wxSize& size, long style,
84 const wxValidator& validator,
85 const wxString& name)
86 {
87 m_macControl = NULL ;
88 m_macHorizontalBorder = 0 ; // additional pixels around the real control
89 m_macVerticalBorder = 0 ;
90 bool rval = wxWindow::Create(parent, id, pos, size, style, name);
91 if (rval) {
92 #if wxUSE_VALIDATORS
93 SetValidator(validator);
94 #endif
95 }
96 return rval;
97 }
98
99 wxControl::~wxControl()
100 {
101 m_isBeingDeleted = TRUE;
102 // If we delete an item, we should initialize the parent panel,
103 // because it could now be invalid.
104 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
105 if ( panel )
106 {
107 if (panel->GetDefaultItem() == (wxButton*) this)
108 panel->SetDefaultItem(NULL);
109 }
110 if ( m_macControl )
111 {
112 UMADisposeControl( m_macControl ) ;
113 m_macControl = NULL ;
114 }
115 }
116
117 void wxControl::SetLabel(const wxString& title)
118 {
119 m_label = title ;
120
121 if ( m_macControl )
122 {
123 Str255 maclabel ;
124 wxString label ;
125
126 if( wxApp::s_macDefaultEncodingIsPC )
127 label = wxMacMakeMacStringFromPC( title ) ;
128 else
129 label = title ;
130
131 #if TARGET_CARBON
132 c2pstrcpy( (StringPtr) maclabel , label ) ;
133 #else
134 strcpy( (char *) maclabel , label ) ;
135 c2pstr( (char *) maclabel ) ;
136 #endif
137 ::SetControlTitle( m_macControl , maclabel ) ;
138 }
139 }
140
141 wxSize wxControl::DoGetBestSize() const
142 {
143 return wxSize(20, 20);
144 }
145
146 bool wxControl::ProcessCommand (wxCommandEvent & event)
147 {
148 // Tries:
149 // 1) A callback function (to become obsolete)
150 // 2) OnCommand, starting at this window and working up parent hierarchy
151 // 3) OnCommand then calls ProcessEvent to search the event tables.
152 #if WXWIN_COMPATIBILITY
153 if ( m_callback )
154 {
155 (void)(*m_callback)(this, event);
156
157 return TRUE;
158 }
159 else
160 #endif // WXWIN_COMPATIBILITY
161 {
162 return GetEventHandler()->ProcessEvent(event);
163 }
164 }
165
166 // ------------------------
167 wxList *wxWinMacControlList = NULL;
168 wxControl *wxFindControlFromMacControl(ControlHandle inControl )
169 {
170 wxNode *node = wxWinMacControlList->Find((long)inControl);
171 if (!node)
172 return NULL;
173 return (wxControl *)node->Data();
174 }
175
176 void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control)
177 {
178 // adding NULL WindowRef is (first) surely a result of an error and
179 // (secondly) breaks menu command processing
180 wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" );
181
182 if ( !wxWinMacControlList->Find((long)inControl) )
183 wxWinMacControlList->Append((long)inControl, control);
184 }
185
186 void wxRemoveMacControlAssociation(wxControl *control)
187 {
188 wxWinMacControlList->DeleteObject(control);
189 }
190
191 void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
192 const wxPoint& pos,
193 const wxSize& size, long style,
194 const wxValidator& validator,
195 const wxString& name , Rect *outBounds , StringPtr maclabel )
196 {
197 m_label = label ;
198 SetName(name);
199 if ( &validator )
200 SetValidator(validator);
201
202 m_windowStyle = style;
203 parent->AddChild((wxButton *)this);
204
205 m_backgroundColour = parent->GetBackgroundColour() ;
206 m_foregroundColour = parent->GetForegroundColour() ;
207
208 if (id == -1)
209 m_windowId = NewControlId();
210 else
211 m_windowId = id;
212
213 m_width = size.x ;
214 m_height = size.y ;
215 int x = pos.x ;
216 int y = pos.y ;
217 AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
218 m_x = x ;
219 m_y = y ;
220
221
222 parent->MacClientToRootWindow( &x , &y ) ;
223 outBounds->top = y + m_macVerticalBorder ;
224 outBounds->left = x + m_macHorizontalBorder ;
225 outBounds->bottom = outBounds->top + m_height - 2 * m_macVerticalBorder;
226 outBounds->right = outBounds->left + m_width - 2 * m_macHorizontalBorder ;
227
228 char c_text[255];
229 strcpy( c_text , label ) ;
230 if( wxApp::s_macDefaultEncodingIsPC )
231 {
232 wxMacConvertFromPCForControls( c_text ) ;
233 }
234
235 #if TARGET_CARBON
236 c2pstrcpy( (StringPtr) maclabel , c_text ) ;
237 #else
238 strcpy( (char *) maclabel , c_text ) ;
239 c2pstr( (char *) maclabel ) ;
240 #endif
241 }
242
243 void wxControl::MacPostControlCreate()
244 {
245 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
246
247 if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
248 {
249 // no font
250 }
251 else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
252 {
253 ControlFontStyleRec controlstyle ;
254 controlstyle.flags = kControlUseFontMask ;
255 controlstyle.font = kControlFontSmallBoldSystemFont ;
256
257 ::UMASetControlFontStyle( m_macControl , &controlstyle ) ;
258 }
259 else
260 {
261 ControlFontStyleRec controlstyle ;
262 controlstyle.flags = kControlUseFontMask ;
263 controlstyle.font = kControlFontSmallSystemFont ;
264
265 ::UMASetControlFontStyle( m_macControl , &controlstyle ) ;
266 }
267 ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
268 wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
269 ::UMAEmbedControl( m_macControl , container ) ;
270 m_macControlIsShown = true ;
271 MacAdjustControlRect() ;
272 wxAssociateControlWithMacControl( m_macControl , this ) ;
273 }
274
275 void wxControl::MacAdjustControlRect()
276 {
277 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
278 if ( m_width == -1 || m_height == -1 )
279 {
280 Rect bestsize = { 0 , 0 , 0 , 0 } ;
281 short baselineoffset ;
282
283 UMAGetBestControlRect( m_macControl , &bestsize , &baselineoffset ) ;
284
285 if ( EmptyRect( &bestsize ) )
286 {
287 baselineoffset = 0;
288 bestsize.left = bestsize.top = 0 ;
289 bestsize.right = 16 ;
290 bestsize.bottom = 16 ;
291 if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
292 {
293 bestsize.bottom = 16 ;
294 }
295 else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
296 {
297 bestsize.bottom = 24 ;
298 }
299 }
300
301 if ( m_width == -1 )
302 {
303 if ( IsKindOf( CLASSINFO( wxButton ) ) )
304 {
305 m_width = m_label.Length() * 8 + 12 ;
306 }
307 else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
308 {
309 m_width = m_label.Length() * 8 ;
310 }
311 else
312 m_width = bestsize.right - bestsize.left ;
313
314 m_width += 2 * m_macHorizontalBorder ;
315 }
316 if ( m_height == -1 )
317 {
318 m_height = bestsize.bottom - bestsize.top ;
319 if ( m_height < 10 )
320 m_height = 13 ;
321
322 m_height += 2 * m_macVerticalBorder;
323 }
324
325 wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
326 if ( helper.Ok() )
327 {
328 UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
329 }
330 }
331 }
332 ControlHandle wxControl::MacGetContainerForEmbedding()
333 {
334 if ( m_macControl )
335 return m_macControl ;
336
337 return wxWindow::MacGetContainerForEmbedding() ;
338 }
339
340 void wxControl::MacSuperChangedPosition()
341 {
342 if ( m_macControl )
343 {
344 Rect contrlRect ;
345 GetControlBounds( m_macControl , &contrlRect ) ;
346 int former_mac_x = contrlRect.left ;
347 int former_mac_y = contrlRect.top ;
348 int mac_x = m_x ;
349 int mac_y = m_y ;
350 GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
351
352 WindowRef rootwindow = GetMacRootWindow() ;
353 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
354 UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
355 wxMacDrawingHelper focus( wxrootwindow ) ;
356
357 if ( mac_x != former_mac_x || mac_y != former_mac_y )
358 {
359 {
360 Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
361 InvalWindowRect( rootwindow , &inval ) ;
362 }
363 UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
364 {
365 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
366 InvalWindowRect( rootwindow , &inval ) ;
367 }
368 }
369 if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
370 {
371 }
372 else
373 {
374 UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
375 }
376 }
377
378 wxWindow::MacSuperChangedPosition() ;
379 }
380
381 void wxControl::MacSuperEnabled( bool enabled )
382 {
383 /*
384 if ( m_macControl )
385 {
386 if ( UMAHasAppearance() )
387 {
388 if ( !enabled )
389 {
390 ::DeactivateControl( m_macControl ) ;
391 }
392 else
393 {
394 if ( m_macEnabled )
395 ::ActivateControl( m_macControl ) ;
396 }
397 }
398 else
399 {
400 if ( !enabled )
401 {
402 ::HiliteControl( m_macControl , 255 ) ;
403 }
404 else
405 {
406 if ( m_macEnabled )
407 ::HiliteControl( m_macControl , 0 ) ;
408 }
409 }
410 }
411 wxWindow::MacSuperEnabled( enabled ) ;
412 */
413 }
414
415 void wxControl::MacSuperShown( bool show )
416 {
417 if ( m_macControl )
418 {
419 if ( !show )
420 {
421 if ( m_macControlIsShown )
422 {
423 ::UMAHideControl( m_macControl ) ;
424 m_macControlIsShown = false ;
425 }
426 }
427 else
428 {
429 if ( MacIsReallyShown() && !m_macControlIsShown )
430 {
431 ::UMAShowControl( m_macControl ) ;
432 m_macControlIsShown = true ;
433 }
434 }
435 }
436
437 wxWindow::MacSuperShown( show ) ;
438 }
439
440 void wxControl::DoSetSize(int x, int y,
441 int width, int height,
442 int sizeFlags )
443 {
444 if ( m_macControl == NULL )
445 {
446 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
447 return ;
448 }
449
450 WindowRef rootwindow = GetMacRootWindow() ;
451 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
452 UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
453
454 int former_x = m_x ;
455 int former_y = m_y ;
456 int former_w = m_width ;
457 int former_h = m_height ;
458
459 Rect contrlRect ;
460 GetControlBounds( m_macControl , &contrlRect ) ;
461 int former_mac_x = contrlRect.left ;
462 int former_mac_y = contrlRect.top ;
463
464 int currentX, currentY;
465 GetPosition(&currentX, &currentY);
466 int currentW,currentH;
467 GetSize(&currentW, &currentH);
468
469 int actualWidth = width;
470 int actualHeight = height;
471 int actualX = x;
472 int actualY = y;
473 if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
474 actualX = currentX;
475 if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
476 actualY = currentY;
477 if (width == -1)
478 actualWidth = currentW ;
479 if (height == -1)
480 actualHeight = currentH ;
481
482 if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH)
483 return ;
484
485 AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
486 WindowRef macrootwindow = GetMacRootWindow() ;
487 wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
488
489 int mac_x = actualX ;
490 int mac_y = actualY ;
491 GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
492
493 if ( mac_x != former_mac_x || mac_y != former_mac_y )
494 {
495 {
496 Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
497 InvalWindowRect( macrootwindow, &inval ) ;
498 }
499 UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
500 {
501 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
502 InvalWindowRect(macrootwindow, &inval ) ;
503 }
504 }
505
506 if ( actualX != former_x || actualY != former_y )
507 {
508 m_x = actualX ;
509 m_y = actualY ;
510
511 MacRepositionScrollBars() ;
512 // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..)
513 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
514 event.SetEventObject(this);
515 GetEventHandler()->ProcessEvent(event);
516 }
517 if ( actualWidth != former_w || actualHeight != former_h )
518 {
519 {
520 Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ;
521 InvalWindowRect( macrootwindow, &inval ) ;
522 }
523 m_width = actualWidth ;
524 m_height = actualHeight ;
525
526 UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
527 {
528 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
529 InvalWindowRect( macrootwindow , &inval ) ;
530 }
531
532 MacRepositionScrollBars() ;
533 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
534 event.SetEventObject(this);
535 GetEventHandler()->ProcessEvent(event);
536 }
537 if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
538 {
539 }
540 else
541 {
542 UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
543 }
544 }
545
546 bool wxControl::Show(bool show)
547 {
548 if ( !wxWindow::Show( show ) )
549 return FALSE ;
550
551 if ( m_macControl )
552 {
553 if ( !show )
554 {
555 if ( m_macControlIsShown )
556 {
557 ::UMAHideControl( m_macControl ) ;
558 m_macControlIsShown = false ;
559 }
560 }
561 else
562 {
563 if ( MacIsReallyShown() && !m_macControlIsShown )
564 {
565 ::UMAShowControl( m_macControl ) ;
566 m_macControlIsShown = true ;
567 }
568 }
569 }
570 return TRUE ;
571 }
572
573 bool wxControl::Enable(bool enable)
574 {
575 if ( !wxWindow::Enable(enable) )
576 return FALSE;
577
578 if ( m_macControl )
579 {
580
581 if ( UMAHasAppearance() )
582 {
583 if ( enable )
584 ::ActivateControl( m_macControl ) ;
585 else
586 ::DeactivateControl( m_macControl ) ;
587 }
588 else
589 {
590 if ( enable )
591 ::HiliteControl( m_macControl , 0 ) ;
592 else
593 ::HiliteControl( m_macControl , 255 ) ;
594 }
595 }
596 return TRUE ;
597 }
598
599 void wxControl::Refresh(bool eraseBack, const wxRect *rect)
600 {
601 if ( m_macControl )
602 {
603 wxWindow::Refresh( eraseBack , rect ) ;
604 }
605 else
606 {
607 wxWindow::Refresh( eraseBack , rect ) ;
608 }
609 }
610
611 void wxControl::MacRedrawControl()
612 {
613 if ( m_macControl )
614 {
615 WindowRef window = GetMacRootWindow() ;
616 if ( window )
617 {
618 wxWindow* win = wxFindWinFromMacWindow( window ) ;
619 if ( win )
620 {
621 wxMacDrawingHelper help( win ) ;
622 // the mac control manager always assumes to have the origin at 0,0
623 SetOrigin( 0 , 0 ) ;
624
625 bool hasTabBehind = false ;
626 wxWindow* parent = GetParent() ;
627 while ( parent )
628 {
629 if( parent->MacGetWindowData() )
630 {
631 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
632 break ;
633 }
634
635 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
636 {
637 if ( ((wxControl*)parent)->m_macControl )
638 SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
639 break ;
640 }
641
642 parent = parent->GetParent() ;
643 }
644
645 UMADrawControl( m_macControl ) ;
646 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
647 wxDC::MacInvalidateSetup() ;
648 }
649 }
650 }
651 }
652
653 void wxControl::OnPaint(wxPaintEvent& event)
654 {
655 if ( m_macControl )
656 {
657 WindowRef window = GetMacRootWindow() ;
658 if ( window )
659 {
660 wxWindow* win = wxFindWinFromMacWindow( window ) ;
661 if ( win )
662 {
663 wxMacDrawingHelper help( win ) ;
664 // the mac control manager always assumes to have the origin at 0,0
665 SetOrigin( 0 , 0 ) ;
666
667 bool hasTabBehind = false ;
668 wxWindow* parent = GetParent() ;
669 while ( parent )
670 {
671 if( parent->MacGetWindowData() )
672 {
673 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
674 break ;
675 }
676
677 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
678 {
679 if ( ((wxControl*)parent)->m_macControl )
680 SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
681 break ;
682 }
683
684 parent = parent->GetParent() ;
685 }
686
687 UMADrawControl( m_macControl ) ;
688 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
689 wxDC::MacInvalidateSetup() ;
690 }
691 }
692 }
693 else
694 {
695 // wxWindow::OnPaint( event ) ;
696 }
697 }
698 void wxControl::OnEraseBackground(wxEraseEvent& event)
699 {
700 // In general, you don't want to erase the background of a control,
701 // or you'll get a flicker.
702 // TODO: move this 'null' function into each control that
703 // might flicker.
704 }
705
706
707 void wxControl::OnKeyDown( wxKeyEvent &event )
708 {
709 if ( m_macControl == NULL )
710 return ;
711
712 EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
713 short keycode ;
714 short keychar ;
715 keychar = short(ev->message & charCodeMask);
716 keycode = short(ev->message & keyCodeMask) >> 8 ;
717
718 UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
719 }
720
721 void wxControl::OnMouseEvent( wxMouseEvent &event )
722 {
723 if ( m_macControl == NULL )
724 {
725 event.Skip() ;
726 return ;
727 }
728
729 if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
730 {
731
732 int x = event.m_x ;
733 int y = event.m_y ;
734
735 MacClientToRootWindow( &x , &y ) ;
736
737 ControlHandle control ;
738 Point localwhere ;
739 GrafPtr port ;
740 SInt16 controlpart ;
741 WindowRef window = GetMacRootWindow() ;
742
743 localwhere.h = x ;
744 localwhere.v = y ;
745
746 short modifiers = 0;
747
748 if ( !event.m_leftDown && !event.m_rightDown )
749 modifiers |= btnState ;
750
751 if ( event.m_shiftDown )
752 modifiers |= shiftKey ;
753
754 if ( event.m_controlDown )
755 modifiers |= controlKey ;
756
757 if ( event.m_altDown )
758 modifiers |= optionKey ;
759
760 if ( event.m_metaDown )
761 modifiers |= cmdKey ;
762
763 controlpart = FindControl( localwhere , window , &control ) ;
764 {
765 /*
766 if ( AcceptsFocus() && FindFocus() != this )
767 {
768 SetFocus() ;
769 }
770 */
771 if ( control && UMAIsControlActive( control ) )
772 {
773 {
774 if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
775 controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
776 else
777 controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
778 wxTheApp->s_lastMouseDown = 0 ;
779 if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
780 && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
781 {
782 MacHandleControlClick( control , controlpart ) ;
783 }
784 }
785 }
786 }
787 }
788 }
789
790 bool wxControl::MacCanFocus() const
791 {
792 { if ( m_macControl == NULL )
793 return true ;
794 else
795 return false ;
796 }
797 }
798
799 void wxControl::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
800 {
801 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
802 }
803