1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxWindowMac 
   4 // Author:      Stefan Csomor 
   8 // Copyright:   (c) Stefan Csomor 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "window.h" 
  18 #include "wx/window.h" 
  20 #include "wx/dcclient.h" 
  24 #include "wx/layout.h" 
  25 #include "wx/dialog.h" 
  26 #include "wx/scrolbar.h" 
  27 #include "wx/statbox.h" 
  28 #include "wx/button.h" 
  29 #include "wx/settings.h" 
  30 #include "wx/msgdlg.h" 
  32 #include "wx/tooltip.h" 
  33 #include "wx/statusbr.h" 
  34 #include "wx/menuitem.h" 
  35 #include "wx/spinctrl.h" 
  37 #include "wx/geometry.h" 
  39 #include "wx/toolbar.h" 
  46 #define wxWINDOW_HSCROLL 5998 
  47 #define wxWINDOW_VSCROLL 5997 
  48 #define MAC_SCROLLBAR_SIZE 16 
  50 #include "wx/mac/uma.h" 
  53 #include <ToolUtils.h> 
  56 #if TARGET_API_MAC_OSX 
  58         #include <HIToolbox/HIView.h> 
  62 #if  wxUSE_DRAG_AND_DROP 
  68 extern wxList wxPendingDelete
; 
  70 #ifdef __WXUNIVERSAL__ 
  71     IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
) 
  73     IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
) 
  74 #endif // __WXUNIVERSAL__/__WXMAC__ 
  76 #if !USE_SHARED_LIBRARY 
  78 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
) 
  79     EVT_NC_PAINT(wxWindowMac::OnNcPaint
) 
  80     EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
) 
  81 // TODO    EVT_PAINT(wxWindowMac::OnPaint) 
  82     EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged
) 
  83     EVT_INIT_DIALOG(wxWindowMac::OnInitDialog
) 
  84 //    EVT_SET_FOCUS(wxWindowMac::OnSetFocus) 
  85     EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent
) 
  90 #define wxMAC_DEBUG_REDRAW 0 
  91 #ifndef wxMAC_DEBUG_REDRAW 
  92 #define wxMAC_DEBUG_REDRAW 0 
  95 #define wxMAC_USE_THEME_BORDER 0 
  97 // --------------------------------------------------------------------------- 
  99 // --------------------------------------------------------------------------- 
 101 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ; 
 102 pascal OSStatus 
wxMacSetupControlBackground( ControlRef iControl 
, SInt16 iMessage 
, SInt16 iDepth 
, Boolean iIsColor 
) ; 
 104 #if TARGET_API_MAC_OSX 
 106 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3  
 108   kEventControlVisibilityChanged 
= 157 
 114 static const EventTypeSpec eventList
[] = 
 116     { kEventClassControl 
, kEventControlHit 
} , 
 117 #if TARGET_API_MAC_OSX 
 118     { kEventClassControl 
, kEventControlDraw 
} , 
 119     { kEventClassControl 
, kEventControlVisibilityChanged 
} , 
 120     { kEventClassControl 
, kEventControlEnabledStateChanged 
} , 
 121     { kEventClassControl 
, kEventControlHiliteChanged 
} , 
 122     { kEventClassControl 
, kEventControlSetFocusPart 
} , 
 123 //      { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only 
 124 //  { kEventClassControl , kEventControlBoundsChanged } , 
 128 static pascal OSStatus 
wxMacWindowControlEventHandler( EventHandlerCallRef handler 
, EventRef event 
, void *data 
) 
 130     OSStatus result 
= eventNotHandledErr 
; 
 132     wxMacCarbonEvent 
cEvent( event 
) ; 
 134     ControlRef controlRef 
; 
 135     wxWindowMac
* thisWindow 
= (wxWindowMac
*) data 
; 
 137     cEvent
.GetParameter( kEventParamDirectObject 
, &controlRef 
) ; 
 139     switch( GetEventKind( event 
) ) 
 141 #if TARGET_API_MAC_OSX 
 142         case kEventControlDraw 
: 
 144                 RgnHandle updateRgn 
= NULL 
; 
 146                 wxRegion visRegion 
= thisWindow
->MacGetVisibleRegion() ; 
 147                 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr 
)  
 149                     updateRgn 
= (RgnHandle
) visRegion
.GetWXHRGN() ; 
 151                 // GrafPtr myport = cEvent.GetParameter<GrafPtr>(kEventParamGrafPort,typeGrafPtr) ; 
 154               // in case we would need a coregraphics compliant background erase first 
 155                 // now usable to track redraws 
 156                 CGContextRef cgContext 
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ; 
 157                 if ( thisWindow
->MacIsUserPane() ) 
 159                     static float color 
= 0.5 ; 
 162                         HIViewGetBounds( controlRef
, &bounds 
); 
 163                                     CGContextSetRGBFillColor( cgContext
, channel 
== 0 ? color 
: 0.5 ,  
 164                                         channel 
== 1 ? color 
: 0.5 , channel 
== 2 ? color 
: 0.5 , 1 ); 
 165                                     CGContextFillRect( cgContext
, bounds 
); 
 176                 if ( thisWindow
->MacDoRedraw( updateRgn 
, cEvent
.GetTicks() ) ) 
 180         case kEventControlVisibilityChanged 
: 
 181                 thisWindow
->MacVisibilityChanged() ; 
 183         case kEventControlEnabledStateChanged 
: 
 184                 thisWindow
->MacEnabledStateChanged() ; 
 186         case kEventControlHiliteChanged 
: 
 187                 thisWindow
->MacHiliteChanged() ; 
 189         case kEventControlSetFocusPart 
: 
 191                 Boolean focusEverything 
= false ; 
 192                 ControlPartCode controlPart 
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart 
, typeControlPartCode 
); 
 193                 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything 
, &focusEverything 
) == noErr 
) 
 196                 if ( controlPart 
== kControlFocusNoPart 
) 
 199                     if ( thisWindow
->GetCaret() ) 
 201                         thisWindow
->GetCaret()->OnKillFocus(); 
 203         #endif // wxUSE_CARET 
 204                     wxFocusEvent 
event(wxEVT_KILL_FOCUS
, thisWindow
->GetId()); 
 205                     event
.SetEventObject(thisWindow
); 
 206                     thisWindow
->GetEventHandler()->ProcessEvent(event
) ; 
 210                     // panel wants to track the window which was the last to have focus in it 
 211                     wxChildFocusEvent 
eventFocus(thisWindow
); 
 212                     thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
); 
 215                     if ( thisWindow
->GetCaret() ) 
 217                         thisWindow
->GetCaret()->OnSetFocus(); 
 219         #endif // wxUSE_CARET 
 221                     wxFocusEvent 
event(wxEVT_SET_FOCUS
, thisWindow
->GetId()); 
 222                     event
.SetEventObject(thisWindow
); 
 223                     thisWindow
->GetEventHandler()->ProcessEvent(event
) ; 
 228         case kEventControlHit 
: 
 230                 result 
= thisWindow
->MacControlHit( handler 
, event 
) ; 
 239 pascal OSStatus 
wxMacWindowEventHandler( EventHandlerCallRef handler 
, EventRef event 
, void *data 
) 
 241     OSStatus result 
= eventNotHandledErr 
; 
 243     switch ( GetEventClass( event 
) ) 
 245         case kEventClassControl 
: 
 246             result 
= wxMacWindowControlEventHandler( handler
, event
, data 
) ; 
 254 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler 
) 
 256 // --------------------------------------------------------------------------- 
 257 // UserPane events for non OSX builds 
 258 // --------------------------------------------------------------------------- 
 260 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
) 
 262     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 263     wxCHECK_RET( win 
, wxT("Callback from unkown control") ) ; 
 264     win
->MacControlUserPaneDrawProc(part
) ; 
 267 static pascal ControlPartCode 
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
) 
 269     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 270     wxCHECK_MSG( win 
, kControlNoPart 
, wxT("Callback from unkown control") ) ; 
 271     return win
->MacControlUserPaneHitTestProc(where
.h 
, where
.v
) ; 
 274 static pascal ControlPartCode 
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
) 
 276     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 277     wxCHECK_MSG( win 
, kControlNoPart 
, wxT("Callback from unkown control") ) ; 
 278     return win
->MacControlUserPaneTrackingProc( startPt
.h 
, startPt
.v 
, (void*) actionProc
) ; 
 281 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
) 
 283     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 284     wxCHECK_RET( win 
, wxT("Callback from unkown control") ) ; 
 285     win
->MacControlUserPaneIdleProc() ; 
 288 static pascal ControlPartCode 
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
) 
 290     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 291     wxCHECK_MSG( win 
, kControlNoPart 
, wxT("Callback from unkown control") ) ; 
 292     return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ; 
 295 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
) 
 297     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 298     wxCHECK_RET( win 
, wxT("Callback from unkown control") ) ; 
 299     win
->MacControlUserPaneActivateProc(activating
) ; 
 302 static pascal ControlPartCode 
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
) 
 304     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 305     wxCHECK_MSG( win 
, kControlNoPart 
, wxT("Callback from unkown control") ) ; 
 306     return win
->MacControlUserPaneFocusProc(action
) ; 
 309 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
) 
 311     wxWindow 
* win 
= wxFindControlFromMacControl(control
) ; 
 312     wxCHECK_RET( win 
, wxT("Callback from unkown control") ) ; 
 313     win
->MacControlUserPaneBackgroundProc(info
) ; 
 316 void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part
)  
 318     RgnHandle rgn 
= NewRgn() ; 
 320     wxMacWindowStateSaver 
sv( this ) ; 
 321     SectRgn( rgn 
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn 
) ; 
 322     MacDoRedraw( rgn 
, 0 ) ; 
 326 wxInt16 
wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)  
 328     return kControlNoPart 
; 
 331 wxInt16 
wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)  
 333     return kControlNoPart 
; 
 336 void wxWindowMac::MacControlUserPaneIdleProc()  
 340 wxInt16 
wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)  
 342     return kControlNoPart 
; 
 345 void wxWindowMac::MacControlUserPaneActivateProc(bool activating
)  
 349 wxInt16 
wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action
)  
 351     return kControlNoPart 
; 
 354 void wxWindowMac::MacControlUserPaneBackgroundProc(void* info
)  
 358 ControlUserPaneDrawUPP gControlUserPaneDrawUPP 
= NULL 
; 
 359 ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP 
= NULL 
; 
 360 ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP 
= NULL 
; 
 361 ControlUserPaneIdleUPP gControlUserPaneIdleUPP 
= NULL 
; 
 362 ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP 
= NULL 
; 
 363 ControlUserPaneActivateUPP gControlUserPaneActivateUPP 
= NULL 
; 
 364 ControlUserPaneFocusUPP gControlUserPaneFocusUPP 
= NULL 
; 
 365 ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP 
= NULL 
; 
 367 // =========================================================================== 
 369 // =========================================================================== 
 371 wxList 
wxWinMacControlList(wxKEY_INTEGER
); 
 373 wxWindow 
*wxFindControlFromMacControl(ControlRef inControl 
) 
 375     wxNode 
*node 
= wxWinMacControlList
.Find((long)inControl
); 
 378     return (wxControl 
*)node
->GetData(); 
 381 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow 
