1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/mac/classic/control.cpp 
   3 // Purpose:     wxControl class 
   4 // Author:      Stefan Csomor 
   8 // Copyright:   (c) Stefan Csomor 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 #include "wx/wxprec.h" 
  18 #include "wx/control.h" 
  24     #include "wx/dcclient.h" 
  25     #include "wx/button.h" 
  26     #include "wx/dialog.h" 
  27     #include "wx/scrolbar.h" 
  28     #include "wx/stattext.h" 
  29     #include "wx/statbox.h" 
  30     #include "wx/radiobox.h" 
  33 #include "wx/notebook.h" 
  34 #include "wx/tabctrl.h" 
  35 #include "wx/spinbutt.h" 
  38 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
) 
  40 BEGIN_EVENT_TABLE(wxControl
, wxWindow
) 
  41     EVT_MOUSE_EVENTS( wxControl::OnMouseEvent 
) 
  42     EVT_PAINT( wxControl::OnPaint 
) 
  45 #include "wx/mac/uma.h" 
  46 #include "wx/mac/private.h" 
  51 #if PRAGMA_STRUCT_ALIGN 
  52     #pragma options align=mac68k 
  53 #elif PRAGMA_STRUCT_PACKPUSH 
  55 #elif PRAGMA_STRUCT_PACK 
  60  unsigned short instruction
; 
  62 } cdefRec
, *cdefPtr
, **cdefHandle
; 
  64 #if PRAGMA_STRUCT_ALIGN 
  65     #pragma options align=reset 
  66 #elif PRAGMA_STRUCT_PACKPUSH 
  68 #elif PRAGMA_STRUCT_PACK 
  72 ControlActionUPP wxMacLiveScrollbarActionUPP 
= NULL 
; 
  73 wxControl 
*wxFindControlFromMacControl(ControlHandle inControl 
) ; 
  75 pascal void wxMacLiveScrollbarActionProc( ControlHandle control 
, ControlPartCode partCode 
) ; 
  76 pascal void wxMacLiveScrollbarActionProc( ControlHandle control 
, ControlPartCode partCode 
) 
  80         wxControl
*  wx 
= (wxControl
*) GetControlReference( control 
) ; 
  83             wx
->MacHandleControlClick( (WXWidget
) control 
, partCode 
, true /* stillDown */ ) ; 
  88 ControlColorUPP wxMacSetupControlBackgroundUPP 
= NULL 
; 
  89 ControlDefUPP wxMacControlActionUPP 
= NULL 
; 
  91 pascal SInt32  
wxMacControlDefinition(SInt16 varCode
, ControlRef theControl
, ControlDefProcMessage message
, SInt32 param
) 
  94     wxControl
*  wx 
= (wxControl
*) wxFindControlFromMacControl( theControl 
) ; 
  95     if ( wx 
!= NULL 
&& wx
->IsKindOf( CLASSINFO( wxControl 
) ) ) 
  97         if( message 
== drawCntl 
) 
  99             wxMacWindowClipper 
clip( wx 
) ; 
 100             return InvokeControlDefUPP( varCode 
, theControl 
, message 
, param 
, (ControlDefUPP
) wx
->MacGetControlAction() ) ; 
 103             return InvokeControlDefUPP( varCode 
, theControl 
, message 
, param 
, (ControlDefUPP
) wx
->MacGetControlAction() ) ; 
 108 pascal OSStatus 
wxMacSetupControlBackground( ControlRef iControl 
, SInt16 iMessage 
, SInt16 iDepth 
, Boolean iIsColor 
) 
 110     OSStatus status 
= noErr 
; 
 113         case kControlMsgSetUpBackground 
: 
 115                 wxControl
*  wx 
= (wxControl
*) GetControlReference( iControl 
) ; 
 116                 if ( wx 
!= NULL 
&& wx
->IsKindOf( CLASSINFO( wxControl 
) ) ) 
 118                     wxDC::MacSetupBackgroundForCurrentPort( wx
->MacGetBackgroundBrush() ) ; 
 120                     // under classic this would lead to partial redraws 
 121                     RgnHandle clip 
