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