case kEventControlHiliteChanged :
thisWindow->MacHiliteChanged() ;
break ;
+#endif
+ // we emulate this event under Carbon CFM
case kEventControlSetFocusPart :
{
Boolean focusEverything = false ;
ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
+#ifdef __WXMAC_OSX__
if ( cEvent.GetParameter<Boolean>(kEventParamControlFocusEverything , &focusEverything ) == noErr )
{
}
+#endif
if ( controlPart == kControlFocusNoPart )
{
#if wxUSE_CARET
result = noErr ;
}
break ;
-#endif
case kEventControlHit :
{
result = thisWindow->MacControlHit( handler , event ) ;
m_isBeingDeleted = TRUE;
- if ( m_peer )
- {
- // deleting a window while it is shown invalidates the region occupied by border or
- // focus
- int outerBorder = MacGetLeftBorderSize() ;
- if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
- outerBorder += 4 ;
-
- if ( IsShown() && ( outerBorder > 0 ) )
- {
- // as the borders are drawn on the parent we have to properly invalidate all these areas
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
-
- Rect rect ;
-
- m_peer->GetRect( &rect ) ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- CopyRgn( updateOuter , updateTotal ) ;
-
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
- DisposeRgn(updateTotal) ;
- }
- }
+ MacInvalidateBorders() ;
#ifndef __WXUNIVERSAL__
// VS: make sure there's no wxFrame with last focus set to us:
// | kControlWantsIdle
;
- m_peer = new wxMacControl() ;
+ m_peer = new wxMacControl(this) ;
::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() );
void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
{
- #if TARGET_API_MAC_OSX
wxPoint pt ;
if ( x ) pt.x = *x ;
if ( y ) pt.y = *y ;
if ( x ) *x = (int) pt.x ;
if ( y ) *y = (int) pt.y ;
- #else
- if ( !IsTopLevel() )
- {
- Rect bounds ;
- m_peer->GetRect( &bounds ) ;
- if(x) *x += bounds.left - MacGetLeftBorderSize() ;
- if(y) *y += bounds.top - MacGetTopBorderSize() ;
- }
-#endif
}
void wxWindowMac::MacWindowToRootWindow( short *x , short *y ) const
void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
{
- #if TARGET_API_MAC_OSX
wxPoint pt ;
if ( x ) pt.x = *x ;
if ( y ) pt.y = *y ;
if ( x ) *x = (int) pt.x ;
if ( y ) *y = (int) pt.y ;
- #else
- if ( !IsTopLevel() )
- {
- Rect bounds ;
- m_peer->GetRect( &bounds ) ;
- if(x) *x -= bounds.left + MacGetLeftBorderSize() ;
- if(y) *y -= bounds.top + MacGetTopBorderSize() ;
- }
-#endif
}
void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const
#endif // wxUSE_TOOLTIPS
+void wxWindowMac::MacInvalidateBorders()
+{
+ if ( m_peer == NULL )
+ return ;
+
+ bool vis = MacIsReallyShown() ;
+ if ( !vis )
+ return ;
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( outerBorder == 0 )
+ return ;
+
+ // now we know that we have something to do at all
+
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() ,
+ updateOuter = NewRgn() ;
+
+ // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
+ Rect rect ;
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+#ifdef __WXMAC_OSX__
+ GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
+#else
+ WindowRef tlw = (WindowRef) MacGetTopLevelWindowRef() ;
+ if ( tlw )
+ InvalWindowRgn( tlw , updateOuter ) ;
+#endif
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+/*
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -4 , -4 ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+*/
+/*
+ if ( m_peer )
+ {
+ // deleting a window while it is shown invalidates the region occupied by border or
+ // focus
+
+ if ( IsShown() && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+ }
+*/
+#if 0
+ Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( vis && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ /*
+ wxPoint parent(0,0);
+#if TARGET_API_MAC_OSX
+ // no offsetting needed when compositing
+#else
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+#endif
+ */
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ rect = r ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+/*
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+*/
+ UnionRgn( updateOuter , updateTotal , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+#endif
+}
+
void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
{
// this is never called for a toplevel window, so we know we have a parent
{
// we don't adjust twice for the origin
Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
- bool vis = m_peer->IsVisible();
-
- int outerBorder = MacGetLeftBorderSize() ;
- if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
- outerBorder += 4 ;
-
- if ( vis && ( outerBorder > 0 ) )
- {
- // as the borders are drawn on the parent we have to properly invalidate all these areas
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+ bool vis = MacIsReallyShown() ;
- Rect rect ;
-
- m_peer->GetRect( &rect ) ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
-#if TARGET_API_MAC_OSX
- // no offsetting needed when compositing
-#else
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
-#endif
- CopyRgn( updateOuter , updateTotal ) ;
-
- rect = r ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
-
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- UnionRgn( updateOuter , updateTotal , updateTotal ) ;
-
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
- DisposeRgn(updateTotal) ;
- }
+ MacInvalidateBorders() ;
// the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
if ( vis )
if ( vis )
m_peer->SetVisibility( true , true ) ;
+ MacInvalidateBorders() ;
+
MacRepositionScrollBars() ;
if ( doMove )
{
InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
DisposeRgn(updateRgn) ;
*/
- if ( m_peer->IsVisible())
+ if ( MacIsReallyShown() )
{
m_peer->SetVisibility( false , false ) ;
m_peer->SetVisibility( true , true ) ;
else
#endif
{
+#ifdef __WXMAC_OSX__
+ // as the non OSX Version is already working in window relative coordinates, it's not needed
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
if (top)
{
rect.top += pt.y ;
rect.bottom += pt.y ;
}
+#endif
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
{
{
#if !wxMAC_USE_CORE_GRAPHICS
wxMacWindowStateSaver sv( this ) ;
-
- int w , h ;
- int x , y ;
- x = y = 0 ;
- MacWindowToRootWindow( &x , &y ) ;
- GetSize( &w , &h ) ;
- Rect rect = {y , x , h + y , w + x } ;
+ Rect rect ;
+ m_peer->GetRect( &rect ) ;
+ InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+#ifdef __WXMAC_OSX__
+ // as the non OSX Version is already working in window relative coordinates, it's not needed
+ wxTopLevelWindowMac* top = MacGetTopLevelWindow();
+ if (top)
+ {
+ wxPoint pt(0,0) ;
+ wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
+ rect.left += pt.x ;
+ rect.right += pt.x ;
+ rect.top += pt.y ;
+ rect.bottom += pt.y ;
+ }
+#endif
if ( event.GetEventType() == wxEVT_SET_FOCUS )
DrawThemeFocusRect( &rect , true ) ;
// as this erases part of the frame we have to redraw borders
// and because our z-ordering is not always correct (staticboxes)
// we have to invalidate things, we cannot simple redraw
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -4 , -4 ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
+ MacInvalidateBorders() ;
}
#else
GetParent()->Refresh() ;
Rect r ;
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
- if ( !m_isBeingDeleted && m_peer->IsVisible())
+ if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ )
{
m_peer->GetRect( &r ) ;
r.left -= MacGetLeftBorderSize() ;