= NewRgn() ; 
 124                     wx
->MacWindowToRootWindow( &x
,&y 
) ; 
 125                     CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion(false).GetWXHRGN() , clip 
) ; 
 126                     OffsetRgn( clip 
, x 
, y 
) ; 
 144 wxControl::wxControl() 
 146     m_macControl 
= NULL 
; 
 147     m_macControlAction 
= NULL 
; 
 148     m_macHorizontalBorder 
= 0 ; // additional pixels around the real control 
 149     m_macVerticalBorder 
= 0 ; 
 150     m_backgroundColour 
= *wxWHITE
; 
 151     m_foregroundColour 
= *wxBLACK
; 
 153     if ( wxMacLiveScrollbarActionUPP 
== NULL 
) 
 155 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) 
 156         wxMacLiveScrollbarActionUPP 
= NewControlActionUPP( wxMacLiveScrollbarActionProc 
); 
 158         wxMacLiveScrollbarActionUPP 
= NewControlActionProc( wxMacLiveScrollbarActionProc 
) ; 
 163 bool wxControl::Create(wxWindow 
*parent
, wxWindowID id
, 
 165                        const wxSize
& size
, long style
, 
 166                        const wxValidator
& validator
, 
 167                        const wxString
& name
) 
 169     m_macControl 
= NULL 
; 
 170     m_macHorizontalBorder 
= 0 ; // additional pixels around the real control 
 171     m_macVerticalBorder 
= 0 ; 
 173     bool rval 
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
); 
 176         m_backgroundColour 
= parent
->GetBackgroundColour() ; 
 177         m_foregroundColour 
= parent
->GetForegroundColour() ; 
 181         SetValidator(validator
); 
 187 wxControl::~wxControl() 
 189     m_isBeingDeleted 
= true; 
 190     wxRemoveMacControlAssociation( this ) ; 
 191     // If we delete an item, we should initialize the parent panel, 
 192     // because it could now be invalid. 
 193     wxWindow 
*parent 
= GetParent() ; 
 196         if (parent
->GetDefaultItem() == (wxButton
*) this) 
 197             parent
->SetDefaultItem(NULL
); 
 199     if ( (ControlHandle
) m_macControl 
) 
 201         // in case the callback might be called during destruction 
 202         ::SetControlColorProc( (ControlHandle
) m_macControl 
, NULL 
) ; 
 203         ::DisposeControl( (ControlHandle
) m_macControl 
) ; 
 204         m_macControl 
= NULL 
; 
 208 void wxControl::SetLabel(const wxString
& title
) 
 210     m_label 
= wxStripMenuCodes(title
) ; 
 214         UMASetControlTitle( (ControlHandle
) m_macControl 
, m_label 
, m_font
.GetEncoding() ) ; 
 219 wxSize 
wxControl::DoGetBestSize() const 
 221     if ( (ControlHandle
) m_macControl 
== NULL 
) 
 222         return wxWindow::DoGetBestSize() ; 
 224     Rect    bestsize 
= { 0 , 0 , 0 , 0 } ; 
 225     short   baselineoffset 
; 
 226     int bestWidth
, bestHeight 
; 
 227     ::GetBestControlRect( (ControlHandle
) m_macControl 
, &bestsize 
, &baselineoffset 
) ; 
 229     if ( EmptyRect( &bestsize 
) ) 
 232         bestsize
.left 
= bestsize
.top 
= 0 ; 
 233         bestsize
.right 
= 16 ; 
 234         bestsize
.bottom 
= 16 ; 
 235         if ( IsKindOf( CLASSINFO( wxScrollBar 
) ) ) 
 237             bestsize
