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/scrolwin.h"
28 #include "wx/statbox.h"
29 #include "wx/button.h"
30 #include "wx/settings.h"
31 #include "wx/msgdlg.h"
33 #include "wx/tooltip.h"
34 #include "wx/statusbr.h"
35 #include "wx/menuitem.h"
36 #include "wx/spinctrl.h"
38 #include "wx/geometry.h"
39 #include "wx/textctrl.h"
40 #include "wx/laywin.h"
41 #include "wx/splitter.h"
43 #include "wx/toolbar.h"
50 #define wxWINDOW_HSCROLL 5998
51 #define wxWINDOW_VSCROLL 5997
53 #define MAC_SCROLLBAR_SIZE 15
54 #define MAC_SMALL_SCROLLBAR_SIZE 11
56 #include "wx/mac/uma.h"
59 #include <ToolUtils.h>
61 #include <MacTextEditor.h>
64 #if TARGET_API_MAC_OSX
66 #include <HIToolbox/HIView.h>
70 #if wxUSE_DRAG_AND_DROP
76 extern wxList wxPendingDelete
;
78 #ifdef __WXUNIVERSAL__
79 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
81 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
82 #endif // __WXUNIVERSAL__/__WXMAC__
84 #if !USE_SHARED_LIBRARY
86 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
87 EVT_NC_PAINT(wxWindowMac
::OnNcPaint
)
88 EVT_ERASE_BACKGROUND(wxWindowMac
::OnEraseBackground
)
89 // TODO EVT_PAINT(wxWindowMac::OnPaint)
90 EVT_SET_FOCUS(wxWindowMac
::OnSetFocus
)
91 EVT_KILL_FOCUS(wxWindowMac
::OnSetFocus
)
92 EVT_MOUSE_EVENTS(wxWindowMac
::OnMouseEvent
)
97 #define wxMAC_DEBUG_REDRAW 0
98 #ifndef wxMAC_DEBUG_REDRAW
99 #define wxMAC_DEBUG_REDRAW 0
102 #define wxMAC_USE_THEME_BORDER 1
104 // ---------------------------------------------------------------------------
105 // Utility Routines to move between different coordinate systems
106 // ---------------------------------------------------------------------------
109 * Right now we have the following setup :
110 * a border that is not part of the native control is always outside the
111 * control's border (otherwise we loose all native intelligence, future ways
112 * may be to have a second embedding control responsible for drawing borders
113 * and backgrounds eventually)
114 * so all this border calculations have to be taken into account when calling
115 * native methods or getting native oriented data
116 * so we have three coordinate systems here
117 * wx client coordinates
118 * wx window coordinates (including window frames)
123 // originating from native control
127 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
129 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
132 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
134 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
138 // directed towards native control
141 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
143 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
146 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
148 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
152 // ---------------------------------------------------------------------------
154 // ---------------------------------------------------------------------------
156 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
157 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
) ;
159 #if TARGET_API_MAC_OSX
161 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
163 kEventControlVisibilityChanged
= 157
169 static const EventTypeSpec eventList
[] =
171 { kEventClassControl
, kEventControlHit
} ,
172 #if TARGET_API_MAC_OSX
173 { kEventClassControl
, kEventControlDraw
} ,
174 { kEventClassControl
, kEventControlVisibilityChanged
} ,
175 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
176 { kEventClassControl
, kEventControlHiliteChanged
} ,
177 { kEventClassControl
, kEventControlSetFocusPart
} ,
179 { kEventClassService
, kEventServiceGetTypes
},
180 { kEventClassService
, kEventServiceCopy
},
181 { kEventClassService
, kEventServicePaste
},
183 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
184 // { kEventClassControl , kEventControlBoundsChanged } ,
188 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
190 OSStatus result
= eventNotHandledErr
;
192 wxMacCarbonEvent
cEvent( event
) ;
194 ControlRef controlRef
;
195 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
197 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
199 switch( GetEventKind( event
) )
201 #if TARGET_API_MAC_OSX
202 case kEventControlDraw
:
204 RgnHandle updateRgn
= NULL
;
205 RgnHandle allocatedRgn
= NULL
;
206 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
207 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
209 updateRgn
= (RgnHandle
) visRegion
.GetWXHRGN() ;
213 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
215 allocatedRgn
= NewRgn() ;
216 CopyRgn( updateRgn
, allocatedRgn
) ;
217 // hide the given region by the new region that must be shifted
218 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
219 updateRgn
= allocatedRgn
;
224 // in case we would need a coregraphics compliant background erase first
225 // now usable to track redraws
226 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
227 if ( thisWindow
->MacIsUserPane() )
229 static float color
= 0.5 ;
232 HIViewGetBounds( controlRef
, &bounds
);
233 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
234 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
235 CGContextFillRect( cgContext
, bounds
);
246 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
249 DisposeRgn( allocatedRgn
) ;
252 case kEventControlVisibilityChanged
:
253 thisWindow
->MacVisibilityChanged() ;
255 case kEventControlEnabledStateChanged
:
256 thisWindow
->MacEnabledStateChanged() ;
258 case kEventControlHiliteChanged
:
259 thisWindow
->MacHiliteChanged() ;
261 case kEventControlSetFocusPart
:
263 Boolean focusEverything
= false ;
264 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
265 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
268 if ( controlPart
== kControlFocusNoPart
)
271 if ( thisWindow
->GetCaret() )
273 thisWindow
->GetCaret()->OnKillFocus();
275 #endif // wxUSE_CARET
276 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
277 event
.SetEventObject(thisWindow
);
278 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
282 // panel wants to track the window which was the last to have focus in it
283 wxChildFocusEvent
eventFocus(thisWindow
);
284 thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
);
287 if ( thisWindow
->GetCaret() )
289 thisWindow
->GetCaret()->OnSetFocus();
291 #endif // wxUSE_CARET
293 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
294 event
.SetEventObject(thisWindow
);
295 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
297 if ( thisWindow
->MacIsUserPane() )
302 case kEventControlHit
:
304 result
= thisWindow
->MacControlHit( handler
, event
) ;
313 static pascal OSStatus
wxMacWindowServiceEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
315 OSStatus result
= eventNotHandledErr
;
317 wxMacCarbonEvent
cEvent( event
) ;
319 ControlRef controlRef
;
320 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
321 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
322 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
324 switch( GetEventKind( event
) )
326 case kEventServiceGetTypes
:
330 textCtrl
->GetSelection( &from
, &to
) ;
332 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
334 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
335 if ( textCtrl
->IsEditable() )
336 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
338 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ };
339 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
341 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
345 CFArrayAppendValue (copyTypes
, typestring
) ;
347 CFArrayAppendValue (pasteTypes
, typestring
) ;
348 CFRelease( typestring
) ;
354 case kEventServiceCopy
:
358 textCtrl
->GetSelection( &from
, &to
) ;
359 wxString val
= textCtrl
->GetValue() ;
360 val
= val
.Mid( from
, to
- from
) ;
361 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
362 verify_noerr( ClearScrap( &scrapRef
) ) ;
363 verify_noerr( PutScrapFlavor( scrapRef
, kTXNTextData
, 0 , val
.Length() , val
.c_str() ) ) ;
367 case kEventServicePaste
:
370 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
371 Size textSize
, pastedSize
;
372 verify_noerr( GetScrapFlavorSize (scrapRef
, kTXNTextData
, &textSize
) ) ;
374 char *content
= new char[textSize
] ;
375 GetScrapFlavorData (scrapRef
, kTXNTextData
, &pastedSize
, content
);
376 content
[textSize
-1] = 0 ;
378 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
380 textCtrl
->WriteText( wxString( content
) ) ;
391 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
393 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
394 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
395 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
396 OSStatus result
= eventNotHandledErr
;
398 switch ( GetEventClass( event
) )
400 case kEventClassControl
:
401 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
403 case kEventClassService
:
404 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
408 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
412 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
414 // ---------------------------------------------------------------------------
415 // UserPane events for non OSX builds
416 // ---------------------------------------------------------------------------
418 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
420 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
421 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
422 win
->MacControlUserPaneDrawProc(part
) ;
425 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
427 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
428 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
429 return win
->MacControlUserPaneHitTestProc(where
.h
, where
.v
) ;
432 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
434 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
435 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
436 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
439 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
441 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
442 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
443 win
->MacControlUserPaneIdleProc() ;
446 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
448 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
449 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
450 return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ;
453 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
455 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
456 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
457 win
->MacControlUserPaneActivateProc(activating
) ;
460 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
462 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
463 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
464 return win
->MacControlUserPaneFocusProc(action
) ;
467 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
469 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
470 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
471 win
->MacControlUserPaneBackgroundProc(info
) ;
474 void wxWindowMac
::MacControlUserPaneDrawProc(wxInt16 part
)
476 RgnHandle rgn
= NewRgn() ;
478 wxMacWindowStateSaver
sv( this ) ;
479 SectRgn( rgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn
) ;
480 MacDoRedraw( rgn
, 0 ) ;
484 wxInt16 wxWindowMac
::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
486 return kControlNoPart
;
489 wxInt16 wxWindowMac
::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
491 return kControlNoPart
;
494 void wxWindowMac
::MacControlUserPaneIdleProc()
498 wxInt16 wxWindowMac
::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
500 return kControlNoPart
;
503 void wxWindowMac
::MacControlUserPaneActivateProc(bool activating
)
507 wxInt16 wxWindowMac
::MacControlUserPaneFocusProc(wxInt16 action
)
509 return kControlNoPart
;
512 void wxWindowMac
::MacControlUserPaneBackgroundProc(void* info
)
516 ControlUserPaneDrawUPP gControlUserPaneDrawUPP
= NULL
;
517 ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP
= NULL
;
518 ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP
= NULL
;
519 ControlUserPaneIdleUPP gControlUserPaneIdleUPP
= NULL
;
520 ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP
= NULL
;
521 ControlUserPaneActivateUPP gControlUserPaneActivateUPP
= NULL
;
522 ControlUserPaneFocusUPP gControlUserPaneFocusUPP
= NULL
;
523 ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP
= NULL
;
525 // ===========================================================================
527 // ===========================================================================
529 wxList
wxWinMacControlList(wxKEY_INTEGER
);
531 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
533 wxNode
*node
= wxWinMacControlList
.Find((long)inControl
);
536 return (wxControl
*)node
->GetData();
539 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
541 // adding NULL ControlRef is (first) surely a result of an error and
542 // (secondly) breaks native event processing
543 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
545 if ( !wxWinMacControlList
.Find((long)inControl
) )
546 wxWinMacControlList
.Append((long)inControl
, control
);
549 void wxRemoveMacControlAssociation(wxWindow
*control
)
551 wxWinMacControlList
.DeleteObject(control
);
555 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
557 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
559 // we have to setup the brush in the current port and return noErr
560 // or return an error code so that the control manager walks further up the
561 // hierarchy to find a correct background
563 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
565 OSStatus status
= paramErr
;
568 case kControlMsgApplyTextColor
:
570 case kControlMsgSetUpBackground
:
572 wxWindow
* wx
= (wxWindow
*) wxFindControlFromMacControl( iControl
) ;
576 const wxBrush &brush = wx->MacGetBackgroundBrush() ;
579 wxDC::MacSetupBackgroundForCurrentPort( brush ) ;
581 // this clipping is only needed for non HIView
583 RgnHandle clip
= NewRgn() ;
586 wx
->MacWindowToRootWindow( &x
,&y
) ;
587 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion().GetWXHRGN() , clip
) ;
588 OffsetRgn( clip
, x
, y
) ;
595 else if ( wx->MacIsUserPane() )
597 // if we don't have a valid brush for such a control, we have to call the
598 // setup of our parent ourselves
599 status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ;
612 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
613 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
617 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
620 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
625 // ----------------------------------------------------------------------------
626 // constructors and such
627 // ----------------------------------------------------------------------------
629 wxWindowMac
::wxWindowMac()
634 wxWindowMac
::wxWindowMac(wxWindowMac
*parent
,
639 const wxString
& name
)
642 Create(parent
, id
, pos
, size
, style
, name
);
645 void wxWindowMac
::Init()
649 #if WXWIN_COMPATIBILITY_2_4
650 m_backgroundTransparent
= FALSE
;
653 // as all windows are created with WS_VISIBLE style...
656 m_hScrollBar
= NULL
;
657 m_vScrollBar
= NULL
;
658 m_macBackgroundBrush
= wxNullBrush
;
660 m_macIsUserPane
= TRUE
;
662 // make sure all proc ptrs are available
664 if ( gControlUserPaneDrawUPP
== NULL
)
666 gControlUserPaneDrawUPP
= NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc
) ;
667 gControlUserPaneHitTestUPP
= NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc
) ;
668 gControlUserPaneTrackingUPP
= NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc
) ;
669 gControlUserPaneIdleUPP
= NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc
) ;
670 gControlUserPaneKeyDownUPP
= NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc
) ;
671 gControlUserPaneActivateUPP
= NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc
) ;
672 gControlUserPaneFocusUPP
= NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc
) ;
673 gControlUserPaneBackgroundUPP
= NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc
) ;
675 if ( wxMacLiveScrollbarActionUPP
== NULL
)
677 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
680 if ( wxMacSetupControlBackgroundUPP
== NULL
)
682 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
685 // we need a valid font for the encodings
686 wxWindowBase
::SetFont(wxSystemSettings
::GetFont(wxSYS_DEFAULT_GUI_FONT
));
690 wxWindowMac
::~wxWindowMac()
694 m_isBeingDeleted
= TRUE
;
696 #ifndef __WXUNIVERSAL__
697 // VS: make sure there's no wxFrame with last focus set to us:
698 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
700 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
703 if ( frame
->GetLastFocus() == this )
705 frame
->SetLastFocus((wxWindow
*)NULL
);
710 #endif // __WXUNIVERSAL__
712 // wxRemoveMacControlAssociation( this ) ;
713 // If we delete an item, we should initialize the parent panel,
714 // because it could now be invalid.
715 wxWindow
*parent
= GetParent() ;
718 if (parent
->GetDefaultItem() == (wxButton
*) this)
719 parent
->SetDefaultItem(NULL
);
721 if ( m_peer
&& m_peer
->Ok() )
723 // in case the callback might be called during destruction
724 wxRemoveMacControlAssociation( this) ;
725 // we currently are not using this hook
726 // ::SetControlColorProc( *m_peer , NULL ) ;
730 if ( g_MacLastWindow
== this )
732 g_MacLastWindow
= NULL
;
735 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame
) ;
738 if ( frame
->GetLastFocus() == this )
739 frame
->SetLastFocus( NULL
) ;
744 // delete our drop target if we've got one
745 #if wxUSE_DRAG_AND_DROP
746 if ( m_dropTarget
!= NULL
)
751 #endif // wxUSE_DRAG_AND_DROP
755 WXWidget wxWindowMac
::GetHandle() const
757 return (WXWidget
) m_peer
->GetControlRef() ;
761 void wxWindowMac
::MacInstallEventHandler( WXWidget control
)
763 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
764 InstallControlEventHandler( (ControlRef
) control
, GetwxMacWindowEventHandlerUPP(),
765 GetEventTypeCount(eventList
), eventList
, this,
766 (EventHandlerRef
*)&m_macControlEventHandler
);
771 bool wxWindowMac
::Create(wxWindowMac
*parent
, wxWindowID id
,
775 const wxString
& name
)
777 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
779 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
782 parent
->AddChild(this);
784 m_windowVariant
= parent
->GetWindowVariant() ;
786 if ( m_macIsUserPane
)
788 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
791 | kControlSupportsEmbedding
792 // | kControlSupportsLiveFeedback
793 // | kControlHasSpecialBackground
794 // | kControlSupportsCalcBestRect
795 // | kControlHandlesTracking
796 | kControlSupportsFocus
797 // | kControlWantsActivate
798 // | kControlWantsIdle
801 m_peer
= new wxMacControl() ;
802 ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
805 MacPostControlCreate(pos
,size
) ;
806 #if !TARGET_API_MAC_OSX
807 m_peer
->SetData
<ControlUserPaneDrawUPP
>(kControlEntireControl
,kControlUserPaneDrawProcTag
,&gControlUserPaneDrawUPP
) ;
808 m_peer
->SetData
<ControlUserPaneHitTestUPP
>(kControlEntireControl
,kControlUserPaneHitTestProcTag
,&gControlUserPaneHitTestUPP
) ;
809 m_peer
->SetData
<ControlUserPaneTrackingUPP
>(kControlEntireControl
,kControlUserPaneTrackingProcTag
,&gControlUserPaneTrackingUPP
) ;
810 m_peer
->SetData
<ControlUserPaneIdleUPP
>(kControlEntireControl
,kControlUserPaneIdleProcTag
,&gControlUserPaneIdleUPP
) ;
811 m_peer
->SetData
<ControlUserPaneKeyDownUPP
>(kControlEntireControl
,kControlUserPaneKeyDownProcTag
,&gControlUserPaneKeyDownUPP
) ;
812 m_peer
->SetData
<ControlUserPaneActivateUPP
>(kControlEntireControl
,kControlUserPaneActivateProcTag
,&gControlUserPaneActivateUPP
) ;
813 m_peer
->SetData
<ControlUserPaneFocusUPP
>(kControlEntireControl
,kControlUserPaneFocusProcTag
,&gControlUserPaneFocusUPP
) ;
814 m_peer
->SetData
<ControlUserPaneBackgroundUPP
>(kControlEntireControl
,kControlUserPaneBackgroundProcTag
,&gControlUserPaneBackgroundUPP
) ;
817 #ifndef __WXUNIVERSAL__
818 // Don't give scrollbars to wxControls unless they ask for them
819 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) ||
820 (IsKindOf(CLASSINFO(wxControl
)) && ( style
& wxHSCROLL
|| style
& wxVSCROLL
)))
822 MacCreateScrollBars( style
) ;
826 wxWindowCreateEvent
event(this);
827 GetEventHandler()->AddPendingEvent(event
);
832 void wxWindowMac
::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
)
834 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
836 m_peer
->SetReference( (long) this ) ;
838 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
840 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
841 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
842 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
844 // adjust font, controlsize etc
845 DoSetWindowVariant( m_windowVariant
) ;
847 #if !TARGET_API_MAC_OSX
848 // eventually we can fix some clipping issues be reactivating this hook
849 //if ( m_macIsUserPane )
850 // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
852 m_peer
->SetTitle( wxStripMenuCodes(m_label
) ) ;
854 if (!m_macIsUserPane
)
856 SetInitialBestSize(size
);
859 SetCursor( *wxSTANDARD_CURSOR
) ;
862 void wxWindowMac
::DoSetWindowVariant( wxWindowVariant variant
)
864 // Don't assert, in case we set the window variant before
865 // the window is created
866 // wxASSERT( m_peer->Ok() ) ;
868 m_windowVariant
= variant
;
870 if (m_peer
== NULL
|| !m_peer
->Ok())
874 ThemeFontID themeFont
= kThemeSystemFont
;
876 // we will get that from the settings later
877 // and make this NORMAL later, but first
878 // we have a few calculations that we must fix
882 case wxWINDOW_VARIANT_NORMAL
:
883 size
= kControlSizeNormal
;
884 themeFont
= kThemeSystemFont
;
886 case wxWINDOW_VARIANT_SMALL
:
887 size
= kControlSizeSmall
;
888 themeFont
= kThemeSmallSystemFont
;
890 case wxWINDOW_VARIANT_MINI
:
891 if (UMAGetSystemVersion() >= 0x1030 )
893 // not always defined in the headers
899 size
= kControlSizeSmall
;
900 themeFont
= kThemeSmallSystemFont
;
903 case wxWINDOW_VARIANT_LARGE
:
904 size
= kControlSizeLarge
;
905 themeFont
= kThemeSystemFont
;
908 wxFAIL_MSG(_T("unexpected window variant"));
911 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
,&size
) ;
914 font
.MacCreateThemeFont( themeFont
) ;
918 void wxWindowMac
::MacUpdateControlFont()
920 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
924 bool wxWindowMac
::SetFont(const wxFont
& font
)
926 bool retval
= !wxWindowBase
::SetFont( font
) ;
928 MacUpdateControlFont() ;
933 bool wxWindowMac
::SetForegroundColour(const wxColour
& col
)
935 if ( !wxWindowBase
::SetForegroundColour(col
) )
938 MacUpdateControlFont() ;
943 bool wxWindowMac
::SetBackgroundColour(const wxColour
& col
)
945 if ( !wxWindowBase
::SetBackgroundColour(col
) && m_hasBgCol
)
949 wxColour
newCol(GetBackgroundColour());
950 if ( newCol
== wxSystemSettings
::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
952 brush
.MacSetTheme( kThemeBrushDocumentWindowBackground
) ;
954 else if ( newCol
== wxSystemSettings
::GetColour(wxSYS_COLOUR_3DFACE
) )
956 brush
.MacSetTheme( kThemeBrushDialogBackgroundActive
) ;
960 brush
.SetColour( newCol
) ;
962 MacSetBackgroundBrush( brush
) ;
964 MacUpdateControlFont() ;
969 void wxWindowMac
::MacSetBackgroundBrush( const wxBrush
&brush
)
971 m_macBackgroundBrush
= brush
;
972 m_peer
->SetBackground( brush
) ;
975 bool wxWindowMac
::MacCanFocus() const
977 // there is currently no way to determine whether the window is running in full keyboard
978 // access mode, therefore we cannot rely on these features, yet the only other way would be
979 // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
980 // in event handlers...
981 UInt32 features
= 0 ;
982 m_peer
->GetFeatures( & features
) ;
983 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
987 void wxWindowMac
::SetFocus()
989 if ( AcceptsFocus() )
991 #if !TARGET_API_MAC_OSX
992 wxWindow
* former
= FindFocus() ;
994 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
995 // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
996 // leave in case of an error
997 if ( err
== errCouldntSetFocus
)
1000 #if !TARGET_API_MAC_OSX
1001 // emulate carbon events when running under carbonlib where they are not natively available
1004 EventRef evRef
= NULL
;
1005 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1008 wxMacCarbonEvent
cEvent( evRef
) ;
1009 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) former
->GetHandle() ) ;
1010 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNoPart
) ;
1012 wxMacWindowEventHandler( NULL
, evRef
, former
) ;
1013 ReleaseEvent(evRef
) ;
1015 // send new focus event
1017 EventRef evRef
= NULL
;
1018 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1021 wxMacCarbonEvent
cEvent( evRef
) ;
1022 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) GetHandle() ) ;
1023 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNextPart
) ;
1025 wxMacWindowEventHandler( NULL
, evRef
, this ) ;
1026 ReleaseEvent(evRef
) ;
1033 void wxWindowMac
::DoCaptureMouse()
1035 wxTheApp
->s_captureWindow
= this ;
1038 wxWindow
* wxWindowBase
::GetCapture()
1040 return wxTheApp
->s_captureWindow
;
1043 void wxWindowMac
::DoReleaseMouse()
1045 wxTheApp
->s_captureWindow
= NULL
;
1048 #if wxUSE_DRAG_AND_DROP
1050 void wxWindowMac
::SetDropTarget(wxDropTarget
*pDropTarget
)
1052 if ( m_dropTarget
!= 0 ) {
1053 delete m_dropTarget
;
1056 m_dropTarget
= pDropTarget
;
1057 if ( m_dropTarget
!= 0 )
1065 // Old style file-manager drag&drop
1066 void wxWindowMac
::DragAcceptFiles(bool accept
)
1071 // Returns the size of the native control. In the case of the toplevel window
1072 // this is the content area root control
1074 void wxWindowMac
::MacGetPositionAndSizeFromControl(int& x
, int& y
,
1075 int& w
, int& h
) const
1078 m_peer
->GetRect( &bounds
) ;
1083 w
= bounds
.right
- bounds
.left
;
1084 h
= bounds
.bottom
- bounds
.top
;
1087 // From a wx position / size calculate the appropriate size of the native control
1089 bool wxWindowMac
::MacGetBoundsForControl(const wxPoint
& pos
,
1092 int& w
, int& h
, bool adjustOrigin
) const
1094 // the desired size, minus the border pixels gives the correct size of the control
1098 // todo the default calls may be used as soon as PostCreateControl Is moved here
1099 w
= size
.x
; // WidthDefault( size.x );
1100 h
= size
.y
; // HeightDefault( size.y ) ;
1101 #if !TARGET_API_MAC_OSX
1102 GetParent()->MacWindowToRootWindow( &x
, &y
) ;
1105 x
+= MacGetLeftBorderSize() ;
1106 y
+= MacGetTopBorderSize() ;
1107 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1108 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1111 AdjustForParentClientOrigin( x
, y
) ;
1115 // Get window size (not client size)
1116 void wxWindowMac
::DoGetSize(int *x
, int *y
) const
1118 // take the size of the control and add the borders that have to be drawn outside
1119 int x1
, y1
, w1
, h1
;
1121 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1123 w1
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1124 h1
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1130 // get the position of the bounds of this window in client coordinates of its parent
1131 void wxWindowMac
::DoGetPosition(int *x
, int *y
) const
1133 int x1
, y1
, w1
,h1
;
1134 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1135 x1
-= MacGetLeftBorderSize() ;
1136 y1
-= MacGetTopBorderSize() ;
1138 #if !TARGET_API_MAC_OSX
1139 if ( !GetParent()->IsTopLevel() )
1142 GetControlBounds( (ControlRef
) GetParent()->GetHandle() , &bounds
) ;
1147 if ( !IsTopLevel() )
1149 wxWindow
*parent
= GetParent();
1152 // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix
1153 x1
+= parent
->MacGetLeftBorderSize() ;
1154 y1
+= parent
->MacGetTopBorderSize() ;
1155 // and now to client coordinates
1156 wxPoint
pt(parent
->GetClientAreaOrigin());
1165 void wxWindowMac
::DoScreenToClient(int *x
, int *y
) const
1167 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1169 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1172 Point localwhere
= {0,0} ;
1174 if(x
) localwhere
.h
= * x
;
1175 if(y
) localwhere
.v
= * y
;
1177 QDGlobalToLocalPoint( GetWindowPort( window
) , &localwhere
) ;
1178 if(x
) *x
= localwhere
.h
;
1179 if(y
) *y
= localwhere
.v
;
1182 MacRootWindowToWindow( x
, y
) ;
1184 wxPoint origin
= GetClientAreaOrigin() ;
1185 if(x
) *x
-= origin
.x
;
1186 if(y
) *y
-= origin
.y
;
1189 void wxWindowMac
::DoClientToScreen(int *x
, int *y
) const
1191 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1192 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1194 wxPoint origin
= GetClientAreaOrigin() ;
1195 if(x
) *x
+= origin
.x
;
1196 if(y
) *y
+= origin
.y
;
1198 MacWindowToRootWindow( x
, y
) ;
1201 Point localwhere
= { 0,0 };
1202 if(x
) localwhere
.h
= * x
;
1203 if(y
) localwhere
.v
= * y
;
1204 QDLocalToGlobalPoint( GetWindowPort( window
) , &localwhere
) ;
1205 if(x
) *x
= localwhere
.h
;
1206 if(y
) *y
= localwhere
.v
;
1210 void wxWindowMac
::MacClientToRootWindow( int *x
, int *y
) const
1212 wxPoint origin
= GetClientAreaOrigin() ;
1213 if(x
) *x
+= origin
.x
;
1214 if(y
) *y
+= origin
.y
;
1216 MacWindowToRootWindow( x
, y
) ;
1219 void wxWindowMac
::MacRootWindowToClient( int *x
, int *y
) const
1221 MacRootWindowToWindow( x
, y
) ;
1223 wxPoint origin
= GetClientAreaOrigin() ;
1224 if(x
) *x
-= origin
.x
;
1225 if(y
) *y
-= origin
.y
;
1228 void wxWindowMac
::MacWindowToRootWindow( int *x
, int *y
) const
1230 #if TARGET_API_MAC_OSX
1232 if ( x
) pt
.x
= *x
;
1233 if ( y
) pt
.y
= *y
;
1235 if ( !IsTopLevel() )
1237 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1240 pt
.x
-= MacGetLeftBorderSize() ;
1241 pt
.y
-= MacGetTopBorderSize() ;
1242 wxMacControl
::Convert( &pt
, m_peer
, top
->m_peer
) ;
1246 if ( x
) *x
= (int) pt
.x
;
1247 if ( y
) *y
= (int) pt
.y
;
1249 if ( !IsTopLevel() )
1252 m_peer
->GetRect( &bounds
) ;
1253 if(x
) *x
+= bounds
.left
- MacGetLeftBorderSize() ;
1254 if(y
) *y
+= bounds
.top
- MacGetTopBorderSize() ;
1259 void wxWindowMac
::MacWindowToRootWindow( short *x
, short *y
) const
1264 MacWindowToRootWindow( &x1
, &y1
) ;
1269 void wxWindowMac
::MacRootWindowToWindow( int *x
, int *y
) const
1271 #if TARGET_API_MAC_OSX
1273 if ( x
) pt
.x
= *x
;
1274 if ( y
) pt
.y
= *y
;
1276 if ( !IsTopLevel() )
1278 wxMacControl
::Convert( &pt
, MacGetTopLevelWindow()->m_peer
, m_peer
) ;
1279 pt
.x
+= MacGetLeftBorderSize() ;
1280 pt
.y
+= MacGetTopBorderSize() ;
1283 if ( x
) *x
= (int) pt
.x
;
1284 if ( y
) *y
= (int) pt
.y
;
1286 if ( !IsTopLevel() )
1289 m_peer
->GetRect( &bounds
) ;
1290 if(x
) *x
-= bounds
.left
+ MacGetLeftBorderSize() ;
1291 if(y
) *y
-= bounds
.top
+ MacGetTopBorderSize() ;
1296 void wxWindowMac
::MacRootWindowToWindow( short *x
, short *y
) const
1301 MacRootWindowToWindow( &x1
, &y1
) ;
1306 void wxWindowMac
::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1308 RgnHandle rgn
= NewRgn() ;
1310 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1312 GetRegionBounds( rgn
, &content
) ;
1317 m_peer
->GetRect( &content
) ;
1320 m_peer
->GetRect( &structure
) ;
1321 #if !TARGET_API_MAC_OSX
1322 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1324 left
= content
.left
- structure
.left
;
1325 top
= content
.top
- structure
.top
;
1326 right
= structure
.right
- content
.right
;
1327 bottom
= structure
.bottom
- content
.bottom
;
1330 wxSize wxWindowMac
::DoGetSizeFromClientSize( const wxSize
& size
) const
1332 wxSize sizeTotal
= size
;
1334 RgnHandle rgn
= NewRgn() ;
1338 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1340 GetRegionBounds( rgn
, &content
) ;
1345 m_peer
->GetRect( &content
) ;
1348 m_peer
->GetRect( &structure
) ;
1349 #if !TARGET_API_MAC_OSX
1350 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1353 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1354 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1356 sizeTotal
.x
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1357 sizeTotal
.y
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1363 // Get size *available for subwindows* i.e. excluding menu bar etc.
1364 void wxWindowMac
::DoGetClientSize(int *x
, int *y
) const
1368 RgnHandle rgn
= NewRgn() ;
1370 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1372 GetRegionBounds( rgn
, &content
) ;
1377 m_peer
->GetRect( &content
) ;
1379 #if !TARGET_API_MAC_OSX
1381 m_peer
->GetRect( &structure
) ;
1382 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1384 ww
= content
.right
- content
.left
;
1385 hh
= content
.bottom
- content
.top
;
1387 ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1388 hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
1391 if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
1397 GetSize( &w , &h ) ;
1399 MacClientToRootWindow( &x1 , &y1 ) ;
1400 MacClientToRootWindow( &w , &h ) ;
1402 wxWindowMac *iter = (wxWindowMac*)this ;
1404 int totW = 10000 , totH = 10000;
1407 if ( iter->IsTopLevel() )
1409 iter->GetSize( &totW , &totH ) ;
1413 iter = iter->GetParent() ;
1416 if (m_hScrollBar && m_hScrollBar->IsShown() )
1418 hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
1424 if (m_vScrollBar && m_vScrollBar->IsShown() )
1426 ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
1434 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1436 hh
-= m_hScrollBar
->GetSize().y
; // MAC_SCROLLBAR_SIZE ;
1438 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1440 ww
-= m_vScrollBar
->GetSize().x
; // MAC_SCROLLBAR_SIZE;
1447 bool wxWindowMac
::SetCursor(const wxCursor
& cursor
)
1449 if (m_cursor
== cursor
)
1452 if (wxNullCursor
== cursor
)
1454 if ( ! wxWindowBase
::SetCursor( *wxSTANDARD_CURSOR
) )
1459 if ( ! wxWindowBase
::SetCursor( cursor
) )
1463 wxASSERT_MSG( m_cursor
.Ok(),
1464 wxT("cursor must be valid after call to the base version"));
1467 wxWindowMac
*mouseWin
= 0 ;
1469 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1471 Boolean swapped
= QDSwapPort( GetWindowPort( window
) , &savePort
) ;
1473 // TODO If we ever get a GetCurrentEvent.. replacement for the mouse
1474 // position, use it...
1478 ControlPartCode part
;
1479 ControlRef control
;
1480 control
= wxMacFindControlUnderMouse( pt
, window
, &part
) ;
1482 mouseWin
= wxFindControlFromMacControl( control
) ;
1485 QDSwapPort( savePort
, NULL
) ;
1488 if ( mouseWin
== this && !wxIsBusy() )
1490 m_cursor
.MacInstall() ;
1497 bool wxWindowMac
::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1499 menu
->SetInvokingWindow(this);
1502 if ( x
== -1 && y
== -1 )
1504 wxPoint mouse
= wxGetMousePosition();
1505 x
= mouse
.x
; y
= mouse
.y
;
1509 ClientToScreen( &x
, &y
) ;
1512 menu
->MacBeforeDisplay( true ) ;
1513 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
1514 if ( HiWord(menuResult
) != 0 )
1517 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id
) ;
1518 wxMenuItem
* item
= NULL
;
1520 item
= menu
->FindItem(id
, &realmenu
) ;
1521 if (item
->IsCheckable())
1523 item
->Check( !item
->IsChecked() ) ;
1525 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1527 menu
->MacAfterDisplay( true ) ;
1529 menu
->SetInvokingWindow(NULL
);
1535 // ----------------------------------------------------------------------------
1537 // ----------------------------------------------------------------------------
1541 void wxWindowMac
::DoSetToolTip(wxToolTip
*tooltip
)
1543 wxWindowBase
::DoSetToolTip(tooltip
);
1546 m_tooltip
->SetWindow(this);
1549 #endif // wxUSE_TOOLTIPS
1551 void wxWindowMac
::DoMoveWindow(int x
, int y
, int width
, int height
)
1553 // this is never called for a toplevel window, so we know we have a parent
1554 int former_x
, former_y
, former_w
, former_h
;
1556 // Get true coordinates of former position
1557 DoGetPosition( &former_x
, &former_y
) ;
1558 DoGetSize( &former_w
, &former_h
) ;
1560 wxWindow
*parent
= GetParent();
1563 wxPoint
pt(parent
->GetClientAreaOrigin());
1568 int actualWidth
= width
;
1569 int actualHeight
= height
;
1573 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1574 actualWidth
= m_minWidth
;
1575 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1576 actualHeight
= m_minHeight
;
1577 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1578 actualWidth
= m_maxWidth
;
1579 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1580 actualHeight
= m_maxHeight
;
1582 bool doMove
= false ;
1583 bool doResize
= false ;
1585 if ( actualX
!= former_x
|| actualY
!= former_y
)
1589 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1594 if ( doMove
|| doResize
)
1596 // we don't adjust twice for the origin
1597 Rect r
= wxMacGetBoundsForControl(this , wxPoint( actualX
,actualY
), wxSize( actualWidth
, actualHeight
) , false ) ;
1598 #if TARGET_API_MAC_OSX
1599 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1600 if ( ! GetParent()->IsTopLevel() )
1602 r
.left
-= GetParent()->MacGetLeftBorderSize() ;
1603 r
.top
-= GetParent()->MacGetTopBorderSize() ;
1604 r
.right
-= GetParent()->MacGetLeftBorderSize() ;
1605 r
.bottom
-= GetParent()->MacGetTopBorderSize() ;
1608 bool vis
= m_peer
->IsVisible();
1610 // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
1612 m_peer
->SetVisibility( false , true ) ;
1613 m_peer
->SetRect( &r
) ;
1615 m_peer
->SetVisibility( true , true ) ;
1617 MacRepositionScrollBars() ;
1620 wxPoint
point(actualX
,actualY
);
1621 wxMoveEvent
event(point
, m_windowId
);
1622 event
.SetEventObject(this);
1623 GetEventHandler()->ProcessEvent(event
) ;
1627 MacRepositionScrollBars() ;
1628 wxSize
size(actualWidth
, actualHeight
);
1629 wxSizeEvent
event(size
, m_windowId
);
1630 event
.SetEventObject(this);
1631 GetEventHandler()->ProcessEvent(event
);
1637 wxSize wxWindowMac
::DoGetBestSize() const
1639 if ( m_macIsUserPane
|| IsTopLevel() )
1640 return wxWindowBase
::DoGetBestSize() ;
1642 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1643 int bestWidth
, bestHeight
;
1644 m_peer
->GetBestRect( &bestsize
) ;
1646 if ( EmptyRect( &bestsize
) )
1648 bestsize
.left
= bestsize
.top
= 0 ;
1649 bestsize
.right
= 16 ;
1650 bestsize
.bottom
= 16 ;
1651 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1653 bestsize
.bottom
= 16 ;
1655 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1657 bestsize
.bottom
= 24 ;
1661 // return wxWindowBase::DoGetBestSize() ;
1665 bestWidth
= bestsize
.right
- bestsize
.left
;
1666 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1667 if ( bestHeight
< 10 )
1670 return wxSize(bestWidth
, bestHeight
);
1674 // set the size of the window: if the dimensions are positive, just use them,
1675 // but if any of them is equal to -1, it means that we must find the value for
1676 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1677 // which case -1 is a valid value for x and y)
1679 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1680 // the width/height to best suit our contents, otherwise we reuse the current
1682 void wxWindowMac
::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1684 // get the current size and position...
1685 int currentX
, currentY
;
1686 GetPosition(¤tX
, ¤tY
);
1688 int currentW
,currentH
;
1689 GetSize(¤tW
, ¤tH
);
1691 // ... and don't do anything (avoiding flicker) if it's already ok
1692 if ( x
== currentX
&& y
== currentY
&&
1693 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1696 MacRepositionScrollBars() ; // we might have a real position shift
1700 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1702 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1705 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
1707 wxSize
size(-1, -1);
1710 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1712 size
= DoGetBestSize();
1717 // just take the current one
1724 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1728 size
= DoGetBestSize();
1730 //else: already called DoGetBestSize() above
1736 // just take the current one
1741 DoMoveWindow(x
, y
, width
, height
);
1745 wxPoint wxWindowMac
::GetClientAreaOrigin() const
1747 RgnHandle rgn
= NewRgn() ;
1749 m_peer
->GetRegion( kControlContentMetaPart
, rgn
) ;
1750 GetRegionBounds( rgn
, &content
) ;
1752 #if !TARGET_API_MAC_OSX
1753 // if the content rgn is empty / not supported
1754 // don't attempt to correct the coordinates to wxWindow relative ones
1755 if (!::EmptyRect( &content
) )
1758 m_peer
->GetRect( &structure
) ;
1759 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1763 return wxPoint( content
.left
+ MacGetLeftBorderSize( ) , content
.top
+ MacGetTopBorderSize( ) );
1766 void wxWindowMac
::DoSetClientSize(int clientwidth
, int clientheight
)
1768 if ( clientheight
!= -1 || clientheight
!= -1 )
1770 int currentclientwidth
, currentclientheight
;
1771 int currentwidth
, currentheight
;
1773 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1774 GetSize( ¤twidth
, ¤theight
) ;
1776 DoSetSize( -1 , -1 , currentwidth
+ clientwidth
- currentclientwidth
,
1777 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1781 void wxWindowMac
::SetTitle(const wxString
& title
)
1783 m_label
= wxStripMenuCodes(title
) ;
1785 if ( m_peer
&& m_peer
->Ok() )
1787 m_peer
->SetTitle( m_label
) ;
1792 wxString wxWindowMac
::GetTitle() const
1797 bool wxWindowMac
::Show(bool show
)
1799 if ( !wxWindowBase
::Show(show
) )
1802 // TODO use visibilityChanged Carbon Event for OSX
1803 bool former
= MacIsReallyShown() ;
1805 m_peer
->SetVisibility( show
, true ) ;
1806 if ( former
!= MacIsReallyShown() )
1807 MacPropagateVisibilityChanged() ;
1811 bool wxWindowMac
::Enable(bool enable
)
1813 wxASSERT( m_peer
->Ok() ) ;
1814 if ( !wxWindowBase
::Enable(enable
) )
1817 bool former
= MacIsReallyEnabled() ;
1818 m_peer
->Enable( enable
) ;
1820 if ( former
!= MacIsReallyEnabled() )
1821 MacPropagateEnabledStateChanged() ;
1826 // status change propagations (will be not necessary for OSX later )
1829 void wxWindowMac
::MacPropagateVisibilityChanged()
1831 #if !TARGET_API_MAC_OSX
1832 MacVisibilityChanged() ;
1834 wxWindowListNode
*node
= GetChildren().GetFirst();
1837 wxWindowMac
*child
= node
->GetData();
1838 if ( child
->IsShown() )
1839 child
->MacPropagateVisibilityChanged( ) ;
1840 node
= node
->GetNext();
1845 void wxWindowMac
::MacPropagateEnabledStateChanged( )
1847 #if !TARGET_API_MAC_OSX
1848 MacEnabledStateChanged() ;
1850 wxWindowListNode
*node
= GetChildren().GetFirst();
1853 wxWindowMac
*child
= node
->GetData();
1854 if ( child
->IsEnabled() )
1855 child
->MacPropagateEnabledStateChanged() ;
1856 node
= node
->GetNext();
1861 void wxWindowMac
::MacPropagateHiliteChanged( )
1863 #if !TARGET_API_MAC_OSX
1864 MacHiliteChanged() ;
1866 wxWindowListNode
*node
= GetChildren().GetFirst();
1869 wxWindowMac
*child
= node
->GetData();
1870 // if ( child->IsEnabled() )
1871 child
->MacPropagateHiliteChanged() ;
1872 node
= node
->GetNext();
1878 // status change notifications
1881 void wxWindowMac
::MacVisibilityChanged()
1885 void wxWindowMac
::MacHiliteChanged()
1889 void wxWindowMac
::MacEnabledStateChanged()
1894 // status queries on the inherited window's state
1897 bool wxWindowMac
::MacIsReallyShown()
1899 // only under OSX the visibility of the TLW is taken into account
1900 #if TARGET_API_MAC_OSX
1901 if ( m_peer
&& m_peer
->Ok() )
1902 return m_peer
->IsVisible();
1904 wxWindow
* win
= this ;
1905 while( win
->IsShown() )
1907 if ( win
->IsTopLevel() )
1910 win
= win
->GetParent() ;
1918 bool wxWindowMac
::MacIsReallyEnabled()
1920 return m_peer
->IsEnabled() ;
1923 bool wxWindowMac
::MacIsReallyHilited()
1925 return m_peer
->IsActive();
1928 void wxWindowMac
::MacFlashInvalidAreas()
1930 #if TARGET_API_MAC_OSX
1931 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
1939 int wxWindowMac
::GetCharHeight() const
1941 wxClientDC
dc ( (wxWindowMac
*)this ) ;
1942 return dc
.GetCharHeight() ;
1945 int wxWindowMac
::GetCharWidth() const
1947 wxClientDC
dc ( (wxWindowMac
*)this ) ;
1948 return dc
.GetCharWidth() ;
1951 void wxWindowMac
::GetTextExtent(const wxString
& string
, int *x
, int *y
,
1952 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
1954 const wxFont
*fontToUse
= theFont
;
1956 fontToUse
= &m_font
;
1958 wxClientDC
dc( (wxWindowMac
*) this ) ;
1960 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
1961 if ( externalLeading
)
1962 *externalLeading
= le
;
1972 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
1973 * we always intersect with the entire window, not only with the client area
1976 void wxWindowMac
::Refresh(bool eraseBack
, const wxRect
*rect
)
1978 if ( m_peer
== NULL
)
1981 #if TARGET_API_MAC_OSX
1983 m_peer
->SetNeedsDisplay( true ) ;
1986 RgnHandle update
= NewRgn() ;
1987 SetRectRgn( update
, rect
->x
, rect
->y
, rect
->x
+ rect
->width
, rect
->y
+ rect
->height
) ;
1988 SectRgn( (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , update
, update
) ;
1989 wxPoint origin
= GetClientAreaOrigin() ;
1990 OffsetRgn( update
, origin
.x
, origin
.y
) ;
1991 // right now this is wx' window coordinates, as our native peer does not have borders, this is
1993 OffsetRgn( update
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
1994 m_peer
->SetNeedsDisplay( true , update
) ;
1995 DisposeRgn( update
) ;
1999 RgnHandle updateRgn = NewRgn() ;
2002 CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
2006 SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
2007 SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
2009 InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
2010 DisposeRgn(updateRgn) ;
2012 if ( m_peer
->IsVisible())
2014 m_peer
->SetVisibility( false , false ) ;
2015 m_peer
->SetVisibility( true , true ) ;
2018 if ( MacGetTopLevelWindow() == NULL )
2021 if ( !m_peer->IsVisible())
2024 wxPoint client = GetClientAreaOrigin();
2027 int x2 = m_width - client.x;
2028 int y2 = m_height - client.y;
2030 if (IsKindOf( CLASSINFO(wxButton)))
2032 // buttons have an "aura"
2039 Rect clientrect = { y1, x1, y2, x2 };
2043 Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
2044 SectRect( &clientrect , &r , &clientrect ) ;
2047 if ( !EmptyRect( &clientrect ) )
2049 int top = 0 , left = 0 ;
2051 MacClientToRootWindow( &left , &top ) ;
2052 OffsetRect( &clientrect , left , top ) ;
2054 MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
2060 void wxWindowMac
::Freeze()
2062 #if TARGET_API_MAC_OSX
2063 if ( !m_frozenness
++ )
2065 m_peer
->SetDrawingEnabled( false ) ;
2071 void wxWindowMac
::Thaw()
2073 #if TARGET_API_MAC_OSX
2074 wxASSERT_MSG( m_frozenness
> 0, _T("Thaw() without matching Freeze()") );
2076 if ( !--m_frozenness
)
2078 m_peer
->SetDrawingEnabled( true ) ;
2079 m_peer
->InvalidateWithChildren() ;
2084 void wxWindowMac
::MacRedrawControl()
2087 if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
2089 #if TARGET_API_MAC_CARBON
2092 wxClientDC dc(this) ;
2093 wxMacPortSetter helper(&dc) ;
2094 wxMacWindowClipper clipper(this) ;
2095 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
2096 UMADrawControl( *m_peer ) ;
2103 void wxWindowMac::OnPaint(wxPaintEvent& event)
2105 // why don't we skip that here ?
2109 wxWindowMac
*wxGetActiveWindow()
2111 // actually this is a windows-only concept
2115 // Coordinates relative to the window
2116 void wxWindowMac
::WarpPointer (int x_pos
, int y_pos
)
2118 // We really don't move the mouse programmatically under Mac.
2121 void wxWindowMac
::OnEraseBackground(wxEraseEvent
& event
)
2123 #if TARGET_API_MAC_OSX
2124 if ( m_macBackgroundBrush
.Ok() == false || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT
)
2130 event
.GetDC()->Clear() ;
2133 void wxWindowMac
::OnNcPaint( wxNcPaintEvent
& event
)
2138 int wxWindowMac
::GetScrollPos(int orient
) const
2140 if ( orient
== wxHORIZONTAL
)
2143 return m_hScrollBar
->GetThumbPosition() ;
2148 return m_vScrollBar
->GetThumbPosition() ;
2153 // This now returns the whole range, not just the number
2154 // of positions that we can scroll.
2155 int wxWindowMac
::GetScrollRange(int orient
) const
2157 if ( orient
== wxHORIZONTAL
)
2160 return m_hScrollBar
->GetRange() ;
2165 return m_vScrollBar
->GetRange() ;
2170 int wxWindowMac
::GetScrollThumb(int orient
) const
2172 if ( orient
== wxHORIZONTAL
)
2175 return m_hScrollBar
->GetThumbSize() ;
2180 return m_vScrollBar
->GetThumbSize() ;
2185 void wxWindowMac
::SetScrollPos(int orient
, int pos
, bool refresh
)
2187 if ( orient
== wxHORIZONTAL
)
2190 m_hScrollBar
->SetThumbPosition( pos
) ;
2195 m_vScrollBar
->SetThumbPosition( pos
) ;
2199 void wxWindowMac
::MacPaintBorders( int left
, int top
)
2205 m_peer
->GetRect( &rect
) ;
2206 InsetRect( &rect
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2208 if ( !IsTopLevel() )
2210 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2214 wxMacControl
::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2216 rect
.right
+= pt
.x
;
2218 rect
.bottom
+= pt
.y
;
2222 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2226 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
2227 InsetRect( &srect
, border
, border
);
2228 DrawThemeEditTextFrame(&srect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2230 else if (HasFlag(wxSIMPLE_BORDER
))
2234 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
2235 InsetRect( &srect
, border
, border
);
2236 DrawThemeListBoxFrame(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2240 void wxWindowMac
::RemoveChild( wxWindowBase
*child
)
2242 if ( child
== m_hScrollBar
)
2243 m_hScrollBar
= NULL
;
2244 if ( child
== m_vScrollBar
)
2245 m_vScrollBar
= NULL
;
2247 wxWindowBase
::RemoveChild( child
) ;
2250 // New function that will replace some of the above.
2251 void wxWindowMac
::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2252 int range
, bool refresh
)
2254 if ( orient
== wxHORIZONTAL
)
2258 if ( range
== 0 || thumbVisible
>= range
)
2260 if ( m_hScrollBar
->IsShown() )
2261 m_hScrollBar
->Show(false) ;
2265 if ( !m_hScrollBar
->IsShown() )
2266 m_hScrollBar
->Show(true) ;
2267 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2275 if ( range
== 0 || thumbVisible
>= range
)
2277 if ( m_vScrollBar
->IsShown() )
2278 m_vScrollBar
->Show(false) ;
2282 if ( !m_vScrollBar
->IsShown() )
2283 m_vScrollBar
->Show(true) ;
2284 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2288 MacRepositionScrollBars() ;
2291 // Does a physical scroll
2292 void wxWindowMac
::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2294 if( dx
== 0 && dy
==0 )
2300 int width
, height
;
2301 GetClientSize( &width
, &height
) ;
2302 #if TARGET_API_MAC_OSX
2303 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2304 // area is scrolled, this does not occur if width and height are 2 pixels less,
2305 // TODO write optimal workaround
2306 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2309 scrollrect
.Intersect( *rect
) ;
2311 if ( m_peer
->GetNeedsDisplay() )
2313 // becuase HIViewScrollRect does not scroll the already invalidated area we have two options
2314 // either immediate redraw or full invalidate
2316 // is the better overall solution, as it does not slow down scrolling
2317 m_peer
->SetNeedsDisplay( true ) ;
2319 // this would be the preferred version for fast drawing controls
2320 if( UMAGetSystemVersion() < 0x1030 )
2323 HIViewRender(m_peer
->GetControlRef()) ;
2326 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2327 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2328 m_peer
->ScrollRect( scrollrect
, dx
, dy
) ;
2335 RgnHandle updateRgn
= NewRgn() ;
2338 wxClientDC
dc(this) ;
2339 wxMacPortSetter
helper(&dc
) ;
2341 m_peer
->GetRect( &scrollrect
) ;
2342 scrollrect
.top
+= MacGetTopBorderSize() ;
2343 scrollrect
.left
+= MacGetLeftBorderSize() ;
2344 scrollrect
.bottom
= scrollrect
.top
+ height
;
2345 scrollrect
.right
= scrollrect
.left
+ width
;
2349 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
2350 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
2351 SectRect( &scrollrect
, &r
, &scrollrect
) ;
2353 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
2355 // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
2359 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2361 wxWindowMac
*child
= node
->GetData();
2362 if (child
== m_vScrollBar
) continue;
2363 if (child
== m_hScrollBar
) continue;
2364 if (child
->IsTopLevel()) continue;
2367 child
->GetPosition( &x
, &y
);
2369 child
->GetSize( &w
, &h
);
2373 if (rect
->Intersects(rc
))
2374 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2378 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2383 void wxWindowMac
::MacOnScroll(wxScrollEvent
&event
)
2385 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
2387 wxScrollWinEvent wevent
;
2388 wevent
.SetPosition(event
.GetPosition());
2389 wevent
.SetOrientation(event
.GetOrientation());
2390 wevent
.m_eventObject
= this;
2392 if (event
.m_eventType
== wxEVT_SCROLL_TOP
)
2393 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
2394 else if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
)
2395 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2396 else if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
)
2397 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
2398 else if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
)
2399 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
2400 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
)
2401 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2402 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
)
2403 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2404 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
)
2405 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2406 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBRELEASE
)
2407 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2409 GetEventHandler()->ProcessEvent(wevent
);
2413 // Get the window with the focus
2414 wxWindowMac
*wxWindowBase
::FindFocus()
2416 ControlRef control
;
2417 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2418 return wxFindControlFromMacControl( control
) ;
2421 void wxWindowMac
::OnSetFocus(wxFocusEvent
& event
)
2423 // panel wants to track the window which was the last to have focus in it,
2424 // so we want to set ourselves as the window which last had focus
2426 // notice that it's also important to do it upwards the tree becaus
2427 // otherwise when the top level panel gets focus, it won't set it back to
2428 // us, but to some other sibling
2430 // CS:don't know if this is still needed:
2431 //wxChildFocusEvent eventFocus(this);
2432 //(void)GetEventHandler()->ProcessEvent(eventFocus);
2434 if ( MacGetTopLevelWindow() && m_peer
->NeedsFocusRect() )
2436 wxMacWindowStateSaver
sv( this ) ;
2441 MacWindowToRootWindow( &x
, &y
) ;
2442 GetSize( &w
, &h
) ;
2443 Rect rect
= {y
, x
, h
+ y
, w
+ x
} ;
2445 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
2446 DrawThemeFocusRect( &rect
, true ) ;
2449 DrawThemeFocusRect( &rect
, false ) ;
2451 // as this erases part of the frame we have to redraw borders
2452 // and because our z-ordering is not always correct (staticboxes)
2453 // we have to invalidate things, we cannot simple redraw
2454 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() ;
2455 RectRgn( updateInner
, &rect
) ;
2456 InsetRect( &rect
, -4 , -4 ) ;
2457 RectRgn( updateOuter
, &rect
) ;
2458 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
2459 wxPoint
parent(0,0);
2460 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
2461 parent
-= GetParent()->GetClientAreaOrigin() ;
2462 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
2463 GetParent()->m_peer
->SetNeedsDisplay( true , updateOuter
) ;
2464 DisposeRgn(updateOuter
) ;
2465 DisposeRgn(updateInner
) ;
2472 void wxWindowMac
::OnInternalIdle()
2474 // This calls the UI-update mechanism (querying windows for
2475 // menu/toolbar/control state information)
2476 if (wxUpdateUIEvent
::CanUpdate(this))
2477 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2480 // Raise the window to the top of the Z order
2481 void wxWindowMac
::Raise()
2483 m_peer
->SetZOrder( true , NULL
) ;
2486 // Lower the window to the bottom of the Z order
2487 void wxWindowMac
::Lower()
2489 m_peer
->SetZOrder( false , NULL
) ;
2493 // static wxWindow *gs_lastWhich = NULL;
2495 bool wxWindowMac
::MacSetupCursor( const wxPoint
& pt
)
2497 // first trigger a set cursor event
2499 wxPoint clientorigin
= GetClientAreaOrigin() ;
2500 wxSize clientsize
= GetClientSize() ;
2502 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2504 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2506 bool processedEvtSetCursor
= GetEventHandler()->ProcessEvent(event
);
2507 if ( processedEvtSetCursor
&& event
.HasCursor() )
2509 cursor
= event
.GetCursor() ;
2514 // the test for processedEvtSetCursor is here to prevent using m_cursor
2515 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2516 // it - this is a way to say that our cursor shouldn't be used for this
2518 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2528 cursor
= *wxSTANDARD_CURSOR
;
2532 cursor
.MacInstall() ;
2534 return cursor
.Ok() ;
2537 wxString wxWindowMac
::MacGetToolTipString( wxPoint
&pt
)
2541 return m_tooltip
->GetTip() ;
2543 return wxEmptyString
;
2546 void wxWindowMac
::Update()
2548 #if TARGET_API_MAC_OSX
2549 WindowRef window
= (WindowRef
)MacGetTopLevelWindowRef() ;
2550 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2551 // for composited windows this also triggers a redraw of all
2552 // invalid views in the window
2553 if( UMAGetSystemVersion() >= 0x1030 )
2554 HIWindowFlush(window
) ;
2558 // the only way to trigger the redrawing on earlier systems is to call
2561 EventRef currentEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
2562 UInt32 currentEventClass
= 0 ;
2563 UInt32 currentEventKind
= 0 ;
2564 if ( currentEvent
!= NULL
)
2566 currentEventClass
= ::GetEventClass( currentEvent
) ;
2567 currentEventKind
= ::GetEventKind( currentEvent
) ;
2569 if ( currentEventClass
!= kEventClassMenu
)
2571 // when tracking a menu, strange redraw errors occur if we flush now, so leave..
2574 OSStatus status
= noErr
;
2575 status
= ReceiveNextEvent( 0 , NULL
, kEventDurationNoWait
, false , &theEvent
) ;
2578 m_peer
->SetNeedsDisplay( true ) ;
2581 ::Draw1Control( m_peer
->GetControlRef() ) ;
2585 wxTopLevelWindowMac
* wxWindowMac
::MacGetTopLevelWindow() const
2587 wxTopLevelWindowMac
* win
= NULL
;
2588 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2591 win
= wxFindWinFromMacWindow( window
) ;
2595 wxRegion wxWindowMac
::MacGetVisibleRegion( bool includeOuterStructures
)
2597 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2598 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2599 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2600 // to add focus borders everywhere
2603 RgnHandle visRgn
= NewRgn() ;
2604 RgnHandle tempRgn
= NewRgn() ;
2605 if ( m_peer
->IsVisible())
2607 m_peer
->GetRect( &r
) ;
2608 r
.left
-= MacGetLeftBorderSize() ;
2609 r
.top
-= MacGetTopBorderSize() ;
2610 r
.bottom
+= MacGetBottomBorderSize() ;
2611 r
.right
+= MacGetRightBorderSize() ;
2613 if (! MacGetTopLevelWindow()->MacUsesCompositing() )
2615 MacRootWindowToWindow( &r
.left
, & r
.top
) ;
2616 MacRootWindowToWindow( &r
.right
, & r
.bottom
) ;
2625 if ( includeOuterStructures
)
2626 InsetRect( &r
, -4 , -4 ) ;
2627 RectRgn( visRgn
, &r
) ;
2629 if ( !IsTopLevel() )
2631 wxWindow
* child
= this ;
2632 wxWindow
* parent
= child
->GetParent() ;
2637 // we have to find a better clipping algorithm here, in order not to clip things
2638 // positioned like status and toolbar
2639 if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
2641 size
= parent
->GetSize() ;
2646 size
= parent
->GetClientSize() ;
2647 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2651 parent
->MacWindowToRootWindow( &x
, &y
) ;
2652 MacRootWindowToWindow( &x
, &y
) ;
2654 if ( !includeOuterStructures
|| (
2655 parent
->IsKindOf( CLASSINFO( wxScrolledWindow
) ) ||
2656 parent
->IsKindOf( CLASSINFO( wxSashLayoutWindow
) ) ||
2657 ( parent
->GetParent() && parent
->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow
) ) )
2660 SetRectRgn( tempRgn
,
2661 x
+ parent
->MacGetLeftBorderSize() , y
+ parent
->MacGetTopBorderSize() ,
2662 x
+ size
.x
- parent
->MacGetRightBorderSize(),
2663 y
+ size
.y
- parent
->MacGetBottomBorderSize()) ;
2665 SectRgn( visRgn
, tempRgn
, visRgn
) ;
2667 if ( parent
->IsTopLevel() )
2670 parent
= child
->GetParent() ;
2675 wxRegion vis
= visRgn
;
2676 DisposeRgn( visRgn
) ;
2677 DisposeRgn( tempRgn
) ;
2682 This function must not change the updatergn !
2684 bool wxWindowMac
::MacDoRedraw( WXHRGN updatergnr
, long time
)
2686 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2687 bool handled
= false ;
2689 GetRegionBounds( updatergn
, &updatebounds
) ;
2690 // wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2691 if ( !EmptyRgn(updatergn
) )
2693 RgnHandle newupdate
= NewRgn() ;
2694 wxSize point
= GetClientSize() ;
2695 wxPoint origin
= GetClientAreaOrigin() ;
2696 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
2697 SectRgn( newupdate
, updatergn
, newupdate
) ;
2699 // first send an erase event to the entire update area
2701 wxWindowDC
dc(this);
2702 dc
.SetClippingRegion(wxRegion(updatergn
));
2703 wxEraseEvent
eevent( GetId(), &dc
);
2704 eevent
.SetEventObject( this );
2705 GetEventHandler()->ProcessEvent( eevent
);
2708 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2709 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2710 m_updateRegion
= newupdate
;
2711 DisposeRgn( newupdate
) ;
2713 if ( !m_updateRegion
.Empty() )
2715 // paint the window itself
2717 event
.m_timeStamp
= time
;
2718 event
.SetEventObject(this);
2719 handled
= GetEventHandler()->ProcessEvent(event
);
2721 // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards
2724 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
)
2726 CallNextEventHandler((EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() , (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
2733 // now we cannot rely on having its borders drawn by a window itself, as it does not
2734 // get the updateRgn wide enough to always do so, so we do it from the parent
2735 // this would also be the place to draw any custom backgrounds for native controls
2736 // in Composited windowing
2737 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2739 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2741 wxWindowMac
*child
= node
->GetData();
2742 if (child
== m_vScrollBar
) continue;
2743 if (child
== m_hScrollBar
) continue;
2744 if (child
->IsTopLevel()) continue;
2745 if (!child
->IsShown()) continue;
2748 child
->GetPosition( &x
, &y
);
2750 child
->GetSize( &w
, &h
);
2751 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2752 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2753 if ( child
->MacGetTopBorderSize() )
2755 if ( RectInRgn( &childRect
, updatergn
) )
2757 // paint custom borders
2758 wxNcPaintEvent
eventNc( child
->GetId() );
2759 eventNc
.SetEventObject( child
);
2760 if ( !child
->GetEventHandler()->ProcessEvent( eventNc
) )
2762 wxWindowDC
dc(this) ;
2763 dc
.SetClippingRegion(wxRegion(updatergn
));
2764 wxMacPortSetter
helper(&dc
) ;
2765 child
->MacPaintBorders( dc
.m_macLocalOrigin
.x
+ childRect
.left
, dc
.m_macLocalOrigin
.y
+ childRect
.top
) ;
2769 if ( child
->m_peer
->NeedsFocusRect() && child
->m_peer
->HasFocus() )
2771 wxWindowDC
dc(this) ;
2772 dc
.SetClippingRegion(wxRegion(updatergn
));
2773 wxMacPortSetter
helper(&dc
) ;
2774 OffsetRect( &childRect
, dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
2775 DrawThemeFocusRect( &childRect
, true ) ;
2782 void wxWindowMac
::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
2784 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2785 // updatergn is always already clipped to our boundaries
2786 // if we are in compositing mode then it is in relative to the upper left of the control
2787 // if we are in non-compositing, then it is relatvie to the uppder left of the content area
2788 // of the toplevel window
2789 // it is in window coordinates, not in client coordinates
2791 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
2792 RgnHandle ownUpdateRgn
= NewRgn() ;
2793 CopyRgn( updatergn
, ownUpdateRgn
) ;
2795 if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
2798 m_peer
->GetRectInWindowCoords( &bounds
);
2799 RgnHandle controlRgn
= NewRgn();
2800 RectRgn( controlRgn
, &bounds
);
2801 //KO: This sets the ownUpdateRgn to the area of this control that is inside
2802 // the window update region
2803 SectRgn( ownUpdateRgn
, controlRgn
, ownUpdateRgn
);
2804 DisposeRgn( controlRgn
);
2806 //KO: convert ownUpdateRgn to local coordinates
2807 OffsetRgn( ownUpdateRgn
, -bounds
.left
, -bounds
.top
);
2810 MacDoRedraw( ownUpdateRgn
, time
) ;
2811 DisposeRgn( ownUpdateRgn
) ;
2815 WXWindow wxWindowMac
::MacGetTopLevelWindowRef() const
2817 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2821 if ( iter
->IsTopLevel() )
2822 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
2824 iter
= iter
->GetParent() ;
2826 wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ;
2830 void wxWindowMac
::MacCreateScrollBars( long style
)
2832 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2834 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2836 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
2837 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2838 wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
;
2839 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2841 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2842 variant
= wxWINDOW_VARIANT_SMALL
;
2845 int adjust
= hasBoth ? scrlsize
- 1: 0 ;
2847 GetClientSize( &width
, &height
) ;
2849 wxPoint
vPoint(width
-scrlsize
, 0) ;
2850 wxSize
vSize(scrlsize
, height
- adjust
) ;
2851 wxPoint
hPoint(0 , height
-scrlsize
) ;
2852 wxSize
hSize( width
- adjust
, scrlsize
) ;
2855 if ( style
& wxVSCROLL
)
2857 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
2858 vSize
, wxVERTICAL
);
2861 if ( style
& wxHSCROLL
)
2863 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
2864 hSize
, wxHORIZONTAL
);
2869 // because the create does not take into account the client area origin
2870 MacRepositionScrollBars() ; // we might have a real position shift
2873 void wxWindowMac
::MacRepositionScrollBars()
2875 if ( !m_hScrollBar
&& !m_vScrollBar
)
2878 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
2879 int scrlsize
= m_hScrollBar ? m_hScrollBar
->GetSize().y
: ( m_vScrollBar ? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2880 int adjust
= hasBoth ? scrlsize
- 1 : 0 ;
2882 // get real client area
2886 GetSize( &width
, &height
) ;
2888 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2889 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2891 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
2892 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
2893 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
2894 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
2900 GetSize( &w , &h ) ;
2902 MacClientToRootWindow( &x , &y ) ;
2903 MacClientToRootWindow( &w , &h ) ;
2905 wxWindowMac *iter = (wxWindowMac*)this ;
2907 int totW = 10000 , totH = 10000;
2910 if ( iter->IsTopLevel() )
2912 iter->GetSize( &totW , &totH ) ;
2916 iter = iter->GetParent() ;
2944 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
2948 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
2952 bool wxWindowMac
::AcceptsFocus() const
2954 return MacCanFocus() && wxWindowBase
::AcceptsFocus();
2957 void wxWindowMac
::MacSuperChangedPosition()
2959 // only window-absolute structures have to be moved i.e. controls
2961 wxWindowListNode
*node
= GetChildren().GetFirst();
2964 wxWindowMac
*child
= node
->GetData();
2965 child
->MacSuperChangedPosition() ;
2966 node
= node
->GetNext();
2970 void wxWindowMac
::MacTopLevelWindowChangedPosition()
2972 // only screen-absolute structures have to be moved i.e. glcanvas
2974 wxWindowListNode
*node
= GetChildren().GetFirst();
2977 wxWindowMac
*child
= node
->GetData();
2978 child
->MacTopLevelWindowChangedPosition() ;
2979 node
= node
->GetNext();
2983 long wxWindowMac
::MacGetLeftBorderSize( ) const
2988 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
2993 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
2998 else if (m_windowStyle
&wxSIMPLE_BORDER
)
3005 long wxWindowMac
::MacGetRightBorderSize( ) const
3007 // they are all symmetric in mac themes
3008 return MacGetLeftBorderSize() ;
3011 long wxWindowMac
::MacGetTopBorderSize( ) const
3013 // they are all symmetric in mac themes
3014 return MacGetLeftBorderSize() ;
3017 long wxWindowMac
::MacGetBottomBorderSize( ) const
3019 // they are all symmetric in mac themes
3020 return MacGetLeftBorderSize() ;
3023 long wxWindowMac
::MacRemoveBordersFromStyle( long style
)
3025 return style
& ~wxBORDER_MASK
;
3028 // Find the wxWindowMac at the current mouse position, returning the mouse
3030 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
3032 pt
= wxGetMousePosition();
3033 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3037 // Get the current mouse position.
3038 wxPoint
wxGetMousePosition()
3041 wxGetMousePosition(& x
, & y
);
3042 return wxPoint(x
, y
);
3045 void wxWindowMac
::OnMouseEvent( wxMouseEvent
&event
)
3047 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3049 // copied from wxGTK : CS
3050 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3053 // (a) it's a command event and so is propagated to the parent
3054 // (b) under MSW it can be generated from kbd too
3055 // (c) it uses screen coords (because of (a))
3056 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3058 this->ClientToScreen(event
.GetPosition()));
3059 if ( ! GetEventHandler()->ProcessEvent(evtCtx
) )
3068 void wxWindowMac
::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
3072 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3076 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3077 Rect bounds
= { y
, x
, y
+h
, x
+w
};
3081 wxInt32 wxWindowMac
::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3083 return eventNotHandledErr
;