1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowMac
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
18 #include "wx/window.h"
20 #include "wx/dcclient.h"
24 #include "wx/layout.h"
25 #include "wx/dialog.h"
26 #include "wx/scrolbar.h"
27 #include "wx/statbox.h"
28 #include "wx/button.h"
29 #include "wx/settings.h"
30 #include "wx/msgdlg.h"
32 #include "wx/tooltip.h"
33 #include "wx/statusbr.h"
34 #include "wx/menuitem.h"
35 #include "wx/spinctrl.h"
37 #include "wx/geometry.h"
38 #include "wx/textctrl.h"
40 #include "wx/toolbar.h"
47 #define wxWINDOW_HSCROLL 5998
48 #define wxWINDOW_VSCROLL 5997
50 #define MAC_SCROLLBAR_SIZE 15
51 #define MAC_SMALL_SCROLLBAR_SIZE 11
53 #include "wx/mac/uma.h"
56 #include <ToolUtils.h>
58 #include <MacTextEditor.h>
61 #if TARGET_API_MAC_OSX
63 #include <HIToolbox/HIView.h>
67 #if wxUSE_DRAG_AND_DROP
73 extern wxList wxPendingDelete
;
75 #ifdef __WXUNIVERSAL__
76 IMPLEMENT_ABSTRACT_CLASS(wxWindowMac
, wxWindowBase
)
78 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
79 #endif // __WXUNIVERSAL__/__WXMAC__
81 #if !USE_SHARED_LIBRARY
83 BEGIN_EVENT_TABLE(wxWindowMac
, wxWindowBase
)
84 EVT_NC_PAINT(wxWindowMac::OnNcPaint
)
85 EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground
)
86 // TODO EVT_PAINT(wxWindowMac::OnPaint)
87 EVT_SET_FOCUS(wxWindowMac::OnSetFocus
)
88 EVT_KILL_FOCUS(wxWindowMac::OnSetFocus
)
89 EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent
)
94 #define wxMAC_DEBUG_REDRAW 0
95 #ifndef wxMAC_DEBUG_REDRAW
96 #define wxMAC_DEBUG_REDRAW 0
99 #define wxMAC_USE_THEME_BORDER 1
101 // ---------------------------------------------------------------------------
102 // Utility Routines to move between different coordinate systems
103 // ---------------------------------------------------------------------------
106 * Right now we have the following setup :
107 * a border that is not part of the native control is always outside the
108 * control's border (otherwise we loose all native intelligence, future ways
109 * may be to have a second embedding control responsible for drawing borders
110 * and backgrounds eventually)
111 * so all this border calculations have to be taken into account when calling
112 * native methods or getting native oriented data
113 * so we have three coordinate systems here
114 * wx client coordinates
115 * wx window coordinates (including window frames)
120 // originating from native control
124 void wxMacNativeToWindow( const wxWindow
* window
, RgnHandle handle
)
126 OffsetRgn( handle
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
129 void wxMacNativeToWindow( const wxWindow
* window
, Rect
*rect
)
131 OffsetRect( rect
, window
->MacGetLeftBorderSize() , window
->MacGetTopBorderSize() ) ;
135 // directed towards native control
138 void wxMacWindowToNative( const wxWindow
* window
, RgnHandle handle
)
140 OffsetRgn( handle
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() );
143 void wxMacWindowToNative( const wxWindow
* window
, Rect
*rect
)
145 OffsetRect( rect
, -window
->MacGetLeftBorderSize() , -window
->MacGetTopBorderSize() ) ;
149 // ---------------------------------------------------------------------------
151 // ---------------------------------------------------------------------------
153 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
154 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
) ;
156 #if TARGET_API_MAC_OSX
158 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
160 kEventControlVisibilityChanged
= 157
166 static const EventTypeSpec eventList
[] =
168 { kEventClassControl
, kEventControlHit
} ,
169 #if TARGET_API_MAC_OSX
170 { kEventClassControl
, kEventControlDraw
} ,
171 { kEventClassControl
, kEventControlVisibilityChanged
} ,
172 { kEventClassControl
, kEventControlEnabledStateChanged
} ,
173 { kEventClassControl
, kEventControlHiliteChanged
} ,
174 { kEventClassControl
, kEventControlSetFocusPart
} ,
176 { kEventClassService
, kEventServiceGetTypes
},
177 { kEventClassService
, kEventServiceCopy
},
178 { kEventClassService
, kEventServicePaste
},
180 // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only
181 // { kEventClassControl , kEventControlBoundsChanged } ,
185 static pascal OSStatus
wxMacWindowControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
187 OSStatus result
= eventNotHandledErr
;
189 wxMacCarbonEvent
cEvent( event
) ;
191 ControlRef controlRef
;
192 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
194 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
196 switch( GetEventKind( event
) )
198 #if TARGET_API_MAC_OSX
199 case kEventControlDraw
:
201 RgnHandle updateRgn
= NULL
;
202 RgnHandle allocatedRgn
= NULL
;
203 wxRegion visRegion
= thisWindow
->MacGetVisibleRegion() ;
204 if ( cEvent
.GetParameter
<RgnHandle
>(kEventParamRgnHandle
, &updateRgn
) != noErr
)
206 updateRgn
= (RgnHandle
) visRegion
.GetWXHRGN() ;
210 if ( thisWindow
->MacGetLeftBorderSize() != 0 || thisWindow
->MacGetTopBorderSize() != 0 )
212 allocatedRgn
= NewRgn() ;
213 CopyRgn( updateRgn
, allocatedRgn
) ;
214 // hide the given region by the new region that must be shifted
215 wxMacNativeToWindow( thisWindow
, allocatedRgn
) ;
216 updateRgn
= allocatedRgn
;
221 // in case we would need a coregraphics compliant background erase first
222 // now usable to track redraws
223 CGContextRef cgContext
= cEvent
.GetParameter
<CGContextRef
>(kEventParamCGContextRef
) ;
224 if ( thisWindow
->MacIsUserPane() )
226 static float color
= 0.5 ;
229 HIViewGetBounds( controlRef
, &bounds
);
230 CGContextSetRGBFillColor( cgContext
, channel
== 0 ? color
: 0.5 ,
231 channel
== 1 ? color
: 0.5 , channel
== 2 ? color
: 0.5 , 1 );
232 CGContextFillRect( cgContext
, bounds
);
243 if ( thisWindow
->MacDoRedraw( updateRgn
, cEvent
.GetTicks() ) )
246 DisposeRgn( allocatedRgn
) ;
249 case kEventControlVisibilityChanged
:
250 thisWindow
->MacVisibilityChanged() ;
252 case kEventControlEnabledStateChanged
:
253 thisWindow
->MacEnabledStateChanged() ;
255 case kEventControlHiliteChanged
:
256 thisWindow
->MacHiliteChanged() ;
258 case kEventControlSetFocusPart
:
260 Boolean focusEverything
= false ;
261 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
262 if ( cEvent
.GetParameter
<Boolean
>(kEventParamControlFocusEverything
, &focusEverything
) == noErr
)
265 if ( controlPart
== kControlFocusNoPart
)
268 if ( thisWindow
->GetCaret() )
270 thisWindow
->GetCaret()->OnKillFocus();
272 #endif // wxUSE_CARET
273 wxFocusEvent
event( wxEVT_KILL_FOCUS
, thisWindow
->GetId());
274 event
.SetEventObject(thisWindow
);
275 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
279 // panel wants to track the window which was the last to have focus in it
280 wxChildFocusEvent
eventFocus(thisWindow
);
281 thisWindow
->GetEventHandler()->ProcessEvent(eventFocus
);
284 if ( thisWindow
->GetCaret() )
286 thisWindow
->GetCaret()->OnSetFocus();
288 #endif // wxUSE_CARET
290 wxFocusEvent
event(wxEVT_SET_FOCUS
, thisWindow
->GetId());
291 event
.SetEventObject(thisWindow
);
292 thisWindow
->GetEventHandler()->ProcessEvent(event
) ;
294 if ( thisWindow
->MacIsUserPane() )
299 case kEventControlHit
:
301 result
= thisWindow
->MacControlHit( handler
, event
) ;
310 static pascal OSStatus
wxMacWindowServiceEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
312 OSStatus result
= eventNotHandledErr
;
314 wxMacCarbonEvent
cEvent( event
) ;
316 ControlRef controlRef
;
317 wxWindowMac
* thisWindow
= (wxWindowMac
*) data
;
318 wxTextCtrl
* textCtrl
= wxDynamicCast( thisWindow
, wxTextCtrl
) ;
319 cEvent
.GetParameter( kEventParamDirectObject
, &controlRef
) ;
321 switch( GetEventKind( event
) )
323 case kEventServiceGetTypes
:
327 textCtrl
->GetSelection( &from
, &to
) ;
329 CFMutableArrayRef copyTypes
= 0 , pasteTypes
= 0;
331 copyTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServiceCopyTypes
, typeCFMutableArrayRef
) ;
332 if ( textCtrl
->IsEditable() )
333 pasteTypes
= cEvent
.GetParameter
< CFMutableArrayRef
>( kEventParamServicePasteTypes
, typeCFMutableArrayRef
) ;
335 static const OSType textDataTypes
[] = { kTXNTextData
/* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ };
336 for ( size_t i
= 0 ; i
< WXSIZEOF(textDataTypes
) ; ++i
)
338 CFStringRef typestring
= CreateTypeStringWithOSType(textDataTypes
[i
]);
342 CFArrayAppendValue (copyTypes
, typestring
) ;
344 CFArrayAppendValue (pasteTypes
, typestring
) ;
345 CFRelease( typestring
) ;
351 case kEventServiceCopy
:
355 textCtrl
->GetSelection( &from
, &to
) ;
356 wxString val
= textCtrl
->GetValue() ;
357 val
= val
.Mid( from
, to
- from
) ;
358 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
359 verify_noerr( ClearScrap( &scrapRef
) ) ;
360 verify_noerr( PutScrapFlavor( scrapRef
, kTXNTextData
, 0 , val
.Length() , val
.c_str() ) ) ;
364 case kEventServicePaste
:
367 ScrapRef scrapRef
= cEvent
.GetParameter
< ScrapRef
> ( kEventParamScrapRef
, typeScrapRef
) ;
368 Size textSize
, pastedSize
;
369 verify_noerr( GetScrapFlavorSize (scrapRef
, kTXNTextData
, &textSize
) ) ;
371 char *content
= new char[textSize
] ;
372 GetScrapFlavorData (scrapRef
, kTXNTextData
, &pastedSize
, content
);
373 content
[textSize
-1] = 0 ;
375 textCtrl
->WriteText( wxString( content
, wxConvLocal
) );
377 textCtrl
->WriteText( wxString( content
) ) ;
388 pascal OSStatus
wxMacWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
390 EventRef formerEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
391 EventHandlerCallRef formerEventHandlerCallRef
= (EventHandlerCallRef
) wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
392 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
393 OSStatus result
= eventNotHandledErr
;
395 switch ( GetEventClass( event
) )
397 case kEventClassControl
:
398 result
= wxMacWindowControlEventHandler( handler
, event
, data
) ;
400 case kEventClassService
:
401 result
= wxMacWindowServiceEventHandler( handler
, event
, data
) ;
405 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerEventHandlerCallRef
) ;
409 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler
)
411 // ---------------------------------------------------------------------------
412 // UserPane events for non OSX builds
413 // ---------------------------------------------------------------------------
415 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
417 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
418 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
419 win
->MacControlUserPaneDrawProc(part
) ;
422 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
424 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
425 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
426 return win
->MacControlUserPaneHitTestProc(where
.h
, where
.v
) ;
429 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
431 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
432 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
433 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
436 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
438 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
439 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
440 win
->MacControlUserPaneIdleProc() ;
443 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
445 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
446 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
447 return win
->MacControlUserPaneKeyDownProc(keyCode
,charCode
,modifiers
) ;
450 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
452 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
453 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
454 win
->MacControlUserPaneActivateProc(activating
) ;
457 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
459 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
460 wxCHECK_MSG( win
, kControlNoPart
, wxT("Callback from unkown control") ) ;
461 return win
->MacControlUserPaneFocusProc(action
) ;
464 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
466 wxWindow
* win
= wxFindControlFromMacControl(control
) ;
467 wxCHECK_RET( win
, wxT("Callback from unkown control") ) ;
468 win
->MacControlUserPaneBackgroundProc(info
) ;
471 void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part
)
473 RgnHandle rgn
= NewRgn() ;
475 wxMacWindowStateSaver
sv( this ) ;
476 SectRgn( rgn
, (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , rgn
) ;
477 MacDoRedraw( rgn
, 0 ) ;
481 wxInt16
wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
483 return kControlNoPart
;
486 wxInt16
wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
488 return kControlNoPart
;
491 void wxWindowMac::MacControlUserPaneIdleProc()
495 wxInt16
wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
497 return kControlNoPart
;
500 void wxWindowMac::MacControlUserPaneActivateProc(bool activating
)
504 wxInt16
wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action
)
506 return kControlNoPart
;
509 void wxWindowMac::MacControlUserPaneBackgroundProc(void* info
)
513 ControlUserPaneDrawUPP gControlUserPaneDrawUPP
= NULL
;
514 ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP
= NULL
;
515 ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP
= NULL
;
516 ControlUserPaneIdleUPP gControlUserPaneIdleUPP
= NULL
;
517 ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP
= NULL
;
518 ControlUserPaneActivateUPP gControlUserPaneActivateUPP
= NULL
;
519 ControlUserPaneFocusUPP gControlUserPaneFocusUPP
= NULL
;
520 ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP
= NULL
;
522 // ===========================================================================
524 // ===========================================================================
526 wxList
wxWinMacControlList(wxKEY_INTEGER
);
528 wxWindow
*wxFindControlFromMacControl(ControlRef inControl
)
530 wxNode
*node
= wxWinMacControlList
.Find((long)inControl
);
533 return (wxControl
*)node
->GetData();
536 void wxAssociateControlWithMacControl(ControlRef inControl
, wxWindow
*control
)
538 // adding NULL ControlRef is (first) surely a result of an error and
539 // (secondly) breaks native event processing
540 wxCHECK_RET( inControl
!= (ControlRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
542 if ( !wxWinMacControlList
.Find((long)inControl
) )
543 wxWinMacControlList
.Append((long)inControl
, control
);
546 void wxRemoveMacControlAssociation(wxWindow
*control
)
548 wxWinMacControlList
.DeleteObject(control
);
552 ControlActionUPP wxMacLiveScrollbarActionUPP
= NULL
;
554 ControlColorUPP wxMacSetupControlBackgroundUPP
= NULL
;
556 // we have to setup the brush in the current port and return noErr
557 // or return an error code so that the control manager walks further up the
558 // hierarchy to find a correct background
560 pascal OSStatus
wxMacSetupControlBackground( ControlRef iControl
, SInt16 iMessage
, SInt16 iDepth
, Boolean iIsColor
)
562 OSStatus status
= paramErr
;
565 case kControlMsgApplyTextColor
:
567 case kControlMsgSetUpBackground
:
569 wxWindow
* wx
= (wxWindow
*) wxFindControlFromMacControl( iControl
) ;
573 const wxBrush &brush = wx->MacGetBackgroundBrush() ;
576 wxDC::MacSetupBackgroundForCurrentPort( brush ) ;
578 // this clipping is only needed for non HIView
580 RgnHandle clip
= NewRgn() ;
583 wx
->MacWindowToRootWindow( &x
,&y
) ;
584 CopyRgn( (RgnHandle
) wx
->MacGetVisibleRegion().GetWXHRGN() , clip
) ;
585 OffsetRgn( clip
, x
, y
) ;
592 else if ( wx->MacIsUserPane() )
594 // if we don't have a valid brush for such a control, we have to call the
595 // setup of our parent ourselves
596 status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ;
609 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
) ;
610 pascal void wxMacLiveScrollbarActionProc( ControlRef control
, ControlPartCode partCode
)
614 wxWindow
* wx
= wxFindControlFromMacControl( control
) ;
617 wx
->MacHandleControlClick( (WXWidget
) control
, partCode
, true /* stillDown */ ) ;
622 // ----------------------------------------------------------------------------
623 // constructors and such
624 // ----------------------------------------------------------------------------
626 wxWindowMac::wxWindowMac()
631 wxWindowMac::wxWindowMac(wxWindowMac
*parent
,
636 const wxString
& name
)
639 Create(parent
, id
, pos
, size
, style
, name
);
642 void wxWindowMac::Init()
646 #if WXWIN_COMPATIBILITY_2_4
647 m_backgroundTransparent
= FALSE
;
650 // as all windows are created with WS_VISIBLE style...
653 m_hScrollBar
= NULL
;
654 m_vScrollBar
= NULL
;
655 m_macBackgroundBrush
= wxNullBrush
;
657 m_macIsUserPane
= TRUE
;
659 // make sure all proc ptrs are available
661 if ( gControlUserPaneDrawUPP
== NULL
)
663 gControlUserPaneDrawUPP
= NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc
) ;
664 gControlUserPaneHitTestUPP
= NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc
) ;
665 gControlUserPaneTrackingUPP
= NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc
) ;
666 gControlUserPaneIdleUPP
= NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc
) ;
667 gControlUserPaneKeyDownUPP
= NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc
) ;
668 gControlUserPaneActivateUPP
= NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc
) ;
669 gControlUserPaneFocusUPP
= NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc
) ;
670 gControlUserPaneBackgroundUPP
= NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc
) ;
672 if ( wxMacLiveScrollbarActionUPP
== NULL
)
674 wxMacLiveScrollbarActionUPP
= NewControlActionUPP( wxMacLiveScrollbarActionProc
);
677 if ( wxMacSetupControlBackgroundUPP
== NULL
)
679 wxMacSetupControlBackgroundUPP
= NewControlColorUPP( wxMacSetupControlBackground
) ;
682 // we need a valid font for the encodings
683 wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
687 wxWindowMac::~wxWindowMac()
691 m_isBeingDeleted
= TRUE
;
695 // deleting a window while it is shown invalidates the region occupied by border or
697 int outerBorder
= MacGetLeftBorderSize() ;
698 if ( m_peer
->NeedsFocusRect() && m_peer
->HasFocus() )
701 if ( IsShown() && ( outerBorder
> 0 ) )
703 // as the borders are drawn on the parent we have to properly invalidate all these areas
704 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() , updateTotal
= NewRgn() ;
708 m_peer
->GetRect( &rect
) ;
709 RectRgn( updateInner
, &rect
) ;
710 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
711 RectRgn( updateOuter
, &rect
) ;
712 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
714 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
715 parent
-= GetParent()->GetClientAreaOrigin() ;
716 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
717 CopyRgn( updateOuter
, updateTotal
) ;
719 GetParent()->m_peer
->SetNeedsDisplay( true , updateTotal
) ;
720 DisposeRgn(updateOuter
) ;
721 DisposeRgn(updateInner
) ;
722 DisposeRgn(updateTotal
) ;
726 #ifndef __WXUNIVERSAL__
727 // VS: make sure there's no wxFrame with last focus set to us:
728 for ( wxWindow
*win
= GetParent(); win
; win
= win
->GetParent() )
730 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
733 if ( frame
->GetLastFocus() == this )
735 frame
->SetLastFocus((wxWindow
*)NULL
);
740 #endif // __WXUNIVERSAL__
742 // destroy children before destroying this window itself
745 // wxRemoveMacControlAssociation( this ) ;
746 // If we delete an item, we should initialize the parent panel,
747 // because it could now be invalid.
748 wxWindow
*parent
= GetParent() ;
751 if (parent
->GetDefaultItem() == (wxButton
*) this)
752 parent
->SetDefaultItem(NULL
);
754 if ( m_peer
&& m_peer
->Ok() )
756 // in case the callback might be called during destruction
757 wxRemoveMacControlAssociation( this) ;
758 // we currently are not using this hook
759 // ::SetControlColorProc( *m_peer , NULL ) ;
763 if ( g_MacLastWindow
== this )
765 g_MacLastWindow
= NULL
;
768 wxFrame
* frame
= wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame
) ;
771 if ( frame
->GetLastFocus() == this )
772 frame
->SetLastFocus( NULL
) ;
775 // delete our drop target if we've got one
776 #if wxUSE_DRAG_AND_DROP
777 if ( m_dropTarget
!= NULL
)
782 #endif // wxUSE_DRAG_AND_DROP
786 WXWidget
wxWindowMac::GetHandle() const
788 return (WXWidget
) m_peer
->GetControlRef() ;
792 void wxWindowMac::MacInstallEventHandler( WXWidget control
)
794 wxAssociateControlWithMacControl( (ControlRef
) control
, this ) ;
795 InstallControlEventHandler( (ControlRef
) control
, GetwxMacWindowEventHandlerUPP(),
796 GetEventTypeCount(eventList
), eventList
, this,
797 (EventHandlerRef
*)&m_macControlEventHandler
);
802 bool wxWindowMac::Create(wxWindowMac
*parent
, wxWindowID id
,
806 const wxString
& name
)
808 wxCHECK_MSG( parent
, FALSE
, wxT("can't create wxWindowMac without parent") );
810 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
813 m_windowVariant
= parent
->GetWindowVariant() ;
815 if ( m_macIsUserPane
)
817 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
820 | kControlSupportsEmbedding
821 // | kControlSupportsLiveFeedback
822 // | kControlHasSpecialBackground
823 // | kControlSupportsCalcBestRect
824 // | kControlHandlesTracking
825 | kControlSupportsFocus
826 // | kControlWantsActivate
827 // | kControlWantsIdle
830 m_peer
= new wxMacControl() ;
831 ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds
, features
, m_peer
->GetControlRefAddr() );
834 MacPostControlCreate(pos
,size
) ;
835 #if !TARGET_API_MAC_OSX
836 m_peer
->SetData
<ControlUserPaneDrawUPP
>(kControlEntireControl
,kControlUserPaneDrawProcTag
,&gControlUserPaneDrawUPP
) ;
837 m_peer
->SetData
<ControlUserPaneHitTestUPP
>(kControlEntireControl
,kControlUserPaneHitTestProcTag
,&gControlUserPaneHitTestUPP
) ;
838 m_peer
->SetData
<ControlUserPaneTrackingUPP
>(kControlEntireControl
,kControlUserPaneTrackingProcTag
,&gControlUserPaneTrackingUPP
) ;
839 m_peer
->SetData
<ControlUserPaneIdleUPP
>(kControlEntireControl
,kControlUserPaneIdleProcTag
,&gControlUserPaneIdleUPP
) ;
840 m_peer
->SetData
<ControlUserPaneKeyDownUPP
>(kControlEntireControl
,kControlUserPaneKeyDownProcTag
,&gControlUserPaneKeyDownUPP
) ;
841 m_peer
->SetData
<ControlUserPaneActivateUPP
>(kControlEntireControl
,kControlUserPaneActivateProcTag
,&gControlUserPaneActivateUPP
) ;
842 m_peer
->SetData
<ControlUserPaneFocusUPP
>(kControlEntireControl
,kControlUserPaneFocusProcTag
,&gControlUserPaneFocusUPP
) ;
843 m_peer
->SetData
<ControlUserPaneBackgroundUPP
>(kControlEntireControl
,kControlUserPaneBackgroundProcTag
,&gControlUserPaneBackgroundUPP
) ;
846 #ifndef __WXUNIVERSAL__
847 // Don't give scrollbars to wxControls unless they ask for them
848 if ( (! IsKindOf(CLASSINFO(wxControl
)) && ! IsKindOf(CLASSINFO(wxStatusBar
))) ||
849 (IsKindOf(CLASSINFO(wxControl
)) && ( style
& wxHSCROLL
|| style
& wxVSCROLL
)))
851 MacCreateScrollBars( style
) ;
855 wxWindowCreateEvent
event(this);
856 GetEventHandler()->AddPendingEvent(event
);
861 void wxWindowMac::MacPostControlCreate(const wxPoint
& pos
, const wxSize
& size
)
863 wxASSERT_MSG( m_peer
!= NULL
&& m_peer
->Ok() , wxT("No valid mac control") ) ;
865 m_peer
->SetReference( (long) this ) ;
866 GetParent()->AddChild(this);
868 MacInstallEventHandler( (WXWidget
) m_peer
->GetControlRef() );
870 ControlRef container
= (ControlRef
) GetParent()->GetHandle() ;
871 wxASSERT_MSG( container
!= NULL
, wxT("No valid mac container control") ) ;
872 ::EmbedControl( m_peer
->GetControlRef() , container
) ;
874 // adjust font, controlsize etc
875 DoSetWindowVariant( m_windowVariant
) ;
877 #if !TARGET_API_MAC_OSX
878 // eventually we can fix some clipping issues be reactivating this hook
879 //if ( m_macIsUserPane )
880 // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
882 m_peer
->SetTitle( wxStripMenuCodes(m_label
) ) ;
884 if (!m_macIsUserPane
)
886 SetInitialBestSize(size
);
889 SetCursor( *wxSTANDARD_CURSOR
) ;
892 void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant
)
894 // Don't assert, in case we set the window variant before
895 // the window is created
896 // wxASSERT( m_peer->Ok() ) ;
898 m_windowVariant
= variant
;
900 if (m_peer
== NULL
|| !m_peer
->Ok())
904 ThemeFontID themeFont
= kThemeSystemFont
;
906 // we will get that from the settings later
907 // and make this NORMAL later, but first
908 // we have a few calculations that we must fix
912 case wxWINDOW_VARIANT_NORMAL
:
913 size
= kControlSizeNormal
;
914 themeFont
= kThemeSystemFont
;
916 case wxWINDOW_VARIANT_SMALL
:
917 size
= kControlSizeSmall
;
918 themeFont
= kThemeSmallSystemFont
;
920 case wxWINDOW_VARIANT_MINI
:
921 if (UMAGetSystemVersion() >= 0x1030 )
923 // not always defined in the headers
929 size
= kControlSizeSmall
;
930 themeFont
= kThemeSmallSystemFont
;
933 case wxWINDOW_VARIANT_LARGE
:
934 size
= kControlSizeLarge
;
935 themeFont
= kThemeSystemFont
;
938 wxFAIL_MSG(_T("unexpected window variant"));
941 m_peer
->SetData
<ControlSize
>(kControlEntireControl
, kControlSizeTag
,&size
) ;
944 font
.MacCreateThemeFont( themeFont
) ;
948 void wxWindowMac::MacUpdateControlFont()
950 m_peer
->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
954 bool wxWindowMac::SetFont(const wxFont
& font
)
956 bool retval
= wxWindowBase::SetFont( font
) ;
958 MacUpdateControlFont() ;
963 bool wxWindowMac::SetForegroundColour(const wxColour
& col
)
965 if ( !wxWindowBase::SetForegroundColour(col
) )
968 MacUpdateControlFont() ;
973 bool wxWindowMac::SetBackgroundColour(const wxColour
& col
)
975 if ( !wxWindowBase::SetBackgroundColour(col
) && m_hasBgCol
)
979 wxColour
newCol(GetBackgroundColour());
980 if ( newCol
== wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
) )
982 brush
.MacSetTheme( kThemeBrushDocumentWindowBackground
) ;
984 else if ( newCol
== wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) )
986 brush
.MacSetTheme( kThemeBrushDialogBackgroundActive
) ;
990 brush
.SetColour( newCol
) ;
992 MacSetBackgroundBrush( brush
) ;
994 MacUpdateControlFont() ;
999 void wxWindowMac::MacSetBackgroundBrush( const wxBrush
&brush
)
1001 m_macBackgroundBrush
= brush
;
1002 m_peer
->SetBackground( brush
) ;
1005 bool wxWindowMac::MacCanFocus() const
1007 // there is currently no way to determine whether the window is running in full keyboard
1008 // access mode, therefore we cannot rely on these features, yet the only other way would be
1009 // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems
1010 // in event handlers...
1011 UInt32 features
= 0 ;
1012 m_peer
->GetFeatures( & features
) ;
1013 return features
& ( kControlSupportsFocus
| kControlGetsFocusOnClick
) ;
1017 void wxWindowMac::SetFocus()
1019 if ( AcceptsFocus() )
1022 wxWindow
* former
= FindFocus() ;
1023 if ( former
== this )
1026 OSStatus err
= m_peer
->SetFocus( kControlFocusNextPart
) ;
1027 // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
1028 // leave in case of an error
1029 if ( err
== errCouldntSetFocus
)
1032 #if !TARGET_API_MAC_OSX
1033 // emulate carbon events when running under carbonlib where they are not natively available
1036 EventRef evRef
= NULL
;
1037 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1040 wxMacCarbonEvent
cEvent( evRef
) ;
1041 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) former
->GetHandle() ) ;
1042 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNoPart
) ;
1044 wxMacWindowEventHandler( NULL
, evRef
, former
) ;
1045 ReleaseEvent(evRef
) ;
1047 // send new focus event
1049 EventRef evRef
= NULL
;
1050 verify_noerr( MacCreateEvent( NULL
, kEventClassControl
, kEventControlSetFocusPart
, TicksToEventTime( TickCount() ) , kEventAttributeUserEvent
,
1053 wxMacCarbonEvent
cEvent( evRef
) ;
1054 cEvent
.SetParameter
<ControlRef
>( kEventParamDirectObject
, (ControlRef
) GetHandle() ) ;
1055 cEvent
.SetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
, kControlFocusNextPart
) ;
1057 wxMacWindowEventHandler( NULL
, evRef
, this ) ;
1058 ReleaseEvent(evRef
) ;
1065 void wxWindowMac::DoCaptureMouse()
1067 wxTheApp
->s_captureWindow
= this ;
1070 wxWindow
* wxWindowBase::GetCapture()
1072 return wxTheApp
->s_captureWindow
;
1075 void wxWindowMac::DoReleaseMouse()
1077 wxTheApp
->s_captureWindow
= NULL
;
1080 #if wxUSE_DRAG_AND_DROP
1082 void wxWindowMac::SetDropTarget(wxDropTarget
*pDropTarget
)
1084 if ( m_dropTarget
!= 0 ) {
1085 delete m_dropTarget
;
1088 m_dropTarget
= pDropTarget
;
1089 if ( m_dropTarget
!= 0 )
1097 // Old style file-manager drag&drop
1098 void wxWindowMac::DragAcceptFiles(bool accept
)
1103 // Returns the size of the native control. In the case of the toplevel window
1104 // this is the content area root control
1106 void wxWindowMac::MacGetPositionAndSizeFromControl(int& x
, int& y
,
1107 int& w
, int& h
) const
1110 m_peer
->GetRect( &bounds
) ;
1115 w
= bounds
.right
- bounds
.left
;
1116 h
= bounds
.bottom
- bounds
.top
;
1119 // From a wx position / size calculate the appropriate size of the native control
1121 bool wxWindowMac::MacGetBoundsForControl(const wxPoint
& pos
,
1124 int& w
, int& h
, bool adjustOrigin
) const
1126 // the desired size, minus the border pixels gives the correct size of the control
1130 // todo the default calls may be used as soon as PostCreateControl Is moved here
1131 w
= size
.x
; // WidthDefault( size.x );
1132 h
= size
.y
; // HeightDefault( size.y ) ;
1133 #if !TARGET_API_MAC_OSX
1134 GetParent()->MacWindowToRootWindow( &x
, &y
) ;
1137 x
+= MacGetLeftBorderSize() ;
1138 y
+= MacGetTopBorderSize() ;
1139 w
-= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1140 h
-= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1143 AdjustForParentClientOrigin( x
, y
) ;
1144 #if TARGET_API_MAC_OSX
1145 // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
1146 if ( ! GetParent()->IsTopLevel() )
1148 x
-= GetParent()->MacGetLeftBorderSize() ;
1149 y
-= GetParent()->MacGetTopBorderSize() ;
1155 // Get window size (not client size)
1156 void wxWindowMac::DoGetSize(int *x
, int *y
) const
1158 // take the size of the control and add the borders that have to be drawn outside
1159 int x1
, y1
, w1
, h1
;
1161 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1163 w1
+= MacGetLeftBorderSize() + MacGetRightBorderSize() ;
1164 h1
+= MacGetTopBorderSize() + MacGetBottomBorderSize() ;
1170 // get the position of the bounds of this window in client coordinates of its parent
1171 void wxWindowMac::DoGetPosition(int *x
, int *y
) const
1173 int x1
, y1
, w1
,h1
;
1174 MacGetPositionAndSizeFromControl( x1
, y1
, w1
,h1
) ;
1175 x1
-= MacGetLeftBorderSize() ;
1176 y1
-= MacGetTopBorderSize() ;
1178 #if !TARGET_API_MAC_OSX
1179 if ( !GetParent()->IsTopLevel() )
1182 GetControlBounds( (ControlRef
) GetParent()->GetHandle() , &bounds
) ;
1187 if ( !IsTopLevel() )
1189 wxWindow
*parent
= GetParent();
1192 // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix
1193 x1
+= parent
->MacGetLeftBorderSize() ;
1194 y1
+= parent
->MacGetTopBorderSize() ;
1195 // and now to client coordinates
1196 wxPoint
pt(parent
->GetClientAreaOrigin());
1205 void wxWindowMac::DoScreenToClient(int *x
, int *y
) const
1207 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1209 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1212 Point localwhere
= {0,0} ;
1214 if(x
) localwhere
.h
= * x
;
1215 if(y
) localwhere
.v
= * y
;
1217 QDGlobalToLocalPoint( GetWindowPort( window
) , &localwhere
) ;
1218 if(x
) *x
= localwhere
.h
;
1219 if(y
) *y
= localwhere
.v
;
1222 MacRootWindowToWindow( x
, y
) ;
1224 wxPoint origin
= GetClientAreaOrigin() ;
1225 if(x
) *x
-= origin
.x
;
1226 if(y
) *y
-= origin
.y
;
1229 void wxWindowMac::DoClientToScreen(int *x
, int *y
) const
1231 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1232 wxCHECK_RET( window
, wxT("TopLevel Window Missing") ) ;
1234 wxPoint origin
= GetClientAreaOrigin() ;
1235 if(x
) *x
+= origin
.x
;
1236 if(y
) *y
+= origin
.y
;
1238 MacWindowToRootWindow( x
, y
) ;
1241 Point localwhere
= { 0,0 };
1242 if(x
) localwhere
.h
= * x
;
1243 if(y
) localwhere
.v
= * y
;
1244 QDLocalToGlobalPoint( GetWindowPort( window
) , &localwhere
) ;
1245 if(x
) *x
= localwhere
.h
;
1246 if(y
) *y
= localwhere
.v
;
1250 void wxWindowMac::MacClientToRootWindow( int *x
, int *y
) const
1252 wxPoint origin
= GetClientAreaOrigin() ;
1253 if(x
) *x
+= origin
.x
;
1254 if(y
) *y
+= origin
.y
;
1256 MacWindowToRootWindow( x
, y
) ;
1259 void wxWindowMac::MacRootWindowToClient( int *x
, int *y
) const
1261 MacRootWindowToWindow( x
, y
) ;
1263 wxPoint origin
= GetClientAreaOrigin() ;
1264 if(x
) *x
-= origin
.x
;
1265 if(y
) *y
-= origin
.y
;
1268 void wxWindowMac::MacWindowToRootWindow( int *x
, int *y
) const
1270 #if TARGET_API_MAC_OSX
1272 if ( x
) pt
.x
= *x
;
1273 if ( y
) pt
.y
= *y
;
1275 if ( !IsTopLevel() )
1277 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
1280 pt
.x
-= MacGetLeftBorderSize() ;
1281 pt
.y
-= MacGetTopBorderSize() ;
1282 wxMacControl::Convert( &pt
, m_peer
, top
->m_peer
) ;
1286 if ( x
) *x
= (int) pt
.x
;
1287 if ( y
) *y
= (int) pt
.y
;
1289 if ( !IsTopLevel() )
1292 m_peer
->GetRect( &bounds
) ;
1293 if(x
) *x
+= bounds
.left
- MacGetLeftBorderSize() ;
1294 if(y
) *y
+= bounds
.top
- MacGetTopBorderSize() ;
1299 void wxWindowMac::MacWindowToRootWindow( short *x
, short *y
) const
1304 MacWindowToRootWindow( &x1
, &y1
) ;
1309 void wxWindowMac::MacRootWindowToWindow( int *x
, int *y
) const
1311 #if TARGET_API_MAC_OSX
1313 if ( x
) pt
.x
= *x
;
1314 if ( y
) pt
.y
= *y
;
1316 if ( !IsTopLevel() )
1318 wxMacControl::Convert( &pt
, MacGetTopLevelWindow()->m_peer
, m_peer
) ;
1319 pt
.x
+= MacGetLeftBorderSize() ;
1320 pt
.y
+= MacGetTopBorderSize() ;
1323 if ( x
) *x
= (int) pt
.x
;
1324 if ( y
) *y
= (int) pt
.y
;
1326 if ( !IsTopLevel() )
1329 m_peer
->GetRect( &bounds
) ;
1330 if(x
) *x
-= bounds
.left
+ MacGetLeftBorderSize() ;
1331 if(y
) *y
-= bounds
.top
+ MacGetTopBorderSize() ;
1336 void wxWindowMac::MacRootWindowToWindow( short *x
, short *y
) const
1341 MacRootWindowToWindow( &x1
, &y1
) ;
1346 void wxWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1348 RgnHandle rgn
= NewRgn() ;
1350 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1352 GetRegionBounds( rgn
, &content
) ;
1357 m_peer
->GetRect( &content
) ;
1360 m_peer
->GetRect( &structure
) ;
1361 #if !TARGET_API_MAC_OSX
1362 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1364 left
= content
.left
- structure
.left
;
1365 top
= content
.top
- structure
.top
;
1366 right
= structure
.right
- content
.right
;
1367 bottom
= structure
.bottom
- content
.bottom
;
1370 wxSize
wxWindowMac::DoGetSizeFromClientSize( const wxSize
& size
) const
1372 wxSize sizeTotal
= size
;
1374 RgnHandle rgn
= NewRgn() ;
1378 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1380 GetRegionBounds( rgn
, &content
) ;
1385 m_peer
->GetRect( &content
) ;
1388 m_peer
->GetRect( &structure
) ;
1389 #if !TARGET_API_MAC_OSX
1390 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1393 sizeTotal
.x
+= (structure
.right
- structure
.left
) - (content
.right
- content
.left
) ;
1394 sizeTotal
.y
+= (structure
.bottom
- structure
.top
) - (content
.bottom
- content
.top
) ;
1396 sizeTotal
.x
+= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1397 sizeTotal
.y
+= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
1403 // Get size *available for subwindows* i.e. excluding menu bar etc.
1404 void wxWindowMac::DoGetClientSize(int *x
, int *y
) const
1408 RgnHandle rgn
= NewRgn() ;
1410 if ( m_peer
->GetRegion( kControlContentMetaPart
, rgn
) == noErr
)
1412 GetRegionBounds( rgn
, &content
) ;
1417 m_peer
->GetRect( &content
) ;
1419 #if !TARGET_API_MAC_OSX
1421 m_peer
->GetRect( &structure
) ;
1422 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1424 ww
= content
.right
- content
.left
;
1425 hh
= content
.bottom
- content
.top
;
1427 ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
1428 hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
1431 if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
1437 GetSize( &w , &h ) ;
1439 MacClientToRootWindow( &x1 , &y1 ) ;
1440 MacClientToRootWindow( &w , &h ) ;
1442 wxWindowMac *iter = (wxWindowMac*)this ;
1444 int totW = 10000 , totH = 10000;
1447 if ( iter->IsTopLevel() )
1449 iter->GetSize( &totW , &totH ) ;
1453 iter = iter->GetParent() ;
1456 if (m_hScrollBar && m_hScrollBar->IsShown() )
1458 hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
1464 if (m_vScrollBar && m_vScrollBar->IsShown() )
1466 ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
1474 if (m_hScrollBar
&& m_hScrollBar
->IsShown() )
1476 hh
-= m_hScrollBar
->GetSize().y
; // MAC_SCROLLBAR_SIZE ;
1478 if (m_vScrollBar
&& m_vScrollBar
->IsShown() )
1480 ww
-= m_vScrollBar
->GetSize().x
; // MAC_SCROLLBAR_SIZE;
1487 bool wxWindowMac::SetCursor(const wxCursor
& cursor
)
1489 if (m_cursor
== cursor
)
1492 if (wxNullCursor
== cursor
)
1494 if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR
) )
1499 if ( ! wxWindowBase::SetCursor( cursor
) )
1503 wxASSERT_MSG( m_cursor
.Ok(),
1504 wxT("cursor must be valid after call to the base version"));
1507 wxWindowMac
*mouseWin
= 0 ;
1509 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
1511 Boolean swapped
= QDSwapPort( GetWindowPort( window
) , &savePort
) ;
1513 // TODO If we ever get a GetCurrentEvent.. replacement for the mouse
1514 // position, use it...
1518 ControlPartCode part
;
1519 ControlRef control
;
1520 control
= wxMacFindControlUnderMouse( pt
, window
, &part
) ;
1522 mouseWin
= wxFindControlFromMacControl( control
) ;
1525 QDSwapPort( savePort
, NULL
) ;
1528 if ( mouseWin
== this && !wxIsBusy() )
1530 m_cursor
.MacInstall() ;
1537 bool wxWindowMac::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1539 menu
->SetInvokingWindow(this);
1542 if ( x
== -1 && y
== -1 )
1544 wxPoint mouse
= wxGetMousePosition();
1545 x
= mouse
.x
; y
= mouse
.y
;
1549 ClientToScreen( &x
, &y
) ;
1552 menu
->MacBeforeDisplay( true ) ;
1553 long menuResult
= ::PopUpMenuSelect((MenuHandle
) menu
->GetHMenu() ,y
,x
, 0) ;
1554 if ( HiWord(menuResult
) != 0 )
1557 GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult
)) , LoWord(menuResult
) , &id
) ;
1558 wxMenuItem
* item
= NULL
;
1560 item
= menu
->FindItem(id
, &realmenu
) ;
1561 if (item
->IsCheckable())
1563 item
->Check( !item
->IsChecked() ) ;
1565 menu
->SendEvent( id
, item
->IsCheckable() ? item
->IsChecked() : -1 ) ;
1567 menu
->MacAfterDisplay( true ) ;
1569 menu
->SetInvokingWindow(NULL
);
1575 // ----------------------------------------------------------------------------
1577 // ----------------------------------------------------------------------------
1581 void wxWindowMac::DoSetToolTip(wxToolTip
*tooltip
)
1583 wxWindowBase::DoSetToolTip(tooltip
);
1586 m_tooltip
->SetWindow(this);
1589 #endif // wxUSE_TOOLTIPS
1591 void wxWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1593 // this is never called for a toplevel window, so we know we have a parent
1594 int former_x
, former_y
, former_w
, former_h
;
1596 // Get true coordinates of former position
1597 DoGetPosition( &former_x
, &former_y
) ;
1598 DoGetSize( &former_w
, &former_h
) ;
1600 wxWindow
*parent
= GetParent();
1603 wxPoint
pt(parent
->GetClientAreaOrigin());
1608 int actualWidth
= width
;
1609 int actualHeight
= height
;
1613 if ((m_minWidth
!= -1) && (actualWidth
< m_minWidth
))
1614 actualWidth
= m_minWidth
;
1615 if ((m_minHeight
!= -1) && (actualHeight
< m_minHeight
))
1616 actualHeight
= m_minHeight
;
1617 if ((m_maxWidth
!= -1) && (actualWidth
> m_maxWidth
))
1618 actualWidth
= m_maxWidth
;
1619 if ((m_maxHeight
!= -1) && (actualHeight
> m_maxHeight
))
1620 actualHeight
= m_maxHeight
;
1622 bool doMove
= false ;
1623 bool doResize
= false ;
1625 if ( actualX
!= former_x
|| actualY
!= former_y
)
1629 if ( actualWidth
!= former_w
|| actualHeight
!= former_h
)
1634 if ( doMove
|| doResize
)
1636 // we don't adjust twice for the origin
1637 Rect r
= wxMacGetBoundsForControl(this , wxPoint( actualX
,actualY
), wxSize( actualWidth
, actualHeight
) , false ) ;
1638 bool vis
= m_peer
->IsVisible();
1640 int outerBorder
= MacGetLeftBorderSize() ;
1641 if ( m_peer
->NeedsFocusRect() && m_peer
->HasFocus() )
1644 if ( vis
&& ( outerBorder
> 0 ) )
1646 // as the borders are drawn on the parent we have to properly invalidate all these areas
1647 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() , updateTotal
= NewRgn() ;
1651 m_peer
->GetRect( &rect
) ;
1652 RectRgn( updateInner
, &rect
) ;
1653 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1654 RectRgn( updateOuter
, &rect
) ;
1655 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
1656 wxPoint
parent(0,0);
1657 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
1658 parent
-= GetParent()->GetClientAreaOrigin() ;
1659 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
1660 CopyRgn( updateOuter
, updateTotal
) ;
1663 RectRgn( updateInner
, &rect
) ;
1664 InsetRect( &rect
, -outerBorder
, -outerBorder
) ;
1665 RectRgn( updateOuter
, &rect
) ;
1666 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
1668 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
1669 UnionRgn( updateOuter
, updateTotal
, updateTotal
) ;
1671 GetParent()->m_peer
->SetNeedsDisplay( true , updateTotal
) ;
1672 DisposeRgn(updateOuter
) ;
1673 DisposeRgn(updateInner
) ;
1674 DisposeRgn(updateTotal
) ;
1677 // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
1679 m_peer
->SetVisibility( false , true ) ;
1681 m_peer
->SetRect( &r
) ;
1683 m_peer
->SetVisibility( true , true ) ;
1685 MacRepositionScrollBars() ;
1688 wxPoint
point(actualX
,actualY
);
1689 wxMoveEvent
event(point
, m_windowId
);
1690 event
.SetEventObject(this);
1691 GetEventHandler()->ProcessEvent(event
) ;
1695 MacRepositionScrollBars() ;
1696 wxSize
size(actualWidth
, actualHeight
);
1697 wxSizeEvent
event(size
, m_windowId
);
1698 event
.SetEventObject(this);
1699 GetEventHandler()->ProcessEvent(event
);
1705 wxSize
wxWindowMac::DoGetBestSize() const
1707 if ( m_macIsUserPane
|| IsTopLevel() )
1708 return wxWindowBase::DoGetBestSize() ;
1710 Rect bestsize
= { 0 , 0 , 0 , 0 } ;
1711 int bestWidth
, bestHeight
;
1712 m_peer
->GetBestRect( &bestsize
) ;
1714 if ( EmptyRect( &bestsize
) )
1716 bestsize
.left
= bestsize
.top
= 0 ;
1717 bestsize
.right
= 16 ;
1718 bestsize
.bottom
= 16 ;
1719 if ( IsKindOf( CLASSINFO( wxScrollBar
) ) )
1721 bestsize
.bottom
= 16 ;
1724 else if ( IsKindOf( CLASSINFO( wxSpinButton
) ) )
1726 bestsize
.bottom
= 24 ;
1728 #endif // wxUSE_SPINBTN
1731 // return wxWindowBase::DoGetBestSize() ;
1735 bestWidth
= bestsize
.right
- bestsize
.left
;
1736 bestHeight
= bestsize
.bottom
- bestsize
.top
;
1737 if ( bestHeight
< 10 )
1740 return wxSize(bestWidth
, bestHeight
);
1744 // set the size of the window: if the dimensions are positive, just use them,
1745 // but if any of them is equal to -1, it means that we must find the value for
1746 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1747 // which case -1 is a valid value for x and y)
1749 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1750 // the width/height to best suit our contents, otherwise we reuse the current
1752 void wxWindowMac::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1754 // get the current size and position...
1755 int currentX
, currentY
;
1756 GetPosition(¤tX
, ¤tY
);
1758 int currentW
,currentH
;
1759 GetSize(¤tW
, ¤tH
);
1761 // ... and don't do anything (avoiding flicker) if it's already ok
1762 if ( x
== currentX
&& y
== currentY
&&
1763 width
== currentW
&& height
== currentH
&& ( height
!= -1 && width
!= -1 ) )
1766 MacRepositionScrollBars() ; // we might have a real position shift
1770 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1772 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1775 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
1777 wxSize
size(-1, -1);
1780 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
1782 size
= DoGetBestSize();
1787 // just take the current one
1794 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
1798 size
= DoGetBestSize();
1800 //else: already called DoGetBestSize() above
1806 // just take the current one
1811 DoMoveWindow(x
, y
, width
, height
);
1815 wxPoint
wxWindowMac::GetClientAreaOrigin() const
1817 RgnHandle rgn
= NewRgn() ;
1819 m_peer
->GetRegion( kControlContentMetaPart
, rgn
) ;
1820 GetRegionBounds( rgn
, &content
) ;
1822 #if !TARGET_API_MAC_OSX
1823 // if the content rgn is empty / not supported
1824 // don't attempt to correct the coordinates to wxWindow relative ones
1825 if (!::EmptyRect( &content
) )
1828 m_peer
->GetRect( &structure
) ;
1829 OffsetRect( &content
, -structure
.left
, -structure
.top
) ;
1833 return wxPoint( content
.left
+ MacGetLeftBorderSize( ) , content
.top
+ MacGetTopBorderSize( ) );
1836 void wxWindowMac::DoSetClientSize(int clientwidth
, int clientheight
)
1838 if ( clientheight
!= -1 || clientheight
!= -1 )
1840 int currentclientwidth
, currentclientheight
;
1841 int currentwidth
, currentheight
;
1843 GetClientSize( ¤tclientwidth
, ¤tclientheight
) ;
1844 GetSize( ¤twidth
, ¤theight
) ;
1846 DoSetSize( -1 , -1 , currentwidth
+ clientwidth
- currentclientwidth
,
1847 currentheight
+ clientheight
- currentclientheight
, wxSIZE_USE_EXISTING
) ;
1851 void wxWindowMac::SetTitle(const wxString
& title
)
1853 m_label
= wxStripMenuCodes(title
) ;
1855 if ( m_peer
&& m_peer
->Ok() )
1857 m_peer
->SetTitle( m_label
) ;
1862 wxString
wxWindowMac::GetTitle() const
1867 bool wxWindowMac::Show(bool show
)
1869 if ( !wxWindowBase::Show(show
) )
1872 // TODO use visibilityChanged Carbon Event for OSX
1875 bool former
= MacIsReallyShown() ;
1877 m_peer
->SetVisibility( show
, true ) ;
1878 if ( former
!= MacIsReallyShown() )
1879 MacPropagateVisibilityChanged() ;
1884 bool wxWindowMac::Enable(bool enable
)
1886 wxASSERT( m_peer
->Ok() ) ;
1887 if ( !wxWindowBase::Enable(enable
) )
1890 bool former
= MacIsReallyEnabled() ;
1891 m_peer
->Enable( enable
) ;
1893 if ( former
!= MacIsReallyEnabled() )
1894 MacPropagateEnabledStateChanged() ;
1899 // status change propagations (will be not necessary for OSX later )
1902 void wxWindowMac::MacPropagateVisibilityChanged()
1904 #if !TARGET_API_MAC_OSX
1905 MacVisibilityChanged() ;
1907 wxWindowListNode
*node
= GetChildren().GetFirst();
1910 wxWindowMac
*child
= node
->GetData();
1911 if ( child
->IsShown() )
1912 child
->MacPropagateVisibilityChanged( ) ;
1913 node
= node
->GetNext();
1918 void wxWindowMac::MacPropagateEnabledStateChanged( )
1920 #if !TARGET_API_MAC_OSX
1921 MacEnabledStateChanged() ;
1923 wxWindowListNode
*node
= GetChildren().GetFirst();
1926 wxWindowMac
*child
= node
->GetData();
1927 if ( child
->IsEnabled() )
1928 child
->MacPropagateEnabledStateChanged() ;
1929 node
= node
->GetNext();
1934 void wxWindowMac::MacPropagateHiliteChanged( )
1936 #if !TARGET_API_MAC_OSX
1937 MacHiliteChanged() ;
1939 wxWindowListNode
*node
= GetChildren().GetFirst();
1942 wxWindowMac
*child
= node
->GetData();
1943 // if ( child->IsEnabled() )
1944 child
->MacPropagateHiliteChanged() ;
1945 node
= node
->GetNext();
1951 // status change notifications
1954 void wxWindowMac::MacVisibilityChanged()
1958 void wxWindowMac::MacHiliteChanged()
1962 void wxWindowMac::MacEnabledStateChanged()
1967 // status queries on the inherited window's state
1970 bool wxWindowMac::MacIsReallyShown()
1972 // only under OSX the visibility of the TLW is taken into account
1973 #if TARGET_API_MAC_OSX
1974 if ( m_peer
&& m_peer
->Ok() )
1975 return m_peer
->IsVisible();
1977 wxWindow
* win
= this ;
1978 while( win
->IsShown() )
1980 if ( win
->IsTopLevel() )
1983 win
= win
->GetParent() ;
1991 bool wxWindowMac::MacIsReallyEnabled()
1993 return m_peer
->IsEnabled() ;
1996 bool wxWindowMac::MacIsReallyHilited()
1998 return m_peer
->IsActive();
2001 void wxWindowMac::MacFlashInvalidAreas()
2003 #if TARGET_API_MAC_OSX
2004 HIViewFlashDirtyArea( (WindowRef
) MacGetTopLevelWindowRef() ) ;
2012 int wxWindowMac::GetCharHeight() const
2014 wxClientDC
dc ( (wxWindowMac
*)this ) ;
2015 return dc
.GetCharHeight() ;
2018 int wxWindowMac::GetCharWidth() const
2020 wxClientDC
dc ( (wxWindowMac
*)this ) ;
2021 return dc
.GetCharWidth() ;
2024 void wxWindowMac::GetTextExtent(const wxString
& string
, int *x
, int *y
,
2025 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
2027 const wxFont
*fontToUse
= theFont
;
2029 fontToUse
= &m_font
;
2031 wxClientDC
dc( (wxWindowMac
*) this ) ;
2033 dc
.GetTextExtent( string
, &lx
, &ly
, &ld
, &le
, (wxFont
*)fontToUse
) ;
2034 if ( externalLeading
)
2035 *externalLeading
= le
;
2045 * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
2046 * we always intersect with the entire window, not only with the client area
2049 void wxWindowMac::Refresh(bool eraseBack
, const wxRect
*rect
)
2051 if ( m_peer
== NULL
)
2054 #if TARGET_API_MAC_OSX
2056 m_peer
->SetNeedsDisplay( true ) ;
2059 RgnHandle update
= NewRgn() ;
2060 SetRectRgn( update
, rect
->x
, rect
->y
, rect
->x
+ rect
->width
, rect
->y
+ rect
->height
) ;
2061 SectRgn( (RgnHandle
) MacGetVisibleRegion().GetWXHRGN() , update
, update
) ;
2062 wxPoint origin
= GetClientAreaOrigin() ;
2063 OffsetRgn( update
, origin
.x
, origin
.y
) ;
2064 // right now this is wx' window coordinates, as our native peer does not have borders, this is
2066 OffsetRgn( update
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2067 m_peer
->SetNeedsDisplay( true , update
) ;
2068 DisposeRgn( update
) ;
2072 RgnHandle updateRgn = NewRgn() ;
2075 CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
2079 SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
2080 SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
2082 InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
2083 DisposeRgn(updateRgn) ;
2085 if ( m_peer
->IsVisible())
2087 m_peer
->SetVisibility( false , false ) ;
2088 m_peer
->SetVisibility( true , true ) ;
2091 if ( MacGetTopLevelWindow() == NULL )
2094 if ( !m_peer->IsVisible())
2097 wxPoint client = GetClientAreaOrigin();
2100 int x2 = m_width - client.x;
2101 int y2 = m_height - client.y;
2103 if (IsKindOf( CLASSINFO(wxButton)))
2105 // buttons have an "aura"
2112 Rect clientrect = { y1, x1, y2, x2 };
2116 Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
2117 SectRect( &clientrect , &r , &clientrect ) ;
2120 if ( !EmptyRect( &clientrect ) )
2122 int top = 0 , left = 0 ;
2124 MacClientToRootWindow( &left , &top ) ;
2125 OffsetRect( &clientrect , left , top ) ;
2127 MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
2133 void wxWindowMac::Freeze()
2135 #if TARGET_API_MAC_OSX
2136 if ( !m_frozenness
++ )
2138 if ( m_peer
&& m_peer
->Ok() )
2139 m_peer
->SetDrawingEnabled( false ) ;
2145 void wxWindowMac::Thaw()
2147 #if TARGET_API_MAC_OSX
2148 wxASSERT_MSG( m_frozenness
> 0, _T("Thaw() without matching Freeze()") );
2150 if ( !--m_frozenness
)
2152 if ( m_peer
&& m_peer
->Ok() )
2154 m_peer
->SetDrawingEnabled( true ) ;
2155 m_peer
->InvalidateWithChildren() ;
2161 void wxWindowMac::MacRedrawControl()
2164 if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
2166 #if TARGET_API_MAC_CARBON
2169 wxClientDC dc(this) ;
2170 wxMacPortSetter helper(&dc) ;
2171 wxMacWindowClipper clipper(this) ;
2172 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
2173 UMADrawControl( *m_peer ) ;
2180 void wxWindowMac::OnPaint(wxPaintEvent& event)
2182 // why don't we skip that here ?
2186 wxWindowMac
*wxGetActiveWindow()
2188 // actually this is a windows-only concept
2192 // Coordinates relative to the window
2193 void wxWindowMac::WarpPointer (int x_pos
, int y_pos
)
2195 // We really don't move the mouse programmatically under Mac.
2198 void wxWindowMac::OnEraseBackground(wxEraseEvent
& event
)
2200 #if TARGET_API_MAC_OSX
2201 if ( m_macBackgroundBrush
.Ok() == false || m_macBackgroundBrush
.GetStyle() == wxTRANSPARENT
)
2208 event
.GetDC()->Clear() ;
2212 void wxWindowMac::OnNcPaint( wxNcPaintEvent
& event
)
2217 int wxWindowMac::GetScrollPos(int orient
) const
2219 if ( orient
== wxHORIZONTAL
)
2222 return m_hScrollBar
->GetThumbPosition() ;
2227 return m_vScrollBar
->GetThumbPosition() ;
2232 // This now returns the whole range, not just the number
2233 // of positions that we can scroll.
2234 int wxWindowMac::GetScrollRange(int orient
) const
2236 if ( orient
== wxHORIZONTAL
)
2239 return m_hScrollBar
->GetRange() ;
2244 return m_vScrollBar
->GetRange() ;
2249 int wxWindowMac::GetScrollThumb(int orient
) const
2251 if ( orient
== wxHORIZONTAL
)
2254 return m_hScrollBar
->GetThumbSize() ;
2259 return m_vScrollBar
->GetThumbSize() ;
2264 void wxWindowMac::SetScrollPos(int orient
, int pos
, bool refresh
)
2266 if ( orient
== wxHORIZONTAL
)
2269 m_hScrollBar
->SetThumbPosition( pos
) ;
2274 m_vScrollBar
->SetThumbPosition( pos
) ;
2278 void wxWindowMac::MacPaintBorders( int left
, int top
)
2284 m_peer
->GetRect( &rect
) ;
2285 InsetRect( &rect
, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2287 if ( !IsTopLevel() )
2289 wxTopLevelWindowMac
* top
= MacGetTopLevelWindow();
2293 wxMacControl::Convert( &pt
, GetParent()->m_peer
, top
->m_peer
) ;
2295 rect
.right
+= pt
.x
;
2297 rect
.bottom
+= pt
.y
;
2301 if (HasFlag(wxRAISED_BORDER
) || HasFlag( wxSUNKEN_BORDER
) || HasFlag(wxDOUBLE_BORDER
) )
2305 GetThemeMetric( kThemeMetricEditTextFrameOutset
, &border
) ;
2306 InsetRect( &srect
, border
, border
);
2307 DrawThemeEditTextFrame(&srect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2309 else if (HasFlag(wxSIMPLE_BORDER
))
2313 GetThemeMetric( kThemeMetricListBoxFrameOutset
, &border
) ;
2314 InsetRect( &srect
, border
, border
);
2315 DrawThemeListBoxFrame(&rect
,IsEnabled() ? kThemeStateActive
: kThemeStateInactive
) ;
2319 void wxWindowMac::RemoveChild( wxWindowBase
*child
)
2321 if ( child
== m_hScrollBar
)
2322 m_hScrollBar
= NULL
;
2323 if ( child
== m_vScrollBar
)
2324 m_vScrollBar
= NULL
;
2326 wxWindowBase::RemoveChild( child
) ;
2329 // New function that will replace some of the above.
2330 void wxWindowMac::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2331 int range
, bool refresh
)
2333 if ( orient
== wxHORIZONTAL
)
2337 if ( range
== 0 || thumbVisible
>= range
)
2339 if ( m_hScrollBar
->IsShown() )
2340 m_hScrollBar
->Show(false) ;
2344 if ( !m_hScrollBar
->IsShown() )
2345 m_hScrollBar
->Show(true) ;
2346 m_hScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2354 if ( range
== 0 || thumbVisible
>= range
)
2356 if ( m_vScrollBar
->IsShown() )
2357 m_vScrollBar
->Show(false) ;
2361 if ( !m_vScrollBar
->IsShown() )
2362 m_vScrollBar
->Show(true) ;
2363 m_vScrollBar
->SetScrollbar( pos
, thumbVisible
, range
, thumbVisible
, refresh
) ;
2367 MacRepositionScrollBars() ;
2370 // Does a physical scroll
2371 void wxWindowMac::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2373 if( dx
== 0 && dy
==0 )
2379 int width
, height
;
2380 GetClientSize( &width
, &height
) ;
2381 #if TARGET_API_MAC_OSX
2382 // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
2383 // area is scrolled, this does not occur if width and height are 2 pixels less,
2384 // TODO write optimal workaround
2385 wxRect
scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width
, height
) ;
2388 scrollrect
.Intersect( *rect
) ;
2390 if ( m_peer
->GetNeedsDisplay() )
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( true ) ;
2398 // this would be the preferred version for fast drawing controls
2399 if( UMAGetSystemVersion() < 0x1030 )
2402 HIViewRender(m_peer
->GetControlRef()) ;
2405 // as the native control might be not a 0/0 wx window coordinates, we have to offset
2406 scrollrect
.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
2407 m_peer
->ScrollRect( scrollrect
, dx
, dy
) ;
2414 RgnHandle updateRgn
= NewRgn() ;
2417 wxClientDC
dc(this) ;
2418 wxMacPortSetter
helper(&dc
) ;
2420 m_peer
->GetRect( &scrollrect
) ;
2421 scrollrect
.top
+= MacGetTopBorderSize() ;
2422 scrollrect
.left
+= MacGetLeftBorderSize() ;
2423 scrollrect
.bottom
= scrollrect
.top
+ height
;
2424 scrollrect
.right
= scrollrect
.left
+ width
;
2428 Rect r
= { dc
.YLOG2DEVMAC(rect
->y
) , dc
.XLOG2DEVMAC(rect
->x
) , dc
.YLOG2DEVMAC(rect
->y
+ rect
->height
) ,
2429 dc
.XLOG2DEVMAC(rect
->x
+ rect
->width
) } ;
2430 SectRect( &scrollrect
, &r
, &scrollrect
) ;
2432 ScrollRect( &scrollrect
, dx
, dy
, updateRgn
) ;
2434 // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
2438 for (wxWindowListNode
*node
= GetChildren().GetFirst(); node
; node
= node
->GetNext())
2440 wxWindowMac
*child
= node
->GetData();
2441 if (child
== m_vScrollBar
) continue;
2442 if (child
== m_hScrollBar
) continue;
2443 if (child
->IsTopLevel()) continue;
2446 child
->GetPosition( &x
, &y
);
2448 child
->GetSize( &w
, &h
);
2452 if (rect
->Intersects(rc
))
2453 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2457 child
->SetSize( x
+dx
, y
+dy
, w
, h
);
2462 void wxWindowMac::MacOnScroll(wxScrollEvent
&event
)
2464 if ( event
.m_eventObject
== m_vScrollBar
|| event
.m_eventObject
== m_hScrollBar
)
2466 wxScrollWinEvent wevent
;
2467 wevent
.SetPosition(event
.GetPosition());
2468 wevent
.SetOrientation(event
.GetOrientation());
2469 wevent
.m_eventObject
= this;
2471 if (event
.m_eventType
== wxEVT_SCROLL_TOP
)
2472 wevent
.m_eventType
= wxEVT_SCROLLWIN_TOP
;
2473 else if (event
.m_eventType
== wxEVT_SCROLL_BOTTOM
)
2474 wevent
.m_eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2475 else if (event
.m_eventType
== wxEVT_SCROLL_LINEUP
)
2476 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
2477 else if (event
.m_eventType
== wxEVT_SCROLL_LINEDOWN
)
2478 wevent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
2479 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEUP
)
2480 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2481 else if (event
.m_eventType
== wxEVT_SCROLL_PAGEDOWN
)
2482 wevent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2483 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBTRACK
)
2484 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2485 else if (event
.m_eventType
== wxEVT_SCROLL_THUMBRELEASE
)
2486 wevent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2488 GetEventHandler()->ProcessEvent(wevent
);
2492 // Get the window with the focus
2493 wxWindowMac
*wxWindowBase::DoFindFocus()
2495 ControlRef control
;
2496 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
2497 return wxFindControlFromMacControl( control
) ;
2500 void wxWindowMac::OnSetFocus(wxFocusEvent
& event
)
2502 // panel wants to track the window which was the last to have focus in it,
2503 // so we want to set ourselves as the window which last had focus
2505 // notice that it's also important to do it upwards the tree becaus
2506 // otherwise when the top level panel gets focus, it won't set it back to
2507 // us, but to some other sibling
2509 // CS:don't know if this is still needed:
2510 //wxChildFocusEvent eventFocus(this);
2511 //(void)GetEventHandler()->ProcessEvent(eventFocus);
2513 if ( MacGetTopLevelWindow() && m_peer
->NeedsFocusRect() )
2515 wxMacWindowStateSaver
sv( this ) ;
2520 MacWindowToRootWindow( &x
, &y
) ;
2521 GetSize( &w
, &h
) ;
2522 Rect rect
= {y
, x
, h
+ y
, w
+ x
} ;
2524 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
2525 DrawThemeFocusRect( &rect
, true ) ;
2528 DrawThemeFocusRect( &rect
, false ) ;
2530 // as this erases part of the frame we have to redraw borders
2531 // and because our z-ordering is not always correct (staticboxes)
2532 // we have to invalidate things, we cannot simple redraw
2533 RgnHandle updateInner
= NewRgn() , updateOuter
= NewRgn() ;
2534 RectRgn( updateInner
, &rect
) ;
2535 InsetRect( &rect
, -4 , -4 ) ;
2536 RectRgn( updateOuter
, &rect
) ;
2537 DiffRgn( updateOuter
, updateInner
,updateOuter
) ;
2538 wxPoint
parent(0,0);
2539 GetParent()->MacWindowToRootWindow( &parent
.x
, &parent
.y
) ;
2540 parent
-= GetParent()->GetClientAreaOrigin() ;
2541 OffsetRgn( updateOuter
, -parent
.x
, -parent
.y
) ;
2542 GetParent()->m_peer
->SetNeedsDisplay( true , updateOuter
) ;
2543 DisposeRgn(updateOuter
) ;
2544 DisposeRgn(updateInner
) ;
2551 void wxWindowMac::OnInternalIdle()
2553 // This calls the UI-update mechanism (querying windows for
2554 // menu/toolbar/control state information)
2555 if (wxUpdateUIEvent::CanUpdate(this))
2556 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
2559 // Raise the window to the top of the Z order
2560 void wxWindowMac::Raise()
2562 m_peer
->SetZOrder( true , NULL
) ;
2565 // Lower the window to the bottom of the Z order
2566 void wxWindowMac::Lower()
2568 m_peer
->SetZOrder( false , NULL
) ;
2572 // static wxWindow *gs_lastWhich = NULL;
2574 bool wxWindowMac::MacSetupCursor( const wxPoint
& pt
)
2576 // first trigger a set cursor event
2578 wxPoint clientorigin
= GetClientAreaOrigin() ;
2579 wxSize clientsize
= GetClientSize() ;
2581 if ( wxRect2DInt( clientorigin
.x
, clientorigin
.y
, clientsize
.x
, clientsize
.y
).Contains( wxPoint2DInt( pt
) ) )
2583 wxSetCursorEvent
event( pt
.x
, pt
.y
);
2585 bool processedEvtSetCursor
= GetEventHandler()->ProcessEvent(event
);
2586 if ( processedEvtSetCursor
&& event
.HasCursor() )
2588 cursor
= event
.GetCursor() ;
2593 // the test for processedEvtSetCursor is here to prevent using m_cursor
2594 // if the user code caught EVT_SET_CURSOR() and returned nothing from
2595 // it - this is a way to say that our cursor shouldn't be used for this
2597 if ( !processedEvtSetCursor
&& m_cursor
.Ok() )
2607 cursor
= *wxSTANDARD_CURSOR
;
2611 cursor
.MacInstall() ;
2613 return cursor
.Ok() ;
2616 wxString
wxWindowMac::MacGetToolTipString( wxPoint
&pt
)
2620 return m_tooltip
->GetTip() ;
2622 return wxEmptyString
;
2625 void wxWindowMac::Update()
2627 #if TARGET_API_MAC_OSX
2629 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
2630 WindowRef window
= (WindowRef
)MacGetTopLevelWindowRef() ;
2632 // for composited windows this also triggers a redraw of all
2633 // invalid views in the window
2634 if( UMAGetSystemVersion() >= 0x1030 )
2635 HIWindowFlush(window
) ;
2639 // the only way to trigger the redrawing on earlier systems is to call
2642 EventRef currentEvent
= (EventRef
) wxTheApp
->MacGetCurrentEvent() ;
2643 UInt32 currentEventClass
= 0 ;
2644 UInt32 currentEventKind
= 0 ;
2645 if ( currentEvent
!= NULL
)
2647 currentEventClass
= ::GetEventClass( currentEvent
) ;
2648 currentEventKind
= ::GetEventKind( currentEvent
) ;
2650 if ( currentEventClass
!= kEventClassMenu
)
2652 // when tracking a menu, strange redraw errors occur if we flush now, so leave..
2655 OSStatus status
= noErr
;
2656 status
= ReceiveNextEvent( 0 , NULL
, kEventDurationNoWait
, false , &theEvent
) ;
2659 m_peer
->SetNeedsDisplay( true ) ;
2662 ::Draw1Control( m_peer
->GetControlRef() ) ;
2666 wxTopLevelWindowMac
* wxWindowMac::MacGetTopLevelWindow() const
2668 wxTopLevelWindowMac
* win
= NULL
;
2669 WindowRef window
= (WindowRef
) MacGetTopLevelWindowRef() ;
2672 win
= wxFindWinFromMacWindow( window
) ;
2676 wxRegion
wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures
)
2678 // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
2679 // also a window dc uses this, in this case we only clip in the hierarchy for hard
2680 // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
2681 // to add focus borders everywhere
2684 RgnHandle visRgn
= NewRgn() ;
2685 RgnHandle tempRgn
= NewRgn() ;
2686 if ( m_peer
->IsVisible())
2688 m_peer
->GetRect( &r
) ;
2689 r
.left
-= MacGetLeftBorderSize() ;
2690 r
.top
-= MacGetTopBorderSize() ;
2691 r
.bottom
+= MacGetBottomBorderSize() ;
2692 r
.right
+= MacGetRightBorderSize() ;
2694 if (! MacGetTopLevelWindow()->MacUsesCompositing() )
2696 MacRootWindowToWindow( &r
.left
, & r
.top
) ;
2697 MacRootWindowToWindow( &r
.right
, & r
.bottom
) ;
2706 if ( includeOuterStructures
)
2707 InsetRect( &r
, -4 , -4 ) ;
2708 RectRgn( visRgn
, &r
) ;
2710 if ( !IsTopLevel() )
2712 wxWindow
* child
= this ;
2713 wxWindow
* parent
= child
->GetParent() ;
2718 // we have to find a better clipping algorithm here, in order not to clip things
2719 // positioned like status and toolbar
2720 if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
2722 size
= parent
->GetSize() ;
2727 size
= parent
->GetClientSize() ;
2728 wxPoint origin
= parent
->GetClientAreaOrigin() ;
2732 parent
->MacWindowToRootWindow( &x
, &y
) ;
2733 MacRootWindowToWindow( &x
, &y
) ;
2735 if ( !includeOuterStructures
|| (
2736 parent
->MacClipChildren() ||
2737 ( parent
->GetParent() && parent
->GetParent()->MacClipGrandChildren() )
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
;