1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
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_PAINT( wxControl::OnPaint
)
43 #include "wx/mac/uma.h"
44 #include "wx/mac/private.h"
49 #if PRAGMA_STRUCT_ALIGN
50 #pragma options align=mac68k
51 #elif PRAGMA_STRUCT_PACKPUSH
53 #elif PRAGMA_STRUCT_PACK
58 unsigned short instruction
;
60 } cdefRec
, *cdefPtr
, **cdefHandle
;
62 #if PRAGMA_STRUCT_ALIGN
63 #pragma options align=reset
64 #elif PRAGMA_STRUCT_PACKPUSH
66 #elif PRAGMA_STRUCT_PACK
70 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
71 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
) ;
73 pascal void wxMacLiveScrollbarActionProc( ControlHandle control
, ControlPartCode partCode
) ;
74 pascal void wxMacLiveScrollbarActionProc( ControlHandle control
, ControlPartCode partCode
)
78 wxControl
* wx
= (wxControl
*) GetControlReference( control
) ;
81 wx
->MacHandleControlClick( control
, partCode
, true /* stillDown */ ) ;
86 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
87 ControlDefUPP wxMacControlActionUPP
= NULL
;
89 pascal SInt32
wxMacControlDefinition(SInt16 varCode
, ControlRef theControl
, ControlDefProcMessage message
, SInt32 param
)
92 wxControl
* wx
= (wxControl
*) wxFindControlFromMacControl( theControl
) ;
93 if ( wx
!= NULL
&& wx
->IsKindOf( CLASSINFO( wxControl
) ) )
95 if( message
== drawCntl
)
97 wxMacWindowClipper
clip( wx
) ;
98 return InvokeControlDefUPP( varCode
, theControl
, message
, param
, (ControlDefUPP
) wx
->MacGetControlAction() ) ;
101 return InvokeControlDefUPP( varCode
, theControl
, message
, param
, (ControlDefUPP
) wx
->MacGetControlAction() ) ;
106 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
108 OSStatus status
= noErr
;
111 case kControlMsgSetUpBackground
:
113 wxControl
* wx
= (wxControl
*) GetControlReference( iControl
) ;
114 if ( wx
!= NULL
&& wx
->IsKindOf( CLASSINFO( wxControl
) ) )
116 wxDC::MacSetupBackgroundForCurrentPort( wx
->MacGetBackgroundBrush() ) ;
118 // under classic this would lead to partial redraws
119 RgnHandle clip
= NewRgn() ;
122 wx
->MacWindowToRootWindow( &x
,&y
) ;
123 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion(false).GetWXHRGN() , clip
) ;
124 OffsetRgn( clip
, x
, y
) ;
142 wxControl::wxControl()
144 m_macControl
= NULL
;
145 m_macControlAction
= NULL
;
146 m_macHorizontalBorder
= 0 ; // additional pixels around the real control
147 m_macVerticalBorder
= 0 ;
148 m_backgroundColour
= *wxWHITE
;
149 m_foregroundColour
= *wxBLACK
;
151 if ( wxMacLiveScrollbarActionUPP
== NULL
)
153 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
154 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
156 wxMacLiveScrollbarActionUPP
= NewControlActionProc( wxMacLiveScrollbarActionProc
) ;
161 bool wxControl::Create(wxWindow
*parent
, wxWindowID id
,
163 const wxSize
& size
, long style
,
164 const wxValidator
& validator
,
165 const wxString
& name
)
167 m_macControl
= NULL
;
168 m_macHorizontalBorder
= 0 ; // additional pixels around the real control
169 m_macVerticalBorder
= 0 ;
171 bool rval
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
174 m_backgroundColour
= parent
->GetBackgroundColour() ;
175 m_foregroundColour
= parent
->GetForegroundColour() ;
179 SetValidator(validator
);
185 wxControl::~wxControl()
187 m_isBeingDeleted
= TRUE
;
188 wxRemoveMacControlAssociation( this ) ;
189 // If we delete an item, we should initialize the parent panel,
190 // because it could now be invalid.
191 wxWindow
*parent
= GetParent() ;
194 if (parent
->GetDefaultItem() == (wxButton
*) this)
195 parent
->SetDefaultItem(NULL
);
197 if ( (ControlHandle
) m_macControl
)
199 ::DisposeControl( (ControlHandle
) m_macControl
) ;
200 m_macControl
= NULL
;
204 void wxControl::SetLabel(const wxString
& title
)
206 m_label
= wxStripMenuCodes(title
) ;
210 UMASetControlTitle( (ControlHandle
) m_macControl
, m_label
) ;
215 wxSize
wxControl::DoGetBestSize() const
217 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
218 short baselineoffset
;
219 int bestWidth
, bestHeight
;
220 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
222 if ( EmptyRect( &bestsize
) )
225 bestsize
.left
= bestsize
.top
= 0 ;
226 bestsize
.right
= 16 ;
227 bestsize
.bottom
= 16 ;
228 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
230 bestsize
.bottom
= 16 ;
232 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
234 bestsize
.bottom
= 24 ;
238 if ( IsKindOf( CLASSINFO( wxButton
) ) )
240 bestWidth
= m_label
.Length() * 8 + 12 ;
241 if ( bestWidth
< 70 )
244 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
246 bestWidth
= m_label
.Length() * 8 ;
249 bestWidth
= bestsize
.right
- bestsize
.left
;
251 bestWidth
+= 2 * m_macHorizontalBorder
;
253 bestHeight
= bestsize
.bottom
- bestsize
.top
;
254 if ( bestHeight
< 10 )
257 bestHeight
+= 2 * m_macVerticalBorder
;
260 return wxSize(bestWidth
, bestHeight
);
263 bool wxControl::ProcessCommand (wxCommandEvent
& event
)
266 // 1) OnCommand, starting at this window and working up parent hierarchy
267 // 2) OnCommand then calls ProcessEvent to search the event tables.
268 return GetEventHandler()->ProcessEvent(event
);
271 // ------------------------
272 wxList
*wxWinMacControlList
= NULL
;
273 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
)
275 wxNode
*node
= wxWinMacControlList
->Find((long)inControl
);
278 return (wxControl
*)node
->GetData();
281 void wxAssociateControlWithMacControl(ControlHandle inControl
, wxControl
*control
)
283 // adding NULL WindowRef is (first) surely a result of an error and
284 // (secondly) breaks menu command processing
285 wxCHECK_RET( inControl
!= (ControlHandle
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
287 if ( !wxWinMacControlList
->Find((long)inControl
) )
288 wxWinMacControlList
->Append((long)inControl
, control
);
291 void wxRemoveMacControlAssociation(wxControl
*control
)
293 wxWinMacControlList
->DeleteObject(control
);
296 void wxControl::MacPreControlCreate( wxWindow
*parent
, wxWindowID id
, wxString label
,
298 const wxSize
& size
, long style
,
299 const wxValidator
& validator
,
300 const wxString
& name
, WXRECTPTR outBounds
, unsigned char* maclabel
)
305 SetValidator(validator
);
307 m_windowStyle
= style
;
308 parent
->AddChild(this);
310 m_backgroundColour
= parent
->GetBackgroundColour() ;
311 m_foregroundColour
= parent
->GetForegroundColour() ;
314 m_windowId
= NewControlId();
318 // These sizes will be adjusted in MacPostControlCreate
325 ((Rect
*)outBounds
)->top
= -10;
326 ((Rect
*)outBounds
)->left
= -10;
327 ((Rect
*)outBounds
)->bottom
= 0;
328 ((Rect
*)outBounds
)->right
= 0;
330 wxMacStringToPascal( wxStripMenuCodes(label
) , maclabel
) ;
333 void wxControl::MacPostControlCreate()
335 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
337 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
341 else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxRadioBox
) ) || IsKindOf( CLASSINFO( wxButton
) ) ) )
343 ControlFontStyleRec controlstyle
;
344 controlstyle
.flags
= kControlUseFontMask
;
345 controlstyle
.font
= kControlFontSmallBoldSystemFont
;
347 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
351 ControlFontStyleRec controlstyle
;
352 controlstyle
.flags
= kControlUseFontMask
;
354 if (IsKindOf( CLASSINFO( wxButton
) ) )
355 controlstyle
.font
= kControlFontSmallSystemFont
; // eventually kControlFontBigSystemFont ;
357 controlstyle
.font
= kControlFontSmallSystemFont
;
359 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
361 ControlHandle container
= (ControlHandle
) GetParent()->MacGetContainerForEmbedding() ;
362 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
363 ::EmbedControl( (ControlHandle
) m_macControl
, container
) ;
364 m_macControlIsShown
= true ;
366 wxAssociateControlWithMacControl( (ControlHandle
) m_macControl
, this ) ;
367 if ( wxMacSetupControlBackgroundUPP
== NULL
)
369 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
371 if ( wxMacControlActionUPP
== NULL
)
373 wxMacControlActionUPP
= NewControlDefUPP( wxMacControlDefinition
) ;
375 // The following block of code is responsible for crashes when switching
376 // back to windows, which can be seen in the dialogs sample.
377 // It is disabled until a proper solution can be found.
381 only working under classic carbon
382 m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
383 (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
386 m_macControlAction
= *(**(ControlHandle
)m_macControl
).contrlDefProc
;
389 cdef
= (cdefHandle
) NewHandle( sizeof(cdefRec
) ) ;
390 if ( (**(ControlHandle
)m_macControl
).contrlDefProc
!= NULL
)
392 (**cdef
).instruction
= 0x4EF9; /* JMP instruction */
393 (**cdef
).function
= (void(*)()) wxMacControlActionUPP
;
394 (**(ControlHandle
)m_macControl
).contrlDefProc
= (Handle
) cdef
;
398 SetControlColorProc( (ControlHandle
) m_macControl
, wxMacSetupControlBackgroundUPP
) ;
400 // Adjust the controls size and position
401 wxPoint
pos(m_x
, m_y
);
402 wxSize
best_size( DoGetBestSize() );
403 wxSize
new_size( m_width
, m_height
);
405 m_x
= m_y
= m_width
= m_height
= -1; // Forces SetSize to move/size the control
407 if (new_size
.x
== -1) {
408 new_size
.x
= best_size
.x
;
410 if (new_size
.y
== -1) {
411 new_size
.y
= best_size
.y
;
414 SetSize(pos
.x
, pos
.y
, new_size
.x
, new_size
.y
);
417 UMASetControlTitle( (ControlHandle
) m_macControl
, wxStripMenuCodes(m_label
) ) ;
420 UMAShowControl( (ControlHandle
) m_macControl
) ;
422 SetCursor( *wxSTANDARD_CURSOR
) ;
427 void wxControl::MacAdjustControlRect()
429 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
430 if ( m_width
== -1 || m_height
== -1 )
432 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
433 short baselineoffset
;
435 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
437 if ( EmptyRect( &bestsize
) )
440 bestsize
.left
= bestsize
.top
= 0 ;
441 bestsize
.right
= 16 ;
442 bestsize
.bottom
= 16 ;
443 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
445 bestsize
.bottom
= 16 ;
447 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
449 bestsize
.bottom
= 24 ;
455 if ( IsKindOf( CLASSINFO( wxButton
) ) )
457 m_width
= m_label
.Length() * 8 + 12 ;
461 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
463 m_width
= m_label
.Length() * 8 ;
466 m_width
= bestsize
.right
- bestsize
.left
;
468 m_width
+= 2 * m_macHorizontalBorder
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
470 if ( m_height
== -1 )
472 m_height
= bestsize
.bottom
- bestsize
.top
;
476 m_height
+= 2 * m_macVerticalBorder
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
478 MacUpdateDimensions() ;
479 // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
483 WXWidget
wxControl::MacGetContainerForEmbedding()
486 return m_macControl
;
488 return wxWindow::MacGetContainerForEmbedding() ;
491 void wxControl::MacUpdateDimensions()
493 // actually in the current systems this should never be possible, but later reparenting
494 // may become a reality
496 if ( (ControlHandle
) m_macControl
== NULL
)
499 if ( GetParent() == NULL
)
502 WindowRef rootwindow
= (WindowRef
) MacGetRootWindow() ;
503 if ( rootwindow
== NULL
)
507 GetControlBounds( (ControlHandle
) m_macControl
, &oldBounds
) ;
509 int new_x
= m_x
+ MacGetLeftBorderSize() + m_macHorizontalBorder
;
510 int new_y
= m_y
+ MacGetTopBorderSize() + m_macVerticalBorder
;
511 int new_width
= m_width
- MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder
;
512 int new_height
= m_height
- MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder
;
514 GetParent()->MacWindowToRootWindow( & new_x
, & new_y
) ;
515 bool doMove
= new_x
!= oldBounds
.left
|| new_y
!= oldBounds
.top
;
516 bool doResize
= ( oldBounds
.right
- oldBounds
.left
) != new_width
|| (oldBounds
.bottom
- oldBounds
.top
) != new_height
;
517 if ( doMove
|| doResize
)
519 InvalWindowRect( rootwindow
, &oldBounds
) ;
522 UMAMoveControl( (ControlHandle
) m_macControl
, new_x
, new_y
) ;
526 UMASizeControl( (ControlHandle
) m_macControl
, new_width
, new_height
) ;
531 void wxControl::MacSuperChangedPosition()
533 MacUpdateDimensions() ;
534 wxWindow::MacSuperChangedPosition() ;
537 void wxControl::MacSuperEnabled( bool enabled
)
540 wxWindow::MacSuperEnabled( enabled
) ;
543 void wxControl::MacSuperShown( bool show
)
545 if ( (ControlHandle
) m_macControl
)
549 if ( m_macControlIsShown
)
551 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
552 m_macControlIsShown
= false ;
557 if ( MacIsReallyShown() && !m_macControlIsShown
)
559 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
560 m_macControlIsShown
= true ;
565 wxWindow::MacSuperShown( show
) ;
568 void wxControl::DoSetSize(int x
, int y
,
569 int width
, int height
,
572 wxWindow::DoSetSize( x
, y
,width
, height
,sizeFlags
) ;
575 Rect meta
, control
;
576 GetControlBounds( (ControlHandle
) m_macControl
, &control
) ;
577 RgnHandle rgn
= NewRgn() ;
578 GetControlRegion( (ControlHandle
) m_macControl
, kControlStructureMetaPart
, rgn
) ;
579 GetRegionBounds( rgn
, &meta
) ;
580 if ( !EmptyRect( &meta
) )
582 wxASSERT( meta
.left
>= control
.left
- m_macHorizontalBorder
) ;
583 wxASSERT( meta
.right
<= control
.right
+ m_macHorizontalBorder
) ;
584 wxASSERT( meta
.top
>= control
.top
- m_macVerticalBorder
) ;
585 wxASSERT( meta
.bottom
<= control
.bottom
+ m_macVerticalBorder
) ;
593 if ( (ControlHandle) m_macControl == NULL )
595 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
600 int new_x, new_y, new_width, new_height;
606 new_height = m_height;
608 if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
617 if (x != -1) new_x = x;
618 if (y != -1) new_y = y;
619 if (width != -1) new_width = width;
620 if (height != -1) new_height = height;
623 if(sizeFlags & wxSIZE_AUTO)
625 wxSize size = GetBestSize();
626 if (sizeFlags & wxSIZE_AUTO_WIDTH)
628 if (width == -1) new_width = size.x;
630 if (sizeFlags & wxSIZE_AUTO_HEIGHT)
632 if (height == -1) new_height = size.y;
635 AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
640 GetParent()->MacWindowToRootWindow(&mac_x, &mac_y);
642 GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
643 oldbounds.right = oldbounds.left + m_width;
644 oldbounds.bottom = oldbounds.top + m_height;
647 bool doResize = false;
649 if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
650 mac_y != (oldbounds.top - m_macVerticalBorder) )
654 if ( new_width != oldbounds.right - oldbounds.left - 2 * m_macHorizontalBorder ||
655 new_height != oldbounds.bottom - oldbounds.top - 2 * m_macVerticalBorder)
660 if ( doMove || doResize )
664 // Ensure resize is within constraints
665 if ((m_minWidth != -1) && (new_width < m_minWidth)) {
666 new_width = m_minWidth;
668 if ((m_minHeight != -1) && (new_height < m_minHeight)) {
669 new_height = m_minHeight;
671 if ((m_maxWidth != -1) && (new_width > m_maxWidth)) {
672 new_width = m_maxWidth;
674 if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
675 new_height = m_maxHeight;
683 UMAMoveControl( (ControlHandle) m_macControl,
684 mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
686 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
687 event.SetEventObject(this);
688 GetEventHandler()->ProcessEvent(event) ;
693 m_height = new_height;
695 UMASizeControl( (ControlHandle) m_macControl,
696 m_width - 2 * m_macHorizontalBorder,
697 m_height - 2 * m_macVerticalBorder ) ;
700 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
701 event.SetEventObject(this);
702 GetEventHandler()->ProcessEvent(event);
710 bool wxControl::Show(bool show
)
712 if ( !wxWindow::Show( show
) )
715 if ( (ControlHandle
) m_macControl
)
719 if ( m_macControlIsShown
)
721 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
722 m_macControlIsShown
= false ;
727 if ( MacIsReallyShown() && !m_macControlIsShown
)
729 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
730 m_macControlIsShown
= true ;
737 bool wxControl::Enable(bool enable
)
739 if ( !wxWindow::Enable(enable
) )
742 if ( (ControlHandle
) m_macControl
)
745 UMAActivateControl( (ControlHandle
) m_macControl
) ;
747 UMADeactivateControl( (ControlHandle
) m_macControl
) ;
752 void wxControl::Refresh(bool eraseBack
, const wxRect
*rect
)
754 wxWindow::Refresh( eraseBack
, rect
) ;
757 void wxControl::MacRedrawControl()
759 if ( (ControlHandle
) m_macControl
&& MacGetRootWindow() && m_macControlIsShown
)
761 wxClientDC
dc(this) ;
762 wxMacPortSetter
helper(&dc
) ;
763 wxMacWindowClipper
clipper(this) ;
764 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
765 UMADrawControl( (ControlHandle
) m_macControl
) ;
769 void wxControl::OnPaint(wxPaintEvent
& event
)
771 if ( (ControlHandle
) m_macControl
)
774 wxMacPortSetter
helper(&dc
) ;
775 wxMacWindowClipper
clipper(this) ;
776 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
777 UMADrawControl( (ControlHandle
) m_macControl
) ;
784 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
786 wxWindow::OnEraseBackground( event
) ;
789 void wxControl::OnKeyDown( wxKeyEvent
&event
)
791 if ( (ControlHandle
) m_macControl
== NULL
)
800 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode
);
801 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
802 GetEventParameter((EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
804 ::HandleControlKey( (ControlHandle
) m_macControl
, keyCode
, charCode
, modifiers
) ;
807 EventRecord
*ev
= (EventRecord
*) wxTheApp
->MacGetCurrentEvent() ;
810 keychar
= short(ev
->message
& charCodeMask
);
811 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
813 ::HandleControlKey( (ControlHandle
) m_macControl
, keycode
, keychar
, ev
->modifiers
) ;
817 void wxControl::OnMouseEvent( wxMouseEvent
&event
)
819 if ( (ControlHandle
) m_macControl
== NULL
)
825 if (event
.GetEventType() == wxEVT_LEFT_DOWN
|| event
.GetEventType() == wxEVT_LEFT_DCLICK
)
831 MacClientToRootWindow( &x
, &y
) ;
833 ControlHandle control
;
842 if ( !event
.m_leftDown
&& !event
.m_rightDown
)
843 modifiers
|= btnState
;
845 if ( event
.m_shiftDown
)
846 modifiers
|= shiftKey
;
848 if ( event
.m_controlDown
)
849 modifiers
|= controlKey
;
851 if ( event
.m_altDown
)
852 modifiers
|= optionKey
;
854 if ( event
.m_metaDown
)
855 modifiers
|= cmdKey
;
857 control
= (ControlHandle
) m_macControl
;
858 if ( control
&& ::IsControlActive( control
) )
861 controlpart
= ::HandleControlClick( control
, localwhere
, modifiers
, (ControlActionUPP
) -1 ) ;
862 wxTheApp
->s_lastMouseDown
= 0 ;
863 if ( control
&& controlpart
!= kControlNoPart
)
865 MacHandleControlClick( control
, controlpart
, false /* mouse not down anymore */ ) ;
877 bool wxControl::MacCanFocus() const
879 if ( (ControlHandle
) m_macControl
== NULL
)
885 void wxControl::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
887 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;