*control
) 
 383     // adding NULL ControlRef is (first) surely a result of an error and 
 384     // (secondly) breaks native event processing 
 385     wxCHECK_RET( inControl 
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") ); 
 387     if ( !wxWinMacControlList
.Find((long)inControl
) ) 
 388         wxWinMacControlList
.Append((long)inControl
, control
); 
 391 void wxRemoveMacControlAssociation(wxWindow 
*control
) 
 393     wxWinMacControlList
.DeleteObject(control
); 
 397 ControlActionUPP wxMacLiveScrollbarActionUPP 
= NULL 
; 
 399 ControlColorUPP wxMacSetupControlBackgroundUPP 
= NULL 
; 
 401 // we have to setup the brush in the current port and return noErr 
 402 // or return an error code so that the control manager walks further up the  
 403 // hierarchy to find a correct background 
 405 pascal OSStatus 
wxMacSetupControlBackground( ControlRef iControl 
, SInt16 iMessage 
, SInt16 iDepth 
, Boolean iIsColor 
) 
 407     OSStatus status 
= paramErr 
; 
 410         case kControlMsgApplyTextColor 
: 
 412         case kControlMsgSetUpBackground 
: 
 414                 wxWindow
*  wx 
= (wxWindow
*) wxFindControlFromMacControl( iControl 
) ; 
 418                     const wxBrush &brush = wx->MacGetBackgroundBrush() ; 
 422                         wxDC::MacSetupBackgroundForCurrentPort( brush ) ; 
 424                         // this clipping is only needed for non HIView 
 426                         RgnHandle clip 
= NewRgn() ; 
 429                         wx
->MacWindowToRootWindow( &x
,&y 
) ; 
 430                         CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion().GetWXHRGN() , clip 
) ; 
 431                         OffsetRgn( clip 
, x 
, y 
) ; 
 438                     else if ( wx->MacIsUserPane() ) 
 440                         // if we don't have a valid brush for such a control, we have to call the 
 441                         // setup of our parent ourselves 
 442                         status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ; 
 455 pascal void wxMacLiveScrollbarActionProc( ControlRef control 
, ControlPartCode partCode 
) ; 
 456 pascal void wxMacLiveScrollbarActionProc( ControlRef control 
, ControlPartCode partCode 
) 
 460         wxWindow
*  wx 
= wxFindControlFromMacControl( control 
) ; 
 463             wx
->MacHandleControlClick( (WXWidget
) control 
, partCode 
, true /* stillDown */ ) ; 
 468 // ---------------------------------------------------------------------------- 
 469  // constructors and such 
 470 // ---------------------------------------------------------------------------- 
 472 void wxWindowMac::Init() 
 475 #if WXWIN_COMPATIBILITY_2_4 
 476     m_backgroundTransparent 
= FALSE
; 
 479     // as all windows are created with WS_VISIBLE style... 
 482     m_hScrollBar 
= NULL 
; 
 483     m_vScrollBar 
= NULL 
; 
 484     m_macBackgroundBrush 
= wxNullBrush 
; 
 486         m_macControl 
= NULL 
; 
 488     m_macIsUserPane 
= TRUE
; 
 490     // make sure all proc ptrs are available 
 492     if ( gControlUserPaneDrawUPP 
== NULL 
) 
 494         gControlUserPaneDrawUPP 
= NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc 
) ; 
 495         gControlUserPaneHitTestUPP 
= NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc 
) ; 
 496         gControlUserPaneTrackingUPP 
= NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc 
) ; 
 497         gControlUserPaneIdleUPP 
= NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc 
) ; 
 498         gControlUserPaneKeyDownUPP 
= NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc 
) ; 
 499         gControlUserPaneActivateUPP 
= NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc 
) ; 
 500         gControlUserPaneFocusUPP 
= NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc 
) ; 
 501         gControlUserPaneBackgroundUPP 
= NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc 
) ; 
 503     if ( wxMacLiveScrollbarActionUPP 
== NULL 
) 
 505         wxMacLiveScrollbarActionUPP 
= NewControlActionUPP( wxMacLiveScrollbarActionProc 
); 
 508     if ( wxMacSetupControlBackgroundUPP 
== NULL 
) 
 510         wxMacSetupControlBackgroundUPP 
= NewControlColorUPP( wxMacSetupControlBackground 
) ; 
 513     // we need a valid font for the encodings 
 514     wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
)); 
 518 wxWindowMac::~wxWindowMac() 
 522     m_isBeingDeleted 
= TRUE
; 
 524 #ifndef __WXUNIVERSAL__ 
 525     // VS: make sure there's no wxFrame with last focus set to us: 
 526     for ( wxWindow 
*win 
= GetParent(); win
; win 
= win
->GetParent() ) 
 528         wxFrame 
*frame 
= wxDynamicCast(win
, wxFrame
); 
 531             if ( frame
->GetLastFocus() == this ) 
 533                 frame
->SetLastFocus((wxWindow
*)NULL
); 
 538 #endif // __WXUNIVERSAL__ 
 540     // wxRemoveMacControlAssociation( this ) ; 
 541     // If we delete an item, we should initialize the parent panel, 
 542     // because it could now be invalid. 
 543     wxWindow 
*parent 
= GetParent() ; 
 546         if (parent
->GetDefaultItem() == (wxButton
*) this) 
 547             parent
->SetDefaultItem(NULL
); 
 549     if ( (ControlRef
) m_macControl 
) 
 551         // in case the callback might be called during destruction 
 552         wxRemoveMacControlAssociation( this) ; 
 553         ::SetControlColorProc( (ControlRef
) m_macControl 
, NULL 
) ; 
 554         ::DisposeControl( (ControlRef
) m_macControl 
) ; 
 555         m_macControl 
= NULL 
; 
 558     if ( g_MacLastWindow 
== this ) 
 560         g_MacLastWindow 
= NULL 
; 
 563     wxFrame
* frame 
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame 
) ; 
 566         if ( frame
->GetLastFocus() == this ) 
 567             frame
->SetLastFocus( NULL 
) ; 
 572     // delete our drop target if we've got one 
 573 #if wxUSE_DRAG_AND_DROP 
 574     if ( m_dropTarget 
!= NULL 
) 
 579 #endif // wxUSE_DRAG_AND_DROP 
 584 void wxWindowMac::MacInstallEventHandler() 
 586     wxAssociateControlWithMacControl( (ControlRef
) m_macControl 
, this ) ; 
 587     InstallControlEventHandler( (ControlRef
) m_macControl
, GetwxMacWindowEventHandlerUPP(), 
 588         GetEventTypeCount(eventList
), eventList
, this,  
 589         (EventHandlerRef 
*)&m_macControlEventHandler
); 
 594 bool wxWindowMac::Create(wxWindowMac 
*parent
, wxWindowID id
, 
 598            const wxString
& name
) 
 600     wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") ); 
 602     if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) ) 
 605     parent
->AddChild(this); 
 607     m_windowVariant 
= parent
->GetWindowVariant() ; 
 609     if ( m_macIsUserPane 
) 
 611         Rect bounds 
= wxMacGetBoundsForControl( this , pos 
, size 
) ; 
 614                         | kControlSupportsEmbedding 
 
 615 //                      | kControlSupportsLiveFeedback  
 616 //                      | kControlHasSpecialBackground   
 617 //                      | kControlSupportsCalcBestRect  
 618 //                      | kControlHandlesTracking  
 619                         | kControlSupportsFocus 
 
 620 //                      | kControlWantsActivate  
 621 //                      | kControlWantsIdle 
 624         ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features 
, (ControlRef
*) &m_macControl
);  
 626         MacPostControlCreate(pos
,size
) ; 
 627 #if !TARGET_API_MAC_OSX 
 628         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneDrawProcTag
,  
 629                sizeof(gControlUserPaneDrawUPP
),(Ptr
) &gControlUserPaneDrawUPP
); 
 630         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneHitTestProcTag
,  
 631                sizeof(gControlUserPaneHitTestUPP
),(Ptr
) &gControlUserPaneHitTestUPP
); 
 632         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneTrackingProcTag
,  
 633                sizeof(gControlUserPaneTrackingUPP
),(Ptr
) &gControlUserPaneTrackingUPP
); 
 634         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneIdleProcTag
,  
 635                sizeof(gControlUserPaneIdleUPP
),(Ptr
) &gControlUserPaneIdleUPP
); 
 636         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneKeyDownProcTag
,  
 637                sizeof(gControlUserPaneKeyDownUPP
),(Ptr
) &gControlUserPaneKeyDownUPP
); 
 638         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneActivateProcTag
,  
 639                sizeof(gControlUserPaneActivateUPP
),(Ptr
) &gControlUserPaneActivateUPP
); 
 640         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneFocusProcTag
,  
 641                sizeof(gControlUserPaneFocusUPP
),(Ptr
) &gControlUserPaneFocusUPP
); 
 642         SetControlData((ControlRef
) m_macControl
,kControlEntireControl
,kControlUserPaneBackgroundProcTag
,  
 643                sizeof(gControlUserPaneBackgroundUPP
),(Ptr
) &gControlUserPaneBackgroundUPP
); 
 646 #ifndef __WXUNIVERSAL__ 
 647     // Don't give scrollbars to wxControls unless they ask for them 
 648     if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) || 
 649          (IsKindOf(CLASSINFO(wxControl
)) && ( style 
& wxHSCROLL 
|| style 
& wxVSCROLL
))) 
 651         MacCreateScrollBars( style 
) ; 
 655     wxWindowCreateEvent 
event(this); 
 656     GetEventHandler()->AddPendingEvent(event
); 
 661 void wxWindowMac::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
) 
 663     wxASSERT_MSG( (ControlRef
) m_macControl 
!= NULL 
, wxT("No valid mac control") ) ; 
 665     ::SetControlReference( (ControlRef
) m_macControl 
, (long) this ) ; 
 667     MacInstallEventHandler(); 
 669     ControlRef container 
= (ControlRef
) GetParent()->GetHandle() ; 
 670     wxASSERT_MSG( container 
!= NULL 
, wxT("No valid mac container control") ) ; 
 671     ::EmbedControl( (ControlRef
) m_macControl 
, container 
) ; 
 673     // adjust font, controlsize etc 
 674     DoSetWindowVariant( m_windowVariant 
) ; 
 676 #if !TARGET_API_MAC_OSX 
 677     // eventually we can fix some clipping issues be reactivating this hook  
 678     //if ( m_macIsUserPane ) 
 679     // SetControlColorProc( (ControlRef) m_macControl , wxMacSetupControlBackgroundUPP ) ; 
 682     UMASetControlTitle( (ControlRef
) m_macControl 
, wxStripMenuCodes(m_label
) , m_font
.GetEncoding() ) ; 
 684     wxSize new_size 
= size 
; 
 685     if (!m_macIsUserPane
) 
 687         wxSize 
best_size( DoGetBestSize() ); 
 690             new_size
.x 
= best_size
.x
; 
 693             new_size
.y 
= best_size
.y
; 
 695         SetSize( pos
.x
, pos
.y 
, new_size
.x
, new_size
.y
,wxSIZE_USE_EXISTING 
); 
 698     SetCursor( *wxSTANDARD_CURSOR 
) ; 
 702 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant 
) 
 704     // Don't assert, in case we set the window variant before 
 705     // the window is created 
 706     // wxASSERT( m_macControl != NULL ) ; 
 708     m_windowVariant 
