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