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
;
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
) ;
213 UMASetControlTitle( (ControlHandle
) m_macControl
, m_label
) ;
218 wxSize
wxControl::DoGetBestSize() const
220 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
221 short baselineoffset
;
222 int bestWidth
, bestHeight
;
223 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
225 if ( EmptyRect( &bestsize
) )
228 bestsize
.left
= bestsize
.top
= 0 ;
229 bestsize
.right
= 16 ;
230 bestsize
.bottom
= 16 ;
231 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
233 bestsize
.bottom
= 16 ;
235 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
237 bestsize
.bottom
= 24 ;
241 if ( IsKindOf( CLASSINFO( wxButton
) ) )
243 bestWidth
= m_label
.Length() * 8 + 12 ;
244 if ( bestWidth
< 70 )
247 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
249 bestWidth
= m_label
.Length() * 8 ;
252 bestWidth
= bestsize
.right
- bestsize
.left
;
254 bestWidth
+= 2 * m_macHorizontalBorder
;
256 bestHeight
= bestsize
.bottom
- bestsize
.top
;
257 if ( bestHeight
< 10 )
260 bestHeight
+= 2 * m_macVerticalBorder
;
263 return wxSize(bestWidth
, bestHeight
);
266 bool wxControl::ProcessCommand (wxCommandEvent
& event
)
269 // 1) A callback function (to become obsolete)
270 // 2) OnCommand, starting at this window and working up parent hierarchy
271 // 3) OnCommand then calls ProcessEvent to search the event tables.
272 #if WXWIN_COMPATIBILITY
275 (void)(*m_callback
)(this, event
);
280 #endif // WXWIN_COMPATIBILITY
282 return GetEventHandler()->ProcessEvent(event
);
286 // ------------------------
287 wxList
*wxWinMacControlList
= NULL
;
288 wxControl
*wxFindControlFromMacControl(ControlHandle inControl
)
290 wxNode
*node
= wxWinMacControlList
->Find((long)inControl
);
293 return (wxControl
*)node
->GetData();
296 void wxAssociateControlWithMacControl(ControlHandle inControl
, wxControl
*control
)
298 // adding NULL WindowRef is (first) surely a result of an error and
299 // (secondly) breaks menu command processing
300 wxCHECK_RET( inControl
!= (ControlHandle
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
302 if ( !wxWinMacControlList
->Find((long)inControl
) )
303 wxWinMacControlList
->Append((long)inControl
, control
);
306 void wxRemoveMacControlAssociation(wxControl
*control
)
308 wxWinMacControlList
->DeleteObject(control
);
311 void wxControl::MacPreControlCreate( wxWindow
*parent
, wxWindowID id
, wxString label
,
313 const wxSize
& size
, long style
,
314 const wxValidator
& validator
,
315 const wxString
& name
, WXRECTPTR outBounds
, unsigned char* maclabel
)
320 SetValidator(validator
);
322 m_windowStyle
= style
;
323 parent
->AddChild(this);
325 m_backgroundColour
= parent
->GetBackgroundColour() ;
326 m_foregroundColour
= parent
->GetForegroundColour() ;
329 m_windowId
= NewControlId();
333 // These sizes will be adjusted in MacPostControlCreate
340 ((Rect
*)outBounds
)->top
= -10;
341 ((Rect
*)outBounds
)->left
= -10;
342 ((Rect
*)outBounds
)->bottom
= 0;
343 ((Rect
*)outBounds
)->right
= 0;
345 wxMacStringToPascal( wxStripMenuCodes(label
) , maclabel
) ;
348 void wxControl::MacPostControlCreate()
350 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
352 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
356 else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox
) ) || IsKindOf( CLASSINFO( wxRadioBox
) ) || IsKindOf( CLASSINFO( wxButton
) ) ) )
358 ControlFontStyleRec controlstyle
;
359 controlstyle
.flags
= kControlUseFontMask
;
360 controlstyle
.font
= kControlFontSmallBoldSystemFont
;
362 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
366 ControlFontStyleRec controlstyle
;
367 controlstyle
.flags
= kControlUseFontMask
;
369 if (IsKindOf( CLASSINFO( wxButton
) ) )
370 controlstyle
.font
= kControlFontSmallSystemFont
; // eventually kControlFontBigSystemFont ;
372 controlstyle
.font
= kControlFontSmallSystemFont
;
374 ::SetControlFontStyle( (ControlHandle
) m_macControl
, &controlstyle
) ;
376 ControlHandle container
= (ControlHandle
) GetParent()->MacGetContainerForEmbedding() ;
377 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
378 ::EmbedControl( (ControlHandle
) m_macControl
, container
) ;
379 m_macControlIsShown
= true ;
381 wxAssociateControlWithMacControl( (ControlHandle
) m_macControl
, this ) ;
382 if ( wxMacSetupControlBackgroundUPP
== NULL
)
384 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
386 if ( wxMacControlActionUPP
== NULL
)
388 wxMacControlActionUPP
= NewControlDefUPP( wxMacControlDefinition
) ;
390 // The following block of code is responsible for crashes when switching
391 // back to windows, which can be seen in the dialogs sample.
392 // It is disabled until a proper solution can be found.
396 only working under classic carbon
397 m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
398 (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
401 m_macControlAction
= *(**(ControlHandle
)m_macControl
).contrlDefProc
;
404 cdef
= (cdefHandle
) NewHandle( sizeof(cdefRec
) ) ;
405 if ( (**(ControlHandle
)m_macControl
).contrlDefProc
!= NULL
)
407 (**cdef
).instruction
= 0x4EF9; /* JMP instruction */
408 (**cdef
).function
= (void(*)()) wxMacControlActionUPP
;
409 (**(ControlHandle
)m_macControl
).contrlDefProc
= (Handle
) cdef
;
413 SetControlColorProc( (ControlHandle
) m_macControl
, wxMacSetupControlBackgroundUPP
) ;
415 // Adjust the controls size and position
416 wxPoint
pos(m_x
, m_y
);
417 wxSize
best_size( DoGetBestSize() );
418 wxSize
new_size( m_width
, m_height
);
420 m_x
= m_y
= m_width
= m_height
= -1; // Forces SetSize to move/size the control
422 if (new_size
.x
== -1) {
423 new_size
.x
= best_size
.x
;
425 if (new_size
.y
== -1) {
426 new_size
.y
= best_size
.y
;
429 SetSize(pos
.x
, pos
.y
, new_size
.x
, new_size
.y
);
432 UMASetControlTitle( (ControlHandle
) m_macControl
, wxStripMenuCodes(m_label
) ) ;
435 UMAShowControl( (ControlHandle
) m_macControl
) ;
437 SetCursor( *wxSTANDARD_CURSOR
) ;
442 void wxControl::MacAdjustControlRect()
444 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
445 if ( m_width
== -1 || m_height
== -1 )
447 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
448 short baselineoffset
;
450 ::GetBestControlRect( (ControlHandle
) m_macControl
, &bestsize
, &baselineoffset
) ;
452 if ( EmptyRect( &bestsize
) )
455 bestsize
.left
= bestsize
.top
= 0 ;
456 bestsize
.right
= 16 ;
457 bestsize
.bottom
= 16 ;
458 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
460 bestsize
.bottom
= 16 ;
462 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
464 bestsize
.bottom
= 24 ;
470 if ( IsKindOf( CLASSINFO( wxButton
) ) )
472 m_width
= m_label
.Length() * 8 + 12 ;
476 else if ( IsKindOf( CLASSINFO( wxStaticText
) ) )
478 m_width
= m_label
.Length() * 8 ;
481 m_width
= bestsize
.right
- bestsize
.left
;
483 m_width
+= 2 * m_macHorizontalBorder
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
485 if ( m_height
== -1 )
487 m_height
= bestsize
.bottom
- bestsize
.top
;
491 m_height
+= 2 * m_macVerticalBorder
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
493 MacUpdateDimensions() ;
494 // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
498 WXWidget
wxControl::MacGetContainerForEmbedding()
501 return m_macControl
;
503 return wxWindow::MacGetContainerForEmbedding() ;
506 void wxControl::MacUpdateDimensions()
508 // actually in the current systems this should never be possible, but later reparenting
509 // may become a reality
511 if ( (ControlHandle
) m_macControl
== NULL
)
514 if ( GetParent() == NULL
)
517 WindowRef rootwindow
= (WindowRef
) MacGetRootWindow() ;
518 if ( rootwindow
== NULL
)
522 GetControlBounds( (ControlHandle
) m_macControl
, &oldBounds
) ;
524 int new_x
= m_x
+ MacGetLeftBorderSize() + m_macHorizontalBorder
;
525 int new_y
= m_y
+ MacGetTopBorderSize() + m_macVerticalBorder
;
526 int new_width
= m_width
- MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder
;
527 int new_height
= m_height
- MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder
;
529 GetParent()->MacWindowToRootWindow( & new_x
, & new_y
) ;
530 bool doMove
= new_x
!= oldBounds
.left
|| new_y
!= oldBounds
.top
;
531 bool doResize
= ( oldBounds
.right
- oldBounds
.left
) != new_width
|| (oldBounds
.bottom
- oldBounds
.top
) != new_height
;
532 if ( doMove
|| doResize
)
534 InvalWindowRect( rootwindow
, &oldBounds
) ;
537 UMAMoveControl( (ControlHandle
) m_macControl
, new_x
, new_y
) ;
541 UMASizeControl( (ControlHandle
) m_macControl
, new_width
, new_height
) ;
546 void wxControl::MacSuperChangedPosition()
548 MacUpdateDimensions() ;
549 wxWindow::MacSuperChangedPosition() ;
552 void wxControl::MacSuperEnabled( bool enabled
)
555 wxWindow::MacSuperEnabled( enabled
) ;
558 void wxControl::MacSuperShown( bool show
)
560 if ( (ControlHandle
) m_macControl
)
564 if ( m_macControlIsShown
)
566 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
567 m_macControlIsShown
= false ;
572 if ( MacIsReallyShown() && !m_macControlIsShown
)
574 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
575 m_macControlIsShown
= true ;
580 wxWindow::MacSuperShown( show
) ;
583 void wxControl::DoSetSize(int x
, int y
,
584 int width
, int height
,
587 wxWindow::DoSetSize( x
, y
,width
, height
,sizeFlags
) ;
590 Rect meta
, control
;
591 GetControlBounds( (ControlHandle
) m_macControl
, &control
) ;
592 RgnHandle rgn
= NewRgn() ;
593 GetControlRegion( (ControlHandle
) m_macControl
, kControlStructureMetaPart
, rgn
) ;
594 GetRegionBounds( rgn
, &meta
) ;
595 if ( !EmptyRect( &meta
) )
597 wxASSERT( meta
.left
>= control
.left
- m_macHorizontalBorder
) ;
598 wxASSERT( meta
.right
<= control
.right
+ m_macHorizontalBorder
) ;
599 wxASSERT( meta
.top
>= control
.top
- m_macVerticalBorder
) ;
600 wxASSERT( meta
.bottom
<= control
.bottom
+ m_macVerticalBorder
) ;
608 if ( (ControlHandle) m_macControl == NULL )
610 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
615 int new_x, new_y, new_width, new_height;
621 new_height = m_height;
623 if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
632 if (x != -1) new_x = x;
633 if (y != -1) new_y = y;
634 if (width != -1) new_width = width;
635 if (height != -1) new_height = height;
638 if(sizeFlags & wxSIZE_AUTO)
640 wxSize size = GetBestSize();
641 if (sizeFlags & wxSIZE_AUTO_WIDTH)
643 if (width == -1) new_width = size.x;
645 if (sizeFlags & wxSIZE_AUTO_HEIGHT)
647 if (height == -1) new_height = size.y;
650 AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
655 GetParent()->MacWindowToRootWindow(&mac_x, &mac_y);
657 GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
658 oldbounds.right = oldbounds.left + m_width;
659 oldbounds.bottom = oldbounds.top + m_height;
662 bool doResize = false;
664 if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
665 mac_y != (oldbounds.top - m_macVerticalBorder) )
669 if ( new_width != oldbounds.right - oldbounds.left - 2 * m_macHorizontalBorder ||
670 new_height != oldbounds.bottom - oldbounds.top - 2 * m_macVerticalBorder)
675 if ( doMove || doResize )
679 // Ensure resize is within constraints
680 if ((m_minWidth != -1) && (new_width < m_minWidth)) {
681 new_width = m_minWidth;
683 if ((m_minHeight != -1) && (new_height < m_minHeight)) {
684 new_height = m_minHeight;
686 if ((m_maxWidth != -1) && (new_width > m_maxWidth)) {
687 new_width = m_maxWidth;
689 if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
690 new_height = m_maxHeight;
698 UMAMoveControl( (ControlHandle) m_macControl,
699 mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
701 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
702 event.SetEventObject(this);
703 GetEventHandler()->ProcessEvent(event) ;
708 m_height = new_height;
710 UMASizeControl( (ControlHandle) m_macControl,
711 m_width - 2 * m_macHorizontalBorder,
712 m_height - 2 * m_macVerticalBorder ) ;
715 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
716 event.SetEventObject(this);
717 GetEventHandler()->ProcessEvent(event);
725 bool wxControl::Show(bool show
)
727 if ( !wxWindow::Show( show
) )
730 if ( (ControlHandle
) m_macControl
)
734 if ( m_macControlIsShown
)
736 ::UMAHideControl( (ControlHandle
) m_macControl
) ;
737 m_macControlIsShown
= false ;
742 if ( MacIsReallyShown() && !m_macControlIsShown
)
744 ::UMAShowControl( (ControlHandle
) m_macControl
) ;
745 m_macControlIsShown
= true ;
752 bool wxControl::Enable(bool enable
)
754 if ( !wxWindow::Enable(enable
) )
757 if ( (ControlHandle
) m_macControl
)
760 UMAActivateControl( (ControlHandle
) m_macControl
) ;
762 UMADeactivateControl( (ControlHandle
) m_macControl
) ;
767 void wxControl::Refresh(bool eraseBack
, const wxRect
*rect
)
769 wxWindow::Refresh( eraseBack
, rect
) ;
772 void wxControl::MacRedrawControl()
774 if ( (ControlHandle
) m_macControl
&& MacGetRootWindow() && m_macControlIsShown
)
776 wxClientDC
dc(this) ;
777 wxMacPortSetter
helper(&dc
) ;
778 wxMacWindowClipper
clipper(this) ;
779 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
780 UMADrawControl( (ControlHandle
) m_macControl
) ;
784 void wxControl::OnPaint(wxPaintEvent
& event
)
786 if ( (ControlHandle
) m_macControl
)
789 wxMacPortSetter
helper(&dc
) ;
790 wxMacWindowClipper
clipper(this) ;
791 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
792 UMADrawControl( (ControlHandle
) m_macControl
) ;
799 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
801 wxWindow::OnEraseBackground( event
) ;
804 void wxControl::OnKeyDown( wxKeyEvent
&event
)
806 if ( (ControlHandle
) m_macControl
== NULL
)
815 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode
);
816 GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
817 GetEventParameter((EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
819 ::HandleControlKey( (ControlHandle
) m_macControl
, keyCode
, charCode
, modifiers
) ;
822 EventRecord
*ev
= (EventRecord
*) wxTheApp
->MacGetCurrentEvent() ;
825 keychar
= short(ev
->message
& charCodeMask
);
826 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
828 ::HandleControlKey( (ControlHandle
) m_macControl
, keycode
, keychar
, ev
->modifiers
) ;
832 void wxControl::OnMouseEvent( wxMouseEvent
&event
)
834 if ( (ControlHandle
) m_macControl
== NULL
)
840 if (event
.GetEventType() == wxEVT_LEFT_DOWN
|| event
.GetEventType() == wxEVT_LEFT_DCLICK
)
846 MacClientToRootWindow( &x
, &y
) ;
848 ControlHandle control
;
857 if ( !event
.m_leftDown
&& !event
.m_rightDown
)
858 modifiers
|= btnState
;
860 if ( event
.m_shiftDown
)
861 modifiers
|= shiftKey
;
863 if ( event
.m_controlDown
)
864 modifiers
|= controlKey
;
866 if ( event
.m_altDown
)
867 modifiers
|= optionKey
;
869 if ( event
.m_metaDown
)
870 modifiers
|= cmdKey
;
872 control
= (ControlHandle
) m_macControl
;
873 if ( control
&& ::IsControlActive( control
) )
876 controlpart
= ::HandleControlClick( control
, localwhere
, modifiers
, (ControlActionUPP
) -1 ) ;
877 wxTheApp
->s_lastMouseDown
= 0 ;
878 if ( control
&& controlpart
!= kControlNoPart
)
880 MacHandleControlClick( control
, controlpart
, false /* mouse not down anymore */ ) ;
892 bool wxControl::MacCanFocus() const
894 if ( (ControlHandle
) m_macControl
== NULL
)
900 void wxControl::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
902 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;