= variant 
; 
 714     ThemeFontID themeFont 
= kThemeSystemFont 
; 
 716     // we will get that from the settings later 
 717     // and make this NORMAL later, but first  
 718     // we have a few calculations that we must fix 
 722         case wxWINDOW_VARIANT_NORMAL 
: 
 723             size 
= kControlSizeNormal
;  
 724                 themeFont 
= kThemeSystemFont 
; 
 726         case wxWINDOW_VARIANT_SMALL 
: 
 727             size 
= kControlSizeSmall
;  
 728                 themeFont 
= kThemeSmallSystemFont 
; 
 730         case wxWINDOW_VARIANT_MINI 
: 
 731            if (UMAGetSystemVersion() >= 0x1030 ) 
 733                 // not always defined in the headers  
 739                 size 
= kControlSizeSmall
;  
 740                     themeFont 
= kThemeSmallSystemFont 
; 
 743         case wxWINDOW_VARIANT_LARGE 
: 
 744             size 
= kControlSizeLarge
;  
 745                 themeFont 
= kThemeSystemFont 
; 
 748             wxFAIL_MSG(_T("unexpected window variant")); 
 751         ::SetControlData( (ControlRef
) m_macControl 
, kControlEntireControl
, kControlSizeTag
, sizeof( ControlSize 
), &size 
); 
 754     font
.MacCreateThemeFont( themeFont 
) ; 
 758 void wxWindowMac::MacUpdateControlFont()  
 760         ControlFontStyleRec     fontStyle
; 
 761         if ( m_font
.MacGetThemeFontID() != kThemeCurrentPortFont 
) 
 763             switch( m_font
.MacGetThemeFontID() ) 
 765                 case kThemeSmallSystemFont 
:    fontStyle
.font 
= kControlFontSmallSystemFont 
;  break ; 
 766                 case 109 /*mini font */ :       fontStyle
.font 
= -5 ;                           break ; 
 767                 case kThemeSystemFont 
:         fontStyle
.font 
= kControlFontBigSystemFont 
;    break ; 
 768                 default :                       fontStyle
.font 
= kControlFontBigSystemFont 
;    break ; 
 770             fontStyle
.flags 
= kControlUseFontMask 
;  
 774             fontStyle
.font 
= m_font
.MacGetFontNum() ; 
 775             fontStyle
.style 
= m_font
.MacGetFontStyle() ; 
 776             fontStyle
.size 
= m_font
.MacGetFontSize() ; 
 777             fontStyle
.flags 
= kControlUseFontMask 
| kControlUseFaceMask 
| kControlUseSizeMask 
; 
 780     fontStyle
.just 
= teJustLeft 
; 
 781     fontStyle
.flags 
|= kControlUseJustMask 
; 
 782     if ( ( GetWindowStyle() & wxALIGN_MASK 
) & wxALIGN_CENTER_HORIZONTAL 
) 
 783         fontStyle
.just 
= teJustCenter 
; 
 784     else if ( ( GetWindowStyle() & wxALIGN_MASK 
) & wxALIGN_RIGHT 
) 
 785         fontStyle
.just 
= teJustRight 
; 
 788     fontStyle
.foreColor 
= MAC_WXCOLORREF(GetForegroundColour().GetPixel() ) ; 
 789     fontStyle
.flags 
|= kControlUseForeColorMask 
; 
 791         ::SetControlFontStyle( (ControlRef
) m_macControl 
, &fontStyle 
); 
 795 bool wxWindowMac::SetFont(const wxFont
& font
) 
 797     bool retval 
= !wxWindowBase::SetFont( font 
) ; 
 799     MacUpdateControlFont() ; 
 804 bool wxWindowMac::SetForegroundColour(const wxColour
& col 
) 
 806     if ( !wxWindowBase::SetForegroundColour(col
) ) 
 809     MacUpdateControlFont() ; 
 814 bool wxWindowMac::SetBackgroundColour(const wxColour
& col 
) 
 816     if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol 
) 
 820     if ( col 
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) ) 
 822         brush
.MacSetTheme( kThemeBrushDocumentWindowBackground 
) ; 
 824     else if (  col 
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE 
) ) 
 826         brush
.MacSetTheme( kThemeBrushDialogBackgroundActive 
) ;  
 830         brush
.SetColour( col 
) ; 
 832     MacSetBackgroundBrush( brush 
) ; 
 834     MacUpdateControlFont() ; 
 840 bool wxWindowMac::MacCanFocus() const 
 843     // there is currently no way to determinate whether the window is running in full keyboard 
 844     // access mode, therefore we cannot rely on these features yet 
 845     UInt32 features 
= 0 ; 
 846     GetControlFeatures( (ControlRef
) m_macControl 
, &features 
) ; 
 847     return features 
& ( kControlSupportsFocus 
| kControlGetsFocusOnClick 
) ;  
 853 void wxWindowMac::SetFocus() 
 855     if ( AcceptsFocus() ) 
 857 #if !TARGET_API_MAC_OSX 
 858         wxWindow
* former 
= FindFocus() ; 
 860         OSStatus err 
= SetKeyboardFocus(  (WindowRef
) MacGetTopLevelWindowRef() , (ControlRef
) GetHandle()  , kControlFocusNextPart 
) ; 
 861         // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only 
 862         // leave in case of an error 
 863         if ( err 
== errCouldntSetFocus 
) 
 866 #if !TARGET_API_MAC_OSX 
 867         // emulate carbon events when running under carbonlib where they are not natively available 
 870             EventRef evRef 
= NULL 
; 
 871             verify_noerr( MacCreateEvent( NULL 
, kEventClassControl 
, kEventControlSetFocusPart 
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent 
, 
 874             wxMacCarbonEvent 
cEvent( evRef 
) ; 
 875             cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject 
, (ControlRef
) former
->GetHandle() ) ; 
 876             cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart 
, typeControlPartCode 
, kControlFocusNoPart 
) ; 
 878             wxMacWindowEventHandler( NULL 
, evRef 
, former 
) ; 
 879             ReleaseEvent(evRef
) ; 
 881         // send new focus event 
 883             EventRef evRef 
= NULL 
; 
 884             verify_noerr( MacCreateEvent( NULL 
, kEventClassControl 
, kEventControlSetFocusPart 
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent 
, 
 887             wxMacCarbonEvent 
cEvent( evRef 
) ; 
 888             cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject 
, (ControlRef
) GetHandle() ) ; 
 889             cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart 
, typeControlPartCode 
, kControlFocusNextPart 
) ; 
 891             wxMacWindowEventHandler( NULL 
, evRef 
, this ) ; 
 892             ReleaseEvent(evRef
) ; 
 899 void wxWindowMac::DoCaptureMouse() 
 901     wxTheApp
->s_captureWindow 
= this ; 
 904 wxWindow
* wxWindowBase::GetCapture() 
 906     return wxTheApp
->s_captureWindow 
; 
 909 void wxWindowMac::DoReleaseMouse() 
 911     wxTheApp
->s_captureWindow 
= NULL 
; 
 914 #if    wxUSE_DRAG_AND_DROP 
 916 void wxWindowMac::SetDropTarget(wxDropTarget 
*pDropTarget
) 
 918     if ( m_dropTarget 
!= 0 ) { 
 922     m_dropTarget 
= pDropTarget
; 
 923     if ( m_dropTarget 
!= 0 ) 
 931 // Old style file-manager drag&drop 
 932 void wxWindowMac::DragAcceptFiles(bool accept
) 
 937 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x
, int& y
, 
 938                                            int& w
, int& h
) const  
 941     GetControlBounds( (ControlRef
) m_macControl 
, &bounds 
) ;    
 946     w 
= bounds
.right 
- bounds
.left 
; 
 947     h 
= bounds
.bottom 
- bounds
.top 
; 
 949     wxTopLevelWindow
* tlw 
= wxDynamicCast( this , wxTopLevelWindow 
) ; 
 952         Point tlworigin 
=  { 0 , 0  } ; 
 954         bool swapped 
= QDSwapPort( UMAGetWindowPort( (WindowRef
) tlw
->MacGetWindowRef() ) , &port 
) ; 
 955         ::LocalToGlobal( &tlworigin 
) ; 
 963 bool wxWindowMac::MacGetBoundsForControl(const wxPoint
& pos
, 
 966                                        int& w
, int& h 
, bool adjustOrigin 
) const  
 970     // todo the default calls may be used as soon as PostCreateControl Is moved here 
 971     w 
= size
.x 
; // WidthDefault( size.x ); 
 972     h 
= size
.y 
; // HeightDefault( size.y ) ; 
 973 #if !TARGET_API_MAC_OSX 
 974     GetParent()->MacWindowToRootWindow( &x 
, &y 
) ; 
 977         AdjustForParentClientOrigin( x 
, y 
) ; 
 982 void wxWindowMac::DoGetSize(int *x
, int *y
) const 
 984 #if TARGET_API_MAC_OSX 
 985     int x1 
