1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
18 #include "wx/window.h"
20 #include "wx/dcclient.h"
24 #include "wx/layout.h"
25 #include "wx/dialog.h"
26 #include "wx/scrolbar.h"
27 #include "wx/scrolwin.h"
28 #include "wx/statbox.h"
29 #include "wx/button.h"
30 #include "wx/settings.h"
31 #include "wx/msgdlg.h"
33 #include "wx/tooltip.h"
34 #include "wx/statusbr.h"
35 #include "wx/menuitem.h"
36 #include "wx/spinctrl.h"
38 #include "wx/geometry.h"
39 #include "wx/textctrl.h"
40 #include "wx/laywin.h"
41 #include "wx/splitter.h"
43 #include "wx/toolbar.h"
50 #define wxWINDOW_HSCROLL 5998
51 #define wxWINDOW_VSCROLL 5997
53 #define MAC_SCROLLBAR_SIZE 15
54 #define MAC_SMALL_SCROLLBAR_SIZE 11
56 #include "wx/mac/uma.h"
59 #include <ToolUtils.h>
61 #include <MacTextEditor.h>
64 #if TARGET_API_MAC_OSX
66 #include <HIToolbox/HIView.h>
70 #if wxUSE_DRAG_AND_DROP
76 extern wxList wxPendingDelete
;
78 #ifdef __WXUNIVERSAL__
79 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
81 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
82 #endif // __WXUNIVERSAL__/__WXMAC__
84 #if !USE_SHARED_LIBRARY
86 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
87 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
88 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
89 // TODO EVT_PAINT(wxWindowMac::OnPaint)
90 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
91 EVT_KILL_FOCUS(wxWindowMac::OnSetFocus
)
92 EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent
)
97 #define wxMAC_DEBUG_REDRAW 0
98 #ifndef wxMAC_DEBUG_REDRAW
99 #define wxMAC_DEBUG_REDRAW 0
102 #define wxMAC_USE_THEME_BORDER 1
104 // ---------------------------------------------------------------------------
105 // Utility Routines to move between different coordinate systems
106 // ---------------------------------------------------------------------------
109 * Right now we have the following setup :
110 * a border that is not part of the native control is always outside the
111 * control's border (otherwise we loose all native intelligence, future ways
112 * may be to have a second embedding control responsible for drawing borders
113 * and backgrounds eventually)
114 * so all this border calculations have to be taken into account when calling
115 * native methods or getting native oriented data
116 * so we have three coordinate systems here
117 * wx client coordinates
118 * wx window coordinates (including window frames)
123 // originating from native control
127 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
129 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
132 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
134 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
138 // directed towards native control
141 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
143 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
146 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
148 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
152 // ---------------------------------------------------------------------------
154 // ---------------------------------------------------------------------------
156 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
157 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
) ;
159 #if TARGET_API_MAC_OSX
161 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
163 kEventControlVisibilityChanged
= 157
169 static const EventTypeSpec eventList
[] =
171 { kEventClassControl
, kEventControlHit
} ,
172 #if TARGET_API_MAC_OSX
173 { kEventClassControl
, kEventControlDraw
} ,
174 { kEventClassControl
, kEventControlVisibilityChanged
} ,
175 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
176 { kEventClassControl
, kEventControlHiliteChanged
} ,
177 { kEventClassControl
, kEventControlSetFocusPart
} ,
179 { kEventClassService
, kEventServiceGetTypes
},
180 { kEventClassService
, kEventServiceCopy
},
181 { kEventClassService
, kEventServicePaste
},
183 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
184 // { kEventClassControl , kEventControlBoundsChanged } ,
188 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
190 OSStatus result
= eventNotHandledErr
;
192 wxMacCarbonEvent
cEvent( event
) ;
194 ControlRef controlRef
;
195 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
197 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
199 switch( GetEventKind( event
) )
201 #if TARGET_API_MAC_OSX
202 case kEventControlDraw
:
204 RgnHandle updateRgn
= NULL
;
205 RgnHandle allocatedRgn
= NULL
;
206 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
207 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
209 updateRgn
= (RgnHandle
) visRegion
.GetWXHRGN() ;
213 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
215 allocatedRgn
= NewRgn() ;
216 CopyRgn( updateRgn
, allocatedRgn
) ;
217 // hide the given region by the new region that must be shifted
218 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
219 updateRgn
= allocatedRgn
;
224 // in case we would need a coregraphics compliant background erase first
225 // now usable to track redraws
226 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
227 if ( thisWindow
->MacIsUserPane() )
229 static float color
= 0.5 ;
232 HIViewGetBounds( controlRef
, &bounds
);
233 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
234 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
235 CGContextFillRect( cgContext
, bounds
);
246 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
249 DisposeRgn( allocatedRgn
) ;
252 case kEventControlVisibilityChanged
:
253 thisWindow
->MacVisibilityChanged() ;
255 case kEventControlEnabledStateChanged
:
256 thisWindow
->MacEnabledStateChanged() ;
258 case kEventControlHiliteChanged
:
259 thisWindow
->MacHiliteChanged() ;
261 case kEventControlSetFocusPart
:
263 Boolean focusEverything
= false ;
264 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
265 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
268 if ( controlPart
== kControlFocusNoPart
)
271 if ( thisWindow
->GetCaret() )
273 thisWindow
->GetCaret()->OnKillFocus();
275 #endif // wxUSE_CARET
276 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
277 event
.SetEventObject(thisWindow
);
278 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
282 // panel wants to track the window which was the last to have focus in it
283 wxChildFocusEvent
eventFocus(thisWindow
);
284 thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
);
287 if ( thisWindow
->GetCaret() )
289 thisWindow
->GetCaret()->OnSetFocus();
291 #endif // wxUSE_CARET
293 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
294 event
.SetEventObject(thisWindow
);
295 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
297 if ( thisWindow
->MacIsUserPane() )
302 case kEventControlHit
:
304 result
= thisWindow
->MacControlHit( handler
, event
) ;
313 static pascal OSStatus
wxMacWindowServiceEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
315 OSStatus result
= eventNotHandledErr
;
317 wxMacCarbonEvent
cEvent( event
) ;
319 ControlRef controlRef
;
320 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
321 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
322 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
324 switch( GetEventKind( event
) )
326 case kEventServiceGetTypes
:
330 textCtrl
->GetSelection( &from
, &to
) ;
332 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
334 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
335 if ( textCtrl
->IsEditable() )
336 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
338 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ };
339 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
341 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
345 CFArrayAppendValue (copyTypes
, typestring
) ;
347 CFArrayAppendValue (pasteTypes
, typestring
) ;
348 CFRelease( typestring
) ;
354 case kEventServiceCopy
:
358 textCtrl
->GetSelection( &from
, &to
) ;
359 wxString val
= textCtrl
->GetValue() ;
360 val
= val
.Mid( from
, to
- from
) ;
361 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
362 verify_noerr( ClearScrap( &scrapRef
) ) ;
363 verify_noerr( PutScrapFlavor( scrapRef
, kTXNTextData
, 0 , val
.Length() , val
.c_str() ) ) ;
367 case kEventServicePaste
:
370 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
371 Size textSize
, pastedSize
;
372 verify_noerr( GetScrapFlavorSize (scrapRef
, kTXNTextData
, &textSize
) ) ;
374 char *content
= new char[textSize
] ;
375 GetScrapFlavorData (scrapRef
, kTXNTextData
, &pastedSize
, content
);
376 content
[textSize
-1] = 0 ;
378 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
380 textCtrl
->WriteText( wxString( content
) ) ;
391 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
393 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
394 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
395 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
396 OSStatus result
= eventNotHandledErr
;
398 switch ( GetEventClass( event
) )
400 case kEventClassControl
:
401 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
403 case kEventClassService
:
404 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
408 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
412 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
414 // ---------------------------------------------------------------------------
415 // UserPane events for non OSX builds
416 // ---------------------------------------------------------------------------
418 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
420 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
421 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
422 win
->MacControlUserPaneDrawProc(part
) ;
425 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
427 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
428 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
429 return win
->MacControlUserPaneHitTestProc(where
.h
, where
.v
) ;
432 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
434 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
435 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
436 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
439 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
441 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
442 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
443 win
->MacControlUserPaneIdleProc() ;
446 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
448 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
449 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
450 return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ;
453 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
455 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
456 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
457 win
->MacControlUserPaneActivateProc(activating
) ;
460 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
462 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
463 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
464 return win
->MacControlUserPaneFocusProc(action
) ;
467 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
469 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
470 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
471 win
->MacControlUserPaneBackgroundProc(info
) ;
474 void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part
)
476 RgnHandle rgn
= NewRgn() ;
478 wxMacWindowStateSaver
sv( this ) ;
479 SectRgn( rgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn
) ;
480 MacDoRedraw( rgn
, 0 ) ;
484 wxInt16
wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
486 return kControlNoPart
;
489 wxInt16
wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
491 return kControlNoPart
;
494 void wxWindowMac::MacControlUserPaneIdleProc()
498 wxInt16
wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
500 return kControlNoPart
;
503 void wxWindowMac::MacControlUserPaneActivateProc(bool activating
)
507 wxInt16
wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action
)
509 return kControlNoPart
;
512 void wxWindowMac::MacControlUserPaneBackgroundProc(void* info
)
516 ControlUserPaneDrawUPP gControlUserPaneDrawUPP
= NULL
;
517 ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP
= NULL
;
518 ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP
= NULL
;
519 ControlUserPaneIdleUPP gControlUserPaneIdleUPP
= NULL
;
520 ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP
= NULL
;
521 ControlUserPaneActivateUPP gControlUserPaneActivateUPP
= NULL
;
522 ControlUserPaneFocusUPP gControlUserPaneFocusUPP
= NULL
;
523 ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP
= NULL
;
525 // ===========================================================================
527 // ===========================================================================
529 wxList
wxWinMacControlList(wxKEY_INTEGER
);
531 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
533 wxNode
*node
= wxWinMacControlList
.Find((long)inControl
);
536 return (wxControl
*)node
->GetData();
539 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
541 // adding NULL ControlRef is (first) surely a result of an error and
542 // (secondly) breaks native event processing
543 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
545 if ( !wxWinMacControlList
.Find((long)inControl
) )
546 wxWinMacControlList
.Append((long)inControl
, control
);
549 void wxRemoveMacControlAssociation(wxWindow
*control
)
551 wxWinMacControlList
.DeleteObject(control
);
555 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
557 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
559 // we have to setup the brush in the current port and return noErr
560 // or return an error code so that the control manager walks further up the
561 // hierarchy to find a correct background
563 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
565 OSStatus status
= paramErr
;
568 case kControlMsgApplyTextColor
:
570 case kControlMsgSetUpBackground
:
572 wxWindow
* wx
= (wxWindow
*) wxFindControlFromMacControl( iControl
) ;
576 const wxBrush &brush = wx->MacGetBackgroundBrush() ;
579 wxDC::MacSetupBackgroundForCurrentPort( brush ) ;
581 // this clipping is only needed for non HIView
583 RgnHandle clip
= NewRgn() ;
586 wx
->MacWindowToRootWindow( &x
,&y
) ;
587 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion().GetWXHRGN() , clip
) ;
588 OffsetRgn( clip
, x
, y
) ;
595 else if ( wx->MacIsUserPane() )
597 // if we don't have a valid brush for such a control, we have to call the
598 // setup of our parent ourselves
599 status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ;
612 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
613 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
617 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
620 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
625 // ----------------------------------------------------------------------------
626 // constructors and such
627 // ----------------------------------------------------------------------------
629 wxWindowMac::wxWindowMac()
634 wxWindowMac::wxWindowMac(wxWindowMac
*parent
,
639 const wxString
& name
)
642 Create(parent
, id
, pos
, size
, style
, name
);
645 void wxWindowMac::Init()
649 #if WXWIN_COMPATIBILITY_2_4
650 m_backgroundTransparent
= FALSE
;
653 // as all windows are created with WS_VISIBLE style...
656 m_hScrollBar
= NULL
;
657 m_vScrollBar
= NULL
;
658 m_macBackgroundBrush
= wxNullBrush
;
660 m_macIsUserPane
= TRUE
;
662 // make sure all proc ptrs are available
664 if ( gControlUserPaneDrawUPP
== NULL
)
666 gControlUserPaneDrawUPP
= NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc
) ;
667 gControlUserPaneHitTestUPP
= NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc
) ;
668 gControlUserPaneTrackingUPP
= NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc
) ;
669 gControlUserPaneIdleUPP
= NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc
) ;
670 gControlUserPaneKeyDownUPP
= NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc
) ;
671 gControlUserPaneActivateUPP
= NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc
) ;
672 gControlUserPaneFocusUPP
= NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc
) ;
673 gControlUserPaneBackgroundUPP
= NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc
) ;
675 if ( wxMacLiveScrollbarActionUPP
== NULL
)
677 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
680 if ( wxMacSetupControlBackgroundUPP
== NULL
)
682 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
685 // we need a valid font for the encodings
686 wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
690 wxWindowMac::~wxWindowMac()
694 m_isBeingDeleted
= TRUE
;
698 // deleting a window while it is shown invalidates the region occupied by border or
700 int outerBorder
= MacGetLeftBorderSize() ;
701 if ( m_peer
->NeedsFocusRect() && m_peer
->HasFocus() )
704 if ( IsShown() && ( outerBorder
> 0 ) )
706 // as the borders are drawn on the parent we have to properly invalidate all these areas
707 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() , updateTotal
= NewRgn() ;
711 m_peer
->GetRect( &rect
) ;
712 RectRgn( updateInner
, &rect
) ;
713 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
714 RectRgn( updateOuter
, &rect
) ;
715 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
717 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
718 parent
-= GetParent()->GetClientAreaOrigin() ;
719 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
720 CopyRgn( updateOuter
, updateTotal
) ;
722 GetParent()->m_peer
->SetNeedsDisplay( true , updateTotal
) ;
723 DisposeRgn(updateOuter
) ;
724 DisposeRgn(updateInner
) ;
725 DisposeRgn(updateTotal
) ;
729 #ifndef __WXUNIVERSAL__
730 // VS: make sure there's no wxFrame with last focus set to us:
731 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
733 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
736 if ( frame
->GetLastFocus() == this )
738 frame
->SetLastFocus((wxWindow
*)NULL
);
743 #endif // __WXUNIVERSAL__
745 // destroy children before destroying this window itself
748 // wxRemoveMacControlAssociation( this ) ;
749 // If we delete an item, we should initialize the parent panel,
750 // because it could now be invalid.
751 wxWindow
*parent
= GetParent() ;
754 if (parent
->GetDefaultItem() == (wxButton
*) this)
755 parent
->SetDefaultItem(NULL
);
757 if ( m_peer
&& m_peer
->Ok() )
759 // in case the callback might be called during destruction
760 wxRemoveMacControlAssociation( this) ;
761 // we currently are not using this hook
762 // ::SetControlColorProc( *m_peer , NULL ) ;
766 if ( g_MacLastWindow
== this )
768 g_MacLastWindow
= NULL
;
771 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame
) ;
774 if ( frame
->GetLastFocus() == this )
775 frame
->SetLastFocus( NULL
) ;
778 // delete our drop target if we've got one
779 #if wxUSE_DRAG_AND_DROP
780 if ( m_dropTarget
!= NULL
)
785 #endif // wxUSE_DRAG_AND_DROP
789 WXWidget
wxWindowMac::GetHandle() const
791 return (WXWidget
) m_peer
->GetControlRef() ;
795 void wxWindowMac::MacInstallEventHandler( WXWidget control
)
797 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
798 InstallControlEventHandler( (ControlRef
) control
, GetwxMacWindowEventHandlerUPP(),
799 GetEventTypeCount(eventList
), eventList
, this,
800 (EventHandlerRef
*)&m_macControlEventHandler
);
805 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
809 const wxString
& name
)
811 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
813 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
816 parent
->AddChild(this);
818 m_windowVariant
= parent
->GetWindowVariant() ;
820 if ( m_macIsUserPane
)
822 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
825 | kControlSupportsEmbedding
826 // | kControlSupportsLiveFeedback
827 // | kControlHasSpecialBackground
828 // | kControlSupportsCalcBestRect
829 // | kControlHandlesTracking
830 | kControlSupportsFocus
831 // | kControlWantsActivate
832 // | kControlWantsIdle
835 m_peer
= new wxMacControl() ;
836 ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
839 MacPostControlCreate(pos
,size
) ;
840 #if !TARGET_API_MAC_OSX
841 m_peer
->SetData
<ControlUserPaneDrawUPP
>(kControlEntireControl
,kControlUserPaneDrawProcTag
,&gControlUserPaneDrawUPP
) ;
842 m_peer
->SetData
<ControlUserPaneHitTestUPP
>(kControlEntireControl
,kControlUserPaneHitTestProcTag
,&gControlUserPaneHitTestUPP
) ;
843 m_peer
->SetData
<ControlUserPaneTrackingUPP
>(kControlEntireControl
,kControlUserPaneTrackingProcTag
,&gControlUserPaneTrackingUPP
) ;
844 m_peer
->SetData
<ControlUserPaneIdleUPP
>(kControlEntireControl
,kControlUserPaneIdleProcTag
,&gControlUserPaneIdleUPP
) ;
845 m_peer
->SetData
<ControlUserPaneKeyDownUPP
>(kControlEntireControl
,kControlUserPaneKeyDownProcTag
,&gControlUserPaneKeyDownUPP
) ;
846 m_peer
->SetData
<ControlUserPaneActivateUPP
>(kControlEntireControl
,kControlUserPaneActivateProcTag
,&gControlUserPaneActivateUPP
) ;
847 m_peer
->SetData
<ControlUserPaneFocusUPP
>(kControlEntireControl
,kControlUserPaneFocusProcTag
,&gControlUserPaneFocusUPP
) ;
848 m_peer
->SetData
<ControlUserPaneBackgroundUPP
>(kControlEntireControl
,kControlUserPaneBackgroundProcTag
,&gControlUserPaneBackgroundUPP
) ;
851 #ifndef __WXUNIVERSAL__
852 // Don't give scrollbars to wxControls unless they ask for them
853 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) ||
854 (IsKindOf(CLASSINFO(wxControl
)) && ( style
& wxHSCROLL
|| style
& wxVSCROLL
)))
856 MacCreateScrollBars( style
) ;
860 wxWindowCreateEvent
event(this);
861 GetEventHandler()->AddPendingEvent(event
);
866 void wxWindowMac::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
)
868 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
870 m_peer
->SetReference( (long) this ) ;
872 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
874 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
875 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
876 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
878 // adjust font, controlsize etc
879 DoSetWindowVariant( m_windowVariant
) ;
881 #if !TARGET_API_MAC_OSX
882 // eventually we can fix some clipping issues be reactivating this hook
883 //if ( m_macIsUserPane )
884 // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
886 m_peer
->SetTitle( wxStripMenuCodes(m_label
) ) ;
888 if (!m_macIsUserPane
)
890 SetInitialBestSize(size
);
893 SetCursor( *wxSTANDARD_CURSOR
) ;
896 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant
)
898 // Don't assert, in case we set the window variant before
899 // the window is created
900 // wxASSERT( m_peer->Ok() ) ;
902 m_windowVariant
= variant
;
904 if (m_peer
== NULL
|| !m_peer
->Ok())
908 ThemeFontID themeFont
= kThemeSystemFont
;
910 // we will get that from the settings later
911 // and make this NORMAL later, but first
912 // we have a few calculations that we must fix
916 case wxWINDOW_VARIANT_NORMAL
:
917 size
= kControlSizeNormal
;
918 themeFont
= kThemeSystemFont
;
920 case wxWINDOW_VARIANT_SMALL
:
921 size
= kControlSizeSmall
;
922 themeFont
= kThemeSmallSystemFont
;
924 case wxWINDOW_VARIANT_MINI
:
925 if (UMAGetSystemVersion() >= 0x1030 )
927 // not always defined in the headers
933 size
= kControlSizeSmall
;
934 themeFont
= kThemeSmallSystemFont
;
937 case wxWINDOW_VARIANT_LARGE
:
938 size
= kControlSizeLarge
;
939 themeFont
= kThemeSystemFont
;
942 wxFAIL_MSG(_T("unexpected window variant"));
945 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
,&size
) ;
948 font
.MacCreateThemeFont( themeFont
) ;
952 void wxWindowMac::MacUpdateControlFont()
954 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
958 bool wxWindowMac::SetFont(const wxFont
& font
)
960 bool retval
= wxWindowBase::SetFont( font
) ;
962 MacUpdateControlFont() ;
967 bool wxWindowMac::SetForegroundColour(const wxColour
& col
)
969 if ( !wxWindowBase::SetForegroundColour(col
) )
972 MacUpdateControlFont() ;
977 bool wxWindowMac::SetBackgroundColour(const wxColour
& col
)
979 if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol
)
983 wxColour
newCol(GetBackgroundColour());
984 if ( newCol
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
986 brush
.MacSetTheme( kThemeBrushDocumentWindowBackground
) ;
988 else if ( newCol
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
990 brush
.MacSetTheme( kThemeBrushDialogBackgroundActive
) ;
994 brush
.SetColour( newCol
) ;
996 MacSetBackgroundBrush( brush
) ;
998 MacUpdateControlFont() ;
1003 void wxWindowMac::MacSetBackgroundBrush( const wxBrush
&brush
)
1005 m_macBackgroundBrush
= brush
;
1006 m_peer
->SetBackground( brush
) ;
1009 bool wxWindowMac::MacCanFocus() const
1011 // there is currently no way to determine whether the window is running in full keyboard
1012 // access mode, therefore we cannot rely on these features, yet the only other way would be
1013 // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
1014 // in event handlers...
1015 UInt32 features
= 0 ;
1016 m_peer
->GetFeatures( & features
) ;
1017 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1021 void wxWindowMac::SetFocus()
1023 if ( AcceptsFocus() )
1026 wxWindow
* former
= FindFocus() ;
1027 if ( former
== this )
1030 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
1031 // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
1032 // leave in case of an error
1033 if ( err
== errCouldntSetFocus
)
1036 #if !TARGET_API_MAC_OSX
1037 // emulate carbon events when running under carbonlib where they are not natively available
1040 EventRef evRef
= NULL
;
1041 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1044 wxMacCarbonEvent
cEvent( evRef
) ;
1045 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) former
->GetHandle() ) ;
1046 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNoPart
) ;
1048 wxMacWindowEventHandler( NULL
, evRef
, former
) ;
1049 ReleaseEvent(evRef
) ;
1051 // send new focus event
1053 EventRef evRef
= NULL
;
1054 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1057 wxMacCarbonEvent
cEvent( evRef
) ;
1058 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) GetHandle() ) ;
1059 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNextPart
) ;
1061 wxMacWindowEventHandler( NULL
, evRef
, this ) ;
1062 ReleaseEvent(evRef
) ;
1069 void wxWindowMac::DoCaptureMouse()
1071 wxTheApp
->s_captureWindow
= this ;
1074 wxWindow
* wxWindowBase::GetCapture()
1076 return wxTheApp
->s_captureWindow
;
1079 void wxWindowMac::DoReleaseMouse()
1081 wxTheApp
->s_captureWindow
= NULL
;
1084 #if wxUSE_DRAG_AND_DROP
1086 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
1088 if ( m_dropTarget
!= 0 ) {
1089 delete m_dropTarget
;
1092 m_dropTarget
= pDropTarget
;
1093 if ( m_dropTarget
!= 0 )
1101 // Old style file-manager drag&drop
1102 void wxWindowMac::DragAcceptFiles(bool accept
)
1107 // Returns the size of the native control. In the case of the toplevel window
1108 // this is the content area root control
1110 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x
, int& y
,
1111 int& w
, int& h
) const
1114 m_peer
->GetRect( &bounds
) ;
1119 w
= bounds
.right
- bounds
.left
;
1120 h
= bounds
.bottom
- bounds
.top
;
1123 // From a wx position / size calculate the appropriate size of the native control
1125 bool wxWindowMac::MacGetBoundsForControl(const wxPoint
& pos
,
1128 int& w
, int& h
, bool adjustOrigin
) const
1130 // the desired size, minus the border pixels gives the correct size of the control
1134 // todo the default calls may be used as soon as PostCreateControl Is moved here
1135 w
= size
.x
; // WidthDefault( size.x );
1136 h
= size
.y
; // HeightDefault( size.y ) ;
1137 #if !TARGET_API_MAC_OSX
1138 GetParent()->MacWindowToRootWindow( &x
, &y
) ;
1141 x
+= MacGetLeftBorderSize() ;
1142 y
+= MacGetTopBorderSize() ;
1143 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1144 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1147 AdjustForParentClientOrigin( x
, y
) ;
1148 #if TARGET_API_MAC_OSX
1149 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1150 if ( ! GetParent()->IsTopLevel() )
1152 x
-= GetParent()->MacGetLeftBorderSize() ;
1153 y
-= GetParent()->MacGetTopBorderSize() ;
1159 // Get window size (not client size)
1160 void wxWindowMac::DoGetSize(int *x
, int *y
) const
1162 // take the size of the control and add the borders that have to be drawn outside
1163 int x1
, y1
, w1
, h1
;
1165 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1167 w1
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1168 h1
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1174 // get the position of the bounds of this window in client coordinates of its parent
1175 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
1177 int x1
, y1
, w1
,h1
;
1178 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1179 x1
-= MacGetLeftBorderSize() ;
1180 y1
-= MacGetTopBorderSize() ;
1182 #if !TARGET_API_MAC_OSX
1183 if ( !GetParent()->IsTopLevel() )
1186 GetControlBounds( (ControlRef
) GetParent()->GetHandle() , &bounds
) ;
1191 if ( !IsTopLevel() )
1193 wxWindow
*parent
= GetParent();
1196 // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix
1197 x1
+= parent
->MacGetLeftBorderSize() ;
1198 y1
+= parent
->MacGetTopBorderSize() ;
1199 // and now to client coordinates
1200 wxPoint
pt(parent
->GetClientAreaOrigin());
1209 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
1211 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1213 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1216 Point localwhere
= {0,0} ;
1218 if(x
) localwhere
.h
= * x
;
1219 if(y
) localwhere
.v
= * y
;
1221 QDGlobalToLocalPoint( GetWindowPort( window
) , &localwhere
) ;
1222 if(x
) *x
= localwhere
.h
;
1223 if(y
) *y
= localwhere
.v
;
1226 MacRootWindowToWindow( x
, y
) ;
1228 wxPoint origin
= GetClientAreaOrigin() ;
1229 if(x
) *x
-= origin
.x
;
1230 if(y
) *y
-= origin
.y
;
1233 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
1235 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1236 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1238 wxPoint origin
= GetClientAreaOrigin() ;
1239 if(x
) *x
+= origin
.x
;
1240 if(y
) *y
+= origin
.y
;
1242 MacWindowToRootWindow( x
, y
) ;
1245 Point localwhere
= { 0,0 };
1246 if(x
) localwhere
.h
= * x
;
1247 if(y
) localwhere
.v
= * y
;
1248 QDLocalToGlobalPoint( GetWindowPort( window
) , &localwhere
) ;
1249 if(x
) *x
= localwhere
.h
;
1250 if(y
) *y
= localwhere
.v
;
1254 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
1256 wxPoint origin
= GetClientAreaOrigin() ;
1257 if(x
) *x
+= origin
.x
;
1258 if(y
) *y
+= origin
.y
;
1260 MacWindowToRootWindow( x
, y
) ;
1263 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
1265 MacRootWindowToWindow( x
, y
) ;
1267 wxPoint origin
= GetClientAreaOrigin() ;
1268 if(x
) *x
-= origin
.x
;
1269 if(y
) *y
-= origin
.y
;
1272 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
1274 #if TARGET_API_MAC_OSX
1276 if ( x
) pt
.x
= *x
;
1277 if ( y
) pt
.y
= *y
;
1279 if ( !IsTopLevel() )
1281 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1284 pt
.x
-= MacGetLeftBorderSize() ;
1285 pt
.y
-= MacGetTopBorderSize() ;
1286 wxMacControl::Convert( &pt
, m_peer
, top
->m_peer
) ;
1290 if ( x
) *x
= (int) pt
.x
;
1291 if ( y
) *y
= (int) pt
.y
;
1293 if ( !IsTopLevel() )
1296 m_peer
->GetRect( &bounds
) ;
1297 if(x
) *x
+= bounds
.left
- MacGetLeftBorderSize() ;
1298 if(y
) *y
+= bounds
.top
- MacGetTopBorderSize() ;
1303 void wxWindowMac::MacWindowToRootWindow( short *x
, short *y
) const
1308 MacWindowToRootWindow( &x1
, &y1
) ;
1313 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
1315 #if TARGET_API_MAC_OSX
1317 if ( x
) pt
.x
= *x
;
1318 if ( y
) pt
.y
= *y
;
1320 if ( !IsTopLevel() )
1322 wxMacControl::Convert( &pt
, MacGetTopLevelWindow()->m_peer
, m_peer
) ;
1323 pt
.x
+= MacGetLeftBorderSize() ;
1324 pt
.y
+= MacGetTopBorderSize() ;
1327 if ( x
) *x
= (int) pt
.x
;
1328 if ( y
) *y
= (int) pt
.y
;
1330 if ( !IsTopLevel() )
1333 m_peer
->GetRect( &bounds
) ;
1334 if(x
) *x
-= bounds
.left
+ MacGetLeftBorderSize() ;
1335 if(y
) *y
-= bounds
.top
+ MacGetTopBorderSize() ;
1340 void wxWindowMac::MacRootWindowToWindow( short *x
, short *y
) const
1345 MacRootWindowToWindow( &x1
, &y1
) ;
1350 void wxWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1352 RgnHandle rgn
= NewRgn() ;
1354 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1356 GetRegionBounds( rgn
, &content
) ;
1361 m_peer
->GetRect( &content
) ;
1364 m_peer
->GetRect( &structure
) ;
1365 #if !TARGET_API_MAC_OSX
1366 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1368 left
= content
.left
- structure
.left
;
1369 top
= content
.top
- structure
.top
;
1370 right
= structure
.right
- content
.right
;
1371 bottom
= structure
.bottom
- content
.bottom
;
1374 wxSize
wxWindowMac::DoGetSizeFromClientSize( const wxSize
& size
) const
1376 wxSize sizeTotal
= size
;
1378 RgnHandle rgn
= NewRgn() ;
1382 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1384 GetRegionBounds( rgn
, &content
) ;
1389 m_peer
->GetRect( &content
) ;
1392 m_peer
->GetRect( &structure
) ;
1393 #if !TARGET_API_MAC_OSX
1394 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1397 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1398 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1400 sizeTotal
.x
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1401 sizeTotal
.y
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1407 // Get size *available for subwindows* i.e. excluding menu bar etc.
1408 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
1412 RgnHandle rgn
= NewRgn() ;
1414 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1416 GetRegionBounds( rgn
, &content
) ;
1421 m_peer
->GetRect( &content
) ;
1423 #if !TARGET_API_MAC_OSX
1425 m_peer
->GetRect( &structure
) ;
1426 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1428 ww
= content
.right
- content
.left
;
1429 hh
= content
.bottom
- content
.top
;
1431 ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1432 hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
1435 if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
1441 GetSize( &w , &h ) ;
1443 MacClientToRootWindow( &x1 , &y1 ) ;
1444 MacClientToRootWindow( &w , &h ) ;
1446 wxWindowMac *iter = (wxWindowMac*)this ;
1448 int totW = 10000 , totH = 10000;
1451 if ( iter->IsTopLevel() )
1453 iter->GetSize( &totW , &totH ) ;
1457 iter = iter->GetParent() ;
1460 if (m_hScrollBar && m_hScrollBar->IsShown() )
1462 hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
1468 if (m_vScrollBar && m_vScrollBar->IsShown() )
1470 ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
1478 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1480 hh
-= m_hScrollBar
->GetSize().y
; // MAC_SCROLLBAR_SIZE ;
1482 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1484 ww
-= m_vScrollBar
->GetSize().x
; // MAC_SCROLLBAR_SIZE;
1491 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
1493 if (m_cursor
== cursor
)
1496 if (wxNullCursor
== cursor
)
1498 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
1503 if ( ! wxWindowBase::SetCursor( cursor
) )
1507 wxASSERT_MSG( m_cursor
.Ok(),
1508 wxT("cursor must be valid after call to the base version"));
1511 wxWindowMac
*mouseWin
= 0 ;
1513 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1515 Boolean swapped
= QDSwapPort( GetWindowPort( window
) , &savePort
) ;
1517 // TODO If we ever get a GetCurrentEvent.. replacement for the mouse
1518 // position, use it...
1522 ControlPartCode part
;
1523 ControlRef control
;
1524 control
= wxMacFindControlUnderMouse( pt
, window
, &part
) ;
1526 mouseWin
= wxFindControlFromMacControl( control
) ;
1529 QDSwapPort( savePort
, NULL
) ;
1532 if ( mouseWin
== this && !wxIsBusy() )
1534 m_cursor
.MacInstall() ;
1541 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1543 menu
->SetInvokingWindow(this);
1546 if ( x
== -1 && y
== -1 )
1548 wxPoint mouse
= wxGetMousePosition();
1549 x
= mouse
.x
; y
= mouse
.y
;
1553 ClientToScreen( &x
, &y
) ;
1556 menu
->MacBeforeDisplay( true ) ;
1557 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
1558 if ( HiWord(menuResult
) != 0 )
1561 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id
) ;
1562 wxMenuItem
* item
= NULL
;
1564 item
= menu
->FindItem(id
, &realmenu
) ;
1565 if (item
->IsCheckable())
1567 item
->Check( !item
->IsChecked() ) ;
1569 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1571 menu
->MacAfterDisplay( true ) ;
1573 menu
->SetInvokingWindow(NULL
);
1579 // ----------------------------------------------------------------------------
1581 // ----------------------------------------------------------------------------
1585 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
1587 wxWindowBase::DoSetToolTip(tooltip
);
1590 m_tooltip
->SetWindow(this);
1593 #endif // wxUSE_TOOLTIPS
1595 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1597 // this is never called for a toplevel window, so we know we have a parent
1598 int former_x
, former_y
, former_w
, former_h
;
1600 // Get true coordinates of former position
1601 DoGetPosition( &former_x
, &former_y
) ;
1602 DoGetSize( &former_w
, &former_h
) ;
1604 wxWindow
*parent
= GetParent();
1607 wxPoint
pt(parent
->GetClientAreaOrigin());
1612 int actualWidth
= width
;
1613 int actualHeight
= height
;
1617 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1618 actualWidth
= m_minWidth
;
1619 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1620 actualHeight
= m_minHeight
;
1621 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1622 actualWidth
= m_maxWidth
;
1623 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1624 actualHeight
= m_maxHeight
;
1626 bool doMove
= false ;
1627 bool doResize
= false ;
1629 if ( actualX
!= former_x
|| actualY
!= former_y
)
1633 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1638 if ( doMove
|| doResize
)
1640 // we don't adjust twice for the origin
1641 Rect r
= wxMacGetBoundsForControl(this , wxPoint( actualX
,actualY
), wxSize( actualWidth
, actualHeight
) , false ) ;
1642 bool vis
= m_peer
->IsVisible();
1644 int outerBorder
= MacGetLeftBorderSize() ;
1645 if ( m_peer
->NeedsFocusRect() && m_peer
->HasFocus() )
1648 if ( vis
&& ( outerBorder
> 0 ) )
1650 // as the borders are drawn on the parent we have to properly invalidate all these areas
1651 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() , updateTotal
= NewRgn() ;
1655 m_peer
->GetRect( &rect
) ;
1656 RectRgn( updateInner
, &rect
) ;
1657 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1658 RectRgn( updateOuter
, &rect
) ;
1659 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
1660 wxPoint
parent(0,0);
1661 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
1662 parent
-= GetParent()->GetClientAreaOrigin() ;
1663 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
1664 CopyRgn( updateOuter
, updateTotal
) ;
1667 RectRgn( updateInner
, &rect
) ;
1668 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1669 RectRgn( updateOuter
, &rect
) ;
1670 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
1672 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
1673 UnionRgn( updateOuter
, updateTotal
, updateTotal
) ;
1675 GetParent()->m_peer
->SetNeedsDisplay( true , updateTotal
) ;
1676 DisposeRgn(updateOuter
) ;
1677 DisposeRgn(updateInner
) ;
1678 DisposeRgn(updateTotal
) ;
1681 // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
1683 m_peer
->SetVisibility( false , true ) ;
1685 m_peer
->SetRect( &r
) ;
1687 m_peer
->SetVisibility( true , true ) ;
1689 MacRepositionScrollBars() ;
1692 wxPoint
point(actualX
,actualY
);
1693 wxMoveEvent
event(point
, m_windowId
);
1694 event
.SetEventObject(this);
1695 GetEventHandler()->ProcessEvent(event
) ;
1699 MacRepositionScrollBars() ;
1700 wxSize
size(actualWidth
, actualHeight
);
1701 wxSizeEvent
event(size
, m_windowId
);
1702 event
.SetEventObject(this);
1703 GetEventHandler()->ProcessEvent(event
);
1709 wxSize
wxWindowMac::DoGetBestSize() const
1711 if ( m_macIsUserPane
|| IsTopLevel() )
1712 return wxWindowBase::DoGetBestSize() ;
1714 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1715 int bestWidth
, bestHeight
;
1716 m_peer
->GetBestRect( &bestsize
) ;
1718 if ( EmptyRect( &bestsize
) )
1720 bestsize
.left
= bestsize
.top
= 0 ;
1721 bestsize
.right
= 16 ;
1722 bestsize
.bottom
= 16 ;
1723 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1725 bestsize
.bottom
= 16 ;
1727 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1729 bestsize
.bottom
= 24 ;
1733 // return wxWindowBase::DoGetBestSize() ;
1737 bestWidth
= bestsize
.right
- bestsize
.left
;
1738 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1739 if ( bestHeight
< 10 )
1742 return wxSize(bestWidth
, bestHeight
);
1746 // set the size of the window: if the dimensions are positive, just use them,
1747 // but if any of them is equal to -1, it means that we must find the value for
1748 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1749 // which case -1 is a valid value for x and y)
1751 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1752 // the width/height to best suit our contents, otherwise we reuse the current
1754 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1756 // get the current size and position...
1757 int currentX
, currentY
;
1758 GetPosition(¤tX
, ¤tY
);
1760 int currentW
,currentH
;
1761 GetSize(¤tW
, ¤tH
);
1763 // ... and don't do anything (avoiding flicker) if it's already ok
1764 if ( x
== currentX
&& y
== currentY
&&
1765 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1768 MacRepositionScrollBars() ; // we might have a real position shift
1772 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1774 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1777 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
1779 wxSize
size(-1, -1);
1782 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1784 size
= DoGetBestSize();
1789 // just take the current one
1796 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1800 size
= DoGetBestSize();
1802 //else: already called DoGetBestSize() above
1808 // just take the current one
1813 DoMoveWindow(x
, y
, width
, height
);
1817 wxPoint
wxWindowMac::GetClientAreaOrigin() const
1819 RgnHandle rgn
= NewRgn() ;
1821 m_peer
->GetRegion( kControlContentMetaPart
, rgn
) ;
1822 GetRegionBounds( rgn
, &content
) ;
1824 #if !TARGET_API_MAC_OSX
1825 // if the content rgn is empty / not supported
1826 // don't attempt to correct the coordinates to wxWindow relative ones
1827 if (!::EmptyRect( &content
) )
1830 m_peer
->GetRect( &structure
) ;
1831 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1835 return wxPoint( content
.left
+ MacGetLeftBorderSize( ) , content
.top
+ MacGetTopBorderSize( ) );
1838 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
)
1840 if ( clientheight
!= -1 || clientheight
!= -1 )
1842 int currentclientwidth
, currentclientheight
;
1843 int currentwidth
, currentheight
;
1845 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1846 GetSize( ¤twidth
, ¤theight
) ;
1848 DoSetSize( -1 , -1 , currentwidth
+ clientwidth
- currentclientwidth
,
1849 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1853 void wxWindowMac::SetTitle(const wxString
& title
)
1855 m_label
= wxStripMenuCodes(title
) ;
1857 if ( m_peer
&& m_peer
->Ok() )
1859 m_peer
->SetTitle( m_label
) ;
1864 wxString
wxWindowMac::GetTitle() const
1869 bool wxWindowMac::Show(bool show
)
1871 if ( !wxWindowBase::Show(show
) )
1874 // TODO use visibilityChanged Carbon Event for OSX
1875 bool former
= MacIsReallyShown() ;
1877 m_peer
->SetVisibility( show
, true ) ;
1878 if ( former
!= MacIsReallyShown() )
1879 MacPropagateVisibilityChanged() ;
1883 bool wxWindowMac::Enable(bool enable
)
1885 wxASSERT( m_peer
->Ok() ) ;
1886 if ( !wxWindowBase::Enable(enable
) )
1889 bool former
= MacIsReallyEnabled() ;
1890 m_peer
->Enable( enable
) ;
1892 if ( former
!= MacIsReallyEnabled() )
1893 MacPropagateEnabledStateChanged() ;
1898 // status change propagations (will be not necessary for OSX later )
1901 void wxWindowMac::MacPropagateVisibilityChanged()
1903 #if !TARGET_API_MAC_OSX
1904 MacVisibilityChanged() ;
1906 wxWindowListNode
*node
= GetChildren().GetFirst();
1909 wxWindowMac
*child
= node
->GetData();
1910 if ( child
->IsShown() )
1911 child
->MacPropagateVisibilityChanged( ) ;
1912 node
= node
->GetNext();
1917 void wxWindowMac::MacPropagateEnabledStateChanged( )
1919 #if !TARGET_API_MAC_OSX
1920 MacEnabledStateChanged() ;
1922 wxWindowListNode
*node
= GetChildren().GetFirst();
1925 wxWindowMac
*child
= node
->GetData();
1926 if ( child
->IsEnabled() )
1927 child
->MacPropagateEnabledStateChanged() ;
1928 node
= node
->GetNext();
1933 void wxWindowMac::MacPropagateHiliteChanged( )
1935 #if !TARGET_API_MAC_OSX
1936 MacHiliteChanged() ;
1938 wxWindowListNode
*node
= GetChildren().GetFirst();
1941 wxWindowMac
*child
= node
->GetData();
1942 // if ( child->IsEnabled() )
1943 child
->MacPropagateHiliteChanged() ;
1944 node
= node
->GetNext();
1950 // status change notifications
1953 void wxWindowMac::MacVisibilityChanged()
1957 void wxWindowMac::MacHiliteChanged()
1961 void wxWindowMac::MacEnabledStateChanged()
1966 // status queries on the inherited window's state
1969 bool wxWindowMac::MacIsReallyShown()
1971 // only under OSX the visibility of the TLW is taken into account
1972 #if TARGET_API_MAC_OSX
1973 if ( m_peer
&& m_peer
->Ok() )
1974 return m_peer
->IsVisible();
1976 wxWindow
* win
= this ;
1977 while( win
->IsShown() )
1979 if ( win
->IsTopLevel() )
1982 win
= win
->GetParent() ;
1990 bool wxWindowMac::MacIsReallyEnabled()
1992 return m_peer
->IsEnabled() ;
1995 bool wxWindowMac::MacIsReallyHilited()
1997 return m_peer
->IsActive();
2000 void wxWindowMac::MacFlashInvalidAreas()
2002 #if TARGET_API_MAC_OSX
2003 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
2011 int wxWindowMac::GetCharHeight() const
2013 wxClientDC
dc ( (wxWindowMac
*)this ) ;
2014 return dc
.GetCharHeight() ;
2017 int wxWindowMac::GetCharWidth() const
2019 wxClientDC
dc ( (wxWindowMac
*)this ) ;
2020 return dc
.GetCharWidth() ;
2023 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
2024 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
2026 const wxFont
*fontToUse
= theFont
;
2028 fontToUse
= &m_font
;
2030 wxClientDC
dc( (wxWindowMac
*) this ) ;
2032 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
2033 if ( externalLeading
)
2034 *externalLeading
= le
;
2044 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
2045 * we always intersect with the entire window, not only with the client area
2048 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
2050 if ( m_peer
== NULL
)
2053 #if TARGET_API_MAC_OSX
2055 m_peer
->SetNeedsDisplay( true ) ;
2058 RgnHandle update
= NewRgn() ;
2059 SetRectRgn( update
, rect
->x
, rect
->y
, rect
->x
+ rect
->width
, rect
->y
+ rect
->height
) ;
2060 SectRgn( (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , update
, update
) ;
2061 wxPoint origin
= GetClientAreaOrigin() ;
2062 OffsetRgn( update
, origin
.x
, origin
.y
) ;
2063 // right now this is wx' window coordinates, as our native peer does not have borders, this is
2065 OffsetRgn( update
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2066 m_peer
->SetNeedsDisplay( true , update
) ;
2067 DisposeRgn( update
) ;
2071 RgnHandle updateRgn = NewRgn() ;
2074 CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
2078 SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
2079 SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
2081 InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
2082 DisposeRgn(updateRgn) ;
2084 if ( m_peer
->IsVisible())
2086 m_peer
->SetVisibility( false , false ) ;
2087 m_peer
->SetVisibility( true , true ) ;
2090 if ( MacGetTopLevelWindow() == NULL )
2093 if ( !m_peer->IsVisible())
2096 wxPoint client = GetClientAreaOrigin();
2099 int x2 = m_width - client.x;
2100 int y2 = m_height - client.y;
2102 if (IsKindOf( CLASSINFO(wxButton)))
2104 // buttons have an "aura"
2111 Rect clientrect = { y1, x1, y2, x2 };
2115 Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
2116 SectRect( &clientrect , &r , &clientrect ) ;
2119 if ( !EmptyRect( &clientrect ) )
2121 int top = 0 , left = 0 ;
2123 MacClientToRootWindow( &left , &top ) ;
2124 OffsetRect( &clientrect , left , top ) ;
2126 MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
2132 void wxWindowMac::Freeze()
2134 #if TARGET_API_MAC_OSX
2135 if ( !m_frozenness
++ )
2137 if ( m_peer
&& m_peer
->Ok() )
2138 m_peer
->SetDrawingEnabled( false ) ;
2144 void wxWindowMac::Thaw()
2146 #if TARGET_API_MAC_OSX
2147 wxASSERT_MSG( m_frozenness
> 0, _T("Thaw() without matching Freeze()") );
2149 if ( !--m_frozenness
)
2151 if ( m_peer
&& m_peer
->Ok() )
2153 m_peer
->SetDrawingEnabled( true ) ;
2154 m_peer
->InvalidateWithChildren() ;
2160 void wxWindowMac::MacRedrawControl()
2163 if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
2165 #if TARGET_API_MAC_CARBON
2168 wxClientDC dc(this) ;
2169 wxMacPortSetter helper(&dc) ;
2170 wxMacWindowClipper clipper(this) ;
2171 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
2172 UMADrawControl( *m_peer ) ;
2179 void wxWindowMac::OnPaint(wxPaintEvent& event)
2181 // why don't we skip that here ?
2185 wxWindowMac
*wxGetActiveWindow()
2187 // actually this is a windows-only concept
2191 // Coordinates relative to the window
2192 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
2194 // We really don't move the mouse programmatically under Mac.
2197 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
2199 #if TARGET_API_MAC_OSX
2200 if ( m_macBackgroundBrush
.Ok() == false || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT
)
2207 event
.GetDC()->Clear() ;
2211 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
2216 int wxWindowMac::GetScrollPos(int orient
) const
2218 if ( orient
== wxHORIZONTAL
)
2221 return m_hScrollBar
->GetThumbPosition() ;
2226 return m_vScrollBar
->GetThumbPosition() ;
2231 // This now returns the whole range, not just the number
2232 // of positions that we can scroll.
2233 int wxWindowMac::GetScrollRange(int orient
) const
2235 if ( orient
== wxHORIZONTAL
)
2238 return m_hScrollBar
->GetRange() ;
2243 return m_vScrollBar
->GetRange() ;
2248 int wxWindowMac::GetScrollThumb(int orient
) const
2250 if ( orient
== wxHORIZONTAL
)
2253 return m_hScrollBar
->GetThumbSize() ;
2258 return m_vScrollBar
->GetThumbSize() ;
2263 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
2265 if ( orient
== wxHORIZONTAL
)
2268 m_hScrollBar
->SetThumbPosition( pos
) ;
2273 m_vScrollBar
->SetThumbPosition( pos
) ;
2277 void wxWindowMac::MacPaintBorders( int left
, int top
)
2283 m_peer
->GetRect( &rect
) ;
2284 InsetRect( &rect
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2286 if ( !IsTopLevel() )
2288 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2292 wxMacControl::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2294 rect
.right
+= pt
.x
;
2296 rect
.bottom
+= pt
.y
;
2300 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2304 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
2305 InsetRect( &srect
, border
, border
);
2306 DrawThemeEditTextFrame(&srect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2308 else if (HasFlag(wxSIMPLE_BORDER
))
2312 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
2313 InsetRect( &srect
, border
, border
);
2314 DrawThemeListBoxFrame(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2318 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
2320 if ( child
== m_hScrollBar
)
2321 m_hScrollBar
= NULL
;
2322 if ( child
== m_vScrollBar
)
2323 m_vScrollBar
= NULL
;
2325 wxWindowBase::RemoveChild( child
) ;
2328 // New function that will replace some of the above.
2329 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2330 int range
, bool refresh
)
2332 if ( orient
== wxHORIZONTAL
)
2336 if ( range
== 0 || thumbVisible
>= range
)
2338 if ( m_hScrollBar
->IsShown() )
2339 m_hScrollBar
->Show(false) ;
2343 if ( !m_hScrollBar
->IsShown() )
2344 m_hScrollBar
->Show(true) ;
2345 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2353 if ( range
== 0 || thumbVisible
>= range
)
2355 if ( m_vScrollBar
->IsShown() )
2356 m_vScrollBar
->Show(false) ;
2360 if ( !m_vScrollBar
->IsShown() )
2361 m_vScrollBar
->Show(true) ;
2362 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2366 MacRepositionScrollBars() ;
2369 // Does a physical scroll
2370 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2372 if( dx
== 0 && dy
==0 )
2378 int width
, height
;
2379 GetClientSize( &width
, &height
) ;
2380 #if TARGET_API_MAC_OSX
2381 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2382 // area is scrolled, this does not occur if width and height are 2 pixels less,
2383 // TODO write optimal workaround
2384 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2387 scrollrect
.Intersect( *rect
) ;
2389 if ( m_peer
->GetNeedsDisplay() )
2391 // becuase HIViewScrollRect does not scroll the already invalidated area we have two options
2392 // either immediate redraw or full invalidate
2394 // is the better overall solution, as it does not slow down scrolling
2395 m_peer
->SetNeedsDisplay( true ) ;
2397 // this would be the preferred version for fast drawing controls
2398 if( UMAGetSystemVersion() < 0x1030 )
2401 HIViewRender(m_peer
->GetControlRef()) ;
2404 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2405 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2406 m_peer
->ScrollRect( scrollrect
, dx
, dy
) ;
2413 RgnHandle updateRgn
= NewRgn() ;
2416 wxClientDC
dc(this) ;
2417 wxMacPortSetter
helper(&dc
) ;
2419 m_peer
->GetRect( &scrollrect
) ;
2420 scrollrect
.top
+= MacGetTopBorderSize() ;
2421 scrollrect
.left
+= MacGetLeftBorderSize() ;
2422 scrollrect
.bottom
= scrollrect
.top
+ height
;
2423 scrollrect
.right
= scrollrect
.left
+ width
;
2427 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
2428 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
2429 SectRect( &scrollrect
, &r
, &scrollrect
) ;
2431 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
2433 // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
2437 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2439 wxWindowMac
*child
= node
->GetData();
2440 if (child
== m_vScrollBar
) continue;
2441 if (child
== m_hScrollBar
) continue;
2442 if (child
->IsTopLevel()) continue;
2445 child
->GetPosition( &x
, &y
);
2447 child
->GetSize( &w
, &h
);
2451 if (rect
->Intersects(rc
))
2452 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2456 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2461 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
2463 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
2465 wxScrollWinEvent wevent
;
2466 wevent
.SetPosition(event
.GetPosition());
2467 wevent
.SetOrientation(event
.GetOrientation());
2468 wevent
.m_eventObject
= this;
2470 if (event
.m_eventType
== wxEVT_SCROLL_TOP
)
2471 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
2472 else if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
)
2473 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2474 else if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
)
2475 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
2476 else if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
)
2477 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
2478 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
)
2479 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2480 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
)
2481 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2482 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
)
2483 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2484 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBRELEASE
)
2485 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2487 GetEventHandler()->ProcessEvent(wevent
);
2491 // Get the window with the focus
2492 wxWindowMac
*wxWindowBase::FindFocus()
2494 ControlRef control
;
2495 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2496 return wxFindControlFromMacControl( control
) ;
2499 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
2501 // panel wants to track the window which was the last to have focus in it,
2502 // so we want to set ourselves as the window which last had focus
2504 // notice that it's also important to do it upwards the tree becaus
2505 // otherwise when the top level panel gets focus, it won't set it back to
2506 // us, but to some other sibling
2508 // CS:don't know if this is still needed:
2509 //wxChildFocusEvent eventFocus(this);
2510 //(void)GetEventHandler()->ProcessEvent(eventFocus);
2512 if ( MacGetTopLevelWindow() && m_peer
->NeedsFocusRect() )
2514 wxMacWindowStateSaver
sv( this ) ;
2519 MacWindowToRootWindow( &x
, &y
) ;
2520 GetSize( &w
, &h
) ;
2521 Rect rect
= {y
, x
, h
+ y
, w
+ x
} ;
2523 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
2524 DrawThemeFocusRect( &rect
, true ) ;
2527 DrawThemeFocusRect( &rect
, false ) ;
2529 // as this erases part of the frame we have to redraw borders
2530 // and because our z-ordering is not always correct (staticboxes)
2531 // we have to invalidate things, we cannot simple redraw
2532 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() ;
2533 RectRgn( updateInner
, &rect
) ;
2534 InsetRect( &rect
, -4 , -4 ) ;
2535 RectRgn( updateOuter
, &rect
) ;
2536 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
2537 wxPoint
parent(0,0);
2538 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
2539 parent
-= GetParent()->GetClientAreaOrigin() ;
2540 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
2541 GetParent()->m_peer
->SetNeedsDisplay( true , updateOuter
) ;
2542 DisposeRgn(updateOuter
) ;
2543 DisposeRgn(updateInner
) ;
2550 void wxWindowMac::OnInternalIdle()
2552 // This calls the UI-update mechanism (querying windows for
2553 // menu/toolbar/control state information)
2554 if (wxUpdateUIEvent::CanUpdate(this))
2555 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2558 // Raise the window to the top of the Z order
2559 void wxWindowMac::Raise()
2561 m_peer
->SetZOrder( true , NULL
) ;
2564 // Lower the window to the bottom of the Z order
2565 void wxWindowMac::Lower()
2567 m_peer
->SetZOrder( false , NULL
) ;
2571 // static wxWindow *gs_lastWhich = NULL;
2573 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
)
2575 // first trigger a set cursor event
2577 wxPoint clientorigin
= GetClientAreaOrigin() ;
2578 wxSize clientsize
= GetClientSize() ;
2580 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2582 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2584 bool processedEvtSetCursor
= GetEventHandler()->ProcessEvent(event
);
2585 if ( processedEvtSetCursor
&& event
.HasCursor() )
2587 cursor
= event
.GetCursor() ;
2592 // the test for processedEvtSetCursor is here to prevent using m_cursor
2593 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2594 // it - this is a way to say that our cursor shouldn't be used for this
2596 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2606 cursor
= *wxSTANDARD_CURSOR
;
2610 cursor
.MacInstall() ;
2612 return cursor
.Ok() ;
2615 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
2619 return m_tooltip
->GetTip() ;
2621 return wxEmptyString
;
2624 void wxWindowMac::Update()
2626 #if TARGET_API_MAC_OSX
2628 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2629 WindowRef window
= (WindowRef
)MacGetTopLevelWindowRef() ;
2631 // for composited windows this also triggers a redraw of all
2632 // invalid views in the window
2633 if( UMAGetSystemVersion() >= 0x1030 )
2634 HIWindowFlush(window
) ;
2638 // the only way to trigger the redrawing on earlier systems is to call
2641 EventRef currentEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
2642 UInt32 currentEventClass
= 0 ;
2643 UInt32 currentEventKind
= 0 ;
2644 if ( currentEvent
!= NULL
)
2646 currentEventClass
= ::GetEventClass( currentEvent
) ;
2647 currentEventKind
= ::GetEventKind( currentEvent
) ;
2649 if ( currentEventClass
!= kEventClassMenu
)
2651 // when tracking a menu, strange redraw errors occur if we flush now, so leave..
2654 OSStatus status
= noErr
;
2655 status
= ReceiveNextEvent( 0 , NULL
, kEventDurationNoWait
, false , &theEvent
) ;
2658 m_peer
->SetNeedsDisplay( true ) ;
2661 ::Draw1Control( m_peer
->GetControlRef() ) ;
2665 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
2667 wxTopLevelWindowMac
* win
= NULL
;
2668 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2671 win
= wxFindWinFromMacWindow( window
) ;
2675 wxRegion
wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures
)
2677 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2678 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2679 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2680 // to add focus borders everywhere
2683 RgnHandle visRgn
= NewRgn() ;
2684 RgnHandle tempRgn
= NewRgn() ;
2685 if ( m_peer
->IsVisible())
2687 m_peer
->GetRect( &r
) ;
2688 r
.left
-= MacGetLeftBorderSize() ;
2689 r
.top
-= MacGetTopBorderSize() ;
2690 r
.bottom
+= MacGetBottomBorderSize() ;
2691 r
.right
+= MacGetRightBorderSize() ;
2693 if (! MacGetTopLevelWindow()->MacUsesCompositing() )
2695 MacRootWindowToWindow( &r
.left
, & r
.top
) ;
2696 MacRootWindowToWindow( &r
.right
, & r
.bottom
) ;
2705 if ( includeOuterStructures
)
2706 InsetRect( &r
, -4 , -4 ) ;
2707 RectRgn( visRgn
, &r
) ;
2709 if ( !IsTopLevel() )
2711 wxWindow
* child
= this ;
2712 wxWindow
* parent
= child
->GetParent() ;
2717 // we have to find a better clipping algorithm here, in order not to clip things
2718 // positioned like status and toolbar
2719 if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
2721 size
= parent
->GetSize() ;
2726 size
= parent
->GetClientSize() ;
2727 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2731 parent
->MacWindowToRootWindow( &x
, &y
) ;
2732 MacRootWindowToWindow( &x
, &y
) ;
2734 if ( !includeOuterStructures
|| (
2735 parent
->IsKindOf( CLASSINFO( wxScrolledWindow
) ) ||
2736 parent
->IsKindOf( CLASSINFO( wxSashLayoutWindow
) ) ||
2737 ( parent
->GetParent() && parent
->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow
) ) )
2740 SetRectRgn( tempRgn
,
2741 x
+ parent
->MacGetLeftBorderSize() , y
+ parent
->MacGetTopBorderSize() ,
2742 x
+ size
.x
- parent
->MacGetRightBorderSize(),
2743 y
+ size
.y
- parent
->MacGetBottomBorderSize()) ;
2745 SectRgn( visRgn
, tempRgn
, visRgn
) ;
2747 if ( parent
->IsTopLevel() )
2750 parent
= child
->GetParent() ;
2755 wxRegion vis
= visRgn
;
2756 DisposeRgn( visRgn
) ;
2757 DisposeRgn( tempRgn
) ;
2762 This function must not change the updatergn !
2764 bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr
, long time
)
2766 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2767 bool handled
= false ;
2769 GetRegionBounds( updatergn
, &updatebounds
) ;
2770 // wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
2771 if ( !EmptyRgn(updatergn
) )
2773 RgnHandle newupdate
= NewRgn() ;
2774 wxSize point
= GetClientSize() ;
2775 wxPoint origin
= GetClientAreaOrigin() ;
2776 SetRectRgn( newupdate
, origin
.x
, origin
.y
, origin
.x
+ point
.x
, origin
.y
+point
.y
) ;
2777 SectRgn( newupdate
, updatergn
, newupdate
) ;
2779 // first send an erase event to the entire update area
2781 wxWindowDC
dc(this);
2782 dc
.SetClippingRegion(wxRegion(updatergn
));
2783 wxEraseEvent
eevent( GetId(), &dc
);
2784 eevent
.SetEventObject( this );
2785 GetEventHandler()->ProcessEvent( eevent
);
2788 // calculate a client-origin version of the update rgn and set m_updateRegion to that
2789 OffsetRgn( newupdate
, -origin
.x
, -origin
.y
) ;
2790 m_updateRegion
= newupdate
;
2791 DisposeRgn( newupdate
) ;
2793 if ( !m_updateRegion
.Empty() )
2795 // paint the window itself
2797 event
.m_timeStamp
= time
;
2798 event
.SetEventObject(this);
2799 handled
= GetEventHandler()->ProcessEvent(event
);
2801 // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards
2804 if ( wxTheApp
->MacGetCurrentEvent() != NULL
&& wxTheApp
->MacGetCurrentEventHandlerCallRef() != NULL
)
2806 CallNextEventHandler((EventHandlerCallRef
)wxTheApp
->MacGetCurrentEventHandlerCallRef() , (EventRef
) wxTheApp
->MacGetCurrentEvent() ) ;
2813 // now we cannot rely on having its borders drawn by a window itself, as it does not
2814 // get the updateRgn wide enough to always do so, so we do it from the parent
2815 // this would also be the place to draw any custom backgrounds for native controls
2816 // in Composited windowing
2817 wxPoint clientOrigin
= GetClientAreaOrigin() ;
2819 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2821 wxWindowMac
*child
= node
->GetData();
2822 if (child
== m_vScrollBar
) continue;
2823 if (child
== m_hScrollBar
) continue;
2824 if (child
->IsTopLevel()) continue;
2825 if (!child
->IsShown()) continue;
2828 child
->GetPosition( &x
, &y
);
2830 child
->GetSize( &w
, &h
);
2831 Rect childRect
= { y
, x
, y
+ h
, x
+ w
} ;
2832 OffsetRect( &childRect
, clientOrigin
.x
, clientOrigin
.y
) ;
2833 if ( child
->MacGetTopBorderSize() )
2835 if ( RectInRgn( &childRect
, updatergn
) )
2837 // paint custom borders
2838 wxNcPaintEvent
eventNc( child
->GetId() );
2839 eventNc
.SetEventObject( child
);
2840 if ( !child
->GetEventHandler()->ProcessEvent( eventNc
) )
2842 wxWindowDC
dc(this) ;
2843 dc
.SetClippingRegion(wxRegion(updatergn
));
2844 wxMacPortSetter
helper(&dc
) ;
2845 child
->MacPaintBorders( dc
.m_macLocalOrigin
.x
+ childRect
.left
, dc
.m_macLocalOrigin
.y
+ childRect
.top
) ;
2849 if ( child
->m_peer
->NeedsFocusRect() && child
->m_peer
->HasFocus() )
2851 wxWindowDC
dc(this) ;
2852 dc
.SetClippingRegion(wxRegion(updatergn
));
2853 wxMacPortSetter
helper(&dc
) ;
2854 Rect r
= childRect
;
2855 OffsetRect( &r
, dc
.m_macLocalOrigin
.x
, dc
.m_macLocalOrigin
.y
) ;
2856 DrawThemeFocusRect( &r
, true ) ;
2863 void wxWindowMac::MacRedraw( WXHRGN updatergnr
, long time
, bool erase
)
2865 RgnHandle updatergn
= (RgnHandle
) updatergnr
;
2866 // updatergn is always already clipped to our boundaries
2867 // if we are in compositing mode then it is in relative to the upper left of the control
2868 // if we are in non-compositing, then it is relatvie to the uppder left of the content area
2869 // of the toplevel window
2870 // it is in window coordinates, not in client coordinates
2872 // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
2873 RgnHandle ownUpdateRgn
= NewRgn() ;
2874 CopyRgn( updatergn
, ownUpdateRgn
) ;
2876 if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
2879 m_peer
->GetRectInWindowCoords( &bounds
);
2880 RgnHandle controlRgn
= NewRgn();
2881 RectRgn( controlRgn
, &bounds
);
2882 //KO: This sets the ownUpdateRgn to the area of this control that is inside
2883 // the window update region
2884 SectRgn( ownUpdateRgn
, controlRgn
, ownUpdateRgn
);
2885 DisposeRgn( controlRgn
);
2887 //KO: convert ownUpdateRgn to local coordinates
2888 OffsetRgn( ownUpdateRgn
, -bounds
.left
, -bounds
.top
);
2891 MacDoRedraw( ownUpdateRgn
, time
) ;
2892 DisposeRgn( ownUpdateRgn
) ;
2896 WXWindow
wxWindowMac::MacGetTopLevelWindowRef() const
2898 wxWindowMac
*iter
= (wxWindowMac
*)this ;
2902 if ( iter
->IsTopLevel() )
2903 return ((wxTopLevelWindow
*)iter
)->MacGetWindowRef() ;
2905 iter
= iter
->GetParent() ;
2907 wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ;
2911 void wxWindowMac::MacCreateScrollBars( long style
)
2913 wxASSERT_MSG( m_vScrollBar
== NULL
&& m_hScrollBar
== NULL
, wxT("attempt to create window twice") ) ;
2915 if ( style
& ( wxVSCROLL
| wxHSCROLL
) )
2917 bool hasBoth
= ( style
& wxVSCROLL
) && ( style
& wxHSCROLL
) ;
2918 int scrlsize
= MAC_SCROLLBAR_SIZE
;
2919 wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
;
2920 if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL
|| GetWindowVariant() == wxWINDOW_VARIANT_MINI
)
2922 scrlsize
= MAC_SMALL_SCROLLBAR_SIZE
;
2923 variant
= wxWINDOW_VARIANT_SMALL
;
2926 int adjust
= hasBoth
? scrlsize
- 1: 0 ;
2928 GetClientSize( &width
, &height
) ;
2930 wxPoint
vPoint(width
-scrlsize
, 0) ;
2931 wxSize
vSize(scrlsize
, height
- adjust
) ;
2932 wxPoint
hPoint(0 , height
-scrlsize
) ;
2933 wxSize
hSize( width
- adjust
, scrlsize
) ;
2936 if ( style
& wxVSCROLL
)
2938 m_vScrollBar
= new wxScrollBar(this, wxWINDOW_VSCROLL
, vPoint
,
2939 vSize
, wxVERTICAL
);
2942 if ( style
& wxHSCROLL
)
2944 m_hScrollBar
= new wxScrollBar(this, wxWINDOW_HSCROLL
, hPoint
,
2945 hSize
, wxHORIZONTAL
);
2950 // because the create does not take into account the client area origin
2951 MacRepositionScrollBars() ; // we might have a real position shift
2954 void wxWindowMac::MacRepositionScrollBars()
2956 if ( !m_hScrollBar
&& !m_vScrollBar
)
2959 bool hasBoth
= ( m_hScrollBar
&& m_hScrollBar
->IsShown()) && ( m_vScrollBar
&& m_vScrollBar
->IsShown()) ;
2960 int scrlsize
= m_hScrollBar
? m_hScrollBar
->GetSize().y
: ( m_vScrollBar
? m_vScrollBar
->GetSize().x
: MAC_SCROLLBAR_SIZE
) ;
2961 int adjust
= hasBoth
? scrlsize
- 1 : 0 ;
2963 // get real client area
2967 GetSize( &width
, &height
) ;
2969 width
-= MacGetLeftBorderSize() + MacGetRightBorderSize();
2970 height
-= MacGetTopBorderSize() + MacGetBottomBorderSize();
2972 wxPoint
vPoint(width
-MAC_SCROLLBAR_SIZE
, 0) ;
2973 wxSize
vSize(MAC_SCROLLBAR_SIZE
, height
- adjust
) ;
2974 wxPoint
hPoint(0 , height
-MAC_SCROLLBAR_SIZE
) ;
2975 wxSize
hSize( width
- adjust
, MAC_SCROLLBAR_SIZE
) ;
2981 GetSize( &w , &h ) ;
2983 MacClientToRootWindow( &x , &y ) ;
2984 MacClientToRootWindow( &w , &h ) ;
2986 wxWindowMac *iter = (wxWindowMac*)this ;
2988 int totW = 10000 , totH = 10000;
2991 if ( iter->IsTopLevel() )
2993 iter->GetSize( &totW , &totH ) ;
2997 iter = iter->GetParent() ;
3025 m_vScrollBar
->SetSize( vPoint
.x
, vPoint
.y
, vSize
.x
, vSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3029 m_hScrollBar
->SetSize( hPoint
.x
, hPoint
.y
, hSize
.x
, hSize
.y
, wxSIZE_ALLOW_MINUS_ONE
);
3033 bool wxWindowMac::AcceptsFocus() const
3035 return MacCanFocus() && wxWindowBase::AcceptsFocus();
3038 void wxWindowMac::MacSuperChangedPosition()
3040 // only window-absolute structures have to be moved i.e. controls
3042 wxWindowListNode
*node
= GetChildren().GetFirst();
3045 wxWindowMac
*child
= node
->GetData();
3046 child
->MacSuperChangedPosition() ;
3047 node
= node
->GetNext();
3051 void wxWindowMac::MacTopLevelWindowChangedPosition()
3053 // only screen-absolute structures have to be moved i.e. glcanvas
3055 wxWindowListNode
*node
= GetChildren().GetFirst();
3058 wxWindowMac
*child
= node
->GetData();
3059 child
->MacTopLevelWindowChangedPosition() ;
3060 node
= node
->GetNext();
3064 long wxWindowMac::MacGetLeftBorderSize( ) const
3069 if (m_windowStyle
& wxRAISED_BORDER
|| m_windowStyle
& wxSUNKEN_BORDER
)
3074 else if ( m_windowStyle
&wxDOUBLE_BORDER
)
3079 else if (m_windowStyle
&wxSIMPLE_BORDER
)
3086 long wxWindowMac::MacGetRightBorderSize( ) const
3088 // they are all symmetric in mac themes
3089 return MacGetLeftBorderSize() ;
3092 long wxWindowMac::MacGetTopBorderSize( ) const
3094 // they are all symmetric in mac themes
3095 return MacGetLeftBorderSize() ;
3098 long wxWindowMac::MacGetBottomBorderSize( ) const
3100 // they are all symmetric in mac themes
3101 return MacGetLeftBorderSize() ;
3104 long wxWindowMac::MacRemoveBordersFromStyle( long style
)
3106 return style
& ~wxBORDER_MASK
;
3109 // Find the wxWindowMac at the current mouse position, returning the mouse
3111 wxWindowMac
* wxFindWindowAtPointer(wxPoint
& pt
)
3113 pt
= wxGetMousePosition();
3114 wxWindowMac
* found
= wxFindWindowAtPoint(pt
);
3118 // Get the current mouse position.
3119 wxPoint
wxGetMousePosition()
3122 wxGetMousePosition(& x
, & y
);
3123 return wxPoint(x
, y
);
3126 void wxWindowMac::OnMouseEvent( wxMouseEvent
&event
)
3128 if ( event
.GetEventType() == wxEVT_RIGHT_DOWN
)
3130 // copied from wxGTK : CS
3131 // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
3134 // (a) it's a command event and so is propagated to the parent
3135 // (b) under MSW it can be generated from kbd too
3136 // (c) it uses screen coords (because of (a))
3137 wxContextMenuEvent
evtCtx(wxEVT_CONTEXT_MENU
,
3139 this->ClientToScreen(event
.GetPosition()));
3140 if ( ! GetEventHandler()->ProcessEvent(evtCtx
) )
3149 void wxWindowMac::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED( mouseStillDown
) )
3153 Rect
wxMacGetBoundsForControl( wxWindow
* window
, const wxPoint
& pos
, const wxSize
&size
, bool adjustForOrigin
)
3157 window
->MacGetBoundsForControl( pos
, size
, x
, y
, w
, h
, adjustForOrigin
) ;
3158 Rect bounds
= { y
, x
, y
+h
, x
+w
};
3162 wxInt32
wxWindowMac::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
3164 return eventNotHandledErr
;