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
) ;
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
;
150 #if WXWIN_COMPATIBILITY
152 #endif // WXWIN_COMPATIBILITY
154 if ( wxMacLiveScrollbarActionUPP
== NULL
)
156 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
157 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
159 wxMacLiveScrollbarActionUPP
= NewControlActionProc( wxMacLiveScrollbarActionProc
) ;
164 bool wxControl::Create(wxWindow
*parent
, wxWindowID id
,
166 const wxSize
& size
, long style
,
167 const wxValidator
& validator
,
168 const wxString
& name
)
170 m_macControl
= NULL
;
171 m_macHorizontalBorder
= 0 ; // additional pixels around the real control
172 m_macVerticalBorder
= 0 ;
174 bool rval
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
177 m_backgroundColour
= parent
->GetBackgroundColour() ;
178 m_foregroundColour
= parent
->GetForegroundColour() ;
182 SetValidator(validator
);
188 wxControl::~wxControl()
190 m_isBeingDeleted
= TRUE
;
191 wxRemoveMacControlAssociation( this ) ;
192 // If we delete an item, we should initialize the parent panel,
193 // because it could now be invalid.
194 wxWindow
*parent
= GetParent() ;
197 if (parent
->GetDefaultItem() == (wxButton
*) this)
198 parent
->SetDefaultItem(NULL
);
200 if ( (ControlHandle
) m_macControl
)
202 ::DisposeControl( (ControlHandle
) m_macControl
) ;
203 m_macControl
= NULL
;
207 void wxControl::SetLabel(const wxString
& title
)
209 m_label
= wxStripMenuCodes(title
) ;
211 if ( (ControlHandle
) m_macControl
)
216 if( wxApp::s_macDefaultEncodingIsPC
)
217 label
= wxMacMakeMacStringFromPC( m_label
) ;
222 c2pstrcpy( (StringPtr
) maclabel
, label
) ;
224 strcpy( (char *) maclabel
, label
) ;
225 c2pstr( (char *) maclabel
) ;
227 ::SetControlTitle( (ControlHandle
) m_macControl
, maclabel
) ;
232 wxSize
wxControl::DoGetBestSize() const
234 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
235 short baselineoffset
;
236 int bestWidth
, bestHeight
;
237 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
239 if ( EmptyRect( &bestsize
) )
242 bestsize
.left
= bestsize
.top
= 0 ;
243 bestsize
.right
= 16 ;
244 bestsize
.bottom
= 16 ;
245 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
247 bestsize
.bottom
= 16 ;
249 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
251 bestsize
.bottom
= 24 ;
255 if ( IsKindOf( CLASSINFO( wxButton
) ) )
257 bestWidth
= m_label
.Length() * 8 + 12 ;
258 if ( bestWidth
< 70 )
261 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
263 bestWidth
= m_label
.Length() * 8 ;
266 bestWidth
= bestsize
.right
- bestsize
.left
;
268 bestWidth
+= 2 * m_macHorizontalBorder
;
270 bestHeight
= bestsize
.bottom
- bestsize
.top
;
271 if ( bestHeight
< 10 )
274 bestHeight
+= 2 * m_macVerticalBorder
;
277 return wxSize(bestWidth
, bestHeight
);
280 bool wxControl::ProcessCommand (wxCommandEvent
& event
)
283 // 1) A callback function (to become obsolete)
284 // 2) OnCommand, starting at this window and working up parent hierarchy
285 // 3) OnCommand then calls ProcessEvent to search the event tables.
286 #if WXWIN_COMPATIBILITY
289 (void)(*m_callback
)(this, event
);
294 #endif // WXWIN_COMPATIBILITY
296 return GetEventHandler()->ProcessEvent(event
);
300 // ------------------------
301 wxList
*wxWinMacControlList
= NULL
;
302 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
)
304 wxNode
*node
= wxWinMacControlList
->Find((long)inControl
);
307 return (wxControl
*)node
->GetData();
310 void wxAssociateControlWithMacControl(ControlHandle inControl
, wxControl
*control
)
312 // adding NULL WindowRef is (first) surely a result of an error and
313 // (secondly) breaks menu command processing
314 wxCHECK_RET( inControl
!= (ControlHandle
) NULL
, "attempt to add a NULL WindowRef to window list" );
316 if ( !wxWinMacControlList
->Find((long)inControl
) )
317 wxWinMacControlList
->Append((long)inControl
, control
);
320 void wxRemoveMacControlAssociation(wxControl
*control
)
322 wxWinMacControlList
->DeleteObject(control
);
325 void wxControl::MacPreControlCreate( wxWindow
*parent
, wxWindowID id
, wxString label
,
327 const wxSize
& size
, long style
,
328 const wxValidator
& validator
,
329 const wxString
& name
, WXRECTPTR outBounds
, unsigned char* maclabel
)
334 SetValidator(validator
);
336 m_windowStyle
= style
;
337 parent
->AddChild(this);
339 m_backgroundColour
= parent
->GetBackgroundColour() ;
340 m_foregroundColour
= parent
->GetForegroundColour() ;
343 m_windowId
= NewControlId();
347 // These sizes will be adjusted in MacPostControlCreate
354 ((Rect
*)outBounds
)->top
= -10;
355 ((Rect
*)outBounds
)->left
= -10;
356 ((Rect
*)outBounds
)->bottom
= 0;
357 ((Rect
*)outBounds
)->right
= 0;
359 wxMacStringToPascal( wxStripMenuCodes(label
) , maclabel
) ;
362 void wxControl::MacPostControlCreate()
364 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, "No valid mac control" ) ;
366 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
370 else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxRadioBox
) ) || IsKindOf( CLASSINFO( wxButton
) ) ) )
372 ControlFontStyleRec controlstyle
;
373 controlstyle
.flags
= kControlUseFontMask
;
374 controlstyle
.font
= kControlFontSmallBoldSystemFont
;
376 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
380 ControlFontStyleRec controlstyle
;
381 controlstyle
.flags
= kControlUseFontMask
;
382 controlstyle
.font
= kControlFontSmallSystemFont
;
384 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
386 ControlHandle container
= (ControlHandle
) GetParent()->MacGetContainerForEmbedding() ;
387 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
388 ::EmbedControl( (ControlHandle
) m_macControl
, container
) ;
389 m_macControlIsShown
= true ;
391 wxAssociateControlWithMacControl( (ControlHandle
) m_macControl
, this ) ;
392 if ( wxMacSetupControlBackgroundUPP
== NULL
)
394 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
396 if ( wxMacControlActionUPP
== NULL
)
398 wxMacControlActionUPP
= NewControlDefUPP( wxMacControlDefinition
) ;
400 // The following block of code is responsible for crashes when switching
401 // back to windows, which can be seen in the dialogs sample.
402 // It is disabled until a proper solution can be found.
406 only working under classic carbon
407 m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
408 (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
411 m_macControlAction
= *(**(ControlHandle
)m_macControl
).contrlDefProc
;
414 cdef
= (cdefHandle
) NewHandle( sizeof(cdefRec
) ) ;
415 if ( (**(ControlHandle
)m_macControl
).contrlDefProc
!= NULL
)
417 (**cdef
).instruction
= 0x4EF9; /* JMP instruction */
418 (**cdef
).function
= (void(*)()) wxMacControlActionUPP
;
419 (**(ControlHandle
)m_macControl
).contrlDefProc
= (Handle
) cdef
;
423 SetControlColorProc( (ControlHandle
) m_macControl
, wxMacSetupControlBackgroundUPP
) ;
425 // Adjust the controls size and position
426 wxPoint
pos(m_x
, m_y
);
427 wxSize
best_size( DoGetBestSize() );
428 wxSize
new_size( m_width
, m_height
);
430 m_x
= m_y
= m_width
= m_height
= -1; // Forces SetSize to move/size the control
432 if (new_size
.x
== -1) {
433 new_size
.x
= best_size
.x
;
435 if (new_size
.y
== -1) {
436 new_size
.y
= best_size
.y
;
439 SetSize(pos
.x
, pos
.y
, new_size
.x
, new_size
.y
);
441 UMAShowControl( (ControlHandle
) m_macControl
) ;
443 SetCursor( *wxSTANDARD_CURSOR
) ;
448 void wxControl::MacAdjustControlRect()
450 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
451 if ( m_width
== -1 || m_height
== -1 )
453 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
454 short baselineoffset
;
456 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
458 if ( EmptyRect( &bestsize
) )
461 bestsize
.left
= bestsize
.top
= 0 ;
462 bestsize
.right
= 16 ;
463 bestsize
.bottom
= 16 ;
464 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
466 bestsize
.bottom
= 16 ;
468 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
470 bestsize
.bottom
= 24 ;
476 if ( IsKindOf( CLASSINFO( wxButton
) ) )
478 m_width
= m_label
.Length() * 8 + 12 ;
482 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
484 m_width
= m_label
.Length() * 8 ;
487 m_width
= bestsize
.right
- bestsize
.left
;
489 m_width
+= 2 * m_macHorizontalBorder
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
491 if ( m_height
== -1 )
493 m_height
= bestsize
.bottom
- bestsize
.top
;
497 m_height
+= 2 * m_macVerticalBorder
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
499 MacUpdateDimensions() ;
500 // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
504 WXWidget
wxControl::MacGetContainerForEmbedding()
507 return m_macControl
;
509 return wxWindow::MacGetContainerForEmbedding() ;
512 void wxControl::MacUpdateDimensions()
514 // actually in the current systems this should never be possible, but later reparenting
515 // may become a reality
517 if ( (ControlHandle
) m_macControl
== NULL
)
520 if ( GetParent() == NULL
)
523 WindowRef rootwindow
= (WindowRef
) MacGetRootWindow() ;
524 if ( rootwindow
== NULL
)
528 GetControlBounds( (ControlHandle
) m_macControl
, &oldBounds
) ;
530 int new_x
= m_x
+ MacGetLeftBorderSize() + m_macHorizontalBorder
;
531 int new_y
= m_y
+ MacGetTopBorderSize() + m_macVerticalBorder
;
532 int new_width
= m_width
- MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder
;
533 int new_height
= m_height
- MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder
;
535 GetParent()->MacWindowToRootWindow( & new_x
, & new_y
) ;
536 bool doMove
= new_x
!= oldBounds
.left
|| new_y
!= oldBounds
.top
;
537 bool doResize
= ( oldBounds
.right
- oldBounds
.left
) != new_width
|| (oldBounds
.bottom
- oldBounds
.top
) != new_height
;
538 if ( doMove
|| doResize
)
540 InvalWindowRect( rootwindow
, &oldBounds
) ;
543 UMAMoveControl( (ControlHandle
) m_macControl
, new_x
, new_y
) ;
547 UMASizeControl( (ControlHandle
) m_macControl
, new_width
, new_height
) ;
552 void wxControl::MacSuperChangedPosition()
554 MacUpdateDimensions() ;
555 wxWindow::MacSuperChangedPosition() ;
558 void wxControl::MacSuperEnabled( bool enabled
)
561 wxWindow::MacSuperEnabled( enabled
) ;
564 void wxControl::MacSuperShown( bool show
)
566 if ( (ControlHandle
) m_macControl
)
570 if ( m_macControlIsShown
)
572 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
573 m_macControlIsShown
= false ;
578 if ( MacIsReallyShown() && !m_macControlIsShown
)
580 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
581 m_macControlIsShown
= true ;
586 wxWindow::MacSuperShown( show
) ;
589 void wxControl::DoSetSize(int x
, int y
,
590 int width
, int height
,
593 wxWindow::DoSetSize( x
, y
,width
, height
,sizeFlags
) ;
596 Rect meta
, control
;
597 GetControlBounds( (ControlHandle
) m_macControl
, &control
) ;
598 RgnHandle rgn
= NewRgn() ;
599 GetControlRegion( (ControlHandle
) m_macControl
, kControlStructureMetaPart
, rgn
) ;
600 GetRegionBounds( rgn
, &meta
) ;
601 if ( !EmptyRect( &meta
) )
603 wxASSERT( meta
.left
>= control
.left
- m_macHorizontalBorder
) ;
604 wxASSERT( meta
.right
<= control
.right
+ m_macHorizontalBorder
) ;
605 wxASSERT( meta
.top
>= control
.top
- m_macVerticalBorder
) ;
606 wxASSERT( meta
.bottom
<= control
.bottom
+ m_macVerticalBorder
) ;
614 if ( (ControlHandle) m_macControl == NULL )
616 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
621 int new_x, new_y, new_width, new_height;
627 new_height = m_height;
629 if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
638 if (x != -1) new_x = x;
639 if (y != -1) new_y = y;
640 if (width != -1) new_width = width;
641 if (height != -1) new_height = height;
644 if(sizeFlags & wxSIZE_AUTO)
646 wxSize size = GetBestSize();
647 if (sizeFlags & wxSIZE_AUTO_WIDTH)
649 if (width == -1) new_width = size.x;
651 if (sizeFlags & wxSIZE_AUTO_HEIGHT)
653 if (height == -1) new_height = size.y;
656 AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
661 GetParent()->MacWindowToRootWindow(&mac_x, &mac_y);
663 GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
664 oldbounds.right = oldbounds.left + m_width;
665 oldbounds.bottom = oldbounds.top + m_height;
668 bool doResize = false;
670 if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
671 mac_y != (oldbounds.top - m_macVerticalBorder) )
675 if ( new_width != oldbounds.right - oldbounds.left - 2 * m_macHorizontalBorder ||
676 new_height != oldbounds.bottom - oldbounds.top - 2 * m_macVerticalBorder)
681 if ( doMove || doResize )
685 // Ensure resize is within constraints
686 if ((m_minWidth != -1) && (new_width < m_minWidth)) {
687 new_width = m_minWidth;
689 if ((m_minHeight != -1) && (new_height < m_minHeight)) {
690 new_height = m_minHeight;
692 if ((m_maxWidth != -1) && (new_width > m_maxWidth)) {
693 new_width = m_maxWidth;
695 if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
696 new_height = m_maxHeight;
704 UMAMoveControl( (ControlHandle) m_macControl,
705 mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
707 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
708 event.SetEventObject(this);
709 GetEventHandler()->ProcessEvent(event) ;
714 m_height = new_height;
716 UMASizeControl( (ControlHandle) m_macControl,
717 m_width - 2 * m_macHorizontalBorder,
718 m_height - 2 * m_macVerticalBorder ) ;
721 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
722 event.SetEventObject(this);
723 GetEventHandler()->ProcessEvent(event);
731 bool wxControl::Show(bool show
)
733 if ( !wxWindow::Show( show
) )
736 if ( (ControlHandle
) m_macControl
)
740 if ( m_macControlIsShown
)
742 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
743 m_macControlIsShown
= false ;
748 if ( MacIsReallyShown() && !m_macControlIsShown
)
750 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
751 m_macControlIsShown
= true ;
758 bool wxControl::Enable(bool enable
)
760 if ( !wxWindow::Enable(enable
) )
763 if ( (ControlHandle
) m_macControl
)
766 UMAActivateControl( (ControlHandle
) m_macControl
) ;
768 UMADeactivateControl( (ControlHandle
) m_macControl
) ;
773 void wxControl::Refresh(bool eraseBack
, const wxRect
*rect
)
775 wxWindow::Refresh( eraseBack
, rect
) ;
778 void wxControl::MacRedrawControl()
780 if ( (ControlHandle
) m_macControl
&& MacGetRootWindow() && m_macControlIsShown
)
782 wxClientDC
dc(this) ;
783 wxMacPortSetter
helper(&dc
) ;
784 wxMacWindowClipper
clipper(this) ;
785 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
786 UMADrawControl( (ControlHandle
) m_macControl
) ;
790 void wxControl::OnPaint(wxPaintEvent
& event
)
792 if ( (ControlHandle
) m_macControl
)
795 wxMacPortSetter
helper(&dc
) ;
796 wxMacWindowClipper
clipper(this) ;
797 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
798 UMADrawControl( (ControlHandle
) m_macControl
) ;
805 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
807 wxWindow::OnEraseBackground( event
) ;
810 void wxControl::OnKeyDown( wxKeyEvent
&event
)
812 if ( (ControlHandle
) m_macControl
== NULL
)
821 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode
);
822 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
823 GetEventParameter((EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
825 ::HandleControlKey( (ControlHandle
) m_macControl
, keyCode
, charCode
, modifiers
) ;
828 EventRecord
*ev
= (EventRecord
*) wxTheApp
->MacGetCurrentEvent() ;
831 keychar
= short(ev
->message
& charCodeMask
);
832 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
834 ::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" ) ;