, y1 
, w1 
,h1 
; 
 986     MacGetPositionAndSizeFromControl( x1 
, y1
, w1 
,h1 
) ; 
 992     GetControlBounds( (ControlRef
) m_macControl 
, &bounds 
) ;    
 993     if(x
)   *x 
= bounds
.right 
- bounds
.left 
; 
 994     if(y
)   *y 
= bounds
.bottom 
- bounds
.top 
; 
 998 void wxWindowMac::DoGetPosition(int *x
, int *y
) const 
1000  #if TARGET_API_MAC_OSX 
1001     int x1 
, y1 
, w1 
,h1 
; 
1002     MacGetPositionAndSizeFromControl( x1 
, y1
, w1 
,h1 
) ; 
1003     if ( !IsTopLevel() ) 
1005         wxWindow 
*parent 
= GetParent(); 
1008             wxPoint 
pt(parent
->GetClientAreaOrigin()); 
1017     GetControlBounds( (ControlRef
) m_macControl 
, &bounds 
) ;    
1018     wxCHECK_RET( GetParent() , wxT("Missing Parent") ) ; 
1020     int xx 
= bounds
.left 
; 
1021     int yy 
= bounds
.top 
; 
1023     if ( !GetParent()->IsTopLevel() ) 
1025         GetControlBounds( (ControlRef
) GetParent()->GetHandle() , &bounds 
) ; 
1031     wxPoint 
pt(GetParent()->GetClientAreaOrigin()); 
1040 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const 
1042     WindowRef window 
= (WindowRef
) MacGetTopLevelWindowRef() ; 
1044     wxCHECK_RET( window 
, wxT("TopLevel Window Missing") ) ; 
1047         Point localwhere 
= {0,0} ; 
1049         if(x
) localwhere
.h 
= * x 
; 
1050         if(y
) localwhere
.v 
= * y 
; 
1052         wxMacPortSaver 
s((GrafPtr
)GetWindowPort( window 
)) ; 
1053         ::GlobalToLocal( &localwhere 
) ; 
1054         if(x
)   *x 
= localwhere
.h 
; 
1055         if(y
)   *y 
= localwhere
.v 
; 
1058     MacRootWindowToWindow( x 
, y 
) ; 
1060     wxPoint origin 
= GetClientAreaOrigin() ; 
1061     if(x
)   *x 
-= origin
.x 
; 
1062     if(y
)   *y 
-= origin
.y 
; 
1065 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const 
1067     WindowRef window 
= (WindowRef
) MacGetTopLevelWindowRef() ; 
1068     wxCHECK_RET( window 
, wxT("TopLevel Window Missing") ) ; 
1070     wxPoint origin 
= GetClientAreaOrigin() ; 
1071     if(x
)   *x 
+= origin
.x 
; 
1072     if(y
)   *y 
+= origin
.y 
; 
1074     MacWindowToRootWindow( x 
, y 
) ; 
1077         Point localwhere 
= { 0,0 }; 
1078         if(x
)   localwhere
.h 
= * x 
; 
1079         if(y
)   localwhere
.v 
= * y 
; 
1081         wxMacPortSaver 
s((GrafPtr
)GetWindowPort( window 
)) ; 
1082         ::LocalToGlobal( &localwhere 
) ; 
1083         if(x
)   *x 
= localwhere
.h 
; 
1084         if(y
)   *y 
= localwhere
.v 
; 
1088 void wxWindowMac::MacClientToRootWindow( int *x 
, int *y 
) const 
1090     wxPoint origin 
= GetClientAreaOrigin() ; 
1091     if(x
)   *x 
+= origin
.x 
; 
1092     if(y
)   *y 
+= origin
.y 
; 
1094     MacWindowToRootWindow( x 
, y 
) ; 
1097 void wxWindowMac::MacRootWindowToClient( int *x 
, int *y 
) const 
1099     MacRootWindowToWindow( x 
, y 
) ; 
1101     wxPoint origin 
= GetClientAreaOrigin() ; 
1102     if(x
)   *x 
-= origin
.x 
; 
1103     if(y
)   *y 
-= origin
.y 
; 
1106 void wxWindowMac::MacWindowToRootWindow( int *x 
, int *y 
) const 
1108  #if TARGET_API_MAC_OSX 
1110     if ( x 
) pt
.x 
= *x 
; 
1111     if ( y 
) pt
.y 
= *y 
; 
1113     if ( !IsTopLevel() ) 
1114         HIViewConvertPoint( &pt 
, (ControlRef
) m_macControl 
, (ControlRef
) MacGetTopLevelWindow()->GetHandle()  ) ; 
1116     if ( x 
) *x 
= (int) pt
.x 
; 
1117     if ( y 
) *y 
= (int) pt
.y 
; 
1119     if ( !IsTopLevel() ) 
1122         GetControlBounds( (ControlRef
) m_macControl 
, &bounds 
) ;    
1123         if(x
)   *x 
+= bounds
.left 
; 
1124         if(y
)   *y 
+= bounds
.top 
; 
1129 void wxWindowMac::MacWindowToRootWindow( short *x 
, short *y 
) const 
1134     MacWindowToRootWindow( &x1 
, &y1 
) ; 
1139 void wxWindowMac::MacRootWindowToWindow( int *x 
, int *y 
) const 
1141  #if TARGET_API_MAC_OSX 
1143     if ( x 
) pt
.x 
= *x 
; 
1144     if ( y 
) pt
.y 
= *y 
; 
1146     if ( !IsTopLevel() ) 
1147         HIViewConvertPoint( &pt 
, (ControlRef
) MacGetTopLevelWindow()->GetHandle()  , (ControlRef
) m_macControl 
) ; 
1149     if ( x 
) *x 
= (int) pt
.x 
; 
1150     if ( y 
) *y 
= (int) pt
.y 
; 
1152     if ( !IsTopLevel() ) 
1155         GetControlBounds( (ControlRef
) m_macControl 
, &bounds 
) ;    
1156         if(x
)   *x 
-= bounds
.left 
; 
1157         if(y
)   *y 
-= bounds
.top 
; 
1162 void wxWindowMac::MacRootWindowToWindow( short *x 
, short *y 
) const 
1167     MacRootWindowToWindow( &x1 
, &y1 
) ; 
1172 void wxWindowMac::MacGetContentAreaInset( int &left 
, int &top 
, int &right 
, int &bottom 
) 
1174     RgnHandle rgn 
= NewRgn() ; 
1176     if ( GetControlRegion( (ControlRef
) m_macControl 
, kControlContentMetaPart 
, rgn 
) == noErr 
) 
1178         GetRegionBounds( rgn 
, &content 
) ; 
1183         GetControlBounds( (ControlRef
) m_macControl 
, &content 
) ; 
1186     GetControlBounds( (ControlRef
) m_macControl 
, &structure 
) ; 
1187 #if !TARGET_API_MAC_OSX     
1188     OffsetRect( &content 
, -structure
.left 
, -structure
.top 
) ; 
1190     left 
= content
.left 
- structure
.left 
; 
1191     top 
= content
.top  
- structure
.top 
; 
1192     right 
= structure
.right 
- content
.right 
; 
1193     bottom 
= structure
.bottom 
- content
.bottom 
; 
1196 wxSize 
wxWindowMac::DoGetSizeFromClientSize( const wxSize 
& size 
)  const 
1198     wxSize sizeTotal 
= size
; 
1200     RgnHandle rgn 
= NewRgn() ; 
1204     if ( GetControlRegion( (ControlRef
) m_macControl 
, kControlContentMetaPart 
, rgn 
) == noErr 
) 
1206         GetRegionBounds( rgn 
, &content 
) ; 
1211         GetControlBounds( (ControlRef
) m_macControl 
, &content 
) ; 
1214     GetControlBounds( (ControlRef
) m_macControl 
, &structure 
) ; 
1215 #if !TARGET_API_MAC_OSX     
1216     OffsetRect( &content 
, -structure
.left 
, -structure
.top 
) ; 
1219     sizeTotal
.x 
+= (structure
.right 
- structure
.left
) - (content
.right 
- content
.left
) ; 
1220     sizeTotal
.y 
+= (structure
.bottom 
- structure
.top
) - (content
.bottom 
- content
.top 
) ;  
1222     sizeTotal
.x 
+= MacGetLeftBorderSize(  ) + MacGetRightBorderSize( ) ; 
1223     sizeTotal
.y 
+= MacGetTopBorderSize(  ) + MacGetBottomBorderSize( ) ; 
1229 // Get size *available for subwindows* i.e. excluding menu bar etc. 
1230 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const 
1234     RgnHandle rgn 
= NewRgn() ; 
1236     if ( GetControlRegion( (ControlRef
) m_macControl 
, kControlContentMetaPart 
, rgn 
) == noErr 
) 
1238         GetRegionBounds( rgn 
, &content 
) ; 
1243         GetControlBounds( (ControlRef
) m_macControl 
, &content 
) ; 
1245 #if !TARGET_API_MAC_OSX 
1247     GetControlBounds( (ControlRef
) m_macControl 
, &structure 
) ; 
1248     OffsetRect( &content 
, -structure
.left 
, -structure
.top 
) ; 
1250     ww 
= content
.right 
- content
.left 
; 
1251     hh 
= content
.bottom 
- content
.top 
; 
1253     ww 
-= MacGetLeftBorderSize(  )  + MacGetRightBorderSize(  ) ; 
1254     hh 
-= MacGetTopBorderSize(  ) + MacGetBottomBorderSize( ); 
1256     if ( (m_vScrollBar 
&& m_vScrollBar
->IsShown()) || (m_hScrollBar  
&& m_hScrollBar
->IsShown()) ) 
1262         GetSize( &w 
, &h 
) ; 
1264         MacClientToRootWindow( &x1 
, &y1 
) ; 
1265         MacClientToRootWindow( &w 
, &h 
) ; 
1267         wxWindowMac 
*iter 
= (wxWindowMac
*)this ; 
1269         int totW 
= 10000 , totH 
= 10000; 
1272             if ( iter
->IsTopLevel() ) 
1274                 iter
->GetSize( &totW 
, &totH 
) ; 
1278             iter 
= iter
->GetParent() ; 
1281         if (m_hScrollBar  
&& m_hScrollBar
->IsShown() ) 
1283             hh 
-= MAC_SCROLLBAR_SIZE
; 
1289         if (m_vScrollBar  
&& m_vScrollBar
->IsShown() ) 
1291             ww 
-= MAC_SCROLLBAR_SIZE
; 
1303 bool wxWindowMac::SetCursor(const wxCursor
& cursor
) 
1305     if (m_cursor 
== cursor
) 
1308     if (wxNullCursor 
== cursor
) 
1310         if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR 
) ) 
1315         if ( ! wxWindowBase::SetCursor( cursor 
) ) 
1319     wxASSERT_MSG( m_cursor
.Ok(), 
1320         wxT("cursor must be valid after call to the base version")); 
1324     TODO why do we have to use current coordinates ? 
1327     wxWindowMac *mouseWin ; 
1330     // Change the cursor NOW if we're within the correct window 
1333     if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) 
1335         if ( mouseWin == this && !wxIsBusy() ) 
1337             m_cursor.MacInstall() ; 
1343         m_cursor
.MacInstall() ; 
1350 bool wxWindowMac::DoPopupMenu(wxMenu 
*menu
, int x
, int y
) 
1352     menu
->SetInvokingWindow(this); 
1354     ClientToScreen( &x 
, &y 
) ; 
1356     menu
->MacBeforeDisplay( true ) ; 
1357     long menuResult 
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ; 
1358     if ( HiWord(menuResult
) != 0 ) 
1361         GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id 
) ; 
1362         wxMenuItem
* item 
= NULL 
; 
1364         item 
= menu
->FindItem(id
, &realmenu
) ; 
1365         if (item
->IsCheckable()) 
1367             item
->Check( !item
->IsChecked() ) ; 
1369         menu
->SendEvent( id 
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ; 
1371     menu
->MacAfterDisplay( true ) ; 
1373     menu
->SetInvokingWindow(NULL
); 
1379 // ---------------------------------------------------------------------------- 
1381 // ---------------------------------------------------------------------------- 
1385 void wxWindowMac::DoSetToolTip(wxToolTip 
*tooltip
) 
1387     wxWindowBase::DoSetToolTip(tooltip
); 
1390         m_tooltip
->SetWindow(this); 
1393 #endif // wxUSE_TOOLTIPS 
1395 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
) 
1397     int former_x 
, former_y 
, former_w
, former_h 
; 
1398 #if !TARGET_API_MAC_OSX 
1399     DoGetPosition( &former_x 
, &former_y 
) ; 
1400     DoGetSize( &former_w 
, &former_h 
) ; 
1402     MacGetPositionAndSizeFromControl( former_x 
, former_y 
, former_w 
, former_h 
) ; 
1405     int actualWidth 
= width
; 
1406     int actualHeight 
= height
; 
1410     if ((m_minWidth 
!= -1) && (actualWidth 
< m_minWidth
)) 
1411         actualWidth 
= m_minWidth
; 
1412     if ((m_minHeight 
!= -1) && (actualHeight 
< m_minHeight
)) 
1413         actualHeight 
= m_minHeight
; 
1414     if ((m_maxWidth 
!= -1) && (actualWidth 
> m_maxWidth
)) 
1415         actualWidth 
= m_maxWidth
; 
1416     if ((m_maxHeight 
!= -1) && (actualHeight 
> m_maxHeight
)) 
1417         actualHeight 
= m_maxHeight
; 
1419     bool doMove 
= false ; 
1420     bool doResize 
= false ; 
1422     if ( actualX 
!= former_x 
|| actualY 
!= former_y 
) 
1426     if ( actualWidth 
!= former_w 
|| actualHeight 
!= former_h 
) 
1431     if ( doMove 
|| doResize 
) 
1433         // we don't adjust twice for the origin 
1434         Rect r 
= wxMacGetBoundsForControl(this , wxPoint( actualX
,actualY
), wxSize( actualWidth
, actualHeight 
) , false ) ; 
1435         bool vis 
= IsControlVisible( (ControlRef
) m_macControl 
) ; 
1436 #if TARGET_API_MAC_OSX 
1437         // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! 
1439             SetControlVisibility(  (ControlRef
)m_macControl 
, false , true ) ; 
1440         HIRect hir 
= { r
.left 
, r
.top 
, r
.right 
- r
.left 
, r
.bottom 
- r
.top 
} ; 
1441         HIViewSetFrame ( (ControlRef
) m_macControl 
, &hir 
) ; 
1443             SetControlVisibility(  (ControlRef
)m_macControl 
, true , true ) ; 
1446             SetControlVisibility(  (ControlRef
)m_macControl 
, false , true ) ; 
1447         SetControlBounds( (ControlRef
) m_macControl 
, &r 
) ; 
1449             SetControlVisibility(  (ControlRef
)m_macControl 
, true , true ) ; 
1451         MacRepositionScrollBars() ; 
1454             wxPoint 
point(actualX
,actualY
); 
1455             wxMoveEvent 
event(point
, m_windowId
); 
1456             event
.SetEventObject(this); 
1457             GetEventHandler()->ProcessEvent(event
) ; 
1461             MacRepositionScrollBars() ; 
1462             wxSize 
size(actualWidth
, actualHeight
); 
1463             wxSizeEvent 
event(size
, m_windowId
); 
1464             event
.SetEventObject(this); 
1465             GetEventHandler()->ProcessEvent(event
); 
1471 wxSize 
wxWindowMac::DoGetBestSize() const 
1473     if ( m_macIsUserPane 
|| IsTopLevel() ) 
1474         return wxWindowBase::DoGetBestSize() ; 
1476     Rect    bestsize 
= { 0 , 0 , 0 , 0 } ; 
1477     short   baselineoffset 
; 
1478     int bestWidth
, bestHeight 
; 
1479     ::GetBestControlRect( (ControlRef
) m_macControl 
, &bestsize 
, &baselineoffset 
) ; 
1481     if ( EmptyRect( &bestsize 
) ) 
1484         bestsize
.left 
= bestsize
.top 
= 0 ; 
1485         bestsize
.right 
= 16 ; 
1486         bestsize
.bottom 
= 16 ; 
1487         if ( IsKindOf( CLASSINFO( wxScrollBar 
) ) ) 
1489             bestsize
.bottom 
= 16 ; 
1491         else if ( IsKindOf( CLASSINFO( wxSpinButton 
) ) ) 
1493             bestsize
.bottom 
= 24 ;  
1497             // return wxWindowBase::DoGetBestSize() ;   
1501     bestWidth 
= bestsize
.right 
- bestsize
.left 
; 
1502     bestHeight 
= bestsize
.bottom 
- bestsize
.top 
; 
1503     if ( bestHeight 
< 10 ) 
1506     return wxSize(bestWidth
, bestHeight
); 
1507 //    return wxWindowBase::DoGetBestSize() ; 
1511 // set the size of the window: if the dimensions are positive, just use them, 
1512 // but if any of them is equal to -1, it means that we must find the value for 
1513 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in 
1514 // which case -1 is a valid value for x and y) 
1516 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate 
1517 // the width/height to best suit our contents, otherwise we reuse the current 
1519 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
) 
1521     // get the current size and position... 
1522     int currentX
, currentY
; 
1523     GetPosition(¤tX
, ¤tY
); 
1525     int currentW
,currentH
; 
1526     GetSize(¤tW
, ¤tH
); 
1528     // ... and don't do anything (avoiding flicker) if it's already ok 
1529     if ( x 
== currentX 
&& y 
== currentY 
&& 
1530         width 
== currentW 
&& height 
== currentH 
&& ( height 
!= -1 && width 
!= -1 ) ) 
1533         MacRepositionScrollBars() ; // we might have a real position shift 
1537     if ( x 
== -1 && !(sizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
) ) 
1539     if ( y 
== -1 && !(sizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
) ) 
1542     AdjustForParentClientOrigin(x
, y
, sizeFlags
); 
1544     wxSize 
size(-1, -1); 
1547         if ( sizeFlags 
& wxSIZE_AUTO_WIDTH 
) 
1549             size 
= DoGetBestSize(); 
1554             // just take the current one 
1561         if ( sizeFlags 
& wxSIZE_AUTO_HEIGHT 
) 
1565                 size 
= DoGetBestSize(); 
1567             //else: already called DoGetBestSize() above 
1573             // just take the current one 
1578     DoMoveWindow(x
, y
, width
, height
); 
1582 wxPoint 
wxWindowMac::GetClientAreaOrigin() const 
1584     RgnHandle rgn 
= NewRgn() ; 
1586     GetControlRegion( (ControlRef
) m_macControl 
, kControlContentMetaPart 
, rgn 
) ; 
1587     GetRegionBounds( rgn 
, &content 
) ; 
1589 #if !TARGET_API_MAC_OSX 
1590     // if the content rgn is empty / not supported 
1591     // don't attempt to correct the coordinates to wxWindow relative ones 
1592     if (!::EmptyRect( &content 
) ) 
1595         GetControlBounds( (ControlRef
) m_macControl 
, &structure 
) ; 
1596         OffsetRect( &content 
, -structure
.left 
, -structure
.top 
) ; 
1600     return wxPoint( content
.left 
+ MacGetLeftBorderSize(  ) , content
.top 
+ MacGetTopBorderSize(  ) ); 
1603 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
) 
1605     if ( clientheight 
!= -1 || clientheight 
!= -1 ) 
1607         int currentclientwidth 
, currentclientheight 
; 
1608         int currentwidth 
, currentheight 
; 
1610         GetClientSize( ¤tclientwidth 
, ¤tclientheight 
) ; 
1611         GetSize( ¤twidth 
, ¤theight 
) ; 
1613         DoSetSize( -1 , -1 , currentwidth 
+ clientwidth 
- currentclientwidth 
, 
1614             currentheight 
+ clientheight 
- currentclientheight 
, wxSIZE_USE_EXISTING 
) ; 
1618 void wxWindowMac::SetTitle(const wxString
& title
) 
1620     m_label 
= wxStripMenuCodes(title
) ; 
1624                 UMASetControlTitle( (ControlRef
) m_macControl 
, m_label 
, m_font
.GetEncoding() ) ; 
1629 wxString 
wxWindowMac::GetTitle() const 
1634 bool wxWindowMac::Show(bool show
) 
1636     if ( !wxWindowBase::Show(show
) ) 
1639     // TODO use visibilityChanged Carbon Event for OSX 
1640     bool former 
= MacIsReallyShown() ; 
1642     SetControlVisibility( (ControlRef
) m_macControl 
, show 
, true ) ; 
1643     if ( former 
!= MacIsReallyShown() ) 
1644         MacPropagateVisibilityChanged() ; 
1648 bool wxWindowMac::Enable(bool enable
) 
1650     wxASSERT( m_macControl 
!= NULL 
) ; 
1651     if ( !wxWindowBase::Enable(enable
) ) 
1654     bool former 
= MacIsReallyEnabled() ; 
1655 #if TARGET_API_MAC_OSX 
1657         EnableControl( (ControlRef
) m_macControl 
) ; 
1659         DisableControl( (ControlRef
) m_macControl 
) ; 
1662         ActivateControl( (ControlRef
) m_macControl 
) ; 
1664         DeactivateControl( (ControlRef
) m_macControl 
) ; 
1667     if ( former 
!= MacIsReallyEnabled() ) 
1668         MacPropagateEnabledStateChanged() ; 
1673 // status change propagations (will be not necessary for OSX later ) 
1676 void wxWindowMac::MacPropagateVisibilityChanged() 
1678 #if !TARGET_API_MAC_OSX 
1679     MacVisibilityChanged() ; 
1681     wxWindowListNode 
*node 
= GetChildren().GetFirst(); 
1684         wxWindowMac 
*child 
= node
->GetData(); 
1685         if ( child
->IsShown() ) 
1686             child
->MacPropagateVisibilityChanged(  ) ; 
1687         node 
= node
->GetNext(); 
1692 void wxWindowMac::MacPropagateEnabledStateChanged( ) 
1694 #if !TARGET_API_MAC_OSX 
1695     MacEnabledStateChanged() ; 
1697     wxWindowListNode 
*node 
= GetChildren().GetFirst(); 
1700         wxWindowMac 
*child 
= node
->GetData(); 
1701         if ( child
->IsEnabled() ) 
1702             child
->MacPropagateEnabledStateChanged() ; 
1703         node 
= node
->GetNext(); 
1708 void wxWindowMac::MacPropagateHiliteChanged( ) 
1710 #if !TARGET_API_MAC_OSX 
1711     MacHiliteChanged() ; 
1713     wxWindowListNode 
*node 
= GetChildren().GetFirst(); 
1716         wxWindowMac 
*child 
= node
->GetData(); 
1717         // if ( child->IsEnabled() ) 
1718             child
->MacPropagateHiliteChanged() ; 
1719         node 
= node
->GetNext(); 
1725 // status change notifications 
1728 void wxWindowMac::MacVisibilityChanged()  
1732 void wxWindowMac::MacHiliteChanged()  
1736 void wxWindowMac::MacEnabledStateChanged()  
1741 // status queries on the inherited window's state 
1744 bool wxWindowMac::MacIsReallyShown()  
1746     // only under OSX the visibility of the TLW is taken into account 
1747 #if TARGET_API_MAC_OSX 
1748     return IsControlVisible( (ControlRef
) m_macControl 
) ; 
1750     wxWindow
* win 
= this ; 
1751     while( win
->IsShown()  ) 
1753         if ( win
->IsTopLevel() ) 
1756         win 
= win
->GetParent() ; 
1765 bool wxWindowMac::MacIsReallyEnabled()  
1767 #if TARGET_API_MAC_OSX 
1768     return IsControlEnabled( (ControlRef
) m_macControl 
) ; 
1770     return IsControlActive( (ControlRef
) m_macControl 
) ; 
1774 bool wxWindowMac::MacIsReallyHilited()  
1776     return IsControlActive( (ControlRef
) m_macControl 
) ; 
1783 int wxWindowMac::GetCharHeight() const 
1785     wxClientDC 
dc ( (wxWindowMac
*)this ) ; 
1786     return dc
.GetCharHeight() ; 
1789 int wxWindowMac::GetCharWidth() const 
1791     wxClientDC 
dc ( (wxWindowMac
*)this ) ; 
1792     return dc
.GetCharWidth() ; 
1795 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
, 
1796                            int *descent
, int *externalLeading
, const wxFont 
*theFont 
) const 
1798     const wxFont 
*fontToUse 
= theFont
; 
1800         fontToUse 
= &m_font
; 
1802     wxClientDC 
dc( (wxWindowMac
*) this ) ; 
1804     dc
.GetTextExtent( string 
, &lx 
, &ly 
, &ld
, &le
, (wxFont 
*)fontToUse 
) ; 
1805     if ( externalLeading 
) 
1806         *externalLeading 
= le 
; 
1816  * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect 
1817  * we always intersect with the entire window, not only with the client area 
1820 void wxWindowMac::Refresh(bool eraseBack
, const wxRect 
*rect
) 
1822 #if TARGET_API_MAC_OSX 
1824         HIViewSetNeedsDisplay( (ControlRef
) m_macControl 
, true ) ;  
1827         RgnHandle update 
= NewRgn() ; 
1828         SetRectRgn( update 
, rect
->x 
, rect
->y 
, rect
->x 
+ rect
->width 
, rect
->y 
+ rect
->height 
) ; 
1829         SectRgn( (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , update 
, update 
) ; 
1830         wxPoint origin 
= GetClientAreaOrigin() ; 
1831         OffsetRgn( update
, origin
.x 
, origin
.y 
) ;         
1832         HIViewSetNeedsDisplayInRegion( (ControlRef
) m_macControl 
, update 
, true ) ; 
1836         RgnHandle updateRgn = NewRgn() ; 
1839             CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ; 
1843             SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; 
1844             SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;         
1846         InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ; 
1847         DisposeRgn(updateRgn) ; 
1849     if ( IsControlVisible( (ControlRef
) m_macControl 
) ) 
1851         SetControlVisibility( (ControlRef
) m_macControl 
, false , false ) ; 
1852         SetControlVisibility( (ControlRef
) m_macControl 
, true , true ) ; 
1855     if ( MacGetTopLevelWindow() == NULL ) 
1858     if ( !IsControlVisible( (ControlRef) m_macControl ) ) 
1861      wxPoint client = GetClientAreaOrigin(); 
1864     int x2 = m_width - client.x; 
1865     int y2 = m_height - client.y; 
1867     if (IsKindOf( CLASSINFO(wxButton))) 
1869         // buttons have an "aura" 
1876     Rect clientrect = { y1, x1, y2, x2 }; 
1880         Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; 
1881         SectRect( &clientrect , &r , &clientrect ) ; 
1884     if ( !EmptyRect( &clientrect ) ) 
1886       int top = 0 , left = 0 ; 
1888       MacClientToRootWindow( &left , &top ) ; 
1889       OffsetRect( &clientrect , left , top ) ; 
1891       MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ; 
1897 void wxWindowMac::Freeze() 
1899 #if TARGET_API_MAC_OSX 
1900     if ( !m_frozenness
++ ) 
1902         HIViewSetDrawingEnabled( (HIViewRef
) m_macControl 
, false ) ; 
1907 #if TARGET_API_MAC_OSX 
1908 static void InvalidateControlAndChildren( HIViewRef control 
) 
1910     HIViewSetNeedsDisplay( control 
, true ) ; 
1911     UInt16 childrenCount 
= 0 ; 
1912     OSStatus err 
= CountSubControls( control 
, &childrenCount 
) ;  
1913     if ( err 
== errControlIsNotEmbedder 
) 
1915     wxASSERT_MSG( err 
== noErr 
, wxT("Unexpected error when accessing subcontrols") ) ; 
1917     for ( UInt16 i 
= childrenCount 
; i 
>=1  ; --i 
) 
1920         err 
= GetIndexedSubControl( control 
, i 
, & child 
) ; 
1921         if ( err 
== errControlIsNotEmbedder 
) 
1923         InvalidateControlAndChildren( child 
) ; 
1928 void wxWindowMac::Thaw() 
1930 #if TARGET_API_MAC_OSX 
1931     wxASSERT_MSG( m_frozenness 
> 0, _T("Thaw() without matching Freeze()") ); 
1933     if ( !--m_frozenness 
) 
1935         HIViewSetDrawingEnabled( (HIViewRef
) m_macControl 
, true ) ; 
1936         InvalidateControlAndChildren( (HIViewRef
) m_macControl 
)  ; 
1937         // HIViewSetNeedsDisplay( (HIViewRef) m_macControl , true ) ; 
1942 void wxWindowMac::MacRedrawControl() 
1945     if ( (ControlRef) m_macControl && MacGetTopLevelWindowRef() && IsControlVisible( (ControlRef) m_macControl ) ) 
1947 #if TARGET_API_MAC_CARBON 
1950         wxClientDC dc(this) ; 
1951         wxMacPortSetter helper(&dc) ; 
1952         wxMacWindowClipper clipper(this) ; 
1953         wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; 
1954         UMADrawControl( (ControlRef) m_macControl ) ; 
1961 void wxWindowMac::OnPaint(wxPaintEvent& event) 
1963     // why don't we skip that here ? 
1967 wxWindowMac 
*wxGetActiveWindow() 
1969     // actually this is a windows-only concept 
1973 // Coordinates relative to the window 
1974 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
) 
1976     // We really don't move the mouse programmatically under Mac. 
1979 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
) 
1981     if ( m_macBackgroundBrush
.Ok() == false || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT 
) 
1986         event
.GetDC()->Clear() ; 
1989 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event 
) 
1991     wxWindowDC 
dc(this) ; 
1992     wxMacPortSetter 
helper(&dc
) ; 
1994     MacPaintBorders( dc
.m_macLocalOrigin
.x 
, dc
.m_macLocalOrigin
.y
) ; 
1997 int wxWindowMac::GetScrollPos(int orient
) const 
1999     if ( orient 
== wxHORIZONTAL 
) 
2002            return m_hScrollBar
->GetThumbPosition() ; 
2007            return m_vScrollBar
->GetThumbPosition() ; 
2012 // This now returns the whole range, not just the number 
2013 // of positions that we can scroll. 
2014 int wxWindowMac::GetScrollRange(int orient
) const 
2016     if ( orient 
== wxHORIZONTAL 
) 
2019            return m_hScrollBar
->GetRange() ; 
2024            return m_vScrollBar
->GetRange() ; 
2029 int wxWindowMac::GetScrollThumb(int orient
) const 
2031     if ( orient 
== wxHORIZONTAL 
) 
2034            return m_hScrollBar
->GetThumbSize() ; 
2039            return m_vScrollBar
->GetThumbSize() ; 
2044 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
) 
2046     if ( orient 
== wxHORIZONTAL 
) 
2049            m_hScrollBar
->SetThumbPosition( pos 
) ; 
2054            m_vScrollBar
->SetThumbPosition( pos 
) ; 
2058 void wxWindowMac::MacPaintBorders( int left 
, int top 
) 
2064     wxGetOsVersion( &major
, &minor 
); 
2066     RGBColor white 
= { 0xFFFF, 0xFFFF , 0xFFFF } ; 
2067     RGBColor face 
= { 0xDDDD, 0xDDDD , 0xDDDD } ; 
2069     RGBColor darkShadow 
= { 0x0000, 0x0000 , 0x0000 } ; 
2070     RGBColor lightShadow 
= { 0x4444, 0x4444 , 0x4444 } ; 
2071     // OS X has lighter border edges than classic: 
2074         darkShadow
.red          
= 0x8E8E; 
2075         darkShadow
.green        
= 0x8E8E; 
2076         darkShadow
.blue         
= 0x8E8E; 
2077         lightShadow
.red         
= 0xBDBD; 
2078         lightShadow
.green       
= 0xBDBD; 
2079         lightShadow
.blue        
= 0xBDBD; 
2085     GetSize( &w 
, &h 
) ; 
2086     if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) ) 
2088 #if wxMAC_USE_THEME_BORDER 
2089         Rect rect 
= { top 
, left 
, m_height 
+ top 
, m_width 
+ left 
} ; 
2092         GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; 
2093         InsetRect( &rect , border , border ); 
2094         DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; 
2097         DrawThemePrimaryGroup(&rect  
,IsEnabled() ? kThemeStateActive 
: kThemeStateInactive
) ; 
2099         bool sunken 
= HasFlag( wxSUNKEN_BORDER 
) ; 
2100         RGBForeColor( &face 
); 
2101         MoveTo( left 
+ 0 , top 
+ h 
- 2 ); 
2102         LineTo( left 
+ 0 , top 
+ 0 ); 
2103         LineTo( left 
+ w 
- 2 , top 
+ 0 ); 
2105         MoveTo( left 
+ 2 , top 
+ h 
- 3 ); 
2106         LineTo( left 
+ w 
- 3 , top 
+ h 
- 3 ); 
2107         LineTo( left 
+ w 
- 3 , top 
+ 2 ); 
2109         RGBForeColor( sunken 
? &face 
: &darkShadow 
); 
2110         MoveTo( left 
+ 0 , top 
+ h 
- 1 ); 
2111         LineTo( left 
+ w 
- 1 , top 
+ h 
- 1 ); 
2112         LineTo( left 
+ w 
- 1 , top 
+ 0 ); 
2114         RGBForeColor( sunken 
? &lightShadow 
: &white 
); 
2115         MoveTo( left 
+ 1 , top 
+ h 
- 3 ); 
2116         LineTo( left 
+ 1, top 
+ 1 ); 
2117         LineTo( left 
+ w 
- 3 , top 
+ 1 ); 
2119         RGBForeColor( sunken 
? &white 
: &lightShadow 
); 
2120         MoveTo( left 
+ 1 , top 
+ h 
- 2 ); 
2121         LineTo( left 
+ w 
- 2 , top 
+ h 
- 2 ); 
2122         LineTo( left 
+ w 
- 2 , top 
+ 1 ); 
2124         RGBForeColor( sunken 
? &darkShadow 
: &face 
); 
2125         MoveTo( left 
+ 2 , top 
+ h 
- 4 ); 
2126         LineTo( left 
+ 2 , top 
+ 2 ); 
2127         LineTo( left 
+ w 
- 4 , top 
+ 2 ); 
2130     else if (HasFlag(wxSIMPLE_BORDER
)) 
2132         Rect rect 
= { top 
, left 
, h 
+ top 
, w 
+ left 
} ; 
2133         RGBForeColor( &darkShadow 
) ; 
2134         FrameRect( &rect 
) ; 
2138 void wxWindowMac::RemoveChild( wxWindowBase 
*child 
) 
2140     if ( child 
== m_hScrollBar 
) 
2141         m_hScrollBar 
= NULL 
; 
2142     if ( child 
== m_vScrollBar 
) 
2143         m_vScrollBar 
= NULL 
; 
2145     wxWindowBase::RemoveChild( child 
) ; 
2148 // New function that will replace some of the above. 
2149 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
, 
2150     int range
, bool refresh
) 
2152     if ( orient 
== wxHORIZONTAL 
) 
2156             if ( range 
== 0 || thumbVisible 
>= range 
) 
2158                 if ( m_hScrollBar
->IsShown() ) 
2159                     m_hScrollBar
->Show(false) ; 
2163                 if ( !m_hScrollBar
->IsShown() ) 
2164                     m_hScrollBar
->Show(true) ; 
2165                 m_hScrollBar
->SetScrollbar( pos 
, thumbVisible 
, range 
, thumbVisible 
, refresh 
) ; 
2173             if ( range 
== 0 || thumbVisible 
>= range 
) 
2175                 if ( m_vScrollBar
->IsShown() ) 
2176                     m_vScrollBar
->Show(false) ; 
2180                 if ( !m_vScrollBar
->IsShown() ) 
2181                     m_vScrollBar
->Show(true) ; 
2182                 m_vScrollBar
->SetScrollbar( pos 
, thumbVisible 
, range 
, thumbVisible 
, refresh 
) ; 
2186     MacRepositionScrollBars() ; 
2189 // Does a physical scroll 
2190 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect 
*rect
) 
2192     if( dx 
== 0 && dy 
==0 ) 
2197         wxClientDC 
dc(this) ; 
2198         wxMacPortSetter 
helper(&dc
) ; 
2200         int width 
, height 
; 
2201         GetClientSize( &width 
, &height 
) ; 
2208         // TODO take out the boundaries 
2209         GetControlBounds( (ControlRef
) m_macControl
, &scrollrect
); 
2211         RgnHandle updateRgn 
= NewRgn() ; 
2214             Rect r 
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y 
+ rect
->height
) , 
2215                 dc
.XLOG2DEVMAC(rect
->x 
+ rect
->width
) } ; 
2216             SectRect( &scrollrect 
, &r 
, &scrollrect 
) ; 
2218         ScrollRect( &scrollrect 
, dx 
, dy 
, updateRgn 
) ; 
2220         //KO: The docs say ScrollRect creates an update region, which thus calls an update event 
2221         // but it seems the update only refreshes the background of the control, rather than calling  
2222         // kEventControlDraw, so we need to force a proper update here. There has to be a better  
2223         // way of doing this... (Note that code below under !TARGET_CARBON does not work either...) 
2226         // we also have to scroll the update rgn in this rectangle  
2227         // in order not to loose updates 
2229         WindowRef rootWindow 
= (WindowRef
) MacGetTopLevelWindowRef() ; 
2230         RgnHandle formerUpdateRgn 
= NewRgn() ; 
2231         RgnHandle scrollRgn 
= NewRgn() ; 
2232         RectRgn( scrollRgn 
, &scrollrect 
) ; 
2233         GetWindowUpdateRgn( rootWindow 
, formerUpdateRgn 
) ; 
2235         LocalToGlobal( &pt 
) ; 
2236         OffsetRgn( formerUpdateRgn 
, -pt
.h 
, -pt
.v 
) ; 
2237         SectRgn( formerUpdateRgn 
, scrollRgn 
, formerUpdateRgn 
) ; 
2238         if ( !EmptyRgn( formerUpdateRgn 
) ) 
2240             MacOffsetRgn( formerUpdateRgn 
, dx 
, dy 
) ; 
2241             SectRgn( formerUpdateRgn 
, scrollRgn 
, formerUpdateRgn 
) ; 
2242             InvalWindowRgn(rootWindow  
,  formerUpdateRgn 
) ; 
2244         InvalWindowRgn(rootWindow  
,  updateRgn 
) ; 
2245         DisposeRgn( updateRgn 
) ; 
2246         DisposeRgn( formerUpdateRgn 
) ; 
2247         DisposeRgn( scrollRgn 
) ; 
2251     for (wxWindowListNode 
*node 
= GetChildren().GetFirst(); node
; node 
= node
->GetNext()) 
2253         wxWindowMac 
*child 
= node
->GetData(); 
2254         if (child 
== m_vScrollBar
) continue; 
2255         if (child 
== m_hScrollBar
) continue; 
2256         if (child
->IsTopLevel()) continue; 
2259         child
->GetPosition( &x
, &y 
); 
2261         child
->GetSize( &w
, &h 
); 
2265             if (rect
->Intersects(rc
)) 
2266                 child
->SetSize( x
+dx
, y
+dy
, w
, h 
); 
2270             child
->SetSize( x
+dx
, y
+dy
, w
, h 
);          
2274 // TODO remove, was moved higher up    Update() ; 
2278 void wxWindowMac::MacOnScroll(wxScrollEvent 
&event 
) 
2280     if ( event
.m_eventObject 
== m_vScrollBar 
|| event
.m_eventObject 
== m_hScrollBar 
) 
2282         wxScrollWinEvent wevent
; 
2283         wevent
.SetPosition(event
.GetPosition()); 
2284         wevent
.SetOrientation(event
.GetOrientation()); 
2285         wevent
.m_eventObject 
= this; 
2287         if (event
.m_eventType 
== wxEVT_SCROLL_TOP
) 
2288             wevent
.m_eventType 
= wxEVT_SCROLLWIN_TOP
; 
2289         else if (event
.m_eventType 
== wxEVT_SCROLL_BOTTOM
) 
2290             wevent
.m_eventType 
= wxEVT_SCROLLWIN_BOTTOM
; 
2291         else if (event
.m_eventType 
== wxEVT_SCROLL_LINEUP
) 
2292             wevent
.m_eventType 
= wxEVT_SCROLLWIN_LINEUP
; 
2293         else if (event
.m_eventType 
== wxEVT_SCROLL_LINEDOWN
) 
2294             wevent
.m_eventType 
= wxEVT_SCROLLWIN_LINEDOWN
; 
2295         else if (event
.m_eventType 
== wxEVT_SCROLL_PAGEUP
) 
2296             wevent
.m_eventType 
= wxEVT_SCROLLWIN_PAGEUP
; 
2297         else if (event
.m_eventType 
== wxEVT_SCROLL_PAGEDOWN
) 
2298             wevent
.m_eventType 
= wxEVT_SCROLLWIN_PAGEDOWN
; 
2299         else if (event
.m_eventType 
== wxEVT_SCROLL_THUMBTRACK
) 
2300             wevent
.m_eventType 
= wxEVT_SCROLLWIN_THUMBTRACK
; 
2301         else if (event
.m_eventType 
== wxEVT_SCROLL_THUMBRELEASE
) 
2302             wevent
.m_eventType 
= wxEVT_SCROLLWIN_THUMBRELEASE
; 
2304         GetEventHandler()->ProcessEvent(wevent
); 
2308 // Get the window with the focus 
2309 wxWindowMac 
*wxWindowBase::FindFocus() 
2311     ControlRef control 
; 
2312     GetKeyboardFocus( GetUserFocusWindow() , &control 
) ; 
2313     return wxFindControlFromMacControl( control 
) ; 
2316 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
) 
2318     // panel wants to track the window which was the last to have focus in it, 
2319     // so we want to set ourselves as the window which last had focus 
2321     // notice that it's also important to do it upwards the tree becaus 
2322     // otherwise when the top level panel gets focus, it won't set it back to 
2323     // us, but to some other sibling 
2325     // CS:don't know if this is still needed: 
2326     //wxChildFocusEvent eventFocus(this); 
2327     //(void)GetEventHandler()->ProcessEvent(eventFocus); 
2332 void wxWindowMac::OnInternalIdle() 
2334     // This calls the UI-update mechanism (querying windows for 
2335     // menu/toolbar/control state information) 
2336     if (wxUpdateUIEvent::CanUpdate(this)) 
2337         UpdateWindowUI(wxUPDATE_UI_FROMIDLE
); 
2340 // Raise the window to the top of the Z order 
2341 void wxWindowMac::Raise() 
2343 #if TARGET_API_MAC_OSX 
2344     HIViewSetZOrder((ControlRef
)m_macControl
,kHIViewZOrderAbove
, NULL
) ; 
2348 // Lower the window to the bottom of the Z order 
2349 void wxWindowMac::Lower() 
2351 #if TARGET_API_MAC_OSX 
2352     HIViewSetZOrder((ControlRef
)m_macControl
,kHIViewZOrderBelow
, NULL
) ; 
2357 // static wxWindow *gs_lastWhich = NULL; 
2359 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
) 
2361     // first trigger a set cursor event 
2363     wxPoint clientorigin 
= GetClientAreaOrigin() ; 
2364     wxSize clientsize 
= GetClientSize() ; 
2366     if ( wxRect2DInt( clientorigin
.x 
, clientorigin
.y 
, clientsize
.x 
, clientsize
.y 
).Contains( wxPoint2DInt( pt 
) ) ) 
2368         wxSetCursorEvent 
event( pt
.x 
, pt
.y 
); 
2370         bool processedEvtSetCursor 
= GetEventHandler()->ProcessEvent(event
); 
2371         if ( processedEvtSetCursor 
&& event
.HasCursor() ) 
2373             cursor 
= event
.GetCursor() ; 
2378             // the test for processedEvtSetCursor is here to prevent using m_cursor 
2379             // if the user code caught EVT_SET_CURSOR() and returned nothing from 
2380             // it - this is a way to say that our cursor shouldn't be used for this 
2382             if ( !processedEvtSetCursor 
&& m_cursor
.Ok() ) 
2392                     cursor 
= *wxSTANDARD_CURSOR  
; 
2396             cursor
.MacInstall() ; 
2398     return cursor
.Ok() ; 
2401 wxString 
wxWindowMac::MacGetToolTipString( wxPoint 
&pt 
) 
2405         return m_tooltip
->GetTip() ; 
2407     return wxEmptyString 
; 
2410 void wxWindowMac::Update() 
2412 #if TARGET_API_MAC_OSX 
2413     HIViewSetNeedsDisplay( (ControlRef
) m_macControl 
, true ) ; 
2415     ::Draw1Control( (ControlRef
) m_macControl 
) ; 
2419 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const 
2421     wxTopLevelWindowMac
* win 
= NULL 
; 
2422     WindowRef window 
= (WindowRef
) MacGetTopLevelWindowRef() ; 
2425         win 
= wxFindWinFromMacWindow( window 
) ; 
2429 wxRegion 
wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures 
) 
2433     RgnHandle visRgn 
= NewRgn() ; 
2434     RgnHandle tempRgn 
= NewRgn() ; 
2435     if ( IsControlVisible( (ControlRef
) m_macControl 
) ) 
2437         GetControlBounds( (ControlRef
) m_macControl 
, &r 
) ; 
2438         if (! MacGetTopLevelWindow()->MacUsesCompositing() ) 
2440             MacRootWindowToWindow( &r
.left 
, & r
.top 
) ; 
2441             MacRootWindowToWindow( &r
.right 
, & r
.bottom 
) ; 
2450         if ( includeOuterStructures 
) 
2451             InsetRect( &r 
, -3 , -3 ) ; 
2452         RectRgn( visRgn 
, &r 
) ; 
2453         if ( !IsTopLevel() ) 
2455             wxWindow
* child 
= this ; 
2456             wxWindow
* parent 
= child
->GetParent() ; 
2461                 // we have to find a better clipping algorithm here, in order not to clip things 
2462                 // positioned like status and toolbar 
2463                 if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ ) 
2465                     size 
= parent
->GetSize() ; 
2470                     size 
= parent
->GetClientSize() ; 
2471                     wxPoint origin 
= parent
->GetClientAreaOrigin() ; 
2475                 parent
->MacWindowToRootWindow( &x
, &y 
) ; 
2476                 MacRootWindowToWindow( &x 
, &y 
) ; 
2478                 SetRectRgn( tempRgn 
, 
2479                     x 
+ parent
->MacGetLeftBorderSize() , y 
+ parent
->MacGetTopBorderSize() , 
2480                     x 
+ size
.x 
- parent
->MacGetRightBorderSize(), 
2481                     y 
+ size
.y 
- parent
->MacGetBottomBorderSize()) ; 
2483                 SectRgn( visRgn 
, tempRgn 
, visRgn 
) ; 
2484                 if ( parent
->IsTopLevel() ) 
2487                 parent 
= child
->GetParent() ; 
2492     wxRegion vis 
= visRgn 
; 
2493     DisposeRgn( visRgn 
) ; 
2494     DisposeRgn( tempRgn 
) ; 
2499     This function must not change the updatergn ! 
2501 bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr 
, long time 
)  
2503     RgnHandle updatergn 
= (RgnHandle
) updatergnr 
; 
2504     bool handled 
= false ; 
2506     // calculate a client-origin version of the update rgn and set m_updateRegion to that 
2508         RgnHandle newupdate 
= NewRgn() ; 
2509         wxSize point 
= GetClientSize() ; 
2510         wxPoint origin 
= GetClientAreaOrigin() ; 
2511         SetRectRgn( newupdate 
, origin
.x 
, origin
.y 
, origin
.x 
+ point
.x 
, origin
.y
+point
.y 
) ; 
2512         SectRgn( newupdate 
, updatergn 
, newupdate 
) ; 
2513         OffsetRgn( newupdate 
, -origin
.x 
, -origin
.y 
) ; 
2514         m_updateRegion 
= newupdate 
; 
2515         DisposeRgn( newupdate 
) ;  
2518     if ( !EmptyRgn(updatergn
) ) 
2520         wxWindowDC 
dc(this); 
2521         if (!EmptyRgn(updatergn
)) 
2522             dc
.SetClippingRegion(wxRegion(updatergn
)); 
2524         wxEraseEvent 
eevent( GetId(), &dc 
); 
2525         eevent
.SetEventObject( this ); 
2526         GetEventHandler()->ProcessEvent( eevent 
); 
2528         if ( !m_updateRegion
.Empty() ) 
2530             // paint the window itself 
2532             event
.m_timeStamp 
= time 
; 
2533             event
.SetEventObject(this); 
2534             handled 
= GetEventHandler()->ProcessEvent(event
);  
2536             // paint custom borders 
2537             wxNcPaintEvent 
eventNc( GetId() ); 
2538             eventNc
.SetEventObject( this ); 
2539             GetEventHandler()->ProcessEvent( eventNc 
); 
2545 void wxWindowMac::MacRedraw( WXHRGN updatergnr 
, long time
, bool erase
) 
2547     RgnHandle updatergn 
= (RgnHandle
) updatergnr 
; 
2548     // updatergn is always already clipped to our boundaries 
2549     // if we are in compositing mode then it is in relative to the upper left of the control 
2550     // if we are in non-compositing, then it is relatvie to the uppder left of the content area 
2551     // of the toplevel window 
2552     // it is in window coordinates, not in client coordinates 
2554     // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates 
2555     RgnHandle ownUpdateRgn 
= NewRgn() ; 
2556     CopyRgn( updatergn 
, ownUpdateRgn 
) ; 
2558     if ( MacGetTopLevelWindow()->MacUsesCompositing() == false ) 
2561         UMAGetControlBoundsInWindowCoords( (ControlRef
)m_macControl
, &bounds 
); 
2562         RgnHandle controlRgn 
= NewRgn(); 
2563         RectRgn( controlRgn
, &bounds 
); 
2564         //KO: This sets the ownUpdateRgn to the area of this control that is inside 
2565         // the window update region 
2566         SectRgn( ownUpdateRgn
, controlRgn
, ownUpdateRgn 
);  
2567         DisposeRgn( controlRgn 
); 
2569         //KO: convert ownUpdateRgn to local coordinates 
2570         OffsetRgn( ownUpdateRgn
, -bounds
.left
, -bounds
.top 
);  
2573     MacDoRedraw( ownUpdateRgn 
, time 
) ; 
2574     DisposeRgn( ownUpdateRgn 
) ; 
2578 WXWindow 
wxWindowMac::MacGetTopLevelWindowRef() const 
2580     wxWindowMac 
*iter 
= (wxWindowMac
*)this ; 
2584         if ( iter
->IsTopLevel() ) 
2585             return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ; 
2587         iter 
= iter
->GetParent() ; 
2589     wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; 
2593 void wxWindowMac::MacCreateScrollBars( long style 
) 
2595     wxASSERT_MSG( m_vScrollBar 
== NULL 
&& m_hScrollBar 
== NULL 
, wxT("attempt to create window twice") ) ; 
2597     bool hasBoth 
= ( style 
& wxVSCROLL 
) && ( style 
& wxHSCROLL 
) ; 
2598     int adjust 
= hasBoth 
? MAC_SCROLLBAR_SIZE 
- 1: 0 ; 
2600     GetClientSize( &width 
, &height 
) ; 
2602     wxPoint 
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ; 
2603     wxSize 
vSize(MAC_SCROLLBAR_SIZE
, height 
- adjust
) ; 
2604     wxPoint 
hPoint(0 , height
-MAC_SCROLLBAR_SIZE 
) ; 
2605     wxSize 
hSize( width 
- adjust
, MAC_SCROLLBAR_SIZE
) ; 
2607     m_vScrollBar 
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
, 
2608         vSize 
, wxVERTICAL
); 
2610     if ( style 
& wxVSCROLL 
) 
2616         m_vScrollBar
->Show(false) ; 
2618     m_hScrollBar 
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
, 
2619         hSize 
, wxHORIZONTAL
); 
2620     if ( style  
& wxHSCROLL 
) 
2625         m_hScrollBar
->Show(false) ; 
2628     // because the create does not take into account the client area origin 
2629     MacRepositionScrollBars() ; // we might have a real position shift 
2632 void wxWindowMac::MacRepositionScrollBars() 
2634     bool hasBoth 
= ( m_hScrollBar 
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar 
&& m_vScrollBar
->IsShown()) ; 
2635     int adjust 
= hasBoth 
? MAC_SCROLLBAR_SIZE 
- 1 : 0 ; 
2637     // get real client area 
2641     GetSize( &width 
, &height 
) ; 
2643     width 
-= MacGetLeftBorderSize() + MacGetRightBorderSize(); 
2644     height 
-= MacGetTopBorderSize() + MacGetBottomBorderSize(); 
2646     wxPoint 
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ; 
2647     wxSize 
vSize(MAC_SCROLLBAR_SIZE
, height 
- adjust
) ; 
2648     wxPoint 
hPoint(0 , height
-MAC_SCROLLBAR_SIZE 
) ; 
2649     wxSize 
hSize( width 
- adjust
, MAC_SCROLLBAR_SIZE
) ; 
2655     GetSize( &w 
, &h 
) ; 
2657     MacClientToRootWindow( &x 
, &y 
) ; 
2658     MacClientToRootWindow( &w 
, &h 
) ; 
2660     wxWindowMac 
*iter 
= (wxWindowMac
*)this ; 
2662     int totW 
= 10000 , totH 
= 10000; 
2665         if ( iter
->IsTopLevel() ) 
2667             iter
->GetSize( &totW 
, &totH 
) ; 
2671         iter 
= iter
->GetParent() ; 
2699         m_vScrollBar
->SetSize( vPoint
.x 
, vPoint
.y
, vSize
.x
, vSize
.y 
, wxSIZE_ALLOW_MINUS_ONE
); 
2703         m_hScrollBar
->SetSize( hPoint
.x 
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
); 
2707 bool wxWindowMac::AcceptsFocus() const 
2709     return MacCanFocus() && wxWindowBase::AcceptsFocus(); 
2712 void wxWindowMac::MacSuperChangedPosition() 
2714     // only window-absolute structures have to be moved i.e. controls 
2716     wxWindowListNode 
*node 
= GetChildren().GetFirst(); 
2719         wxWindowMac 
*child 
= node
->GetData(); 
2720         child
->MacSuperChangedPosition() ; 
2721         node 
= node
->GetNext(); 
2725 void wxWindowMac::MacTopLevelWindowChangedPosition() 
2727     // only screen-absolute structures have to be moved i.e. glcanvas 
2729     wxWindowListNode 
*node 
= GetChildren().GetFirst(); 
2732         wxWindowMac 
*child 
= node
->GetData(); 
2733         child
->MacTopLevelWindowChangedPosition() ; 
2734         node 
= node
->GetNext(); 
2738 long wxWindowMac::MacGetLeftBorderSize( ) const 
2743     if (m_windowStyle 
& wxRAISED_BORDER 
|| m_windowStyle 
& wxSUNKEN_BORDER 
) 
2746 #if wxMAC_USE_THEME_BORDER 
2747           GetThemeMetric( kThemeMetricListBoxFrameOutset 
, &border 
) ; 
2751     else if (  m_windowStyle 
&wxDOUBLE_BORDER
) 
2754 #if wxMAC_USE_THEME_BORDER 
2755           GetThemeMetric( kThemeMetricListBoxFrameOutset 
, &border 
) ; 
2759     else if (m_windowStyle 
&wxSIMPLE_BORDER
) 
2766 long wxWindowMac::MacGetRightBorderSize( ) const 
2768     // they are all symmetric in mac themes 
2769     return MacGetLeftBorderSize() ; 
2772 long wxWindowMac::MacGetTopBorderSize( ) const 
2774     // they are all symmetric in mac themes 
2775     return MacGetLeftBorderSize() ; 
2778 long wxWindowMac::MacGetBottomBorderSize( ) const 
2780     // they are all symmetric in mac themes 
2781     return MacGetLeftBorderSize() ; 
2784 long wxWindowMac::MacRemoveBordersFromStyle( long style 
) 
2786     return style 
& ~( wxDOUBLE_BORDER 
| wxSUNKEN_BORDER 
| wxRAISED_BORDER 
| wxBORDER 
| wxSTATIC_BORDER 
) ; 
2789 // Find the wxWindowMac at the current mouse position, returning the mouse 
2791 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
) 
2793     pt 
= wxGetMousePosition(); 
2794     wxWindowMac
* found 
= wxFindWindowAtPoint(pt
); 
2798 // Get the current mouse position. 
2799 wxPoint 
wxGetMousePosition() 
2802     wxGetMousePosition(& x
, & y
); 
2803     return wxPoint(x
, y
); 
2806 void wxWindowMac::OnMouseEvent( wxMouseEvent 
&event 
) 
2808         if ( event
.GetEventType() == wxEVT_RIGHT_DOWN 
) 
2810                 // copied from wxGTK : CS 
2811         // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN 
2814         // (a) it's a command event and so is propagated to the parent 
2815         // (b) under MSW it can be generated from kbd too 
2816         // (c) it uses screen coords (because of (a)) 
2817         wxContextMenuEvent 
evtCtx(wxEVT_CONTEXT_MENU
, 
2819                                   this->ClientToScreen(event
.GetPosition())); 
2820         if ( ! GetEventHandler()->ProcessEvent(evtCtx
) ) 
2829 void wxWindowMac::MacHandleControlClick( WXWidget control 
, wxInt16 controlpart 
, bool WXUNUSED( mouseStillDown 
) )  
2833 Rect 
wxMacGetBoundsForControl( wxWindow
* window 
, const wxPoint
& pos 
, const wxSize 
&size 
, bool adjustForOrigin 
)  
2837     window
->MacGetBoundsForControl( pos 
, size 
, x 
, y
, w
, h 
, adjustForOrigin
) ; 
2838     Rect bounds 
=  { y 
, x 
, y
+h 
, x
+w  
}; 
2842 wxInt32 
wxWindowMac::MacControlHit(WXEVENTHANDLERREF 
WXUNUSED(handler
) , WXEVENTREF 
WXUNUSED(event
) )  
2844     return eventNotHandledErr 
;