1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/window.cpp
3 // Purpose: wxWindowMac
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/window.h"
17 #include "wx/dcclient.h"
21 #include "wx/layout.h"
22 #include "wx/dialog.h"
23 #include "wx/scrolbar.h"
24 #include "wx/statbox.h"
25 #include "wx/button.h"
26 #include "wx/settings.h"
27 #include "wx/msgdlg.h"
29 #include "wx/tooltip.h"
30 #include "wx/statusbr.h"
31 #include "wx/menuitem.h"
32 #include "wx/spinctrl.h"
34 #include "wx/geometry.h"
35 #include "wx/textctrl.h"
37 #include "wx/toolbar.h"
44 #define MAC_SCROLLBAR_SIZE 15
45 #define MAC_SMALL_SCROLLBAR_SIZE 11
47 #include "wx/mac/uma.h"
51 #include <ToolUtils.h>
53 #include <MacTextEditor.h>
56 #if TARGET_API_MAC_OSX
58 #include <HIToolbox/HIView.h>
62 #if wxUSE_DRAG_AND_DROP
68 extern wxList wxPendingDelete
;
70 #ifdef __WXUNIVERSAL__
71 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
73 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
76 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
77 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
78 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
79 #if TARGET_API_MAC_OSX
80 EVT_PAINT(wxWindowMac::OnPaint
)
82 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
83 EVT_KILL_FOCUS(wxWindowMac::OnSetFocus
)
84 EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent
)
87 #define wxMAC_DEBUG_REDRAW 0
88 #ifndef wxMAC_DEBUG_REDRAW
89 #define wxMAC_DEBUG_REDRAW 0
92 #define wxMAC_USE_THEME_BORDER 1
94 // ---------------------------------------------------------------------------
95 // Utility Routines to move between different coordinate systems
96 // ---------------------------------------------------------------------------
99 * Right now we have the following setup :
100 * a border that is not part of the native control is always outside the
101 * control's border (otherwise we loose all native intelligence, future ways
102 * may be to have a second embedding control responsible for drawing borders
103 * and backgrounds eventually)
104 * so all this border calculations have to be taken into account when calling
105 * native methods or getting native oriented data
106 * so we have three coordinate systems here
107 * wx client coordinates
108 * wx window coordinates (including window frames)
113 // originating from native control
117 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
119 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
122 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
124 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
128 // directed towards native control
131 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
133 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
136 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
138 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
141 // ---------------------------------------------------------------------------
143 // ---------------------------------------------------------------------------
145 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
146 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
) ;
148 #if TARGET_API_MAC_OSX
150 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
153 kEventControlVisibilityChanged
= 157
159 static const EventTypeSpec eventList
[] =
161 { kEventClassControl
, kEventControlHit
} ,
163 #if TARGET_API_MAC_OSX
164 { kEventClassControl
, kEventControlDraw
} ,
165 { kEventClassControl
, kEventControlVisibilityChanged
} ,
166 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
167 { kEventClassControl
, kEventControlHiliteChanged
} ,
168 { kEventClassControl
, kEventControlSetFocusPart
} ,
170 { kEventClassService
, kEventServiceGetTypes
},
171 { kEventClassService
, kEventServiceCopy
},
172 { kEventClassService
, kEventServicePaste
},
174 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
175 // { kEventClassControl , kEventControlBoundsChanged } ,
179 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
181 OSStatus result
= eventNotHandledErr
;
183 wxMacCarbonEvent
cEvent( event
) ;
185 ControlRef controlRef
;
186 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
188 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
190 switch ( GetEventKind( event
) )
192 #if TARGET_API_MAC_OSX
193 case kEventControlDraw
:
195 RgnHandle updateRgn
= NULL
;
196 RgnHandle allocatedRgn
= NULL
;
197 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
200 if ( ! thisWindow
->GetPeer()->IsCompositing() )
202 if ( thisWindow
->GetPeer()->IsRootControl() )
203 thisWindow
->GetPeer()->GetRect( &controlBounds
) ;
205 GetControlBounds( thisWindow
->GetPeer()->GetControlRef() , &controlBounds
) ;
208 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
210 updateRgn
= (RgnHandle
) visRegion
.GetWXHRGN() ;
214 if ( ! thisWindow
->GetPeer()->IsCompositing() )
216 allocatedRgn
= NewRgn() ;
217 CopyRgn( updateRgn
, allocatedRgn
) ;
218 OffsetRgn( allocatedRgn
, -controlBounds
.left
, -controlBounds
.top
) ;
220 // hide the given region by the new region that must be shifted
221 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
222 updateRgn
= allocatedRgn
;
226 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
228 // as this update region is in native window locals we must adapt it to wx window local
229 allocatedRgn
= NewRgn() ;
230 CopyRgn( updateRgn
, allocatedRgn
) ;
232 // hide the given region by the new region that must be shifted
233 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
234 updateRgn
= allocatedRgn
;
240 GetRegionBounds( updateRgn
, &rgnBounds
) ;
242 #if wxMAC_DEBUG_REDRAW
243 if ( thisWindow
->MacIsUserPane() )
245 static float color
= 0.5 ;
248 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
250 HIViewGetBounds( controlRef
, &bounds
);
251 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
252 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
253 CGContextFillRect( cgContext
, bounds
);
266 #if wxMAC_USE_CORE_GRAPHICS
267 bool created
= false ;
268 CGContextRef cgContext
= NULL
;
269 if ( cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
, &cgContext
) != noErr
)
271 wxASSERT( thisWindow
->GetPeer()->IsCompositing() == false ) ;
273 // this parameter is not provided on non-composited windows
276 // rest of the code expects this to be already transformed and clipped for local
277 CGrafPtr port
= GetWindowPort( (WindowRef
) thisWindow
->MacGetTopLevelWindowRef() ) ;
279 GetPortBounds( port
, &bounds
) ;
280 CreateCGContextForPort( port
, &cgContext
) ;
282 wxMacWindowToNative( thisWindow
, updateRgn
) ;
283 OffsetRgn( updateRgn
, controlBounds
.left
, controlBounds
.top
) ;
284 ClipCGContextToRegion( cgContext
, &bounds
, updateRgn
) ;
285 wxMacNativeToWindow( thisWindow
, updateRgn
) ;
286 OffsetRgn( updateRgn
, -controlBounds
.left
, -controlBounds
.top
) ;
288 CGContextTranslateCTM( cgContext
, 0 , bounds
.bottom
- bounds
.top
) ;
289 CGContextScaleCTM( cgContext
, 1 , -1 ) ;
291 CGContextTranslateCTM( cgContext
, controlBounds
.left
, controlBounds
.top
) ;
294 CGContextSetRGBFillColor( cgContext
, 1.0 , 1.0 , 1.0 , 1.0 ) ;
295 CGContextFillRect( cgContext
,
297 controlBounds
.right
- controlBounds
.left
,
298 controlBounds
.bottom
- controlBounds
.top
) );
302 thisWindow
->MacSetCGContextRef( cgContext
) ;
305 wxMacCGContextStateSaver
sg( cgContext
) ;
307 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
310 #if wxMAC_USE_CORE_GRAPHICS
311 thisWindow
->MacSetCGContextRef( NULL
) ;
315 CGContextRelease( cgContext
) ;
320 DisposeRgn( allocatedRgn
) ;
324 case kEventControlVisibilityChanged
:
325 thisWindow
->MacVisibilityChanged() ;
328 case kEventControlEnabledStateChanged
:
329 thisWindow
->MacEnabledStateChanged() ;
332 case kEventControlHiliteChanged
:
333 thisWindow
->MacHiliteChanged() ;
337 // we emulate this event under Carbon CFM
338 case kEventControlSetFocusPart
:
340 Boolean focusEverything
= false ;
341 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
344 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
349 if ( controlPart
== kControlFocusNoPart
)
352 if ( thisWindow
->GetCaret() )
353 thisWindow
->GetCaret()->OnKillFocus();
356 static bool inKillFocusEvent
= false ;
358 if ( !inKillFocusEvent
)
360 inKillFocusEvent
= true ;
361 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
362 event
.SetEventObject(thisWindow
);
363 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
364 inKillFocusEvent
= false ;
369 // panel wants to track the window which was the last to have focus in it
370 wxChildFocusEvent
eventFocus(thisWindow
);
371 thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
);
374 if ( thisWindow
->GetCaret() )
375 thisWindow
->GetCaret()->OnSetFocus();
378 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
379 event
.SetEventObject(thisWindow
);
380 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
383 if ( thisWindow
->MacIsUserPane() )
388 case kEventControlHit
:
389 result
= thisWindow
->MacControlHit( handler
, event
) ;
399 static pascal OSStatus
wxMacWindowServiceEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
401 OSStatus result
= eventNotHandledErr
;
403 wxMacCarbonEvent
cEvent( event
) ;
405 ControlRef controlRef
;
406 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
407 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
408 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
410 switch ( GetEventKind( event
) )
412 case kEventServiceGetTypes
:
416 textCtrl
->GetSelection( &from
, &to
) ;
418 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
420 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
421 if ( textCtrl
->IsEditable() )
422 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
424 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt', 'PICT', 'MooV', 'AIFF' */ };
425 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
427 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
431 CFArrayAppendValue(copyTypes
, typestring
) ;
433 CFArrayAppendValue(pasteTypes
, typestring
) ;
435 CFRelease( typestring
) ;
443 case kEventServiceCopy
:
448 textCtrl
->GetSelection( &from
, &to
) ;
449 wxString val
= textCtrl
->GetValue() ;
450 val
= val
.Mid( from
, to
- from
) ;
451 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
452 verify_noerr( ClearScrap( &scrapRef
) ) ;
453 verify_noerr( PutScrapFlavor( scrapRef
, kTXNTextData
, 0 , val
.length() , val
.c_str() ) ) ;
458 case kEventServicePaste
:
461 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
462 Size textSize
, pastedSize
;
463 verify_noerr( GetScrapFlavorSize(scrapRef
, kTXNTextData
, &textSize
) ) ;
465 char *content
= new char[textSize
] ;
466 GetScrapFlavorData(scrapRef
, kTXNTextData
, &pastedSize
, content
);
467 content
[textSize
- 1] = 0 ;
470 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
472 textCtrl
->WriteText( wxString( content
) ) ;
487 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
489 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
490 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
491 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
492 OSStatus result
= eventNotHandledErr
;
494 switch ( GetEventClass( event
) )
496 case kEventClassControl
:
497 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
500 case kEventClassService
:
501 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
508 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
513 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
515 #if !TARGET_API_MAC_OSX
517 // ---------------------------------------------------------------------------
518 // UserPane events for non OSX builds
519 // ---------------------------------------------------------------------------
521 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
523 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
525 win
->MacControlUserPaneDrawProc(part
) ;
527 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneDrawUPP
, wxMacControlUserPaneDrawProc
) ;
529 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
531 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
533 return win
->MacControlUserPaneHitTestProc(where
.h
, where
.v
) ;
535 return kControlNoPart
;
537 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneHitTestUPP
, wxMacControlUserPaneHitTestProc
) ;
539 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
541 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
543 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
545 return kControlNoPart
;
547 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneTrackingUPP
, wxMacControlUserPaneTrackingProc
) ;
549 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
551 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
553 win
->MacControlUserPaneIdleProc() ;
555 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneIdleUPP
, wxMacControlUserPaneIdleProc
) ;
557 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
559 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
561 return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ;
563 return kControlNoPart
;
565 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneKeyDownUPP
, wxMacControlUserPaneKeyDownProc
) ;
567 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
569 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
571 win
->MacControlUserPaneActivateProc(activating
) ;
573 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneActivateUPP
, wxMacControlUserPaneActivateProc
) ;
575 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
577 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
579 return win
->MacControlUserPaneFocusProc(action
) ;
581 return kControlNoPart
;
583 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneFocusUPP
, wxMacControlUserPaneFocusProc
) ;
585 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
587 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
589 win
->MacControlUserPaneBackgroundProc(info
) ;
591 wxMAC_DEFINE_PROC_GETTER( ControlUserPaneBackgroundUPP
, wxMacControlUserPaneBackgroundProc
) ;
593 void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part
)
596 RgnHandle rgn
= NewRgn() ;
598 MacWindowToRootWindow( &x
, &y
) ;
599 OffsetRgn( rgn
, -x
, -y
) ;
600 wxMacWindowStateSaver
sv( this ) ;
601 SectRgn( rgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn
) ;
602 MacDoRedraw( rgn
, 0 ) ;
606 wxInt16
wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
608 return kControlNoPart
;
611 wxInt16
wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
613 return kControlNoPart
;
616 void wxWindowMac::MacControlUserPaneIdleProc()
620 wxInt16
wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
622 return kControlNoPart
;
625 void wxWindowMac::MacControlUserPaneActivateProc(bool activating
)
629 wxInt16
wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action
)
631 if ( AcceptsFocus() )
634 return kControlNoPart
;
637 void wxWindowMac::MacControlUserPaneBackgroundProc(void* info
)
643 // ---------------------------------------------------------------------------
644 // Scrollbar Tracking for all
645 // ---------------------------------------------------------------------------
647 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
648 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
652 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
654 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
657 wxMAC_DEFINE_PROC_GETTER( ControlActionUPP
, wxMacLiveScrollbarActionProc
) ;
659 // ===========================================================================
661 // ===========================================================================
663 WX_DECLARE_HASH_MAP(ControlRef
, wxWindow
*, wxPointerHash
, wxPointerEqual
, MacControlMap
);
665 static MacControlMap wxWinMacControlList
;
667 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
669 MacControlMap::iterator node
= wxWinMacControlList
.find(inControl
);
671 return (node
== wxWinMacControlList
.end()) ? NULL
: node
->second
;
674 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
676 // adding NULL ControlRef is (first) surely a result of an error and
677 // (secondly) breaks native event processing
678 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
680 wxWinMacControlList
[inControl
] = control
;
683 void wxRemoveMacControlAssociation(wxWindow
*control
)
685 // iterate over all the elements in the class
686 // is the iterator stable ? as we might have two associations pointing to the same wxWindow
687 // we should go on...
693 MacControlMap::iterator it
;
694 for ( it
= wxWinMacControlList
.begin(); it
!= wxWinMacControlList
.end(); ++it
)
696 if ( it
->second
== control
)
698 wxWinMacControlList
.erase(it
);
706 // ----------------------------------------------------------------------------
707 // constructors and such
708 // ----------------------------------------------------------------------------
710 wxWindowMac::wxWindowMac()
715 wxWindowMac::wxWindowMac(wxWindowMac
*parent
,
720 const wxString
& name
)
723 Create(parent
, id
, pos
, size
, style
, name
);
726 void wxWindowMac::Init()
731 #if WXWIN_COMPATIBILITY_2_4
732 m_backgroundTransparent
= false;
735 #if wxMAC_USE_CORE_GRAPHICS
736 m_cgContextRef
= NULL
;
739 // as all windows are created with WS_VISIBLE style...
742 m_hScrollBar
= NULL
;
743 m_vScrollBar
= NULL
;
744 m_macBackgroundBrush
= wxNullBrush
;
746 m_macIsUserPane
= true;
747 m_clipChildren
= false ;
748 m_cachedClippedRectValid
= false ;
750 // we need a valid font for the encodings
751 wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
755 wxWindowMac::~wxWindowMac()
759 m_isBeingDeleted
= true;
761 MacInvalidateBorders() ;
763 #ifndef __WXUNIVERSAL__
764 // VS: make sure there's no wxFrame with last focus set to us:
765 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
767 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
770 if ( frame
->GetLastFocus() == this )
771 frame
->SetLastFocus((wxWindow
*)NULL
);
775 #endif // __WXUNIVERSAL__
777 // destroy children before destroying this window itself
780 // wxRemoveMacControlAssociation( this ) ;
781 // If we delete an item, we should initialize the parent panel,
782 // because it could now be invalid.
783 wxWindow
*parent
= GetParent() ;
786 if (parent
->GetDefaultItem() == (wxButton
*) this)
787 parent
->SetDefaultItem(NULL
);
790 if ( m_peer
&& m_peer
->Ok() )
792 // in case the callback might be called during destruction
793 wxRemoveMacControlAssociation( this) ;
794 ::RemoveEventHandler( (EventHandlerRef
) m_macControlEventHandler
) ;
795 // we currently are not using this hook
796 // ::SetControlColorProc( *m_peer , NULL ) ;
800 if ( g_MacLastWindow
== this )
801 g_MacLastWindow
= NULL
;
803 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame
) ;
806 if ( frame
->GetLastFocus() == this )
807 frame
->SetLastFocus( NULL
) ;
810 // delete our drop target if we've got one
811 #if wxUSE_DRAG_AND_DROP
812 if ( m_dropTarget
!= NULL
)
822 WXWidget
wxWindowMac::GetHandle() const
824 return (WXWidget
) m_peer
->GetControlRef() ;
827 void wxWindowMac::MacInstallEventHandler( WXWidget control
)
829 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
830 InstallControlEventHandler( (ControlRef
)control
, GetwxMacWindowEventHandlerUPP(),
831 GetEventTypeCount(eventList
), eventList
, this,
832 (EventHandlerRef
*)&m_macControlEventHandler
);
834 #if !TARGET_API_MAC_OSX
835 if ( (ControlRef
) control
== m_peer
->GetControlRef() )
837 m_peer
->SetData
<ControlUserPaneDrawUPP
>(kControlEntireControl
, kControlUserPaneDrawProcTag
, GetwxMacControlUserPaneDrawProc()) ;
838 m_peer
->SetData
<ControlUserPaneHitTestUPP
>(kControlEntireControl
, kControlUserPaneHitTestProcTag
, GetwxMacControlUserPaneHitTestProc()) ;
839 m_peer
->SetData
<ControlUserPaneTrackingUPP
>(kControlEntireControl
, kControlUserPaneTrackingProcTag
, GetwxMacControlUserPaneTrackingProc()) ;
840 m_peer
->SetData
<ControlUserPaneIdleUPP
>(kControlEntireControl
, kControlUserPaneIdleProcTag
, GetwxMacControlUserPaneIdleProc()) ;
841 m_peer
->SetData
<ControlUserPaneKeyDownUPP
>(kControlEntireControl
, kControlUserPaneKeyDownProcTag
, GetwxMacControlUserPaneKeyDownProc()) ;
842 m_peer
->SetData
<ControlUserPaneActivateUPP
>(kControlEntireControl
, kControlUserPaneActivateProcTag
, GetwxMacControlUserPaneActivateProc()) ;
843 m_peer
->SetData
<ControlUserPaneFocusUPP
>(kControlEntireControl
, kControlUserPaneFocusProcTag
, GetwxMacControlUserPaneFocusProc()) ;
844 m_peer
->SetData
<ControlUserPaneBackgroundUPP
>(kControlEntireControl
, kControlUserPaneBackgroundProcTag
, GetwxMacControlUserPaneBackgroundProc()) ;
850 bool wxWindowMac::Create(wxWindowMac
*parent
,
855 const wxString
& name
)
857 wxCHECK_MSG( parent
, false, wxT("can't create wxWindowMac without parent") );
859 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
862 m_windowVariant
= parent
->GetWindowVariant() ;
864 if ( m_macIsUserPane
)
866 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
869 | kControlSupportsEmbedding
870 | kControlSupportsLiveFeedback
871 | kControlGetsFocusOnClick
872 // | kControlHasSpecialBackground
873 // | kControlSupportsCalcBestRect
874 | kControlHandlesTracking
875 | kControlSupportsFocus
876 | kControlWantsActivate
877 | kControlWantsIdle
;
879 m_peer
= new wxMacControl(this) ;
880 OSStatus err
=::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
883 MacPostControlCreate(pos
, size
) ;
886 #ifndef __WXUNIVERSAL__
887 // Don't give scrollbars to wxControls unless they ask for them
888 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
)))
889 || (IsKindOf(CLASSINFO(wxControl
)) && ((style
& wxHSCROLL
) || (style
& wxVSCROLL
))))
891 MacCreateScrollBars( style
) ;
895 wxWindowCreateEvent
event(this);
896 GetEventHandler()->AddPendingEvent(event
);
901 void wxWindowMac::MacChildAdded()
904 m_vScrollBar
->Raise() ;
906 m_hScrollBar
->Raise() ;
909 void wxWindowMac::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
)
911 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
913 m_peer
->SetReference( (long)this ) ;
914 GetParent()->AddChild( this );
916 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
918 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
919 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
920 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
921 GetParent()->MacChildAdded() ;
923 // adjust font, controlsize etc
924 DoSetWindowVariant( m_windowVariant
) ;
926 m_peer
->SetLabel( wxStripMenuCodes(m_label
) ) ;
928 if (!m_macIsUserPane
)
929 SetInitialBestSize(size
);
931 SetCursor( *wxSTANDARD_CURSOR
) ;
934 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant
)
936 // Don't assert, in case we set the window variant before
937 // the window is created
938 // wxASSERT( m_peer->Ok() ) ;
940 m_windowVariant
= variant
;
942 if (m_peer
== NULL
|| !m_peer
->Ok())
946 ThemeFontID themeFont
= kThemeSystemFont
;
948 // we will get that from the settings later
949 // and make this NORMAL later, but first
950 // we have a few calculations that we must fix
954 case wxWINDOW_VARIANT_NORMAL
:
955 size
= kControlSizeNormal
;
956 themeFont
= kThemeSystemFont
;
959 case wxWINDOW_VARIANT_SMALL
:
960 size
= kControlSizeSmall
;
961 themeFont
= kThemeSmallSystemFont
;
964 case wxWINDOW_VARIANT_MINI
:
965 if (UMAGetSystemVersion() >= 0x1030 )
967 // not always defined in the headers
973 size
= kControlSizeSmall
;
974 themeFont
= kThemeSmallSystemFont
;
978 case wxWINDOW_VARIANT_LARGE
:
979 size
= kControlSizeLarge
;
980 themeFont
= kThemeSystemFont
;
984 wxFAIL_MSG(_T("unexpected window variant"));
988 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
, &size
) ;
991 font
.MacCreateThemeFont( themeFont
) ;
995 void wxWindowMac::MacUpdateControlFont()
997 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
1001 bool wxWindowMac::SetFont(const wxFont
& font
)
1003 bool retval
= wxWindowBase::SetFont( font
);
1005 MacUpdateControlFont() ;
1010 bool wxWindowMac::SetForegroundColour(const wxColour
& col
)
1012 bool retval
= wxWindowBase::SetForegroundColour( col
);
1015 MacUpdateControlFont();
1020 bool wxWindowMac::SetBackgroundColour(const wxColour
& col
)
1022 if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol
)
1026 wxColour
newCol(GetBackgroundColour());
1028 if ( newCol
== wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE
) )
1029 brush
.MacSetTheme( kThemeBrushDocumentWindowBackground
) ;
1030 else if ( newCol
== wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE
) )
1031 brush
.MacSetTheme( kThemeBrushDialogBackgroundActive
) ;
1033 brush
.SetColour( newCol
) ;
1035 MacSetBackgroundBrush( brush
) ;
1036 MacUpdateControlFont() ;
1041 void wxWindowMac::MacSetBackgroundBrush( const wxBrush
&brush
)
1043 m_macBackgroundBrush
= brush
;
1044 m_peer
->SetBackground( brush
) ;
1047 bool wxWindowMac::MacCanFocus() const
1049 // there is currently no way to determine whether the window is running in full keyboard
1050 // access mode, therefore we cannot rely on these features, yet the only other way would be
1051 // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
1052 // in event handlers...
1053 UInt32 features
= 0 ;
1054 m_peer
->GetFeatures( &features
) ;
1056 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1059 void wxWindowMac::SetFocus()
1061 if ( !AcceptsFocus() )
1064 wxWindow
* former
= FindFocus() ;
1065 if ( former
== this )
1068 // as we cannot rely on the control features to find out whether we are in full keyboard mode,
1069 // we can only leave in case of an error
1070 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
1071 if ( err
== errCouldntSetFocus
)
1074 SetUserFocusWindow( (WindowRef
)MacGetTopLevelWindowRef() );
1076 #if !TARGET_API_MAC_OSX
1077 // emulate carbon events when running under CarbonLib where they are not natively available
1080 EventRef evRef
= NULL
;
1082 err
= MacCreateEvent(
1083 NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) ,
1084 kEventAttributeUserEvent
, &evRef
);
1085 verify_noerr( err
);
1087 wxMacCarbonEvent
cEvent( evRef
) ;
1088 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) former
->GetHandle() ) ;
1089 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNoPart
) ;
1091 wxMacWindowEventHandler( NULL
, evRef
, former
) ;
1092 ReleaseEvent( evRef
) ;
1095 // send new focus event
1097 EventRef evRef
= NULL
;
1099 err
= MacCreateEvent(
1100 NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) ,
1101 kEventAttributeUserEvent
, &evRef
);
1102 verify_noerr( err
);
1104 wxMacCarbonEvent
cEvent( evRef
) ;
1105 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) GetHandle() ) ;
1106 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNextPart
) ;
1108 wxMacWindowEventHandler( NULL
, evRef
, this ) ;
1109 ReleaseEvent( evRef
) ;
1114 void wxWindowMac::DoCaptureMouse()
1116 wxApp::s_captureWindow
= this ;
1119 wxWindow
* wxWindowBase::GetCapture()
1121 return wxApp::s_captureWindow
;
1124 void wxWindowMac::DoReleaseMouse()
1126 wxApp::s_captureWindow
= NULL
;
1129 #if wxUSE_DRAG_AND_DROP
1131 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
1133 if ( m_dropTarget
!= NULL
)
1134 delete m_dropTarget
;
1136 m_dropTarget
= pDropTarget
;
1137 if ( m_dropTarget
!= NULL
)
1145 // Old style file-manager drag&drop
1146 void wxWindowMac::DragAcceptFiles(bool accept
)
1151 // Returns the size of the native control. In the case of the toplevel window
1152 // this is the content area root control
1154 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x
, int& y
,
1155 int& w
, int& h
) const
1157 wxFAIL_MSG( wxT("Not currently supported") ) ;
1160 // From a wx position / size calculate the appropriate size of the native control
1162 bool wxWindowMac::MacGetBoundsForControl(
1166 int& w
, int& h
, bool adjustOrigin
) const
1168 bool isCompositing
= MacGetTopLevelWindow()->MacUsesCompositing() ;
1170 // the desired size, minus the border pixels gives the correct size of the control
1175 // TODO: the default calls may be used as soon as PostCreateControl Is moved here
1176 w
= wxMax(size
.x
, 0) ; // WidthDefault( size.x );
1177 h
= wxMax(size
.y
, 0) ; // HeightDefault( size.y ) ;
1179 if ( !isCompositing
)
1180 GetParent()->MacWindowToRootWindow( &x
, &y
) ;
1182 x
+= MacGetLeftBorderSize() ;
1183 y
+= MacGetTopBorderSize() ;
1184 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1185 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1188 AdjustForParentClientOrigin( x
, y
) ;
1190 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1191 if ( !GetParent()->IsTopLevel() )
1193 x
-= GetParent()->MacGetLeftBorderSize() ;
1194 y
-= GetParent()->MacGetTopBorderSize() ;
1200 // Get window size (not client size)
1201 void wxWindowMac::DoGetSize(int *x
, int *y
) const
1204 m_peer
->GetRect( &bounds
) ;
1207 *x
= bounds
.right
- bounds
.left
+ MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1209 *y
= bounds
.bottom
- bounds
.top
+ MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1212 // get the position of the bounds of this window in client coordinates of its parent
1213 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
1216 m_peer
->GetRect( &bounds
) ;
1218 int x1
= bounds
.left
;
1219 int y1
= bounds
.top
;
1221 // get the wx window position from the native one
1222 x1
-= MacGetLeftBorderSize() ;
1223 y1
-= MacGetTopBorderSize() ;
1225 if ( !IsTopLevel() )
1227 wxWindow
*parent
= GetParent();
1230 // we must first adjust it to be in window coordinates of the parent,
1231 // as otherwise it gets lost by the ClientAreaOrigin fix
1232 x1
+= parent
->MacGetLeftBorderSize() ;
1233 y1
+= parent
->MacGetTopBorderSize() ;
1235 // and now to client coordinates
1236 wxPoint
pt(parent
->GetClientAreaOrigin());
1248 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
1250 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1251 wxCHECK_RET( window
, wxT("TopLevel Window missing") ) ;
1253 Point localwhere
= { 0, 0 } ;
1260 QDGlobalToLocalPoint( GetWindowPort( window
) , &localwhere
) ;
1267 MacRootWindowToWindow( x
, y
) ;
1269 wxPoint origin
= GetClientAreaOrigin() ;
1276 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
1278 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1279 wxCHECK_RET( window
, wxT("TopLevel window missing") ) ;
1281 wxPoint origin
= GetClientAreaOrigin() ;
1287 MacWindowToRootWindow( x
, y
) ;
1289 Point localwhere
= { 0, 0 };
1295 QDLocalToGlobalPoint( GetWindowPort( window
) , &localwhere
) ;
1303 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
1305 wxPoint origin
= GetClientAreaOrigin() ;
1311 MacWindowToRootWindow( x
, y
) ;
1314 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
1316 MacRootWindowToWindow( x
, y
) ;
1318 wxPoint origin
= GetClientAreaOrigin() ;
1325 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
1334 if ( !IsTopLevel() )
1336 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1339 pt
.x
-= MacGetLeftBorderSize() ;
1340 pt
.y
-= MacGetTopBorderSize() ;
1341 wxMacControl::Convert( &pt
, m_peer
, top
->m_peer
) ;
1351 void wxWindowMac::MacWindowToRootWindow( short *x
, short *y
) const
1360 MacWindowToRootWindow( &x1
, &y1
) ;
1368 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
1377 if ( !IsTopLevel() )
1379 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1382 wxMacControl::Convert( &pt
, top
->m_peer
, m_peer
) ;
1383 pt
.x
+= MacGetLeftBorderSize() ;
1384 pt
.y
+= MacGetTopBorderSize() ;
1394 void wxWindowMac::MacRootWindowToWindow( short *x
, short *y
) const
1403 MacRootWindowToWindow( &x1
, &y1
) ;
1411 void wxWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1413 RgnHandle rgn
= NewRgn() ;
1415 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1417 Rect structure
, content
;
1419 GetRegionBounds( rgn
, &content
) ;
1420 m_peer
->GetRect( &structure
) ;
1421 OffsetRect( &structure
, -structure
.left
, -structure
.top
) ;
1423 left
= content
.left
- structure
.left
;
1424 top
= content
.top
- structure
.top
;
1425 right
= structure
.right
- content
.right
;
1426 bottom
= structure
.bottom
- content
.bottom
;
1430 left
= top
= right
= bottom
= 0 ;
1436 wxSize
wxWindowMac::DoGetSizeFromClientSize( const wxSize
& size
) const
1438 wxSize sizeTotal
= size
;
1440 RgnHandle rgn
= NewRgn() ;
1441 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1443 Rect content
, structure
;
1444 GetRegionBounds( rgn
, &content
) ;
1445 m_peer
->GetRect( &structure
) ;
1447 // structure is in parent coordinates, but we only need width and height, so it's ok
1449 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1450 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1455 sizeTotal
.x
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1456 sizeTotal
.y
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1461 // Get size *available for subwindows* i.e. excluding menu bar etc.
1462 void wxWindowMac::DoGetClientSize( int *x
, int *y
) const
1466 RgnHandle rgn
= NewRgn() ;
1468 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1469 GetRegionBounds( rgn
, &content
) ;
1471 m_peer
->GetRect( &content
) ;
1474 ww
= content
.right
- content
.left
;
1475 hh
= content
.bottom
- content
.top
;
1477 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1478 hh
-= m_hScrollBar
->GetSize().y
;
1480 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1481 ww
-= m_vScrollBar
->GetSize().x
;
1489 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
1491 if (m_cursor
== cursor
)
1494 if (wxNullCursor
== cursor
)
1496 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
1501 if ( ! wxWindowBase::SetCursor( cursor
) )
1505 wxASSERT_MSG( m_cursor
.Ok(),
1506 wxT("cursor must be valid after call to the base version"));
1508 wxWindowMac
*mouseWin
= 0 ;
1510 wxTopLevelWindowMac
*tlw
= MacGetTopLevelWindow() ;
1511 WindowRef window
= (WindowRef
) ( tlw
? tlw
->MacGetWindowRef() : 0 ) ;
1513 Boolean swapped
= QDSwapPort( GetWindowPort( window
) , &savePort
) ;
1515 // TODO: If we ever get a GetCurrentEvent... replacement
1516 // for the mouse position, use it...
1519 ControlPartCode part
;
1520 ControlRef control
;
1523 control
= wxMacFindControlUnderMouse( tlw
, pt
, window
, &part
) ;
1525 mouseWin
= wxFindControlFromMacControl( control
) ;
1528 QDSwapPort( savePort
, NULL
) ;
1531 if ( mouseWin
== this && !wxIsBusy() )
1532 m_cursor
.MacInstall() ;
1538 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1540 menu
->SetInvokingWindow(this);
1543 if ( x
== -1 && y
== -1 )
1545 wxPoint mouse
= wxGetMousePosition();
1551 ClientToScreen( &x
, &y
) ;
1554 menu
->MacBeforeDisplay( true ) ;
1555 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() , y
, x
, 0) ;
1556 if ( HiWord(menuResult
) != 0 )
1559 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id
) ;
1560 wxMenuItem
* item
= NULL
;
1562 item
= menu
->FindItem( id
, &realmenu
) ;
1563 if (item
->IsCheckable())
1564 item
->Check( !item
->IsChecked() ) ;
1566 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1569 menu
->MacAfterDisplay( true ) ;
1570 menu
->SetInvokingWindow( NULL
);
1576 // ----------------------------------------------------------------------------
1578 // ----------------------------------------------------------------------------
1582 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
1584 wxWindowBase::DoSetToolTip(tooltip
);
1587 m_tooltip
->SetWindow(this);
1592 void wxWindowMac::MacInvalidateBorders()
1594 if ( m_peer
== NULL
)
1597 bool vis
= MacIsReallyShown() ;
1601 int outerBorder
= MacGetLeftBorderSize() ;
1602 if ( m_peer
->NeedsFocusRect() && m_peer
->HasFocus() )
1605 if ( outerBorder
== 0 )
1608 // now we know that we have something to do at all
1610 // as the borders are drawn on the parent we have to properly invalidate all these areas
1611 RgnHandle updateInner
, updateOuter
;
1614 // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
1615 updateInner
= NewRgn() ;
1616 updateOuter
= NewRgn() ;
1618 m_peer
->GetRect( &rect
) ;
1619 RectRgn( updateInner
, &rect
) ;
1620 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1621 RectRgn( updateOuter
, &rect
) ;
1622 DiffRgn( updateOuter
, updateInner
, updateOuter
) ;
1624 #ifdef __WXMAC_OSX__
1625 GetParent()->m_peer
->SetNeedsDisplay( updateOuter
) ;
1627 WindowRef tlw
= (WindowRef
) MacGetTopLevelWindowRef() ;
1629 InvalWindowRgn( tlw
, updateOuter
) ;
1632 DisposeRgn( updateOuter
) ;
1633 DisposeRgn( updateInner
) ;
1636 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1638 // this is never called for a toplevel window, so we know we have a parent
1639 int former_x
, former_y
, former_w
, former_h
;
1641 // Get true coordinates of former position
1642 DoGetPosition( &former_x
, &former_y
) ;
1643 DoGetSize( &former_w
, &former_h
) ;
1645 wxWindow
*parent
= GetParent();
1648 wxPoint
pt(parent
->GetClientAreaOrigin());
1653 int actualWidth
= width
;
1654 int actualHeight
= height
;
1658 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1659 actualWidth
= m_minWidth
;
1660 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1661 actualHeight
= m_minHeight
;
1662 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1663 actualWidth
= m_maxWidth
;
1664 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1665 actualHeight
= m_maxHeight
;
1667 bool doMove
= false, doResize
= false ;
1669 if ( actualX
!= former_x
|| actualY
!= former_y
)
1672 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1675 if ( doMove
|| doResize
)
1677 // as the borders are drawn outside the native control, we adjust now
1679 wxRect
bounds( wxPoint( actualX
+ MacGetLeftBorderSize() ,actualY
+ MacGetTopBorderSize() ),
1680 wxSize( actualWidth
- (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
1681 actualHeight
- (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
1684 wxMacRectToNative( &bounds
, &r
) ;
1686 if ( !GetParent()->IsTopLevel() )
1687 wxMacWindowToNative( GetParent() , &r
) ;
1689 MacInvalidateBorders() ;
1691 m_cachedClippedRectValid
= false ;
1692 m_peer
->SetRect( &r
) ;
1694 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
1696 MacInvalidateBorders() ;
1698 MacRepositionScrollBars() ;
1701 wxPoint
point(actualX
, actualY
);
1702 wxMoveEvent
event(point
, m_windowId
);
1703 event
.SetEventObject(this);
1704 GetEventHandler()->ProcessEvent(event
) ;
1709 MacRepositionScrollBars() ;
1710 wxSize
size(actualWidth
, actualHeight
);
1711 wxSizeEvent
event(size
, m_windowId
);
1712 event
.SetEventObject(this);
1713 GetEventHandler()->ProcessEvent(event
);
1718 wxSize
wxWindowMac::DoGetBestSize() const
1720 if ( m_macIsUserPane
|| IsTopLevel() )
1721 return wxWindowBase::DoGetBestSize() ;
1723 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1724 int bestWidth
, bestHeight
;
1726 m_peer
->GetBestRect( &bestsize
) ;
1727 if ( EmptyRect( &bestsize
) )
1732 bestsize
.bottom
= 16 ;
1734 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1736 bestsize
.bottom
= 16 ;
1739 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1741 bestsize
.bottom
= 24 ;
1746 // return wxWindowBase::DoGetBestSize() ;
1750 bestWidth
= bestsize
.right
- bestsize
.left
;
1751 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1752 if ( bestHeight
< 10 )
1755 return wxSize(bestWidth
, bestHeight
);
1758 // set the size of the window: if the dimensions are positive, just use them,
1759 // but if any of them is equal to -1, it means that we must find the value for
1760 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1761 // which case -1 is a valid value for x and y)
1763 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1764 // the width/height to best suit our contents, otherwise we reuse the current
1766 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1768 // get the current size and position...
1769 int currentX
, currentY
;
1770 int currentW
, currentH
;
1772 GetPosition(¤tX
, ¤tY
);
1773 GetSize(¤tW
, ¤tH
);
1775 // ... and don't do anything (avoiding flicker) if it's already ok
1776 if ( x
== currentX
&& y
== currentY
&&
1777 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1780 MacRepositionScrollBars() ; // we might have a real position shift
1785 if ( !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1787 if ( x
== wxDefaultCoord
)
1789 if ( y
== wxDefaultCoord
)
1793 AdjustForParentClientOrigin( x
, y
, sizeFlags
);
1795 wxSize size
= wxDefaultSize
;
1796 if ( width
== wxDefaultCoord
)
1798 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1800 size
= DoGetBestSize();
1805 // just take the current one
1810 if ( height
== wxDefaultCoord
)
1812 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1814 if ( size
.x
== wxDefaultCoord
)
1815 size
= DoGetBestSize();
1816 // else: already called DoGetBestSize() above
1822 // just take the current one
1827 DoMoveWindow( x
, y
, width
, height
);
1830 wxPoint
wxWindowMac::GetClientAreaOrigin() const
1832 RgnHandle rgn
= NewRgn() ;
1834 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1836 GetRegionBounds( rgn
, &content
) ;
1846 return wxPoint( content
.left
+ MacGetLeftBorderSize() , content
.top
+ MacGetTopBorderSize() );
1849 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
)
1851 if ( clientheight
!= wxDefaultCoord
|| clientheight
!= wxDefaultCoord
)
1853 int currentclientwidth
, currentclientheight
;
1854 int currentwidth
, currentheight
;
1856 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1857 GetSize( ¤twidth
, ¤theight
) ;
1859 DoSetSize( wxDefaultCoord
, wxDefaultCoord
, currentwidth
+ clientwidth
- currentclientwidth
,
1860 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1864 void wxWindowMac::SetLabel(const wxString
& title
)
1866 m_label
= wxStripMenuCodes(title
) ;
1868 if ( m_peer
&& m_peer
->Ok() )
1869 m_peer
->SetLabel( m_label
) ;
1874 wxString
wxWindowMac::GetLabel() const
1879 bool wxWindowMac::Show(bool show
)
1881 bool former
= MacIsReallyShown() ;
1882 if ( !wxWindowBase::Show(show
) )
1885 // TODO: use visibilityChanged Carbon Event for OSX
1887 m_peer
->SetVisibility( show
, true ) ;
1889 if ( former
!= MacIsReallyShown() )
1890 MacPropagateVisibilityChanged() ;
1895 bool wxWindowMac::Enable(bool enable
)
1897 wxASSERT( m_peer
->Ok() ) ;
1898 bool former
= MacIsReallyEnabled() ;
1899 if ( !wxWindowBase::Enable(enable
) )
1902 m_peer
->Enable( enable
) ;
1904 if ( former
!= MacIsReallyEnabled() )
1905 MacPropagateEnabledStateChanged() ;
1911 // status change propagations (will be not necessary for OSX later )
1914 void wxWindowMac::MacPropagateVisibilityChanged()
1916 #if !TARGET_API_MAC_OSX
1917 MacVisibilityChanged() ;
1920 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1923 child
= node
->GetData();
1924 if ( child
->IsShown() )
1925 child
->MacPropagateVisibilityChanged() ;
1927 node
= node
->GetNext();
1932 void wxWindowMac::MacPropagateEnabledStateChanged()
1934 #if !TARGET_API_MAC_OSX
1935 MacEnabledStateChanged() ;
1938 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1941 child
= node
->GetData();
1942 if ( child
->IsEnabled() )
1943 child
->MacPropagateEnabledStateChanged() ;
1945 node
= node
->GetNext();
1950 void wxWindowMac::MacPropagateHiliteChanged()
1952 #if !TARGET_API_MAC_OSX
1953 MacHiliteChanged() ;
1956 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1959 child
= node
->GetData();
1960 if (child
/* && child->IsEnabled() */)
1961 child
->MacPropagateHiliteChanged() ;
1963 node
= node
->GetNext();
1969 // status change notifications
1972 void wxWindowMac::MacVisibilityChanged()
1976 void wxWindowMac::MacHiliteChanged()
1980 void wxWindowMac::MacEnabledStateChanged()
1985 // status queries on the inherited window's state
1988 bool wxWindowMac::MacIsReallyShown()
1990 // only under OSX the visibility of the TLW is taken into account
1991 if ( m_isBeingDeleted
)
1994 #if TARGET_API_MAC_OSX
1995 if ( m_peer
&& m_peer
->Ok() )
1996 return m_peer
->IsVisible();
1999 wxWindow
* win
= this ;
2000 while ( win
->IsShown() )
2002 if ( win
->IsTopLevel() )
2005 win
= win
->GetParent() ;
2013 bool wxWindowMac::MacIsReallyEnabled()
2015 return m_peer
->IsEnabled() ;
2018 bool wxWindowMac::MacIsReallyHilited()
2020 return m_peer
->IsActive();
2023 void wxWindowMac::MacFlashInvalidAreas()
2025 #if TARGET_API_MAC_OSX
2026 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
2030 int wxWindowMac::GetCharHeight() const
2032 wxClientDC
dc( (wxWindowMac
*)this ) ;
2034 return dc
.GetCharHeight() ;
2037 int wxWindowMac::GetCharWidth() const
2039 wxClientDC
dc( (wxWindowMac
*)this ) ;
2041 return dc
.GetCharWidth() ;
2044 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
2045 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
2047 const wxFont
*fontToUse
= theFont
;
2049 fontToUse
= &m_font
;
2051 wxClientDC
dc( (wxWindowMac
*) this ) ;
2053 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
2054 if ( externalLeading
)
2055 *externalLeading
= le
;
2065 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
2066 * we always intersect with the entire window, not only with the client area
2069 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
2071 if ( m_peer
== NULL
)
2074 if ( !MacIsReallyShown() )
2081 wxMacRectToNative( rect
, &r
) ;
2082 m_peer
->SetNeedsDisplay( &r
) ;
2086 m_peer
->SetNeedsDisplay() ;
2090 void wxWindowMac::Freeze()
2092 #if TARGET_API_MAC_OSX
2093 if ( !m_frozenness
++ )
2095 if ( m_peer
&& m_peer
->Ok() )
2096 m_peer
->SetDrawingEnabled( false ) ;
2101 void wxWindowMac::Thaw()
2103 #if TARGET_API_MAC_OSX
2104 wxASSERT_MSG( m_frozenness
> 0, wxT("Thaw() without matching Freeze()") );
2106 if ( !--m_frozenness
)
2108 if ( m_peer
&& m_peer
->Ok() )
2110 m_peer
->SetDrawingEnabled( true ) ;
2111 m_peer
->InvalidateWithChildren() ;
2117 wxWindowMac
*wxGetActiveWindow()
2119 // actually this is a windows-only concept
2123 // Coordinates relative to the window
2124 void wxWindowMac::WarpPointer(int x_pos
, int y_pos
)
2126 // We really don't move the mouse programmatically under Mac.
2129 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
2131 if ( MacGetTopLevelWindow() == NULL
)
2134 #if TARGET_API_MAC_OSX
2135 if ( MacGetTopLevelWindow()->MacUsesCompositing() && (!m_macBackgroundBrush
.Ok() || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT
) )
2142 event
.GetDC()->Clear() ;
2146 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
2151 int wxWindowMac::GetScrollPos(int orient
) const
2153 if ( orient
== wxHORIZONTAL
)
2156 return m_hScrollBar
->GetThumbPosition() ;
2161 return m_vScrollBar
->GetThumbPosition() ;
2167 // This now returns the whole range, not just the number
2168 // of positions that we can scroll.
2169 int wxWindowMac::GetScrollRange(int orient
) const
2171 if ( orient
== wxHORIZONTAL
)
2174 return m_hScrollBar
->GetRange() ;
2179 return m_vScrollBar
->GetRange() ;
2185 int wxWindowMac::GetScrollThumb(int orient
) const
2187 if ( orient
== wxHORIZONTAL
)
2190 return m_hScrollBar
->GetThumbSize() ;
2195 return m_vScrollBar
->GetThumbSize() ;
2201 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
2203 if ( orient
== wxHORIZONTAL
)
2206 m_hScrollBar
->SetThumbPosition( pos
) ;
2211 m_vScrollBar
->SetThumbPosition( pos
) ;
2216 // we draw borders and grow boxes, are already set up and clipped in the current port / cgContextRef
2217 // our own window origin is at leftOrigin/rightOrigin
2220 void wxWindowMac::MacPaintBorders( int leftOrigin
, int rightOrigin
)
2226 bool hasFocus
= m_peer
->NeedsFocusRect() && m_peer
->HasFocus() ;
2227 bool hasBothScrollbars
= (m_hScrollBar
&& m_hScrollBar
->IsShown()) && (m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
2229 // back to the surrounding frame rectangle
2230 m_peer
->GetRect( &rect
) ;
2231 InsetRect( &rect
, -1 , -1 ) ;
2233 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2234 if ( UMAGetSystemVersion() >= 0x1030 )
2236 CGRect cgrect
= CGRectMake( rect
.left
, rect
.top
, rect
.right
- rect
.left
,
2237 rect
.bottom
- rect
.top
) ;
2239 HIThemeFrameDrawInfo info
;
2240 memset( &info
, 0 , sizeof(info
) ) ;
2244 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2245 info
.isFocused
= hasFocus
;
2247 CGContextRef cgContext
= (CGContextRef
) GetParent()->MacGetCGContextRef() ;
2248 wxASSERT( cgContext
) ;
2250 if ( HasFlag(wxRAISED_BORDER
) || HasFlag(wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2252 info
.kind
= kHIThemeFrameTextFieldSquare
;
2253 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2255 else if ( HasFlag(wxSIMPLE_BORDER
) )
2257 info
.kind
= kHIThemeFrameListBox
;
2258 HIThemeDrawFrame( &cgrect
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2260 else if ( hasFocus
)
2262 HIThemeDrawFocusRect( &cgrect
, true , cgContext
, kHIThemeOrientationNormal
) ;
2265 m_peer
->GetRect( &rect
) ;
2266 if ( hasBothScrollbars
)
2268 int size
= m_hScrollBar
->GetWindowVariant() == wxWINDOW_VARIANT_NORMAL
? 16 : 12 ;
2269 CGRect cgrect
= CGRectMake( rect
.right
- size
, rect
.bottom
- size
, size
, size
) ;
2270 CGPoint cgpoint
= CGPointMake( rect
.right
- size
, rect
.bottom
- size
) ;
2271 HIThemeGrowBoxDrawInfo info
;
2272 memset( &info
, 0, sizeof(info
) ) ;
2274 info
.state
= IsEnabled() ? kThemeStateActive
: kThemeStateInactive
;
2275 info
.kind
= kHIThemeGrowBoxKindNone
;
2276 info
.size
= kHIThemeGrowBoxSizeNormal
;
2277 info
.direction
= kThemeGrowRight
| kThemeGrowDown
;
2278 HIThemeDrawGrowBox( &cgpoint
, &info
, cgContext
, kHIThemeOrientationNormal
) ;
2284 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2288 wxMacControl::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2289 OffsetRect( &rect
, pt
.x
, pt
.y
) ;
2292 if ( HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2293 DrawThemeEditTextFrame( &rect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2294 else if ( HasFlag(wxSIMPLE_BORDER
) )
2295 DrawThemeListBoxFrame( &rect
, IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2298 DrawThemeFocusRect( &rect
, true ) ;
2300 if ( hasBothScrollbars
)
2302 // GetThemeStandaloneGrowBoxBounds
2303 // DrawThemeStandaloneNoGrowBox
2308 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
2310 if ( child
== m_hScrollBar
)
2311 m_hScrollBar
= NULL
;
2312 if ( child
== m_vScrollBar
)
2313 m_vScrollBar
= NULL
;
2315 wxWindowBase::RemoveChild( child
) ;
2318 // New function that will replace some of the above.
2319 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2320 int range
, bool refresh
)
2324 if ( orient
== wxHORIZONTAL
)
2328 showScroller
= ((range
!= 0) && (range
> thumbVisible
));
2329 if ( m_hScrollBar
->IsShown() != showScroller
)
2330 m_hScrollBar
->Show( showScroller
) ;
2332 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2339 showScroller
= ((range
!= 0) && (range
> thumbVisible
));
2340 if ( m_vScrollBar
->IsShown() != showScroller
)
2341 m_vScrollBar
->Show( showScroller
) ;
2343 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2347 MacRepositionScrollBars() ;
2350 // Does a physical scroll
2351 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2353 if ( dx
== 0 && dy
== 0 )
2356 int width
, height
;
2357 GetClientSize( &width
, &height
) ;
2359 #if TARGET_API_MAC_OSX
2360 if ( true /* m_peer->IsCompositing() */ )
2362 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2363 // area is scrolled, this does not occur if width and height are 2 pixels less,
2364 // TODO: write optimal workaround
2365 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2367 scrollrect
.Intersect( *rect
) ;
2369 if ( m_peer
->GetNeedsDisplay() )
2371 // because HIViewScrollRect does not scroll the already invalidated area we have two options:
2372 // either immediate redraw or full invalidate
2374 // is the better overall solution, as it does not slow down scrolling
2375 m_peer
->SetNeedsDisplay() ;
2377 // this would be the preferred version for fast drawing controls
2379 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2380 if ( UMAGetSystemVersion() >= 0x1030 && m_peer
->IsCompositing() )
2381 HIViewRender(m_peer
->GetControlRef()) ;
2388 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2389 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2390 m_peer
->ScrollRect( &scrollrect
, dx
, dy
) ;
2392 // becuase HIViewScrollRect does not scroll the already invalidated area we have two options
2393 // either immediate redraw or full invalidate
2395 // is the better overall solution, as it does not slow down scrolling
2396 m_peer
->SetNeedsDisplay() ;
2398 // this would be the preferred version for fast drawing controls
2400 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2401 if ( UMAGetSystemVersion() >= 0x1030 && m_peer
->IsCompositing() )
2402 HIViewRender(m_peer
->GetControlRef()) ;
2416 RgnHandle updateRgn
= NewRgn() ;
2419 wxClientDC
dc(this) ;
2420 wxMacPortSetter
helper(&dc
) ;
2422 m_peer
->GetRectInWindowCoords( &scrollrect
) ;
2423 //scrollrect.top += MacGetTopBorderSize() ;
2424 //scrollrect.left += MacGetLeftBorderSize() ;
2425 scrollrect
.bottom
= scrollrect
.top
+ height
;
2426 scrollrect
.right
= scrollrect
.left
+ width
;
2430 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
2431 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
2432 SectRect( &scrollrect
, &r
, &scrollrect
) ;
2435 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
2437 // now scroll the former update region as well and add the new update region
2438 WindowRef rootWindow
= (WindowRef
) MacGetTopLevelWindowRef() ;
2439 RgnHandle formerUpdateRgn
= NewRgn() ;
2440 RgnHandle scrollRgn
= NewRgn() ;
2441 RectRgn( scrollRgn
, &scrollrect
) ;
2442 GetWindowUpdateRgn( rootWindow
, formerUpdateRgn
) ;
2444 LocalToGlobal( &pt
) ;
2445 OffsetRgn( formerUpdateRgn
, -pt
.h
, -pt
.v
) ;
2446 SectRgn( formerUpdateRgn
, scrollRgn
, formerUpdateRgn
) ;
2448 if ( !EmptyRgn( formerUpdateRgn
) )
2450 MacOffsetRgn( formerUpdateRgn
, dx
, dy
) ;
2451 SectRgn( formerUpdateRgn
, scrollRgn
, formerUpdateRgn
) ;
2452 InvalWindowRgn( rootWindow
, formerUpdateRgn
) ;
2455 InvalWindowRgn(rootWindow
, updateRgn
) ;
2456 DisposeRgn( updateRgn
) ;
2457 DisposeRgn( formerUpdateRgn
) ;
2458 DisposeRgn( scrollRgn
) ;
2466 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2468 child
= node
->GetData();
2471 if (child
== m_vScrollBar
)
2473 if (child
== m_hScrollBar
)
2475 if (child
->IsTopLevel())
2478 child
->GetPosition( &x
, &y
);
2479 child
->GetSize( &w
, &h
);
2482 wxRect
rc( x
, y
, w
, h
);
2483 if (rect
->Intersects( rc
))
2484 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
);
2488 child
->SetSize( x
+ dx
, y
+ dy
, w
, h
);
2493 void wxWindowMac::MacOnScroll( wxScrollEvent
&event
)
2495 if ( event
.GetEventObject() == m_vScrollBar
|| event
.GetEventObject() == m_hScrollBar
)
2497 wxScrollWinEvent wevent
;
2498 wevent
.SetPosition(event
.GetPosition());
2499 wevent
.SetOrientation(event
.GetOrientation());
2500 wevent
.SetEventObject(this);
2502 if (event
.GetEventType() == wxEVT_SCROLL_TOP
)
2503 wevent
.SetEventType( wxEVT_SCROLLWIN_TOP
);
2504 else if (event
.GetEventType() == wxEVT_SCROLL_BOTTOM
)
2505 wevent
.SetEventType( wxEVT_SCROLLWIN_BOTTOM
);
2506 else if (event
.GetEventType() == wxEVT_SCROLL_LINEUP
)
2507 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEUP
);
2508 else if (event
.GetEventType() == wxEVT_SCROLL_LINEDOWN
)
2509 wevent
.SetEventType( wxEVT_SCROLLWIN_LINEDOWN
);
2510 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEUP
)
2511 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEUP
);
2512 else if (event
.GetEventType() == wxEVT_SCROLL_PAGEDOWN
)
2513 wevent
.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN
);
2514 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBTRACK
)
2515 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK
);
2516 else if (event
.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
)
2517 wevent
.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE
);
2519 GetEventHandler()->ProcessEvent(wevent
);
2523 // Get the window with the focus
2524 wxWindowMac
*wxWindowBase::DoFindFocus()
2526 ControlRef control
;
2527 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2528 return wxFindControlFromMacControl( control
) ;
2531 void wxWindowMac::OnSetFocus( wxFocusEvent
& event
)
2533 // panel wants to track the window which was the last to have focus in it,
2534 // so we want to set ourselves as the window which last had focus
2536 // notice that it's also important to do it upwards the tree because
2537 // otherwise when the top level panel gets focus, it won't set it back to
2538 // us, but to some other sibling
2540 // CS: don't know if this is still needed:
2541 //wxChildFocusEvent eventFocus(this);
2542 //(void)GetEventHandler()->ProcessEvent(eventFocus);
2544 if ( MacGetTopLevelWindow() && m_peer
->NeedsFocusRect() )
2546 #if wxMAC_USE_CORE_GRAPHICS
2547 GetParent()->Refresh() ;
2549 wxMacWindowStateSaver
sv( this ) ;
2552 m_peer
->GetRect( &rect
) ;
2553 // auf den umgebenden Rahmen zur\9fck
2554 InsetRect( &rect
, -1 , -1 ) ;
2556 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2560 wxMacControl::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2562 rect
.right
+= pt
.x
;
2564 rect
.bottom
+= pt
.y
;
2567 bool bIsFocusEvent
= (event
.GetEventType() == wxEVT_SET_FOCUS
);
2568 DrawThemeFocusRect( &rect
, bIsFocusEvent
) ;
2569 if ( !bIsFocusEvent
)
2571 // as this erases part of the frame we have to redraw borders
2572 // and because our z-ordering is not always correct (staticboxes)
2573 // we have to invalidate things, we cannot simple redraw
2574 MacInvalidateBorders() ;
2582 void wxWindowMac::OnInternalIdle()
2584 // This calls the UI-update mechanism (querying windows for
2585 // menu/toolbar/control state information)
2586 if (wxUpdateUIEvent::CanUpdate(this))
2587 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2590 // Raise the window to the top of the Z order
2591 void wxWindowMac::Raise()
2593 m_peer
->SetZOrder( true , NULL
) ;
2596 // Lower the window to the bottom of the Z order
2597 void wxWindowMac::Lower()
2599 m_peer
->SetZOrder( false , NULL
) ;
2602 // static wxWindow *gs_lastWhich = NULL;
2604 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
)
2606 // first trigger a set cursor event
2608 wxPoint clientorigin
= GetClientAreaOrigin() ;
2609 wxSize clientsize
= GetClientSize() ;
2611 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2613 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2615 bool processedEvtSetCursor
= GetEventHandler()->ProcessEvent(event
);
2616 if ( processedEvtSetCursor
&& event
.HasCursor() )
2618 cursor
= event
.GetCursor() ;
2622 // the test for processedEvtSetCursor is here to prevent using m_cursor
2623 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2624 // it - this is a way to say that our cursor shouldn't be used for this
2626 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2629 if ( !wxIsBusy() && !GetParent() )
2630 cursor
= *wxSTANDARD_CURSOR
;
2634 cursor
.MacInstall() ;
2637 return cursor
.Ok() ;
2640 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
2644 return m_tooltip
->GetTip() ;
2647 return wxEmptyString
;
2650 void wxWindowMac::ClearBackground()
2656 void wxWindowMac::Update()
2658 #if TARGET_API_MAC_OSX
2659 MacGetTopLevelWindow()->MacPerformUpdates() ;
2661 ::Draw1Control( m_peer
->GetControlRef() ) ;
2665 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
2667 wxTopLevelWindowMac
* win
= NULL
;
2668 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2670 win
= wxFindWinFromMacWindow( window
) ;
2675 const wxRect
& wxWindowMac::MacGetClippedClientRect() const
2677 MacUpdateClippedRects() ;
2679 return m_cachedClippedClientRect
;
2682 const wxRect
& wxWindowMac::MacGetClippedRect() const
2684 MacUpdateClippedRects() ;
2686 return m_cachedClippedRect
;
2689 const wxRect
&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
2691 MacUpdateClippedRects() ;
2693 return m_cachedClippedRectWithOuterStructure
;
2696 const wxRegion
& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures
)
2698 static wxRegion emptyrgn
;
2700 if ( !m_isBeingDeleted
&& MacIsReallyShown() /*m_peer->IsVisible() */ )
2702 MacUpdateClippedRects() ;
2703 if ( includeOuterStructures
)
2704 return m_cachedClippedRegionWithOuterStructure
;
2706 return m_cachedClippedRegion
;
2714 void wxWindowMac::MacUpdateClippedRects() const
2716 if ( m_cachedClippedRectValid
)
2719 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2720 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2721 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2722 // to add focus borders everywhere
2724 Rect r
, rIncludingOuterStructures
;
2726 m_peer
->GetRect( &r
) ;
2727 r
.left
-= MacGetLeftBorderSize() ;
2728 r
.top
-= MacGetTopBorderSize() ;
2729 r
.bottom
+= MacGetBottomBorderSize() ;
2730 r
.right
+= MacGetRightBorderSize() ;
2737 rIncludingOuterStructures
= r
;
2738 InsetRect( &rIncludingOuterStructures
, -4 , -4 ) ;
2740 wxRect cl
= GetClientRect() ;
2741 Rect rClient
= { cl
.y
, cl
.x
, cl
.y
+ cl
.height
, cl
.x
+ cl
.width
} ;
2745 const wxWindow
* child
= this ;
2746 const wxWindow
* parent
= NULL
;
2748 while ( !child
->IsTopLevel() && ( parent
= child
->GetParent() ) != NULL
)
2750 if ( parent
->MacIsChildOfClientArea(child
) )
2752 size
= parent
->GetClientSize() ;
2753 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2759 // this will be true for scrollbars, toolbars etc.
2760 size
= parent
->GetSize() ;
2761 y
= parent
->MacGetTopBorderSize() ;
2762 x
= parent
->MacGetLeftBorderSize() ;
2763 size
.x
-= parent
->MacGetLeftBorderSize() + parent
->MacGetRightBorderSize() ;
2764 size
.y
-= parent
->MacGetTopBorderSize() + parent
->MacGetBottomBorderSize() ;
2767 parent
->MacWindowToRootWindow( &x
, &y
) ;
2768 MacRootWindowToWindow( &x
, &y
) ;
2770 Rect rparent
= { y
, x
, y
+ size
.y
, x
+ size
.x
} ;
2772 // the wxwindow and client rects will always be clipped
2773 SectRect( &r
, &rparent
, &r
) ;
2774 SectRect( &rClient
, &rparent
, &rClient
) ;
2776 // the structure only at 'hard' borders
2777 if ( parent
->MacClipChildren() ||
2778 ( parent
->GetParent() && parent
->GetParent()->MacClipGrandChildren() ) )
2780 SectRect( &rIncludingOuterStructures
, &rparent
, &rIncludingOuterStructures
) ;
2786 m_cachedClippedRect
= wxRect( r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
) ;
2787 m_cachedClippedClientRect
= wxRect( rClient
.left
, rClient
.top
,
2788 rClient
.right
- rClient
.left
, rClient
.bottom
- rClient
.top
) ;
2789 m_cachedClippedRectWithOuterStructure
= wxRect(
2790 rIncludingOuterStructures
.left
, rIncludingOuterStructures
.top
,
2791 rIncludingOuterStructures
.right
- rIncludingOuterStructures
.left
,
2792 rIncludingOuterStructures
.bottom
- rIncludingOuterStructures
.top
) ;
2794 m_cachedClippedRegionWithOuterStructure
= wxRegion( m_cachedClippedRectWithOuterStructure
) ;
2795 m_cachedClippedRegion
= wxRegion( m_cachedClippedRect
) ;
2796 m_cachedClippedClientRegion
= wxRegion( m_cachedClippedClientRect
) ;
2798 m_cachedClippedRectValid
= true ;
2802 This function must not change the updatergn !
2804 bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr
, long time
)
2806 bool handled
= false ;
2808 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2809 GetRegionBounds( updatergn
, &updatebounds
) ;
2811 // wxLogDebug(wxT("update for %s bounds %d, %d, %d, %d"), wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left, updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2813 if ( !EmptyRgn(updatergn
) )
2815 RgnHandle newupdate
= NewRgn() ;
2816 wxSize point
= GetClientSize() ;
2817 wxPoint origin
= GetClientAreaOrigin() ;
2818 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+ point
.y
) ;
2819 SectRgn( newupdate
, updatergn
, newupdate
) ;
2821 // first send an erase event to the entire update area
2823 // for the toplevel window this really is the entire area
2824 // for all the others only their client area, otherwise they
2825 // might be drawing with full alpha and eg put blue into
2826 // the grow-box area of a scrolled window (scroll sample)
2827 wxDC
* dc
= new wxWindowDC(this);
2829 dc
->SetClippingRegion(wxRegion(updatergn
));
2831 dc
->SetClippingRegion(wxRegion(newupdate
));
2833 wxEraseEvent
eevent( GetId(), dc
);
2834 eevent
.SetEventObject( this );
2835 GetEventHandler()->ProcessEvent( eevent
);
2839 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2840 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2841 m_updateRegion
= newupdate
;
2842 DisposeRgn( newupdate
) ;
2844 if ( !m_updateRegion
.Empty() )
2846 // paint the window itself
2849 event
.SetTimestamp(time
);
2850 event
.SetEventObject(this);
2851 GetEventHandler()->ProcessEvent(event
);
2855 // now we cannot rely on having its borders drawn by a window itself, as it does not
2856 // get the updateRgn wide enough to always do so, so we do it from the parent
2857 // this would also be the place to draw any custom backgrounds for native controls
2858 // in Composited windowing
2859 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2863 for (wxWindowList::compatibility_iterator node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2865 child
= node
->GetData();
2868 if (child
== m_vScrollBar
)
2870 if (child
== m_hScrollBar
)
2872 if (child
->IsTopLevel())
2874 if (!child
->IsShown())
2877 // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
2879 child
->GetPosition( &x
, &y
);
2880 child
->GetSize( &w
, &h
);
2881 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2882 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2883 InsetRect( &childRect
, -10 , -10) ;
2885 if ( RectInRgn( &childRect
, updatergn
) )
2887 // paint custom borders
2888 wxNcPaintEvent
eventNc( child
->GetId() );
2889 eventNc
.SetEventObject( child
);
2890 if ( !child
->GetEventHandler()->ProcessEvent( eventNc
) )
2892 #if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2893 if ( UMAGetSystemVersion() >= 0x1030 )
2895 child
->MacPaintBorders(0, 0) ;
2900 wxWindowDC
dc(this) ;
2901 dc
.SetClippingRegion(wxRegion(updatergn
));
2902 wxMacPortSetter
helper(&dc
) ;
2903 child
->MacPaintBorders(0, 0) ;
2914 WXWindow
wxWindowMac::MacGetTopLevelWindowRef() const
2916 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2920 if ( iter
->IsTopLevel() )
2921 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
2923 iter
= iter
->GetParent() ;
2926 wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ;
2931 void wxWindowMac::MacCreateScrollBars( long style
)
2933 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2935 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2937 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
2938 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2939 wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
;
2940 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2942 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2943 variant
= wxWINDOW_VARIANT_SMALL
;
2946 int adjust
= hasBoth
? scrlsize
- 1: 0 ;
2948 GetClientSize( &width
, &height
) ;
2950 wxPoint
vPoint(width
- scrlsize
, 0) ;
2951 wxSize
vSize(scrlsize
, height
- adjust
) ;
2952 wxPoint
hPoint(0, height
- scrlsize
) ;
2953 wxSize
hSize(width
- adjust
, scrlsize
) ;
2955 if ( style
& wxVSCROLL
)
2956 m_vScrollBar
= new wxScrollBar(this, wxID_ANY
, vPoint
, vSize
, wxVERTICAL
);
2958 if ( style
& wxHSCROLL
)
2959 m_hScrollBar
= new wxScrollBar(this, wxID_ANY
, hPoint
, hSize
, wxHORIZONTAL
);
2962 // because the create does not take into account the client area origin
2963 // we might have a real position shift
2964 MacRepositionScrollBars() ;
2967 bool wxWindowMac::MacIsChildOfClientArea( const wxWindow
* child
) const
2969 bool result
= ((child
== NULL
) || ((child
!= m_hScrollBar
) && (child
!= m_vScrollBar
)));
2974 void wxWindowMac::MacRepositionScrollBars()
2976 if ( !m_hScrollBar
&& !m_vScrollBar
)
2979 bool hasBoth
= (m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
2980 int scrlsize
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2981 int adjust
= hasBoth
? scrlsize
- 1 : 0 ;
2983 // get real client area
2985 GetSize( &width
, &height
);
2987 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2988 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2990 wxPoint
vPoint( width
- scrlsize
, 0 ) ;
2991 wxSize
vSize( scrlsize
, height
- adjust
) ;
2992 wxPoint
hPoint( 0 , height
- scrlsize
) ;
2993 wxSize
hSize( width
- adjust
, scrlsize
) ;
2996 int x
= 0, y
= 0, w
, h
;
2997 GetSize( &w
, &h
) ;
2999 MacClientToRootWindow( &x
, &y
) ;
3000 MacClientToRootWindow( &w
, &h
) ;
3002 wxWindowMac
*iter
= (wxWindowMac
*)this ;
3004 int totW
= 10000 , totH
= 10000;
3007 if ( iter
->IsTopLevel() )
3009 iter
->GetSize( &totW
, &totH
) ;
3013 iter
= iter
->GetParent() ;
3027 if ( w
- x
>= totW
)
3032 if ( h
- y
>= totH
)
3040 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3042 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3045 bool wxWindowMac::AcceptsFocus() const
3047 return MacCanFocus() && wxWindowBase::AcceptsFocus();
3050 void wxWindowMac::MacSuperChangedPosition()
3052 // only window-absolute structures have to be moved i.e. controls
3054 m_cachedClippedRectValid
= false ;
3057 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3060 child
= node
->GetData();
3061 child
->MacSuperChangedPosition() ;
3063 node
= node
->GetNext();
3067 void wxWindowMac::MacTopLevelWindowChangedPosition()
3069 // only screen-absolute structures have to be moved i.e. glcanvas
3072 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3075 child
= node
->GetData();
3076 child
->MacTopLevelWindowChangedPosition() ;
3078 node
= node
->GetNext();
3082 long wxWindowMac::MacGetLeftBorderSize() const
3089 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
))
3091 // this metric is only the 'outset' outside the simple frame rect
3092 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
3095 else if (HasFlag(wxSIMPLE_BORDER
))
3097 // this metric is only the 'outset' outside the simple frame rect
3098 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
3105 long wxWindowMac::MacGetRightBorderSize() const
3107 // they are all symmetric in mac themes
3108 return MacGetLeftBorderSize() ;
3111 long wxWindowMac::MacGetTopBorderSize() const
3113 // they are all symmetric in mac themes
3114 return MacGetLeftBorderSize() ;
3117 long wxWindowMac::MacGetBottomBorderSize() const
3119 // they are all symmetric in mac themes
3120 return MacGetLeftBorderSize() ;
3123 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
3125 return style
& ~wxBORDER_MASK
;
3128 // Find the wxWindowMac at the current mouse position, returning the mouse
3130 wxWindowMac
* wxFindWindowAtPointer( wxPoint
& pt
)
3132 pt
= wxGetMousePosition();
3133 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3138 // Get the current mouse position.
3139 wxPoint
wxGetMousePosition()
3143 wxGetMousePosition( &x
, &y
);
3145 return wxPoint(x
, y
);
3148 void wxWindowMac::OnMouseEvent( wxMouseEvent
&event
)
3150 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3152 // copied from wxGTK : CS
3153 // VZ: shouldn't we move this to base class then?
3155 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3158 // (a) it's a command event and so is propagated to the parent
3159 // (b) under MSW it can be generated from kbd too
3160 // (c) it uses screen coords (because of (a))
3161 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3163 this->ClientToScreen(event
.GetPosition()));
3164 if ( ! GetEventHandler()->ProcessEvent(evtCtx
) )
3173 void wxWindowMac::OnPaint( wxPaintEvent
& event
)
3175 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
)
3176 CallNextEventHandler(
3177 (EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() ,
3178 (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
3181 void wxWindowMac::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
3185 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3189 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3190 Rect bounds
= { y
, x
, y
+ h
, x
+ w
};
3195 wxInt32
wxWindowMac::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3197 return eventNotHandledErr
;
3200 bool wxWindowMac::Reparent(wxWindowBase
*newParentBase
)
3202 wxWindowMac
*newParent
= (wxWindowMac
*)newParentBase
;
3203 if ( !wxWindowBase::Reparent(newParent
) )
3206 // copied from MacPostControlCreate
3207 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
3209 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
3211 ::EmbedControl( m_peer
->GetControlRef() , container
) ;