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"
38 #include "wx/textctrl.h"
39 #include "wx/laywin.h"
40 #include "wx/splitter.h"
42 #include "wx/toolbar.h"
49 #define wxWINDOW_HSCROLL 5998
50 #define wxWINDOW_VSCROLL 5997
52 #define MAC_SCROLLBAR_SIZE 15
53 #define MAC_SMALL_SCROLLBAR_SIZE 11
55 #include "wx/mac/uma.h"
58 #include <ToolUtils.h>
60 #include <MacTextEditor.h>
63 #if TARGET_API_MAC_OSX
65 #include <HIToolbox/HIView.h>
69 #if wxUSE_DRAG_AND_DROP
75 extern wxList wxPendingDelete
;
77 #ifdef __WXUNIVERSAL__
78 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
80 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
81 #endif // __WXUNIVERSAL__/__WXMAC__
83 #if !USE_SHARED_LIBRARY
85 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
86 EVT_NC_PAINT(wxWindowMac
::OnNcPaint
)
87 EVT_ERASE_BACKGROUND(wxWindowMac
::OnEraseBackground
)
88 // TODO EVT_PAINT(wxWindowMac::OnPaint)
89 EVT_SET_FOCUS(wxWindowMac
::OnSetFocus
)
90 EVT_KILL_FOCUS(wxWindowMac
::OnSetFocus
)
91 EVT_MOUSE_EVENTS(wxWindowMac
::OnMouseEvent
)
96 #define wxMAC_DEBUG_REDRAW 0
97 #ifndef wxMAC_DEBUG_REDRAW
98 #define wxMAC_DEBUG_REDRAW 0
101 #define wxMAC_USE_THEME_BORDER 1
103 // ---------------------------------------------------------------------------
104 // Utility Routines to move between different coordinate systems
105 // ---------------------------------------------------------------------------
108 * Right now we have the following setup :
109 * a border that is not part of the native control is always outside the
110 * control's border (otherwise we loose all native intelligence, future ways
111 * may be to have a second embedding control responsible for drawing borders
112 * and backgrounds eventually)
113 * so all this border calculations have to be taken into account when calling
114 * native methods or getting native oriented data
115 * so we have three coordinate systems here
116 * wx client coordinates
117 * wx window coordinates (including window frames)
122 // originating from native control
126 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
128 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
131 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
133 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
137 // directed towards native control
140 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
142 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
145 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
147 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
151 // ---------------------------------------------------------------------------
153 // ---------------------------------------------------------------------------
155 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
156 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
) ;
158 #if TARGET_API_MAC_OSX
160 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
162 kEventControlVisibilityChanged
= 157
168 static const EventTypeSpec eventList
[] =
170 { kEventClassControl
, kEventControlHit
} ,
171 #if TARGET_API_MAC_OSX
172 { kEventClassControl
, kEventControlDraw
} ,
173 { kEventClassControl
, kEventControlVisibilityChanged
} ,
174 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
175 { kEventClassControl
, kEventControlHiliteChanged
} ,
176 { kEventClassControl
, kEventControlSetFocusPart
} ,
178 { kEventClassService
, kEventServiceGetTypes
},
179 { kEventClassService
, kEventServiceCopy
},
180 { kEventClassService
, kEventServicePaste
},
182 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
183 // { kEventClassControl , kEventControlBoundsChanged } ,
187 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
189 OSStatus result
= eventNotHandledErr
;
191 wxMacCarbonEvent
cEvent( event
) ;
193 ControlRef controlRef
;
194 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
196 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
198 switch( GetEventKind( event
) )
200 #if TARGET_API_MAC_OSX
201 case kEventControlDraw
:
203 RgnHandle updateRgn
= NULL
;
204 RgnHandle allocatedRgn
= NULL
;
205 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
206 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
208 updateRgn
= (RgnHandle
) visRegion
.GetWXHRGN() ;
212 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
214 allocatedRgn
= NewRgn() ;
215 CopyRgn( updateRgn
, allocatedRgn
) ;
216 // hide the given region by the new region that must be shifted
217 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
218 updateRgn
= allocatedRgn
;
223 // in case we would need a coregraphics compliant background erase first
224 // now usable to track redraws
225 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
226 if ( thisWindow
->MacIsUserPane() )
228 static float color
= 0.5 ;
231 HIViewGetBounds( controlRef
, &bounds
);
232 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
233 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
234 CGContextFillRect( cgContext
, bounds
);
245 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
248 DisposeRgn( allocatedRgn
) ;
251 case kEventControlVisibilityChanged
:
252 thisWindow
->MacVisibilityChanged() ;
254 case kEventControlEnabledStateChanged
:
255 thisWindow
->MacEnabledStateChanged() ;
257 case kEventControlHiliteChanged
:
258 thisWindow
->MacHiliteChanged() ;
260 case kEventControlSetFocusPart
:
262 Boolean focusEverything
= false ;
263 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
264 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
267 if ( controlPart
== kControlFocusNoPart
)
270 if ( thisWindow
->GetCaret() )
272 thisWindow
->GetCaret()->OnKillFocus();
274 #endif // wxUSE_CARET
275 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
276 event
.SetEventObject(thisWindow
);
277 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
281 // panel wants to track the window which was the last to have focus in it
282 wxChildFocusEvent
eventFocus(thisWindow
);
283 thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
);
286 if ( thisWindow
->GetCaret() )
288 thisWindow
->GetCaret()->OnSetFocus();
290 #endif // wxUSE_CARET
292 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
293 event
.SetEventObject(thisWindow
);
294 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
296 if ( thisWindow
->MacIsUserPane() )
301 case kEventControlHit
:
303 result
= thisWindow
->MacControlHit( handler
, event
) ;
312 static pascal OSStatus
wxMacWindowServiceEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
314 OSStatus result
= eventNotHandledErr
;
316 wxMacCarbonEvent
cEvent( event
) ;
318 ControlRef controlRef
;
319 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
320 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
321 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
323 switch( GetEventKind( event
) )
325 case kEventServiceGetTypes
:
329 textCtrl
->GetSelection( &from
, &to
) ;
331 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
333 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
334 if ( textCtrl
->IsEditable() )
335 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
337 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ };
338 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
340 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
344 CFArrayAppendValue (copyTypes
, typestring
) ;
346 CFArrayAppendValue (pasteTypes
, typestring
) ;
347 CFRelease( typestring
) ;
353 case kEventServiceCopy
:
357 textCtrl
->GetSelection( &from
, &to
) ;
358 wxString val
= textCtrl
->GetValue() ;
359 val
= val
.Mid( from
, to
- from
) ;
360 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
361 verify_noerr( ClearScrap( &scrapRef
) ) ;
362 verify_noerr( PutScrapFlavor( scrapRef
, kTXNTextData
, 0 , val
.Length() , val
.c_str() ) ) ;
366 case kEventServicePaste
:
369 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
370 Size textSize
, pastedSize
;
371 verify_noerr( GetScrapFlavorSize (scrapRef
, kTXNTextData
, &textSize
) ) ;
373 char *content
= new char[textSize
] ;
374 GetScrapFlavorData (scrapRef
, kTXNTextData
, &pastedSize
, content
);
375 content
[textSize
-1] = 0 ;
377 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
379 textCtrl
->WriteText( wxString( content
) ) ;
390 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
392 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
393 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
394 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
395 OSStatus result
= eventNotHandledErr
;
397 switch ( GetEventClass( event
) )
399 case kEventClassControl
:
400 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
402 case kEventClassService
:
403 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
407 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
411 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
413 // ---------------------------------------------------------------------------
414 // UserPane events for non OSX builds
415 // ---------------------------------------------------------------------------
417 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
419 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
420 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
421 win
->MacControlUserPaneDrawProc(part
) ;
424 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
426 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
427 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
428 return win
->MacControlUserPaneHitTestProc(where
.h
, where
.v
) ;
431 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
433 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
434 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
435 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
438 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
440 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
441 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
442 win
->MacControlUserPaneIdleProc() ;
445 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
447 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
448 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
449 return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ;
452 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
454 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
455 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
456 win
->MacControlUserPaneActivateProc(activating
) ;
459 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
461 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
462 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
463 return win
->MacControlUserPaneFocusProc(action
) ;
466 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
468 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
469 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
470 win
->MacControlUserPaneBackgroundProc(info
) ;
473 void wxWindowMac
::MacControlUserPaneDrawProc(wxInt16 part
)
475 RgnHandle rgn
= NewRgn() ;
477 wxMacWindowStateSaver
sv( this ) ;
478 SectRgn( rgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn
) ;
479 MacDoRedraw( rgn
, 0 ) ;
483 wxInt16 wxWindowMac
::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
485 return kControlNoPart
;
488 wxInt16 wxWindowMac
::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
490 return kControlNoPart
;
493 void wxWindowMac
::MacControlUserPaneIdleProc()
497 wxInt16 wxWindowMac
::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
499 return kControlNoPart
;
502 void wxWindowMac
::MacControlUserPaneActivateProc(bool activating
)
506 wxInt16 wxWindowMac
::MacControlUserPaneFocusProc(wxInt16 action
)
508 return kControlNoPart
;
511 void wxWindowMac
::MacControlUserPaneBackgroundProc(void* info
)
515 ControlUserPaneDrawUPP gControlUserPaneDrawUPP
= NULL
;
516 ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP
= NULL
;
517 ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP
= NULL
;
518 ControlUserPaneIdleUPP gControlUserPaneIdleUPP
= NULL
;
519 ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP
= NULL
;
520 ControlUserPaneActivateUPP gControlUserPaneActivateUPP
= NULL
;
521 ControlUserPaneFocusUPP gControlUserPaneFocusUPP
= NULL
;
522 ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP
= NULL
;
524 // ===========================================================================
526 // ===========================================================================
528 wxList
wxWinMacControlList(wxKEY_INTEGER
);
530 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
532 wxNode
*node
= wxWinMacControlList
.Find((long)inControl
);
535 return (wxControl
*)node
->GetData();
538 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
540 // adding NULL ControlRef is (first) surely a result of an error and
541 // (secondly) breaks native event processing
542 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
544 if ( !wxWinMacControlList
.Find((long)inControl
) )
545 wxWinMacControlList
.Append((long)inControl
, control
);
548 void wxRemoveMacControlAssociation(wxWindow
*control
)
550 wxWinMacControlList
.DeleteObject(control
);
554 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
556 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
558 // we have to setup the brush in the current port and return noErr
559 // or return an error code so that the control manager walks further up the
560 // hierarchy to find a correct background
562 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
564 OSStatus status
= paramErr
;
567 case kControlMsgApplyTextColor
:
569 case kControlMsgSetUpBackground
:
571 wxWindow
* wx
= (wxWindow
*) wxFindControlFromMacControl( iControl
) ;
575 const wxBrush &brush = wx->MacGetBackgroundBrush() ;
578 wxDC::MacSetupBackgroundForCurrentPort( brush ) ;
580 // this clipping is only needed for non HIView
582 RgnHandle clip
= NewRgn() ;
585 wx
->MacWindowToRootWindow( &x
,&y
) ;
586 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion().GetWXHRGN() , clip
) ;
587 OffsetRgn( clip
, x
, y
) ;
594 else if ( wx->MacIsUserPane() )
596 // if we don't have a valid brush for such a control, we have to call the
597 // setup of our parent ourselves
598 status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ;
611 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
612 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
616 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
619 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
624 // ----------------------------------------------------------------------------
625 // constructors and such
626 // ----------------------------------------------------------------------------
628 wxWindowMac
::wxWindowMac()
633 wxWindowMac
::wxWindowMac(wxWindowMac
*parent
,
638 const wxString
& name
)
641 Create(parent
, id
, pos
, size
, style
, name
);
644 void wxWindowMac
::Init()
648 #if WXWIN_COMPATIBILITY_2_4
649 m_backgroundTransparent
= FALSE
;
652 // as all windows are created with WS_VISIBLE style...
655 m_hScrollBar
= NULL
;
656 m_vScrollBar
= NULL
;
657 m_macBackgroundBrush
= wxNullBrush
;
659 m_macIsUserPane
= TRUE
;
661 // make sure all proc ptrs are available
663 if ( gControlUserPaneDrawUPP
== NULL
)
665 gControlUserPaneDrawUPP
= NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc
) ;
666 gControlUserPaneHitTestUPP
= NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc
) ;
667 gControlUserPaneTrackingUPP
= NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc
) ;
668 gControlUserPaneIdleUPP
= NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc
) ;
669 gControlUserPaneKeyDownUPP
= NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc
) ;
670 gControlUserPaneActivateUPP
= NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc
) ;
671 gControlUserPaneFocusUPP
= NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc
) ;
672 gControlUserPaneBackgroundUPP
= NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc
) ;
674 if ( wxMacLiveScrollbarActionUPP
== NULL
)
676 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
679 if ( wxMacSetupControlBackgroundUPP
== NULL
)
681 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
684 // we need a valid font for the encodings
685 wxWindowBase
::SetFont(wxSystemSettings
::GetFont(wxSYS_DEFAULT_GUI_FONT
));
689 wxWindowMac
::~wxWindowMac()
693 m_isBeingDeleted
= TRUE
;
695 #ifndef __WXUNIVERSAL__
696 // VS: make sure there's no wxFrame with last focus set to us:
697 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
699 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
702 if ( frame
->GetLastFocus() == this )
704 frame
->SetLastFocus((wxWindow
*)NULL
);
709 #endif // __WXUNIVERSAL__
711 // wxRemoveMacControlAssociation( this ) ;
712 // If we delete an item, we should initialize the parent panel,
713 // because it could now be invalid.
714 wxWindow
*parent
= GetParent() ;
717 if (parent
->GetDefaultItem() == (wxButton
*) this)
718 parent
->SetDefaultItem(NULL
);
720 if ( m_peer
&& m_peer
->Ok() )
722 // in case the callback might be called during destruction
723 wxRemoveMacControlAssociation( this) ;
724 // we currently are not using this hook
725 // ::SetControlColorProc( *m_peer , NULL ) ;
729 if ( g_MacLastWindow
== this )
731 g_MacLastWindow
= NULL
;
734 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame
) ;
737 if ( frame
->GetLastFocus() == this )
738 frame
->SetLastFocus( NULL
) ;
743 // delete our drop target if we've got one
744 #if wxUSE_DRAG_AND_DROP
745 if ( m_dropTarget
!= NULL
)
750 #endif // wxUSE_DRAG_AND_DROP
754 WXWidget wxWindowMac
::GetHandle() const
756 return (WXWidget
) m_peer
->GetControlRef() ;
760 void wxWindowMac
::MacInstallEventHandler( WXWidget control
)
762 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
763 InstallControlEventHandler( (ControlRef
) control
, GetwxMacWindowEventHandlerUPP(),
764 GetEventTypeCount(eventList
), eventList
, this,
765 (EventHandlerRef
*)&m_macControlEventHandler
);
770 bool wxWindowMac
::Create(wxWindowMac
*parent
, wxWindowID id
,
774 const wxString
& name
)
776 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
778 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
781 parent
->AddChild(this);
783 m_windowVariant
= parent
->GetWindowVariant() ;
785 if ( m_macIsUserPane
)
787 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
790 | kControlSupportsEmbedding
791 // | kControlSupportsLiveFeedback
792 // | kControlHasSpecialBackground
793 // | kControlSupportsCalcBestRect
794 // | kControlHandlesTracking
795 | kControlSupportsFocus
796 // | kControlWantsActivate
797 // | kControlWantsIdle
800 m_peer
= new wxMacControl() ;
801 ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
804 MacPostControlCreate(pos
,size
) ;
805 #if !TARGET_API_MAC_OSX
806 m_peer
->SetData
<ControlUserPaneDrawUPP
>(kControlEntireControl
,kControlUserPaneDrawProcTag
,&gControlUserPaneDrawUPP
) ;
807 m_peer
->SetData
<ControlUserPaneHitTestUPP
>(kControlEntireControl
,kControlUserPaneHitTestProcTag
,&gControlUserPaneHitTestUPP
) ;
808 m_peer
->SetData
<ControlUserPaneTrackingUPP
>(kControlEntireControl
,kControlUserPaneTrackingProcTag
,&gControlUserPaneTrackingUPP
) ;
809 m_peer
->SetData
<ControlUserPaneIdleUPP
>(kControlEntireControl
,kControlUserPaneIdleProcTag
,&gControlUserPaneIdleUPP
) ;
810 m_peer
->SetData
<ControlUserPaneKeyDownUPP
>(kControlEntireControl
,kControlUserPaneKeyDownProcTag
,&gControlUserPaneKeyDownUPP
) ;
811 m_peer
->SetData
<ControlUserPaneActivateUPP
>(kControlEntireControl
,kControlUserPaneActivateProcTag
,&gControlUserPaneActivateUPP
) ;
812 m_peer
->SetData
<ControlUserPaneFocusUPP
>(kControlEntireControl
,kControlUserPaneFocusProcTag
,&gControlUserPaneFocusUPP
) ;
813 m_peer
->SetData
<ControlUserPaneBackgroundUPP
>(kControlEntireControl
,kControlUserPaneBackgroundProcTag
,&gControlUserPaneBackgroundUPP
) ;
816 #ifndef __WXUNIVERSAL__
817 // Don't give scrollbars to wxControls unless they ask for them
818 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) ||
819 (IsKindOf(CLASSINFO(wxControl
)) && ( style
& wxHSCROLL
|| style
& wxVSCROLL
)))
821 MacCreateScrollBars( style
) ;
825 wxWindowCreateEvent
event(this);
826 GetEventHandler()->AddPendingEvent(event
);
831 void wxWindowMac
::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
)
833 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
835 m_peer
->SetReference( (long) this ) ;
837 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
839 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
840 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
841 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
843 // adjust font, controlsize etc
844 DoSetWindowVariant( m_windowVariant
) ;
846 #if !TARGET_API_MAC_OSX
847 // eventually we can fix some clipping issues be reactivating this hook
848 //if ( m_macIsUserPane )
849 // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
851 m_peer
->SetTitle( wxStripMenuCodes(m_label
) ) ;
853 if (!m_macIsUserPane
)
855 SetInitialBestSize(size
);
858 SetCursor( *wxSTANDARD_CURSOR
) ;
861 void wxWindowMac
::DoSetWindowVariant( wxWindowVariant variant
)
863 // Don't assert, in case we set the window variant before
864 // the window is created
865 // wxASSERT( m_peer->Ok() ) ;
867 m_windowVariant
= variant
;
869 if (m_peer
== NULL
|| !m_peer
->Ok())
873 ThemeFontID themeFont
= kThemeSystemFont
;
875 // we will get that from the settings later
876 // and make this NORMAL later, but first
877 // we have a few calculations that we must fix
881 case wxWINDOW_VARIANT_NORMAL
:
882 size
= kControlSizeNormal
;
883 themeFont
= kThemeSystemFont
;
885 case wxWINDOW_VARIANT_SMALL
:
886 size
= kControlSizeSmall
;
887 themeFont
= kThemeSmallSystemFont
;
889 case wxWINDOW_VARIANT_MINI
:
890 if (UMAGetSystemVersion() >= 0x1030 )
892 // not always defined in the headers
898 size
= kControlSizeSmall
;
899 themeFont
= kThemeSmallSystemFont
;
902 case wxWINDOW_VARIANT_LARGE
:
903 size
= kControlSizeLarge
;
904 themeFont
= kThemeSystemFont
;
907 wxFAIL_MSG(_T("unexpected window variant"));
910 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
,&size
) ;
913 font
.MacCreateThemeFont( themeFont
) ;
917 void wxWindowMac
::MacUpdateControlFont()
919 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
923 bool wxWindowMac
::SetFont(const wxFont
& font
)
925 bool retval
= !wxWindowBase
::SetFont( font
) ;
927 MacUpdateControlFont() ;
932 bool wxWindowMac
::SetForegroundColour(const wxColour
& col
)
934 if ( !wxWindowBase
::SetForegroundColour(col
) )
937 MacUpdateControlFont() ;
942 bool wxWindowMac
::SetBackgroundColour(const wxColour
& col
)
944 if ( !wxWindowBase
::SetBackgroundColour(col
) && m_hasBgCol
)
948 wxColour
newCol(GetBackgroundColour());
949 if ( newCol
== wxSystemSettings
::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
951 brush
.MacSetTheme( kThemeBrushDocumentWindowBackground
) ;
953 else if ( newCol
== wxSystemSettings
::GetColour(wxSYS_COLOUR_3DFACE
) )
955 brush
.MacSetTheme( kThemeBrushDialogBackgroundActive
) ;
959 brush
.SetColour( newCol
) ;
961 MacSetBackgroundBrush( brush
) ;
963 MacUpdateControlFont() ;
968 void wxWindowMac
::MacSetBackgroundBrush( const wxBrush
&brush
)
970 m_macBackgroundBrush
= brush
;
971 m_peer
->SetBackground( brush
) ;
974 bool wxWindowMac
::MacCanFocus() const
976 // there is currently no way to determine whether the window is running in full keyboard
977 // access mode, therefore we cannot rely on these features, yet the only other way would be
978 // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
979 // in event handlers...
980 UInt32 features
= 0 ;
981 m_peer
->GetFeatures( & features
) ;
982 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
986 void wxWindowMac
::SetFocus()
988 if ( AcceptsFocus() )
990 #if !TARGET_API_MAC_OSX
991 wxWindow
* former
= FindFocus() ;
993 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
994 // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
995 // leave in case of an error
996 if ( err
== errCouldntSetFocus
)
999 #if !TARGET_API_MAC_OSX
1000 // emulate carbon events when running under carbonlib where they are not natively available
1003 EventRef evRef
= NULL
;
1004 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1007 wxMacCarbonEvent
cEvent( evRef
) ;
1008 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) former
->GetHandle() ) ;
1009 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNoPart
) ;
1011 wxMacWindowEventHandler( NULL
, evRef
, former
) ;
1012 ReleaseEvent(evRef
) ;
1014 // send new focus event
1016 EventRef evRef
= NULL
;
1017 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1020 wxMacCarbonEvent
cEvent( evRef
) ;
1021 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) GetHandle() ) ;
1022 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNextPart
) ;
1024 wxMacWindowEventHandler( NULL
, evRef
, this ) ;
1025 ReleaseEvent(evRef
) ;
1032 void wxWindowMac
::DoCaptureMouse()
1034 wxTheApp
->s_captureWindow
= this ;
1037 wxWindow
* wxWindowBase
::GetCapture()
1039 return wxTheApp
->s_captureWindow
;
1042 void wxWindowMac
::DoReleaseMouse()
1044 wxTheApp
->s_captureWindow
= NULL
;
1047 #if wxUSE_DRAG_AND_DROP
1049 void wxWindowMac
::SetDropTarget(wxDropTarget
*pDropTarget
)
1051 if ( m_dropTarget
!= 0 ) {
1052 delete m_dropTarget
;
1055 m_dropTarget
= pDropTarget
;
1056 if ( m_dropTarget
!= 0 )
1064 // Old style file-manager drag&drop
1065 void wxWindowMac
::DragAcceptFiles(bool accept
)
1070 // Returns the size of the native control. In the case of the toplevel window
1071 // this is the content area root control
1073 void wxWindowMac
::MacGetPositionAndSizeFromControl(int& x
, int& y
,
1074 int& w
, int& h
) const
1077 m_peer
->GetRect( &bounds
) ;
1082 w
= bounds
.right
- bounds
.left
;
1083 h
= bounds
.bottom
- bounds
.top
;
1086 // From a wx position / size calculate the appropriate size of the native control
1088 bool wxWindowMac
::MacGetBoundsForControl(const wxPoint
& pos
,
1091 int& w
, int& h
, bool adjustOrigin
) const
1093 // the desired size, minus the border pixels gives the correct size of the control
1097 // todo the default calls may be used as soon as PostCreateControl Is moved here
1098 w
= size
.x
; // WidthDefault( size.x );
1099 h
= size
.y
; // HeightDefault( size.y ) ;
1100 #if !TARGET_API_MAC_OSX
1101 GetParent()->MacWindowToRootWindow( &x
, &y
) ;
1104 x
+= MacGetLeftBorderSize() ;
1105 y
+= MacGetTopBorderSize() ;
1106 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1107 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1110 AdjustForParentClientOrigin( x
, y
) ;
1114 // Get window size (not client size)
1115 void wxWindowMac
::DoGetSize(int *x
, int *y
) const
1117 // take the size of the control and add the borders that have to be drawn outside
1118 int x1
, y1
, w1
, h1
;
1120 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1122 w1
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1123 h1
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1129 // get the position of the bounds of this window in client coordinates of its parent
1130 void wxWindowMac
::DoGetPosition(int *x
, int *y
) const
1132 int x1
, y1
, w1
,h1
;
1133 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1134 x1
-= MacGetLeftBorderSize() ;
1135 y1
-= MacGetTopBorderSize() ;
1137 #if !TARGET_API_MAC_OSX
1138 if ( !GetParent()->IsTopLevel() )
1141 GetControlBounds( (ControlRef
) GetParent()->GetHandle() , &bounds
) ;
1146 if ( !IsTopLevel() )
1148 wxWindow
*parent
= GetParent();
1151 // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix
1152 x1
+= parent
->MacGetLeftBorderSize() ;
1153 y1
+= parent
->MacGetTopBorderSize() ;
1154 // and now to client coordinates
1155 wxPoint
pt(parent
->GetClientAreaOrigin());
1164 void wxWindowMac
::DoScreenToClient(int *x
, int *y
) const
1166 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1168 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1171 Point localwhere
= {0,0} ;
1173 if(x
) localwhere
.h
= * x
;
1174 if(y
) localwhere
.v
= * y
;
1176 QDGlobalToLocalPoint( GetWindowPort( window
) , &localwhere
) ;
1177 if(x
) *x
= localwhere
.h
;
1178 if(y
) *y
= localwhere
.v
;
1181 MacRootWindowToWindow( x
, y
) ;
1183 wxPoint origin
= GetClientAreaOrigin() ;
1184 if(x
) *x
-= origin
.x
;
1185 if(y
) *y
-= origin
.y
;
1188 void wxWindowMac
::DoClientToScreen(int *x
, int *y
) const
1190 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1191 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1193 wxPoint origin
= GetClientAreaOrigin() ;
1194 if(x
) *x
+= origin
.x
;
1195 if(y
) *y
+= origin
.y
;
1197 MacWindowToRootWindow( x
, y
) ;
1200 Point localwhere
= { 0,0 };
1201 if(x
) localwhere
.h
= * x
;
1202 if(y
) localwhere
.v
= * y
;
1203 QDLocalToGlobalPoint( GetWindowPort( window
) , &localwhere
) ;
1204 if(x
) *x
= localwhere
.h
;
1205 if(y
) *y
= localwhere
.v
;
1209 void wxWindowMac
::MacClientToRootWindow( int *x
, int *y
) const
1211 wxPoint origin
= GetClientAreaOrigin() ;
1212 if(x
) *x
+= origin
.x
;
1213 if(y
) *y
+= origin
.y
;
1215 MacWindowToRootWindow( x
, y
) ;
1218 void wxWindowMac
::MacRootWindowToClient( int *x
, int *y
) const
1220 MacRootWindowToWindow( x
, y
) ;
1222 wxPoint origin
= GetClientAreaOrigin() ;
1223 if(x
) *x
-= origin
.x
;
1224 if(y
) *y
-= origin
.y
;
1227 void wxWindowMac
::MacWindowToRootWindow( int *x
, int *y
) const
1229 #if TARGET_API_MAC_OSX
1231 if ( x
) pt
.x
= *x
;
1232 if ( y
) pt
.y
= *y
;
1234 if ( !IsTopLevel() )
1236 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1239 pt
.x
-= MacGetLeftBorderSize() ;
1240 pt
.y
-= MacGetTopBorderSize() ;
1241 wxMacControl
::Convert( &pt
, m_peer
, top
->m_peer
) ;
1245 if ( x
) *x
= (int) pt
.x
;
1246 if ( y
) *y
= (int) pt
.y
;
1248 if ( !IsTopLevel() )
1251 m_peer
->GetRect( &bounds
) ;
1252 if(x
) *x
+= bounds
.left
- MacGetLeftBorderSize() ;
1253 if(y
) *y
+= bounds
.top
- MacGetTopBorderSize() ;
1258 void wxWindowMac
::MacWindowToRootWindow( short *x
, short *y
) const
1263 MacWindowToRootWindow( &x1
, &y1
) ;
1268 void wxWindowMac
::MacRootWindowToWindow( int *x
, int *y
) const
1270 #if TARGET_API_MAC_OSX
1272 if ( x
) pt
.x
= *x
;
1273 if ( y
) pt
.y
= *y
;
1275 if ( !IsTopLevel() )
1277 wxMacControl
::Convert( &pt
, MacGetTopLevelWindow()->m_peer
, m_peer
) ;
1278 pt
.x
+= MacGetLeftBorderSize() ;
1279 pt
.y
+= MacGetTopBorderSize() ;
1282 if ( x
) *x
= (int) pt
.x
;
1283 if ( y
) *y
= (int) pt
.y
;
1285 if ( !IsTopLevel() )
1288 m_peer
->GetRect( &bounds
) ;
1289 if(x
) *x
-= bounds
.left
+ MacGetLeftBorderSize() ;
1290 if(y
) *y
-= bounds
.top
+ MacGetTopBorderSize() ;
1295 void wxWindowMac
::MacRootWindowToWindow( short *x
, short *y
) const
1300 MacRootWindowToWindow( &x1
, &y1
) ;
1305 void wxWindowMac
::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1307 RgnHandle rgn
= NewRgn() ;
1309 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1311 GetRegionBounds( rgn
, &content
) ;
1316 m_peer
->GetRect( &content
) ;
1319 m_peer
->GetRect( &structure
) ;
1320 #if !TARGET_API_MAC_OSX
1321 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1323 left
= content
.left
- structure
.left
;
1324 top
= content
.top
- structure
.top
;
1325 right
= structure
.right
- content
.right
;
1326 bottom
= structure
.bottom
- content
.bottom
;
1329 wxSize wxWindowMac
::DoGetSizeFromClientSize( const wxSize
& size
) const
1331 wxSize sizeTotal
= size
;
1333 RgnHandle rgn
= NewRgn() ;
1337 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1339 GetRegionBounds( rgn
, &content
) ;
1344 m_peer
->GetRect( &content
) ;
1347 m_peer
->GetRect( &structure
) ;
1348 #if !TARGET_API_MAC_OSX
1349 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1352 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1353 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1355 sizeTotal
.x
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1356 sizeTotal
.y
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1362 // Get size *available for subwindows* i.e. excluding menu bar etc.
1363 void wxWindowMac
::DoGetClientSize(int *x
, int *y
) const
1367 RgnHandle rgn
= NewRgn() ;
1369 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1371 GetRegionBounds( rgn
, &content
) ;
1376 m_peer
->GetRect( &content
) ;
1378 #if !TARGET_API_MAC_OSX
1380 m_peer
->GetRect( &structure
) ;
1381 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1383 ww
= content
.right
- content
.left
;
1384 hh
= content
.bottom
- content
.top
;
1386 ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1387 hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
1390 if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
1396 GetSize( &w , &h ) ;
1398 MacClientToRootWindow( &x1 , &y1 ) ;
1399 MacClientToRootWindow( &w , &h ) ;
1401 wxWindowMac *iter = (wxWindowMac*)this ;
1403 int totW = 10000 , totH = 10000;
1406 if ( iter->IsTopLevel() )
1408 iter->GetSize( &totW , &totH ) ;
1412 iter = iter->GetParent() ;
1415 if (m_hScrollBar && m_hScrollBar->IsShown() )
1417 hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
1423 if (m_vScrollBar && m_vScrollBar->IsShown() )
1425 ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
1433 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1435 hh
-= m_hScrollBar
->GetSize().y
; // MAC_SCROLLBAR_SIZE ;
1437 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1439 ww
-= m_vScrollBar
->GetSize().x
; // MAC_SCROLLBAR_SIZE;
1446 bool wxWindowMac
::SetCursor(const wxCursor
& cursor
)
1448 if (m_cursor
== cursor
)
1451 if (wxNullCursor
== cursor
)
1453 if ( ! wxWindowBase
::SetCursor( *wxSTANDARD_CURSOR
) )
1458 if ( ! wxWindowBase
::SetCursor( cursor
) )
1462 wxASSERT_MSG( m_cursor
.Ok(),
1463 wxT("cursor must be valid after call to the base version"));
1466 wxWindowMac
*mouseWin
= 0 ;
1468 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1470 Boolean swapped
= QDSwapPort( GetWindowPort( window
) , &savePort
) ;
1472 // TODO If we ever get a GetCurrentEvent.. replacement for the mouse
1473 // position, use it...
1477 ControlPartCode part
;
1478 ControlRef control
;
1479 control
= wxMacFindControlUnderMouse( pt
, window
, &part
) ;
1481 mouseWin
= wxFindControlFromMacControl( control
) ;
1484 QDSwapPort( savePort
, NULL
) ;
1487 if ( mouseWin
== this && !wxIsBusy() )
1489 m_cursor
.MacInstall() ;
1496 bool wxWindowMac
::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1498 menu
->SetInvokingWindow(this);
1501 if ( x
== -1 && y
== -1 )
1503 wxPoint mouse
= wxGetMousePosition();
1504 x
= mouse
.x
; y
= mouse
.y
;
1508 ClientToScreen( &x
, &y
) ;
1511 menu
->MacBeforeDisplay( true ) ;
1512 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
1513 if ( HiWord(menuResult
) != 0 )
1516 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id
) ;
1517 wxMenuItem
* item
= NULL
;
1519 item
= menu
->FindItem(id
, &realmenu
) ;
1520 if (item
->IsCheckable())
1522 item
->Check( !item
->IsChecked() ) ;
1524 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1526 menu
->MacAfterDisplay( true ) ;
1528 menu
->SetInvokingWindow(NULL
);
1534 // ----------------------------------------------------------------------------
1536 // ----------------------------------------------------------------------------
1540 void wxWindowMac
::DoSetToolTip(wxToolTip
*tooltip
)
1542 wxWindowBase
::DoSetToolTip(tooltip
);
1545 m_tooltip
->SetWindow(this);
1548 #endif // wxUSE_TOOLTIPS
1550 void wxWindowMac
::DoMoveWindow(int x
, int y
, int width
, int height
)
1552 // this is never called for a toplevel window, so we know we have a parent
1553 int former_x
, former_y
, former_w
, former_h
;
1555 // Get true coordinates of former position
1556 DoGetPosition( &former_x
, &former_y
) ;
1557 DoGetSize( &former_w
, &former_h
) ;
1559 wxWindow
*parent
= GetParent();
1562 wxPoint
pt(parent
->GetClientAreaOrigin());
1567 int actualWidth
= width
;
1568 int actualHeight
= height
;
1572 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1573 actualWidth
= m_minWidth
;
1574 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1575 actualHeight
= m_minHeight
;
1576 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1577 actualWidth
= m_maxWidth
;
1578 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1579 actualHeight
= m_maxHeight
;
1581 bool doMove
= false ;
1582 bool doResize
= false ;
1584 if ( actualX
!= former_x
|| actualY
!= former_y
)
1588 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1593 if ( doMove
|| doResize
)
1595 // we don't adjust twice for the origin
1596 Rect r
= wxMacGetBoundsForControl(this , wxPoint( actualX
,actualY
), wxSize( actualWidth
, actualHeight
) , false ) ;
1597 #if TARGET_API_MAC_OSX
1598 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1599 if ( ! GetParent()->IsTopLevel() )
1601 r
.left
-= GetParent()->MacGetLeftBorderSize() ;
1602 r
.top
-= GetParent()->MacGetTopBorderSize() ;
1603 r
.right
-= GetParent()->MacGetLeftBorderSize() ;
1604 r
.bottom
-= GetParent()->MacGetTopBorderSize() ;
1607 bool vis
= m_peer
->IsVisible();
1609 // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
1611 m_peer
->SetVisibility( false , true ) ;
1612 m_peer
->SetRect( &r
) ;
1614 m_peer
->SetVisibility( true , true ) ;
1616 MacRepositionScrollBars() ;
1619 wxPoint
point(actualX
,actualY
);
1620 wxMoveEvent
event(point
, m_windowId
);
1621 event
.SetEventObject(this);
1622 GetEventHandler()->ProcessEvent(event
) ;
1626 MacRepositionScrollBars() ;
1627 wxSize
size(actualWidth
, actualHeight
);
1628 wxSizeEvent
event(size
, m_windowId
);
1629 event
.SetEventObject(this);
1630 GetEventHandler()->ProcessEvent(event
);
1636 wxSize wxWindowMac
::DoGetBestSize() const
1638 if ( m_macIsUserPane
|| IsTopLevel() )
1639 return wxWindowBase
::DoGetBestSize() ;
1641 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1642 int bestWidth
, bestHeight
;
1643 m_peer
->GetBestRect( &bestsize
) ;
1645 if ( EmptyRect( &bestsize
) )
1647 bestsize
.left
= bestsize
.top
= 0 ;
1648 bestsize
.right
= 16 ;
1649 bestsize
.bottom
= 16 ;
1650 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1652 bestsize
.bottom
= 16 ;
1654 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1656 bestsize
.bottom
= 24 ;
1660 // return wxWindowBase::DoGetBestSize() ;
1664 bestWidth
= bestsize
.right
- bestsize
.left
;
1665 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1666 if ( bestHeight
< 10 )
1669 return wxSize(bestWidth
, bestHeight
);
1673 // set the size of the window: if the dimensions are positive, just use them,
1674 // but if any of them is equal to -1, it means that we must find the value for
1675 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1676 // which case -1 is a valid value for x and y)
1678 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1679 // the width/height to best suit our contents, otherwise we reuse the current
1681 void wxWindowMac
::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1683 // get the current size and position...
1684 int currentX
, currentY
;
1685 GetPosition(¤tX
, ¤tY
);
1687 int currentW
,currentH
;
1688 GetSize(¤tW
, ¤tH
);
1690 // ... and don't do anything (avoiding flicker) if it's already ok
1691 if ( x
== currentX
&& y
== currentY
&&
1692 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1695 MacRepositionScrollBars() ; // we might have a real position shift
1699 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1701 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1704 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
1706 wxSize
size(-1, -1);
1709 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1711 size
= DoGetBestSize();
1716 // just take the current one
1723 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1727 size
= DoGetBestSize();
1729 //else: already called DoGetBestSize() above
1735 // just take the current one
1740 DoMoveWindow(x
, y
, width
, height
);
1744 wxPoint wxWindowMac
::GetClientAreaOrigin() const
1746 RgnHandle rgn
= NewRgn() ;
1748 m_peer
->GetRegion( kControlContentMetaPart
, rgn
) ;
1749 GetRegionBounds( rgn
, &content
) ;
1751 #if !TARGET_API_MAC_OSX
1752 // if the content rgn is empty / not supported
1753 // don't attempt to correct the coordinates to wxWindow relative ones
1754 if (!::EmptyRect( &content
) )
1757 m_peer
->GetRect( &structure
) ;
1758 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1762 return wxPoint( content
.left
+ MacGetLeftBorderSize( ) , content
.top
+ MacGetTopBorderSize( ) );
1765 void wxWindowMac
::DoSetClientSize(int clientwidth
, int clientheight
)
1767 if ( clientheight
!= -1 || clientheight
!= -1 )
1769 int currentclientwidth
, currentclientheight
;
1770 int currentwidth
, currentheight
;
1772 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1773 GetSize( ¤twidth
, ¤theight
) ;
1775 DoSetSize( -1 , -1 , currentwidth
+ clientwidth
- currentclientwidth
,
1776 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1780 void wxWindowMac
::SetTitle(const wxString
& title
)
1782 m_label
= wxStripMenuCodes(title
) ;
1784 if ( m_peer
&& m_peer
->Ok() )
1786 m_peer
->SetTitle( m_label
) ;
1791 wxString wxWindowMac
::GetTitle() const
1796 bool wxWindowMac
::Show(bool show
)
1798 if ( !wxWindowBase
::Show(show
) )
1801 // TODO use visibilityChanged Carbon Event for OSX
1802 bool former
= MacIsReallyShown() ;
1804 m_peer
->SetVisibility( show
, true ) ;
1805 if ( former
!= MacIsReallyShown() )
1806 MacPropagateVisibilityChanged() ;
1810 bool wxWindowMac
::Enable(bool enable
)
1812 wxASSERT( m_peer
->Ok() ) ;
1813 if ( !wxWindowBase
::Enable(enable
) )
1816 bool former
= MacIsReallyEnabled() ;
1817 m_peer
->Enable( enable
) ;
1819 if ( former
!= MacIsReallyEnabled() )
1820 MacPropagateEnabledStateChanged() ;
1825 // status change propagations (will be not necessary for OSX later )
1828 void wxWindowMac
::MacPropagateVisibilityChanged()
1830 #if !TARGET_API_MAC_OSX
1831 MacVisibilityChanged() ;
1833 wxWindowListNode
*node
= GetChildren().GetFirst();
1836 wxWindowMac
*child
= node
->GetData();
1837 if ( child
->IsShown() )
1838 child
->MacPropagateVisibilityChanged( ) ;
1839 node
= node
->GetNext();
1844 void wxWindowMac
::MacPropagateEnabledStateChanged( )
1846 #if !TARGET_API_MAC_OSX
1847 MacEnabledStateChanged() ;
1849 wxWindowListNode
*node
= GetChildren().GetFirst();
1852 wxWindowMac
*child
= node
->GetData();
1853 if ( child
->IsEnabled() )
1854 child
->MacPropagateEnabledStateChanged() ;
1855 node
= node
->GetNext();
1860 void wxWindowMac
::MacPropagateHiliteChanged( )
1862 #if !TARGET_API_MAC_OSX
1863 MacHiliteChanged() ;
1865 wxWindowListNode
*node
= GetChildren().GetFirst();
1868 wxWindowMac
*child
= node
->GetData();
1869 // if ( child->IsEnabled() )
1870 child
->MacPropagateHiliteChanged() ;
1871 node
= node
->GetNext();
1877 // status change notifications
1880 void wxWindowMac
::MacVisibilityChanged()
1884 void wxWindowMac
::MacHiliteChanged()
1888 void wxWindowMac
::MacEnabledStateChanged()
1893 // status queries on the inherited window's state
1896 bool wxWindowMac
::MacIsReallyShown()
1898 // only under OSX the visibility of the TLW is taken into account
1899 #if TARGET_API_MAC_OSX
1900 if ( m_peer
&& m_peer
->Ok() )
1901 return m_peer
->IsVisible();
1903 wxWindow
* win
= this ;
1904 while( win
->IsShown() )
1906 if ( win
->IsTopLevel() )
1909 win
= win
->GetParent() ;
1917 bool wxWindowMac
::MacIsReallyEnabled()
1919 return m_peer
->IsEnabled() ;
1922 bool wxWindowMac
::MacIsReallyHilited()
1924 return m_peer
->IsActive();
1927 void wxWindowMac
::MacFlashInvalidAreas()
1929 #if TARGET_API_MAC_OSX
1930 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
1938 int wxWindowMac
::GetCharHeight() const
1940 wxClientDC
dc ( (wxWindowMac
*)this ) ;
1941 return dc
.GetCharHeight() ;
1944 int wxWindowMac
::GetCharWidth() const
1946 wxClientDC
dc ( (wxWindowMac
*)this ) ;
1947 return dc
.GetCharWidth() ;
1950 void wxWindowMac
::GetTextExtent(const wxString
& string
, int *x
, int *y
,
1951 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
1953 const wxFont
*fontToUse
= theFont
;
1955 fontToUse
= &m_font
;
1957 wxClientDC
dc( (wxWindowMac
*) this ) ;
1959 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
1960 if ( externalLeading
)
1961 *externalLeading
= le
;
1971 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
1972 * we always intersect with the entire window, not only with the client area
1975 void wxWindowMac
::Refresh(bool eraseBack
, const wxRect
*rect
)
1977 if ( m_peer
== NULL
)
1980 #if TARGET_API_MAC_OSX
1982 m_peer
->SetNeedsDisplay( true ) ;
1985 RgnHandle update
= NewRgn() ;
1986 SetRectRgn( update
, rect
->x
, rect
->y
, rect
->x
+ rect
->width
, rect
->y
+ rect
->height
) ;
1987 SectRgn( (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , update
, update
) ;
1988 wxPoint origin
= GetClientAreaOrigin() ;
1989 OffsetRgn( update
, origin
.x
, origin
.y
) ;
1990 // right now this is wx' window coordinates, as our native peer does not have borders, this is
1992 OffsetRgn( update
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
1993 m_peer
->SetNeedsDisplay( true , update
) ;
1994 DisposeRgn( update
) ;
1998 RgnHandle updateRgn = NewRgn() ;
2001 CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
2005 SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
2006 SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
2008 InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
2009 DisposeRgn(updateRgn) ;
2011 if ( m_peer
->IsVisible())
2013 m_peer
->SetVisibility( false , false ) ;
2014 m_peer
->SetVisibility( true , true ) ;
2017 if ( MacGetTopLevelWindow() == NULL )
2020 if ( !m_peer->IsVisible())
2023 wxPoint client = GetClientAreaOrigin();
2026 int x2 = m_width - client.x;
2027 int y2 = m_height - client.y;
2029 if (IsKindOf( CLASSINFO(wxButton)))
2031 // buttons have an "aura"
2038 Rect clientrect = { y1, x1, y2, x2 };
2042 Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
2043 SectRect( &clientrect , &r , &clientrect ) ;
2046 if ( !EmptyRect( &clientrect ) )
2048 int top = 0 , left = 0 ;
2050 MacClientToRootWindow( &left , &top ) ;
2051 OffsetRect( &clientrect , left , top ) ;
2053 MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
2059 void wxWindowMac
::Freeze()
2061 #if TARGET_API_MAC_OSX
2062 if ( !m_frozenness
++ )
2064 m_peer
->SetDrawingEnabled( false ) ;
2070 void wxWindowMac
::Thaw()
2072 #if TARGET_API_MAC_OSX
2073 wxASSERT_MSG( m_frozenness
> 0, _T("Thaw() without matching Freeze()") );
2075 if ( !--m_frozenness
)
2077 m_peer
->SetDrawingEnabled( true ) ;
2078 m_peer
->InvalidateWithChildren() ;
2083 void wxWindowMac
::MacRedrawControl()
2086 if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
2088 #if TARGET_API_MAC_CARBON
2091 wxClientDC dc(this) ;
2092 wxMacPortSetter helper(&dc) ;
2093 wxMacWindowClipper clipper(this) ;
2094 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
2095 UMADrawControl( *m_peer ) ;
2102 void wxWindowMac::OnPaint(wxPaintEvent& event)
2104 // why don't we skip that here ?
2108 wxWindowMac
*wxGetActiveWindow()
2110 // actually this is a windows-only concept
2114 // Coordinates relative to the window
2115 void wxWindowMac
::WarpPointer (int x_pos
, int y_pos
)
2117 // We really don't move the mouse programmatically under Mac.
2120 void wxWindowMac
::OnEraseBackground(wxEraseEvent
& event
)
2122 #if TARGET_API_MAC_OSX
2123 if ( m_macBackgroundBrush
.Ok() == false || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT
)
2129 event
.GetDC()->Clear() ;
2132 void wxWindowMac
::OnNcPaint( wxNcPaintEvent
& event
)
2137 int wxWindowMac
::GetScrollPos(int orient
) const
2139 if ( orient
== wxHORIZONTAL
)
2142 return m_hScrollBar
->GetThumbPosition() ;
2147 return m_vScrollBar
->GetThumbPosition() ;
2152 // This now returns the whole range, not just the number
2153 // of positions that we can scroll.
2154 int wxWindowMac
::GetScrollRange(int orient
) const
2156 if ( orient
== wxHORIZONTAL
)
2159 return m_hScrollBar
->GetRange() ;
2164 return m_vScrollBar
->GetRange() ;
2169 int wxWindowMac
::GetScrollThumb(int orient
) const
2171 if ( orient
== wxHORIZONTAL
)
2174 return m_hScrollBar
->GetThumbSize() ;
2179 return m_vScrollBar
->GetThumbSize() ;
2184 void wxWindowMac
::SetScrollPos(int orient
, int pos
, bool refresh
)
2186 if ( orient
== wxHORIZONTAL
)
2189 m_hScrollBar
->SetThumbPosition( pos
) ;
2194 m_vScrollBar
->SetThumbPosition( pos
) ;
2198 void wxWindowMac
::MacPaintBorders( int left
, int top
)
2204 m_peer
->GetRect( &rect
) ;
2205 InsetRect( &rect
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2207 if ( !IsTopLevel() )
2209 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2213 wxMacControl
::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2215 rect
.right
+= pt
.x
;
2217 rect
.bottom
+= pt
.y
;
2221 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2225 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
2226 InsetRect( &srect
, border
, border
);
2227 DrawThemeEditTextFrame(&srect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2229 else if (HasFlag(wxSIMPLE_BORDER
))
2233 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
2234 InsetRect( &srect
, border
, border
);
2235 DrawThemeListBoxFrame(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2239 void wxWindowMac
::RemoveChild( wxWindowBase
*child
)
2241 if ( child
== m_hScrollBar
)
2242 m_hScrollBar
= NULL
;
2243 if ( child
== m_vScrollBar
)
2244 m_vScrollBar
= NULL
;
2246 wxWindowBase
::RemoveChild( child
) ;
2249 // New function that will replace some of the above.
2250 void wxWindowMac
::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2251 int range
, bool refresh
)
2253 if ( orient
== wxHORIZONTAL
)
2257 if ( range
== 0 || thumbVisible
>= range
)
2259 if ( m_hScrollBar
->IsShown() )
2260 m_hScrollBar
->Show(false) ;
2264 if ( !m_hScrollBar
->IsShown() )
2265 m_hScrollBar
->Show(true) ;
2266 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2274 if ( range
== 0 || thumbVisible
>= range
)
2276 if ( m_vScrollBar
->IsShown() )
2277 m_vScrollBar
->Show(false) ;
2281 if ( !m_vScrollBar
->IsShown() )
2282 m_vScrollBar
->Show(true) ;
2283 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2287 MacRepositionScrollBars() ;
2290 // Does a physical scroll
2291 void wxWindowMac
::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2293 if( dx
== 0 && dy
==0 )
2299 int width
, height
;
2300 GetClientSize( &width
, &height
) ;
2301 #if TARGET_API_MAC_OSX
2302 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2303 // area is scrolled, this does not occur if width and height are 2 pixels less,
2304 // TODO write optimal workaround
2305 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2308 scrollrect
.Intersect( *rect
) ;
2310 if ( m_peer
->GetNeedsDisplay() )
2312 // becuase HIViewScrollRect does not scroll the already invalidated area we have two options
2313 // either immediate redraw or full invalidate
2315 // is the better overall solution, as it does not slow down scrolling
2316 m_peer
->SetNeedsDisplay( true ) ;
2318 // this would be the preferred version for fast drawing controls
2319 if( UMAGetSystemVersion() < 0x1030 )
2322 HIViewRender(m_peer
->GetControlRef()) ;
2325 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2326 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2327 m_peer
->ScrollRect( scrollrect
, dx
, dy
) ;
2334 RgnHandle updateRgn
= NewRgn() ;
2337 wxClientDC
dc(this) ;
2338 wxMacPortSetter
helper(&dc
) ;
2340 m_peer
->GetRect( &scrollrect
) ;
2341 scrollrect
.top
+= MacGetTopBorderSize() ;
2342 scrollrect
.left
+= MacGetLeftBorderSize() ;
2343 scrollrect
.bottom
= scrollrect
.top
+ height
;
2344 scrollrect
.right
= scrollrect
.left
+ width
;
2348 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
2349 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
2350 SectRect( &scrollrect
, &r
, &scrollrect
) ;
2352 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
2354 // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
2358 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2360 wxWindowMac
*child
= node
->GetData();
2361 if (child
== m_vScrollBar
) continue;
2362 if (child
== m_hScrollBar
) continue;
2363 if (child
->IsTopLevel()) continue;
2366 child
->GetPosition( &x
, &y
);
2368 child
->GetSize( &w
, &h
);
2372 if (rect
->Intersects(rc
))
2373 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2377 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2382 void wxWindowMac
::MacOnScroll(wxScrollEvent
&event
)
2384 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
2386 wxScrollWinEvent wevent
;
2387 wevent
.SetPosition(event
.GetPosition());
2388 wevent
.SetOrientation(event
.GetOrientation());
2389 wevent
.m_eventObject
= this;
2391 if (event
.m_eventType
== wxEVT_SCROLL_TOP
)
2392 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
2393 else if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
)
2394 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2395 else if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
)
2396 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
2397 else if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
)
2398 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
2399 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
)
2400 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2401 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
)
2402 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2403 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
)
2404 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2405 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBRELEASE
)
2406 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2408 GetEventHandler()->ProcessEvent(wevent
);
2412 // Get the window with the focus
2413 wxWindowMac
*wxWindowBase
::FindFocus()
2415 ControlRef control
;
2416 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2417 return wxFindControlFromMacControl( control
) ;
2420 void wxWindowMac
::OnSetFocus(wxFocusEvent
& event
)
2422 // panel wants to track the window which was the last to have focus in it,
2423 // so we want to set ourselves as the window which last had focus
2425 // notice that it's also important to do it upwards the tree becaus
2426 // otherwise when the top level panel gets focus, it won't set it back to
2427 // us, but to some other sibling
2429 // CS:don't know if this is still needed:
2430 //wxChildFocusEvent eventFocus(this);
2431 //(void)GetEventHandler()->ProcessEvent(eventFocus);
2433 if ( MacGetTopLevelWindow() && m_peer
->NeedsFocusRect() )
2435 wxMacWindowStateSaver
sv( this ) ;
2440 MacWindowToRootWindow( &x
, &y
) ;
2441 GetSize( &w
, &h
) ;
2442 Rect rect
= {y
, x
, h
+ y
, w
+ x
} ;
2444 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
2445 DrawThemeFocusRect( &rect
, true ) ;
2448 DrawThemeFocusRect( &rect
, false ) ;
2450 // as this erases part of the frame we have to redraw borders
2451 // and because our z-ordering is not always correct (staticboxes)
2452 // we have to invalidate things, we cannot simple redraw
2453 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() ;
2454 RectRgn( updateInner
, &rect
) ;
2455 InsetRect( &rect
, -4 , -4 ) ;
2456 RectRgn( updateOuter
, &rect
) ;
2457 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
2458 wxPoint
parent(0,0);
2459 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
2460 parent
-= GetParent()->GetClientAreaOrigin() ;
2461 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
2462 GetParent()->m_peer
->SetNeedsDisplay( true , updateOuter
) ;
2463 DisposeRgn(updateOuter
) ;
2464 DisposeRgn(updateInner
) ;
2471 void wxWindowMac
::OnInternalIdle()
2473 // This calls the UI-update mechanism (querying windows for
2474 // menu/toolbar/control state information)
2475 if (wxUpdateUIEvent
::CanUpdate(this))
2476 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2479 // Raise the window to the top of the Z order
2480 void wxWindowMac
::Raise()
2482 m_peer
->SetZOrder( true , NULL
) ;
2485 // Lower the window to the bottom of the Z order
2486 void wxWindowMac
::Lower()
2488 m_peer
->SetZOrder( false , NULL
) ;
2492 // static wxWindow *gs_lastWhich = NULL;
2494 bool wxWindowMac
::MacSetupCursor( const wxPoint
& pt
)
2496 // first trigger a set cursor event
2498 wxPoint clientorigin
= GetClientAreaOrigin() ;
2499 wxSize clientsize
= GetClientSize() ;
2501 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2503 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2505 bool processedEvtSetCursor
= GetEventHandler()->ProcessEvent(event
);
2506 if ( processedEvtSetCursor
&& event
.HasCursor() )
2508 cursor
= event
.GetCursor() ;
2513 // the test for processedEvtSetCursor is here to prevent using m_cursor
2514 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2515 // it - this is a way to say that our cursor shouldn't be used for this
2517 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2527 cursor
= *wxSTANDARD_CURSOR
;
2531 cursor
.MacInstall() ;
2533 return cursor
.Ok() ;
2536 wxString wxWindowMac
::MacGetToolTipString( wxPoint
&pt
)
2540 return m_tooltip
->GetTip() ;
2542 return wxEmptyString
;
2545 void wxWindowMac
::Update()
2547 #if TARGET_API_MAC_OSX
2548 WindowRef window
= (WindowRef
)MacGetTopLevelWindowRef() ;
2549 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2550 // for composited windows this also triggers a redraw of all
2551 // invalid views in the window
2552 if( UMAGetSystemVersion() >= 0x1030 )
2553 HIWindowFlush(window
) ;
2557 // the only way to trigger the redrawing on earlier systems is to call
2560 EventRef currentEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
2561 UInt32 currentEventClass
= 0 ;
2562 UInt32 currentEventKind
= 0 ;
2563 if ( currentEvent
!= NULL
)
2565 currentEventClass
= ::GetEventClass( currentEvent
) ;
2566 currentEventKind
= ::GetEventKind( currentEvent
) ;
2568 if ( currentEventClass
!= kEventClassMenu
)
2570 // when tracking a menu, strange redraw errors occur if we flush now, so leave..
2573 OSStatus status
= noErr
;
2574 status
= ReceiveNextEvent( 0 , NULL
, kEventDurationNoWait
, false , &theEvent
) ;
2577 m_peer
->SetNeedsDisplay( true ) ;
2580 ::Draw1Control( m_peer
->GetControlRef() ) ;
2584 wxTopLevelWindowMac
* wxWindowMac
::MacGetTopLevelWindow() const
2586 wxTopLevelWindowMac
* win
= NULL
;
2587 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2590 win
= wxFindWinFromMacWindow( window
) ;
2594 wxRegion wxWindowMac
::MacGetVisibleRegion( bool includeOuterStructures
)
2596 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2597 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2598 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2599 // to add focus borders everywhere
2602 RgnHandle visRgn
= NewRgn() ;
2603 RgnHandle tempRgn
= NewRgn() ;
2604 if ( m_peer
->IsVisible())
2606 m_peer
->GetRect( &r
) ;
2607 r
.left
-= MacGetLeftBorderSize() ;
2608 r
.top
-= MacGetTopBorderSize() ;
2609 r
.bottom
+= MacGetBottomBorderSize() ;
2610 r
.right
+= MacGetRightBorderSize() ;
2612 if (! MacGetTopLevelWindow()->MacUsesCompositing() )
2614 MacRootWindowToWindow( &r
.left
, & r
.top
) ;
2615 MacRootWindowToWindow( &r
.right
, & r
.bottom
) ;
2624 if ( includeOuterStructures
)
2625 InsetRect( &r
, -4 , -4 ) ;
2626 RectRgn( visRgn
, &r
) ;
2628 if ( !IsTopLevel() )
2630 wxWindow
* child
= this ;
2631 wxWindow
* parent
= child
->GetParent() ;
2636 // we have to find a better clipping algorithm here, in order not to clip things
2637 // positioned like status and toolbar
2638 if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
2640 size
= parent
->GetSize() ;
2645 size
= parent
->GetClientSize() ;
2646 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2650 parent
->MacWindowToRootWindow( &x
, &y
) ;
2651 MacRootWindowToWindow( &x
, &y
) ;
2653 if ( !includeOuterStructures
|| (
2654 parent
->IsKindOf( CLASSINFO( wxScrolledWindow
) ) ||
2655 parent
->IsKindOf( CLASSINFO( wxSashLayoutWindow
) ) ||
2656 ( parent
->GetParent() && parent
->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow
) ) )
2659 SetRectRgn( tempRgn
,
2660 x
+ parent
->MacGetLeftBorderSize() , y
+ parent
->MacGetTopBorderSize() ,
2661 x
+ size
.x
- parent
->MacGetRightBorderSize(),
2662 y
+ size
.y
- parent
->MacGetBottomBorderSize()) ;
2664 SectRgn( visRgn
, tempRgn
, visRgn
) ;
2666 if ( parent
->IsTopLevel() )
2669 parent
= child
->GetParent() ;
2674 wxRegion vis
= visRgn
;
2675 DisposeRgn( visRgn
) ;
2676 DisposeRgn( tempRgn
) ;
2681 This function must not change the updatergn !
2683 bool wxWindowMac
::MacDoRedraw( WXHRGN updatergnr
, long time
)
2685 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2686 bool handled
= false ;
2688 GetRegionBounds( updatergn
, &updatebounds
) ;
2689 // wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2690 if ( !EmptyRgn(updatergn
) )
2692 RgnHandle newupdate
= NewRgn() ;
2693 wxSize point
= GetClientSize() ;
2694 wxPoint origin
= GetClientAreaOrigin() ;
2695 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
2696 SectRgn( newupdate
, updatergn
, newupdate
) ;
2698 // first send an erase event to the entire update area
2700 wxWindowDC
dc(this);
2701 dc
.SetClippingRegion(wxRegion(updatergn
));
2702 wxEraseEvent
eevent( GetId(), &dc
);
2703 eevent
.SetEventObject( this );
2704 GetEventHandler()->ProcessEvent( eevent
);
2707 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2708 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2709 m_updateRegion
= newupdate
;
2710 DisposeRgn( newupdate
) ;
2712 if ( !m_updateRegion
.Empty() )
2714 // paint the window itself
2716 event
.m_timeStamp
= time
;
2717 event
.SetEventObject(this);
2718 handled
= GetEventHandler()->ProcessEvent(event
);
2720 // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards
2723 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
)
2725 CallNextEventHandler((EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() , (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
2732 // now we cannot rely on having its borders drawn by a window itself, as it does not
2733 // get the updateRgn wide enough to always do so, so we do it from the parent
2734 // this would also be the place to draw any custom backgrounds for native controls
2735 // in Composited windowing
2736 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2738 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2740 wxWindowMac
*child
= node
->GetData();
2741 if (child
== m_vScrollBar
) continue;
2742 if (child
== m_hScrollBar
) continue;
2743 if (child
->IsTopLevel()) continue;
2744 if (!child
->IsShown()) continue;
2747 child
->GetPosition( &x
, &y
);
2749 child
->GetSize( &w
, &h
);
2750 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2751 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2752 if ( child
->MacGetTopBorderSize() )
2754 if ( RectInRgn( &childRect
, updatergn
) )
2756 // paint custom borders
2757 wxNcPaintEvent
eventNc( child
->GetId() );
2758 eventNc
.SetEventObject( child
);
2759 if ( !child
->GetEventHandler()->ProcessEvent( eventNc
) )
2761 wxWindowDC
dc(this) ;
2762 dc
.SetClippingRegion(wxRegion(updatergn
));
2763 wxMacPortSetter
helper(&dc
) ;
2764 child
->MacPaintBorders( dc
.m_macLocalOrigin
.x
+ childRect
.left
, dc
.m_macLocalOrigin
.y
+ childRect
.top
) ;
2768 if ( child
->m_peer
->NeedsFocusRect() && child
->m_peer
->HasFocus() )
2770 wxWindowDC
dc(this) ;
2771 dc
.SetClippingRegion(wxRegion(updatergn
));
2772 wxMacPortSetter
helper(&dc
) ;
2773 OffsetRect( &childRect
, dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
2774 DrawThemeFocusRect( &childRect
, true ) ;
2781 void wxWindowMac
::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
2783 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2784 // updatergn is always already clipped to our boundaries
2785 // if we are in compositing mode then it is in relative to the upper left of the control
2786 // if we are in non-compositing, then it is relatvie to the uppder left of the content area
2787 // of the toplevel window
2788 // it is in window coordinates, not in client coordinates
2790 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
2791 RgnHandle ownUpdateRgn
= NewRgn() ;
2792 CopyRgn( updatergn
, ownUpdateRgn
) ;
2794 if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
2797 m_peer
->GetRectInWindowCoords( &bounds
);
2798 RgnHandle controlRgn
= NewRgn();
2799 RectRgn( controlRgn
, &bounds
);
2800 //KO: This sets the ownUpdateRgn to the area of this control that is inside
2801 // the window update region
2802 SectRgn( ownUpdateRgn
, controlRgn
, ownUpdateRgn
);
2803 DisposeRgn( controlRgn
);
2805 //KO: convert ownUpdateRgn to local coordinates
2806 OffsetRgn( ownUpdateRgn
, -bounds
.left
, -bounds
.top
);
2809 MacDoRedraw( ownUpdateRgn
, time
) ;
2810 DisposeRgn( ownUpdateRgn
) ;
2814 WXWindow wxWindowMac
::MacGetTopLevelWindowRef() const
2816 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2820 if ( iter
->IsTopLevel() )
2821 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
2823 iter
= iter
->GetParent() ;
2825 wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ;
2829 void wxWindowMac
::MacCreateScrollBars( long style
)
2831 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2833 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2835 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
2836 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2837 wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
;
2838 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2840 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2841 variant
= wxWINDOW_VARIANT_SMALL
;
2844 int adjust
= hasBoth ? scrlsize
- 1: 0 ;
2846 GetClientSize( &width
, &height
) ;
2848 wxPoint
vPoint(width
-scrlsize
, 0) ;
2849 wxSize
vSize(scrlsize
, height
- adjust
) ;
2850 wxPoint
hPoint(0 , height
-scrlsize
) ;
2851 wxSize
hSize( width
- adjust
, scrlsize
) ;
2854 if ( style
& wxVSCROLL
)
2856 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
2857 vSize
, wxVERTICAL
);
2860 if ( style
& wxHSCROLL
)
2862 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
2863 hSize
, wxHORIZONTAL
);
2868 // because the create does not take into account the client area origin
2869 MacRepositionScrollBars() ; // we might have a real position shift
2872 void wxWindowMac
::MacRepositionScrollBars()
2874 if ( !m_hScrollBar
&& !m_vScrollBar
)
2877 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
2878 int scrlsize
= m_hScrollBar ? m_hScrollBar
->GetSize().y
: ( m_vScrollBar ? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2879 int adjust
= hasBoth ? scrlsize
- 1 : 0 ;
2881 // get real client area
2885 GetSize( &width
, &height
) ;
2887 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2888 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2890 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
2891 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
2892 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
2893 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
2899 GetSize( &w , &h ) ;
2901 MacClientToRootWindow( &x , &y ) ;
2902 MacClientToRootWindow( &w , &h ) ;
2904 wxWindowMac *iter = (wxWindowMac*)this ;
2906 int totW = 10000 , totH = 10000;
2909 if ( iter->IsTopLevel() )
2911 iter->GetSize( &totW , &totH ) ;
2915 iter = iter->GetParent() ;
2943 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
2947 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
2951 bool wxWindowMac
::AcceptsFocus() const
2953 return MacCanFocus() && wxWindowBase
::AcceptsFocus();
2956 void wxWindowMac
::MacSuperChangedPosition()
2958 // only window-absolute structures have to be moved i.e. controls
2960 wxWindowListNode
*node
= GetChildren().GetFirst();
2963 wxWindowMac
*child
= node
->GetData();
2964 child
->MacSuperChangedPosition() ;
2965 node
= node
->GetNext();
2969 void wxWindowMac
::MacTopLevelWindowChangedPosition()
2971 // only screen-absolute structures have to be moved i.e. glcanvas
2973 wxWindowListNode
*node
= GetChildren().GetFirst();
2976 wxWindowMac
*child
= node
->GetData();
2977 child
->MacTopLevelWindowChangedPosition() ;
2978 node
= node
->GetNext();
2982 long wxWindowMac
::MacGetLeftBorderSize( ) const
2987 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
2992 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
2997 else if (m_windowStyle
&wxSIMPLE_BORDER
)
3004 long wxWindowMac
::MacGetRightBorderSize( ) const
3006 // they are all symmetric in mac themes
3007 return MacGetLeftBorderSize() ;
3010 long wxWindowMac
::MacGetTopBorderSize( ) const
3012 // they are all symmetric in mac themes
3013 return MacGetLeftBorderSize() ;
3016 long wxWindowMac
::MacGetBottomBorderSize( ) const
3018 // they are all symmetric in mac themes
3019 return MacGetLeftBorderSize() ;
3022 long wxWindowMac
::MacRemoveBordersFromStyle( long style
)
3024 return style
& ~wxBORDER_MASK
;
3027 // Find the wxWindowMac at the current mouse position, returning the mouse
3029 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
3031 pt
= wxGetMousePosition();
3032 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3036 // Get the current mouse position.
3037 wxPoint
wxGetMousePosition()
3040 wxGetMousePosition(& x
, & y
);
3041 return wxPoint(x
, y
);
3044 void wxWindowMac
::OnMouseEvent( wxMouseEvent
&event
)
3046 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3048 // copied from wxGTK : CS
3049 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3052 // (a) it's a command event and so is propagated to the parent
3053 // (b) under MSW it can be generated from kbd too
3054 // (c) it uses screen coords (because of (a))
3055 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3057 this->ClientToScreen(event
.GetPosition()));
3058 if ( ! GetEventHandler()->ProcessEvent(evtCtx
) )
3067 void wxWindowMac
::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
3071 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3075 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3076 Rect bounds
= { y
, x
, y
+h
, x
+w
};
3080 wxInt32 wxWindowMac
::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3082 return eventNotHandledErr
;