.bottom 
= 16 ; 
 239         else if ( IsKindOf( CLASSINFO( wxSpinButton 
) ) ) 
 241             bestsize
.bottom 
= 24 ; 
 245     bestWidth 
= bestsize
.right 
- bestsize
.left 
; 
 247     bestWidth 
+= 2 * m_macHorizontalBorder 
; 
 249     bestHeight 
= bestsize
.bottom 
- bestsize
.top 
; 
 250     if ( bestHeight 
< 10 ) 
 253     bestHeight 
+= 2 * m_macVerticalBorder
; 
 256     return wxSize(bestWidth
, bestHeight
); 
 259 bool wxControl::ProcessCommand (wxCommandEvent 
& event
) 
 262     // 1) OnCommand, starting at this window and working up parent hierarchy 
 263     // 2) OnCommand then calls ProcessEvent to search the event tables. 
 264     return GetEventHandler()->ProcessEvent(event
); 
 267 // ------------------------ 
 268 wxList 
*wxWinMacControlList 
= NULL
; 
 269 wxControl 
*wxFindControlFromMacControl(ControlHandle inControl 
) 
 271     wxNode 
*node 
= wxWinMacControlList
->Find((long)inControl
); 
 274     return (wxControl 
*)node
->GetData(); 
 277 void wxAssociateControlWithMacControl(ControlHandle inControl
, wxControl 
*control
) 
 279     // adding NULL WindowRef is (first) surely a result of an error and 
 280     // (secondly) breaks menu command processing 
 281     wxCHECK_RET( inControl 
!= (ControlHandle
) NULL
, wxT("attempt to add a NULL WindowRef to window list") ); 
 283     if ( !wxWinMacControlList
->Find((long)inControl
) ) 
 284         wxWinMacControlList
->Append((long)inControl
, control
); 
 287 void wxRemoveMacControlAssociation(wxControl 
*control
) 
 289     if ( wxWinMacControlList 
) 
 290         wxWinMacControlList
->DeleteObject(control
); 
 293 void wxControl::MacPreControlCreate( wxWindow 
*parent
, wxWindowID id
, wxString label 
, 
 295              const wxSize
& size
, long style
, 
 296              const wxValidator
& validator
, 
 297              const wxString
& name 
, WXRECTPTR outBounds 
, unsigned char* maclabel 
) 
 301     // These sizes will be adjusted in MacPostControlCreate 
 307     ((Rect
*)outBounds
)->top 
= -10; 
 308     ((Rect
*)outBounds
)->left 
= -10; 
 309     ((Rect
*)outBounds
)->bottom 
= 0; 
 310     ((Rect
*)outBounds
)->right 
= 0; 
 312     wxMacStringToPascal( wxStripMenuCodes(label
) , maclabel 
) ; 
 315 void wxControl::MacPostControlCreate() 
 317     wxASSERT_MSG( (ControlHandle
) m_macControl 
!= NULL 
, wxT("No valid mac control") ) ; 
 318     DoSetWindowVariant( m_windowVariant 
) ; 
 320     if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) 
 324     else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) ) ) 
 326         ControlFontStyleRec     controlstyle ; 
 327         controlstyle.flags = kControlUseFontMask ; 
 328         controlstyle.font = kControlFontSmallBoldSystemFont ; 
 330         ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; 
 334         ControlFontStyleRec     controlstyle ; 
 335         controlstyle.flags = kControlUseFontMask ; 
 337         if (IsKindOf( CLASSINFO( wxButton ) ) ) 
 338             controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ; 
 340             controlstyle.font = kControlFontSmallSystemFont ; 
 342         ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; 
 345     ControlHandle container 
= (ControlHandle
) GetParent()->MacGetContainerForEmbedding() ; 
 346     wxASSERT_MSG( container 
!= NULL 
, wxT("No valid mac container control") ) ; 
 347     ::EmbedControl( (ControlHandle
) m_macControl 
, container 
) ; 
 348     m_macControlIsShown  
