1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
18 #include "wx/control.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"
32 #include "wx/stattext.h"
34 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
37 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
38 EVT_MOUSE_EVENTS( wxControl::OnMouseEvent
)
39 // EVT_CHAR( wxControl::OnKeyDown )
40 EVT_PAINT( wxControl::OnPaint
)
44 #include "wx/mac/uma.h"
45 #include "wx/mac/private.h"
50 #if PRAGMA_STRUCT_ALIGN
51 #pragma options align=mac68k
52 #elif PRAGMA_STRUCT_PACKPUSH
54 #elif PRAGMA_STRUCT_PACK
59 unsigned short instruction
;
61 } cdefRec
, *cdefPtr
, **cdefHandle
;
63 #if PRAGMA_STRUCT_ALIGN
64 #pragma options align=reset
65 #elif PRAGMA_STRUCT_PACKPUSH
67 #elif PRAGMA_STRUCT_PACK
71 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
72 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
) ;
74 pascal void wxMacLiveScrollbarActionProc( ControlHandle control
, ControlPartCode partCode
) ;
75 pascal void wxMacLiveScrollbarActionProc( ControlHandle control
, ControlPartCode partCode
)
79 wxControl
* wx
= (wxControl
*) GetControlReference( control
) ;
82 wx
->MacHandleControlClick( control
, partCode
) ;
87 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
88 ControlDefUPP wxMacControlActionUPP
= NULL
;
90 pascal SInt32
wxMacControlDefinition(SInt16 varCode
, ControlRef theControl
, ControlDefProcMessage message
, SInt32 param
)
93 wxControl
* wx
= (wxControl
*) wxFindControlFromMacControl( theControl
) ;
94 if ( wx
!= NULL
&& wx
->IsKindOf( CLASSINFO( wxControl
) ) )
96 if( message
== drawCntl
)
98 wxMacWindowClipper
clip( wx
) ;
99 return InvokeControlDefUPP( varCode
, theControl
, message
, param
, (ControlDefUPP
) wx
->MacGetControlAction() ) ;
102 return InvokeControlDefUPP( varCode
, theControl
, message
, param
, (ControlDefUPP
) wx
->MacGetControlAction() ) ;
107 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
109 OSStatus status
= noErr
;
112 case kControlMsgSetUpBackground
:
114 wxControl
* wx
= (wxControl
*) GetControlReference( iControl
) ;
115 if ( wx
!= NULL
&& wx
->IsKindOf( CLASSINFO( wxControl
) ) )
117 wxDC::MacSetupBackgroundForCurrentPort( wx
->MacGetBackgroundBrush() ) ;
119 // under classic this would lead to partial redraws
120 RgnHandle clip
= NewRgn() ;
123 wx
->MacWindowToRootWindow( &x
,&y
) ;
124 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion(false).GetWXHRGN() , clip
) ;
125 OffsetRgn( clip
, x
, y
) ;
143 wxControl::wxControl()
145 m_macControl
= NULL
;
146 m_macControlAction
= NULL
;
147 m_macHorizontalBorder
= 0 ; // additional pixels around the real control
148 m_macVerticalBorder
= 0 ;
149 m_backgroundColour
= *wxWHITE
;
150 m_foregroundColour
= *wxBLACK
;
151 #if WXWIN_COMPATIBILITY
153 #endif // WXWIN_COMPATIBILITY
155 if ( wxMacLiveScrollbarActionUPP
== NULL
)
157 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
158 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
160 wxMacLiveScrollbarActionUPP
= NewControlActionProc( wxMacLiveScrollbarActionProc
) ;
165 bool wxControl::Create(wxWindow
*parent
, wxWindowID id
,
167 const wxSize
& size
, long style
,
168 const wxValidator
& validator
,
169 const wxString
& name
)
171 m_macControl
= NULL
;
172 m_macHorizontalBorder
= 0 ; // additional pixels around the real control
173 m_macVerticalBorder
= 0 ;
175 bool rval
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
178 m_backgroundColour
= parent
->GetBackgroundColour() ;
179 m_foregroundColour
= parent
->GetForegroundColour() ;
183 SetValidator(validator
);
189 wxControl::~wxControl()
191 m_isBeingDeleted
= TRUE
;
192 wxRemoveMacControlAssociation( this ) ;
193 // If we delete an item, we should initialize the parent panel,
194 // because it could now be invalid.
195 wxWindow
*parent
= GetParent() ;
198 if (parent
->GetDefaultItem() == (wxButton
*) this)
199 parent
->SetDefaultItem(NULL
);
201 if ( (ControlHandle
) m_macControl
)
203 ::DisposeControl( (ControlHandle
) m_macControl
) ;
204 m_macControl
= NULL
;
208 void wxControl::SetLabel(const wxString
& title
)
210 m_label
= wxStripMenuCodes(title
) ;
212 if ( (ControlHandle
) m_macControl
)
217 if( wxApp::s_macDefaultEncodingIsPC
)
218 label
= wxMacMakeMacStringFromPC( m_label
) ;
223 c2pstrcpy( (StringPtr
) maclabel
, label
) ;
225 strcpy( (char *) maclabel
, label
) ;
226 c2pstr( (char *) maclabel
) ;
228 ::SetControlTitle( (ControlHandle
) m_macControl
, maclabel
) ;
233 wxSize
wxControl::DoGetBestSize() const
235 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
236 short baselineoffset
;
237 int bestWidth
, bestHeight
;
238 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
240 if ( EmptyRect( &bestsize
) )
243 bestsize
.left
= bestsize
.top
= 0 ;
244 bestsize
.right
= 16 ;
245 bestsize
.bottom
= 16 ;
246 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
248 bestsize
.bottom
= 16 ;
250 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
252 bestsize
.bottom
= 24 ;
256 if ( IsKindOf( CLASSINFO( wxButton
) ) )
258 bestWidth
= m_label
.Length() * 8 + 12 ;
259 if ( bestWidth
< 70 )
262 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
264 bestWidth
= m_label
.Length() * 8 ;
267 bestWidth
= bestsize
.right
- bestsize
.left
;
269 bestWidth
+= 2 * m_macHorizontalBorder
;
271 bestHeight
= bestsize
.bottom
- bestsize
.top
;
272 if ( bestHeight
< 10 )
275 bestHeight
+= 2 * m_macVerticalBorder
;
278 return wxSize(bestWidth
, bestHeight
);
281 bool wxControl::ProcessCommand (wxCommandEvent
& event
)
284 // 1) A callback function (to become obsolete)
285 // 2) OnCommand, starting at this window and working up parent hierarchy
286 // 3) OnCommand then calls ProcessEvent to search the event tables.
287 #if WXWIN_COMPATIBILITY
290 (void)(*m_callback
)(this, event
);
295 #endif // WXWIN_COMPATIBILITY
297 return GetEventHandler()->ProcessEvent(event
);
301 // ------------------------
302 wxList
*wxWinMacControlList
= NULL
;
303 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
)
305 wxNode
*node
= wxWinMacControlList
->Find((long)inControl
);
308 return (wxControl
*)node
->GetData();
311 void wxAssociateControlWithMacControl(ControlHandle inControl
, wxControl
*control
)
313 // adding NULL WindowRef is (first) surely a result of an error and
314 // (secondly) breaks menu command processing
315 wxCHECK_RET( inControl
!= (ControlHandle
) NULL
, "attempt to add a NULL WindowRef to window list" );
317 if ( !wxWinMacControlList
->Find((long)inControl
) )
318 wxWinMacControlList
->Append((long)inControl
, control
);
321 void wxRemoveMacControlAssociation(wxControl
*control
)
323 wxWinMacControlList
->DeleteObject(control
);
326 void wxControl::MacPreControlCreate( wxWindow
*parent
, wxWindowID id
, wxString label
,
328 const wxSize
& size
, long style
,
329 const wxValidator
& validator
,
330 const wxString
& name
, WXRECTPTR outBounds
, unsigned char* maclabel
)
335 SetValidator(validator
);
337 m_windowStyle
= style
;
338 parent
->AddChild(this);
340 m_backgroundColour
= parent
->GetBackgroundColour() ;
341 m_foregroundColour
= parent
->GetForegroundColour() ;
344 m_windowId
= NewControlId();
348 // These sizes will be adjusted in MacPostControlCreate
355 ((Rect
*)outBounds
)->top
= -10;
356 ((Rect
*)outBounds
)->left
= -10;
357 ((Rect
*)outBounds
)->bottom
= 0;
358 ((Rect
*)outBounds
)->right
= 0;
361 strcpy( c_text
, label
) ;
362 if( wxApp::s_macDefaultEncodingIsPC
)
364 wxMacConvertFromPCForControls( c_text
) ;
368 c2pstrcpy( (StringPtr
) maclabel
, c_text
) ;
370 strcpy( (char *) maclabel
, c_text
) ;
371 c2pstr( (char *) maclabel
) ;
375 void wxControl::MacPostControlCreate()
377 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, "No valid mac control" ) ;
379 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
383 else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxRadioBox
) ) || IsKindOf( CLASSINFO( wxButton
) ) ) )
385 ControlFontStyleRec controlstyle
;
386 controlstyle
.flags
= kControlUseFontMask
;
387 controlstyle
.font
= kControlFontSmallBoldSystemFont
;
389 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
393 ControlFontStyleRec controlstyle
;
394 controlstyle
.flags
= kControlUseFontMask
;
395 controlstyle
.font
= kControlFontSmallSystemFont
;
397 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
399 ControlHandle container
= (ControlHandle
) GetParent()->MacGetContainerForEmbedding() ;
400 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
401 ::EmbedControl( (ControlHandle
) m_macControl
, container
) ;
402 m_macControlIsShown
= true ;
404 wxAssociateControlWithMacControl( (ControlHandle
) m_macControl
, this ) ;
405 if ( wxMacSetupControlBackgroundUPP
== NULL
)
407 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
409 if ( wxMacControlActionUPP
== NULL
)
411 wxMacControlActionUPP
= NewControlDefUPP( wxMacControlDefinition
) ;
413 // The following block of code is responsible for crashes when switching
414 // back to windows, which can be seen in the dialogs sample.
415 // It is disabled until a proper solution can be found.
419 only working under classic carbon
420 m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
421 (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
424 m_macControlAction
= *(**(ControlHandle
)m_macControl
).contrlDefProc
;
427 cdef
= (cdefHandle
) NewHandle( sizeof(cdefRec
) ) ;
428 if ( (**(ControlHandle
)m_macControl
).contrlDefProc
!= NULL
)
430 (**cdef
).instruction
= 0x4EF9; /* JMP instruction */
431 (**cdef
).function
= (void(*)()) wxMacControlActionUPP
;
432 (**(ControlHandle
)m_macControl
).contrlDefProc
= (Handle
) cdef
;
436 SetControlColorProc( (ControlHandle
) m_macControl
, wxMacSetupControlBackgroundUPP
) ;
438 // Adjust the controls size and position
439 wxPoint
pos(m_x
, m_y
);
440 wxSize
best_size( DoGetBestSize() );
441 wxSize
new_size( m_width
, m_height
);
443 m_x
= m_y
= m_width
= m_height
= -1; // Forces SetSize to move/size the control
445 if (new_size
.x
== -1) {
446 new_size
.x
= best_size
.x
;
448 if (new_size
.y
== -1) {
449 new_size
.y
= best_size
.y
;
452 SetSize(pos
.x
, pos
.y
, new_size
.x
, new_size
.y
);
454 UMAShowControl( (ControlHandle
) m_macControl
) ;
456 SetCursor( *wxSTANDARD_CURSOR
) ;
461 void wxControl::MacAdjustControlRect()
463 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
464 if ( m_width
== -1 || m_height
== -1 )
466 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
467 short baselineoffset
;
469 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
471 if ( EmptyRect( &bestsize
) )
474 bestsize
.left
= bestsize
.top
= 0 ;
475 bestsize
.right
= 16 ;
476 bestsize
.bottom
= 16 ;
477 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
479 bestsize
.bottom
= 16 ;
481 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
483 bestsize
.bottom
= 24 ;
489 if ( IsKindOf( CLASSINFO( wxButton
) ) )
491 m_width
= m_label
.Length() * 8 + 12 ;
495 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
497 m_width
= m_label
.Length() * 8 ;
500 m_width
= bestsize
.right
- bestsize
.left
;
502 m_width
+= 2 * m_macHorizontalBorder
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
504 if ( m_height
== -1 )
506 m_height
= bestsize
.bottom
- bestsize
.top
;
510 m_height
+= 2 * m_macVerticalBorder
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
512 MacUpdateDimensions() ;
513 // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
517 WXWidget
wxControl::MacGetContainerForEmbedding()
520 return m_macControl
;
522 return wxWindow::MacGetContainerForEmbedding() ;
525 void wxControl::MacUpdateDimensions()
527 // actually in the current systems this should never be possible, but later reparenting
528 // may become a reality
530 if ( (ControlHandle
) m_macControl
== NULL
)
533 if ( GetParent() == NULL
)
536 WindowRef rootwindow
= (WindowRef
) MacGetRootWindow() ;
537 if ( rootwindow
== NULL
)
541 GetControlBounds( (ControlHandle
) m_macControl
, &oldBounds
) ;
543 int new_x
= m_x
+ MacGetLeftBorderSize() + m_macHorizontalBorder
;
544 int new_y
= m_y
+ MacGetTopBorderSize() + m_macVerticalBorder
;
545 int new_width
= m_width
- MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder
;
546 int new_height
= m_height
- MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder
;
548 GetParent()->MacWindowToRootWindow( & new_x
, & new_y
) ;
549 bool doMove
= new_x
!= oldBounds
.left
|| new_y
!= oldBounds
.top
;
550 bool doResize
= ( oldBounds
.right
- oldBounds
.left
) != new_width
|| (oldBounds
.bottom
- oldBounds
.top
) != new_height
;
551 if ( doMove
|| doResize
)
553 InvalWindowRect( rootwindow
, &oldBounds
) ;
556 UMAMoveControl( (ControlHandle
) m_macControl
, new_x
, new_y
) ;
560 UMASizeControl( (ControlHandle
) m_macControl
, new_width
, new_height
) ;
565 void wxControl::MacSuperChangedPosition()
567 MacUpdateDimensions() ;
568 wxWindow::MacSuperChangedPosition() ;
571 void wxControl::MacSuperEnabled( bool enabled
)
574 wxWindow::MacSuperEnabled( enabled
) ;
577 void wxControl::MacSuperShown( bool show
)
579 if ( (ControlHandle
) m_macControl
)
583 if ( m_macControlIsShown
)
585 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
586 m_macControlIsShown
= false ;
591 if ( MacIsReallyShown() && !m_macControlIsShown
)
593 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
594 m_macControlIsShown
= true ;
599 wxWindow::MacSuperShown( show
) ;
602 void wxControl::DoSetSize(int x
, int y
,
603 int width
, int height
,
606 wxWindow::DoSetSize( x
, y
,width
, height
,sizeFlags
) ;
609 Rect meta
, control
;
610 GetControlBounds( (ControlHandle
) m_macControl
, &control
) ;
611 RgnHandle rgn
= NewRgn() ;
612 GetControlRegion( (ControlHandle
) m_macControl
, kControlStructureMetaPart
, rgn
) ;
613 GetRegionBounds( rgn
, &meta
) ;
614 if ( !EmptyRect( &meta
) )
616 wxASSERT( meta
.left
>= control
.left
- m_macHorizontalBorder
) ;
617 wxASSERT( meta
.right
<= control
.right
+ m_macHorizontalBorder
) ;
618 wxASSERT( meta
.top
>= control
.top
- m_macVerticalBorder
) ;
619 wxASSERT( meta
.bottom
<= control
.bottom
+ m_macVerticalBorder
) ;
627 if ( (ControlHandle) m_macControl == NULL )
629 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
634 int new_x, new_y, new_width, new_height;
640 new_height = m_height;
642 if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
651 if (x != -1) new_x = x;
652 if (y != -1) new_y = y;
653 if (width != -1) new_width = width;
654 if (height != -1) new_height = height;
657 if(sizeFlags & wxSIZE_AUTO)
659 wxSize size = GetBestSize();
660 if (sizeFlags & wxSIZE_AUTO_WIDTH)
662 if (width == -1) new_width = size.x;
664 if (sizeFlags & wxSIZE_AUTO_HEIGHT)
666 if (height == -1) new_height = size.y;
669 AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
674 GetParent()->MacWindowToRootWindow(&mac_x, &mac_y);
676 GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
677 oldbounds.right = oldbounds.left + m_width;
678 oldbounds.bottom = oldbounds.top + m_height;
681 bool doResize = false;
683 if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
684 mac_y != (oldbounds.top - m_macVerticalBorder) )
688 if ( new_width != oldbounds.right - oldbounds.left - 2 * m_macHorizontalBorder ||
689 new_height != oldbounds.bottom - oldbounds.top - 2 * m_macVerticalBorder)
694 if ( doMove || doResize )
698 // Ensure resize is within constraints
699 if ((m_minWidth != -1) && (new_width < m_minWidth)) {
700 new_width = m_minWidth;
702 if ((m_minHeight != -1) && (new_height < m_minHeight)) {
703 new_height = m_minHeight;
705 if ((m_maxWidth != -1) && (new_width > m_maxWidth)) {
706 new_width = m_maxWidth;
708 if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
709 new_height = m_maxHeight;
717 UMAMoveControl( (ControlHandle) m_macControl,
718 mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
720 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
721 event.SetEventObject(this);
722 GetEventHandler()->ProcessEvent(event) ;
727 m_height = new_height;
729 UMASizeControl( (ControlHandle) m_macControl,
730 m_width - 2 * m_macHorizontalBorder,
731 m_height - 2 * m_macVerticalBorder ) ;
734 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
735 event.SetEventObject(this);
736 GetEventHandler()->ProcessEvent(event);
744 bool wxControl::Show(bool show
)
746 if ( !wxWindow::Show( show
) )
749 if ( (ControlHandle
) m_macControl
)
753 if ( m_macControlIsShown
)
755 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
756 m_macControlIsShown
= false ;
761 if ( MacIsReallyShown() && !m_macControlIsShown
)
763 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
764 m_macControlIsShown
= true ;
771 bool wxControl::Enable(bool enable
)
773 if ( !wxWindow::Enable(enable
) )
776 if ( (ControlHandle
) m_macControl
)
779 UMAActivateControl( (ControlHandle
) m_macControl
) ;
781 UMADeactivateControl( (ControlHandle
) m_macControl
) ;
786 void wxControl::Refresh(bool eraseBack
, const wxRect
*rect
)
788 wxWindow::Refresh( eraseBack
, rect
) ;
791 void wxControl::MacRedrawControl()
793 if ( (ControlHandle
) m_macControl
&& MacGetRootWindow() && m_macControlIsShown
)
795 wxClientDC
dc(this) ;
796 wxMacPortSetter
helper(&dc
) ;
797 wxMacWindowClipper
clipper(this) ;
798 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
799 UMADrawControl( (ControlHandle
) m_macControl
) ;
803 void wxControl::OnPaint(wxPaintEvent
& event
)
805 if ( (ControlHandle
) m_macControl
)
808 wxMacPortSetter
helper(&dc
) ;
809 wxMacWindowClipper
clipper(this) ;
810 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
811 UMADrawControl( (ControlHandle
) m_macControl
) ;
818 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
820 wxWindow::OnEraseBackground( event
) ;
824 void wxControl::OnKeyDown( wxKeyEvent
&event
)
826 if ( (ControlHandle
) m_macControl
== NULL
)
829 EventRecord
*ev
= (EventRecord
*) wxTheApp
->MacGetCurrentEvent() ;
832 keychar
= short(ev
->message
& charCodeMask
);
833 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
835 ::HandleControlKey( (ControlHandle
) m_macControl
, keycode
, keychar
, ev
->modifiers
) ;
838 void wxControl::OnMouseEvent( wxMouseEvent
&event
)
840 if ( (ControlHandle
) m_macControl
== NULL
)
846 if (event
.GetEventType() == wxEVT_LEFT_DOWN
|| event
.GetEventType() == wxEVT_LEFT_DCLICK
)
852 MacClientToRootWindow( &x
, &y
) ;
854 ControlHandle control
;
863 if ( !event
.m_leftDown
&& !event
.m_rightDown
)
864 modifiers
|= btnState
;
866 if ( event
.m_shiftDown
)
867 modifiers
|= shiftKey
;
869 if ( event
.m_controlDown
)
870 modifiers
|= controlKey
;
872 if ( event
.m_altDown
)
873 modifiers
|= optionKey
;
875 if ( event
.m_metaDown
)
876 modifiers
|= cmdKey
;
878 control
= (ControlHandle
) m_macControl
;
879 if ( control
&& ::IsControlActive( control
) )
882 controlpart
= ::HandleControlClick( control
, localwhere
, modifiers
, (ControlActionUPP
) -1 ) ;
883 wxTheApp
->s_lastMouseDown
= 0 ;
884 if ( control
&& controlpart
!= kControlNoPart
&&
885 ! IsKindOf( CLASSINFO( wxScrollBar
) )
886 ) // otherwise we will get the event twice for scrollbar
888 MacHandleControlClick( control
, controlpart
) ;
896 bool wxControl::MacCanFocus() const
898 { if ( (ControlHandle
) m_macControl
== NULL
)
905 void wxControl::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
)
907 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, "No valid mac control" ) ;