= MacIsReallyShown() ; 
 350     wxAssociateControlWithMacControl( (ControlHandle
) m_macControl 
, this ) ; 
 351     if ( wxMacSetupControlBackgroundUPP 
== NULL 
) 
 353         wxMacSetupControlBackgroundUPP 
= NewControlColorUPP( wxMacSetupControlBackground 
) ; 
 355     if ( wxMacControlActionUPP 
== NULL 
) 
 357         wxMacControlActionUPP 
= NewControlDefUPP( wxMacControlDefinition 
) ; 
 359     // The following block of code is responsible for crashes when switching 
 360     // back to windows, which can be seen in the dialogs sample. 
 361     // It is disabled until a proper solution can be found. 
 365     only working under classic carbon 
 366     m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ; 
 367     (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ; 
 370     m_macControlAction 
= *(**(ControlHandle
)m_macControl
).contrlDefProc 
; 
 373     cdef 
= (cdefHandle
) NewHandle( sizeof(cdefRec
) ) ; 
 374     if (  (**(ControlHandle
)m_macControl
).contrlDefProc 
!= NULL 
) 
 376         (**cdef
).instruction 
= 0x4EF9;  /* JMP instruction */ 
 377         (**cdef
).function 
= (void(*)()) wxMacControlActionUPP
; 
 378         (**(ControlHandle
)m_macControl
).contrlDefProc 
= (Handle
) cdef 
; 
 382     SetControlColorProc( (ControlHandle
) m_macControl 
, wxMacSetupControlBackgroundUPP 
) ; 
 384     // Adjust the controls size and position 
 385     wxPoint 
pos(m_x
, m_y
); 
 386     wxSize 
best_size( DoGetBestSize() ); 
 387     wxSize 
new_size( m_width
, m_height 
); 
 389     m_x 
= m_y 
= m_width 
= m_height 
= -1;  // Forces SetSize to move/size the control 
 391     if (new_size
.x 
== -1) { 
 392         new_size
.x 
= best_size
.x
; 
 394     if (new_size
.y 
== -1) { 
 395         new_size
.y 
= best_size
.y
; 
 398     SetSize(pos
.x
, pos
.y
, new_size
.x
, new_size
.y
); 
 401     UMASetControlTitle( (ControlHandle
) m_macControl 
, wxStripMenuCodes(m_label
) , m_font
.GetEncoding() ) ; 
 404     if ( m_macControlIsShown 
) 
 405         UMAShowControl( (ControlHandle
) m_macControl 
) ; 
 407     SetCursor( *wxSTANDARD_CURSOR 
) ; 
 412 void wxControl::MacAdjustControlRect() 
 414     wxASSERT_MSG( (ControlHandle
) m_macControl 
!= NULL 
, wxT("No valid mac control") ) ; 
 415     if ( m_width 
== -1 || m_height 
== -1 ) 
 417         Rect    bestsize 
= { 0 , 0 , 0 , 0 } ; 
 418         short   baselineoffset 
; 
 420         ::GetBestControlRect( (ControlHandle
) m_macControl 
, &bestsize 
, &baselineoffset 
) ; 
 422         if ( EmptyRect( &bestsize 
) ) 
 425             bestsize
.left 
= bestsize
.top 
= 0 ; 
 426             bestsize
.right 
= 16 ; 
 427             bestsize
.bottom 
= 16 ; 
 428             if ( IsKindOf( CLASSINFO( wxScrollBar 
) ) ) 
 430                 bestsize
.bottom 
= 16 ; 
 432             else if ( IsKindOf( CLASSINFO( wxSpinButton 
) ) ) 
 434                 bestsize
.bottom 
= 24 ; 
 440             if ( IsKindOf( CLASSINFO( wxButton 
) ) ) 
 442                 m_width 
= m_label
.length() * 8 + 12 ; 
 446             else if ( IsKindOf( CLASSINFO( wxStaticText 
) ) ) 
 448                 m_width 
= m_label
.length() * 8 ; 
 451                 m_width 
= bestsize
.right 
- bestsize
.left 
; 
 453             m_width 
+= 2 * m_macHorizontalBorder 
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ; 
 455         if ( m_height 
== -1 ) 
 457             m_height 
= bestsize
.bottom 
- bestsize
.top 
; 
 461             m_height 
+= 2 * m_macVerticalBorder 
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ; 
 463         MacUpdateDimensions() ; 
 467 WXWidget 
wxControl::MacGetContainerForEmbedding() 
 470         return m_macControl 
; 
 472     return wxWindow::MacGetContainerForEmbedding() ; 
 475 void wxControl::MacUpdateDimensions() 
 477     // actually in the current systems this should never be possible, but later reparenting 
 478     // may become a reality 
 480     if ( (ControlHandle
) m_macControl 
== NULL 
) 
 483     if ( GetParent() == NULL 
) 
 486     WindowRef rootwindow 
= (WindowRef
) MacGetRootWindow() ; 
 487     if ( rootwindow 
== NULL 
) 
 491     GetControlBounds( (ControlHandle
) m_macControl 
, &oldBounds 
) ; 
 493     int new_x 
= m_x 
+ MacGetLeftBorderSize() + m_macHorizontalBorder 
; 
 494     int new_y 
= m_y 
+ MacGetTopBorderSize() + m_macVerticalBorder 
; 
 495     int new_width 
= m_width 
- MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder 
; 
 496     int new_height 
= m_height 
- MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder 
; 
 498     GetParent()->MacWindowToRootWindow( & new_x 
, & new_y 
) ; 
 499     bool doMove 
= new_x 
!= oldBounds
.left 
|| new_y 
!= oldBounds
.top 
; 
 500     bool doResize 
=  ( oldBounds
.right 
- oldBounds
.left 
) != new_width 
|| (oldBounds
.bottom 
- oldBounds
.top 
) != new_height 
; 
 501     if ( doMove 
|| doResize 
) 
 503         InvalWindowRect( rootwindow
, &oldBounds 
) ; 
 506             UMAMoveControl( (ControlHandle
) m_macControl 
, new_x 
, new_y 
) ; 
 510             UMASizeControl( (ControlHandle
) m_macControl 
, new_width 
, new_height 
) ; 
 515 void wxControl::MacSuperChangedPosition() 
 517      MacUpdateDimensions() ; 
 518     wxWindow::MacSuperChangedPosition() ; 
 521 void wxControl::MacSuperEnabled( bool enabled 
) 
 524     wxWindow::MacSuperEnabled( enabled 
) ; 
 527 void wxControl::MacSuperShown( bool show 
) 
 529     if ( (ControlHandle
) m_macControl 
) 
 533             if ( m_macControlIsShown 
) 
 535                 ::UMAHideControl( (ControlHandle
) m_macControl 
) ; 
 536                 m_macControlIsShown 
= false ; 
 541             if ( MacIsReallyShown() && !m_macControlIsShown 
) 
 543                 ::UMAShowControl( (ControlHandle
) m_macControl 
) ; 
 544                 m_macControlIsShown 
= true ; 
 549     wxWindow::MacSuperShown( show 
) ; 
 552 void  wxControl::DoSetSize(int x
, int y
, 
 553             int width
, int height
, 
 556     wxWindow::DoSetSize( x 
, y 
,width 
, height 
,sizeFlags 
) ; 
 559         Rect meta 
, control 
; 
 560         GetControlBounds( (ControlHandle
) m_macControl 
, &control 
) ; 
 561         RgnHandle rgn 
= NewRgn() ; 
 562         GetControlRegion( (ControlHandle
) m_macControl 
, kControlStructureMetaPart 
, rgn 
) ; 
 563         GetRegionBounds( rgn 
, &meta 
) ; 
 564         if ( !EmptyRect( &meta 
) ) 
 566             wxASSERT( meta
.left 
>= control
.left 
- m_macHorizontalBorder 
) ; 
 567             wxASSERT( meta
.right 
<= control
.right 
+ m_macHorizontalBorder 
) ; 
 568             wxASSERT( meta
.top 
>= control
.top 
- m_macVerticalBorder 
) ; 
 569             wxASSERT( meta
.bottom 
<= control
.bottom 
+ m_macVerticalBorder 
) ; 
 577 bool  wxControl::Show(bool show
) 
 579     if ( !wxWindow::Show( show 
) ) 
 582     if ( (ControlHandle
) m_macControl 
) 
 586             if ( m_macControlIsShown 
) 
 588                 ::UMAHideControl( (ControlHandle
) m_macControl 
) ; 
 589                 m_macControlIsShown 
= false ; 
 594             if ( MacIsReallyShown() && !m_macControlIsShown 
) 
 596                 ::UMAShowControl( (ControlHandle
) m_macControl 
) ; 
 597                 m_macControlIsShown 
= true ; 
 604 bool  wxControl::Enable(bool enable
) 
 606     if ( !wxWindow::Enable(enable
) ) 
 609     if ( (ControlHandle
) m_macControl 
) 
 612             UMAActivateControl( (ControlHandle
) m_macControl 
) ; 
 614             UMADeactivateControl( (ControlHandle
) m_macControl 
) ; 
 619 void wxControl::Refresh(bool eraseBack
, const wxRect 
*rect
) 
 621     wxWindow::Refresh( eraseBack 
, rect 
) ; 
 624 void wxControl::MacRedrawControl() 
 626     if ( (ControlHandle
) m_macControl 
&& MacGetRootWindow() && m_macControlIsShown 
) 
 628         wxClientDC 
dc(this) ; 
 629         wxMacPortSetter 
helper(&dc
) ; 
 630         wxMacWindowClipper 
clipper(this) ; 
 631         wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; 
 632         UMADrawControl( (ControlHandle
) m_macControl 
) ; 
 636 void wxControl::OnPaint(wxPaintEvent
& event
) 
 638     if ( (ControlHandle
) m_macControl 
) 
 641         wxMacPortSetter 
helper(&dc
) ; 
 642         wxMacWindowClipper 
clipper(this) ; 
 643         wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; 
 644         UMADrawControl( (ControlHandle
) m_macControl 
) ; 
 651 void wxControl::OnEraseBackground(wxEraseEvent
& event
) 
 653     wxWindow::OnEraseBackground( event 
) ; 
 656 void  wxControl::OnKeyDown( wxKeyEvent 
&event 
) 
 658     if ( (ControlHandle
) m_macControl 
== NULL 
) 
 667     GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode 
); 
 668     GetEventParameter( (EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyCode
, typeUInt32
, NULL
,  sizeof(UInt32
), NULL
, &keyCode 
); 
 669        GetEventParameter((EventRef
) wxTheApp
->MacGetCurrentEvent(), kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
); 
 671     ::HandleControlKey( (ControlHandle
) m_macControl 
, keyCode 
, charCode 
, modifiers 
) ; 
 674     EventRecord 
*ev 
= (EventRecord
*) wxTheApp
->MacGetCurrentEvent() ; 
 677     keychar 
= short(ev
->message 
& charCodeMask
); 
 678     keycode 
= short(ev
->message 
& keyCodeMask
) >> 8 ; 
 680     ::HandleControlKey( (ControlHandle
) m_macControl 
, keycode 
, keychar 
, ev
->modifiers 
) ; 
 684 void  wxControl::OnMouseEvent( wxMouseEvent 
&event 
) 
 686     if ( (ControlHandle
) m_macControl 
== NULL 
) 
 692     if (event
.GetEventType() == wxEVT_LEFT_DOWN 
|| event
.GetEventType() == wxEVT_LEFT_DCLICK 
) 
 698         MacClientToRootWindow( &x 
, &y 
) ; 
 700         ControlHandle   control 
; 
 709         if ( !event
.m_leftDown 
&& !event
.m_rightDown 
) 
 710             modifiers  
|= btnState 
; 
 712         if ( event
.m_shiftDown 
) 
 713             modifiers 
|= shiftKey 
; 
 715         if ( event
.m_controlDown 
) 
 716             modifiers 
|= controlKey 
; 
 718         if ( event
.m_altDown 
) 
 719             modifiers 
|= optionKey 
; 
 721         if ( event
.m_metaDown 
) 
 722             modifiers 
|= cmdKey 
; 
 724             control 
= (ControlHandle
) m_macControl 
; 
 725             if ( control 
&& ::IsControlActive( control 
) ) 
 728                     controlpart 
= ::HandleControlClick( control 
, localwhere 
, modifiers 
, (ControlActionUPP
) -1 ) ; 
 729                     wxTheApp
->s_lastMouseDown 
= 0 ; 
 730                     if ( control 
&& controlpart 
!= kControlNoPart 
) 
 732                         MacHandleControlClick( (WXWidget
) control 
, controlpart 
, false /* mouse not down anymore */ ) ; 
 744 bool wxControl::MacCanFocus() const 
 746     if ( (ControlHandle
) m_macControl 
== NULL 
) 
 752 void wxControl::MacHandleControlClick( WXWidget control 
, wxInt16 controlpart 
, bool WXUNUSED( mouseStillDown 
) ) 
 754     wxASSERT_MSG( (ControlHandle
) m_macControl 
!= NULL 
, wxT("No valid mac control") ) ; 
 757 void wxControl::DoSetWindowVariant( wxWindowVariant variant 
) 
 759     if ( m_macControl 
== NULL 
) 
 761         wxWindow::SetWindowVariant( variant 
) ; 
 765     m_windowVariant 
= variant 
; 
 768     ControlFontStyleRec fontStyle
; 
 769     fontStyle
.flags 
= kControlUseFontMask  
; 
 771     // we will get that from the settings later 
 772     // and make this NORMAL later, but first 
 773     // we have a few calculations that we must fix 
 775     if ( variant 
== wxWINDOW_VARIANT_NORMAL 
) 
 777         if ( IsKindOf( CLASSINFO( wxScrollBar 
) ) ) 
 778             variant  
= wxWINDOW_VARIANT_NORMAL 
; 
 780             variant 
= wxWINDOW_VARIANT_SMALL 
; 
 785         case wxWINDOW_VARIANT_NORMAL 
: 
 786             size 
= kControlSizeNormal
; 
 787             fontStyle
.font 
= kControlFontBigSystemFont
; 
 789         case wxWINDOW_VARIANT_SMALL 
: 
 790             size 
= kControlSizeSmall
; 
 791             fontStyle
.font 
= kControlFontSmallSystemFont
; 
 793         case wxWINDOW_VARIANT_MINI 
: 
 794            if (UMAGetSystemVersion() >= 0x1030 ) 
 796                 size 
= 3 ; // not always defined in the header 
 797                 fontStyle
.font 
= -5 ; // not always defined in the header 
 801                 size 
= kControlSizeSmall
; 
 802                 fontStyle
.font 
= kControlFontSmallSystemFont
; 
 806         case wxWINDOW_VARIANT_LARGE 
: 
 807             size 
= kControlSizeLarge
; 
 808             fontStyle
.font 
= kControlFontBigSystemFont
; 
 811             wxFAIL_MSG(_T("unexpected window variant")); 
 814     ::SetControlData( (ControlHandle
) m_macControl 
, kControlEntireControl
, kControlSizeTag
, sizeof( ControlSize 
), &size 
); 
 815     ::SetControlFontStyle( (ControlHandle
) m_macControl 
, &fontStyle 
);