#include "wx/layout.h"
#include "wx/dialog.h"
#include "wx/scrolbar.h"
+#include "wx/scrolwin.h"
#include "wx/statbox.h"
#include "wx/button.h"
#include "wx/settings.h"
#include "wx/log.h"
#include "wx/geometry.h"
#include "wx/textctrl.h"
+#include "wx/laywin.h"
+#include "wx/splitter.h"
#include "wx/toolbar.h"
#include "wx/dc.h"
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) ;
+ }
+ }
+
#ifndef __WXUNIVERSAL__
// VS: make sure there's no wxFrame with last focus set to us:
for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
{
if ( AcceptsFocus() )
{
-#if !TARGET_API_MAC_OSX
+
wxWindow* former = FindFocus() ;
-#endif
+ if ( former == this )
+ return ;
+
OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
// as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only
// leave in case of an error
if ( adjustOrigin )
AdjustForParentClientOrigin( x , y ) ;
+#if TARGET_API_MAC_OSX
+ // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
+ if ( ! GetParent()->IsTopLevel() )
+ {
+ x -= GetParent()->MacGetLeftBorderSize() ;
+ y -= GetParent()->MacGetTopBorderSize() ;
+ }
+#endif
return true ;
}
{
// we don't adjust twice for the origin
Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
-#if TARGET_API_MAC_OSX
- // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
- if ( ! GetParent()->IsTopLevel() )
+ bool vis = m_peer->IsVisible();
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( vis && ( outerBorder > 0 ) )
{
- r.left -= GetParent()->MacGetLeftBorderSize() ;
- r.top -= GetParent()->MacGetTopBorderSize() ;
- r.right -= GetParent()->MacGetLeftBorderSize() ;
- r.bottom -= GetParent()->MacGetTopBorderSize() ;
+ // 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 ) ;
+
+ 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
- bool vis = m_peer->IsVisible();
// the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
if ( vis )
m_peer->SetVisibility( false , true ) ;
+
m_peer->SetRect( &r ) ;
if ( vis )
m_peer->SetVisibility( true , true ) ;
}
else
#endif
- event.GetDC()->Clear() ;
+ {
+ event.GetDC()->Clear() ;
+ }
}
void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
if( IsTopLevel() )
return ;
- int w , h ;
- GetSize( &w , &h ) ;
- Rect rect = { top , left , h + top , w + left } ;
+ Rect rect ;
+ m_peer->GetRect( &rect ) ;
+ InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+
+ if ( !IsTopLevel() )
+ {
+ 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 ;
+ }
+ }
+
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
{
Rect srect = rect ;
}
wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures )
{
-
+ // includeOuterStructures is true if we try to draw somthing like a focus ring etc.
+ // also a window dc uses this, in this case we only clip in the hierarchy for hard
+ // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
+ // to add focus borders everywhere
+
Rect r ;
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
parent->MacWindowToRootWindow( &x, &y ) ;
MacRootWindowToWindow( &x , &y ) ;
- SetRectRgn( tempRgn ,
- x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
- x + size.x - parent->MacGetRightBorderSize(),
- y + size.y - parent->MacGetBottomBorderSize()) ;
+ if ( !includeOuterStructures || (
+ parent->IsKindOf( CLASSINFO( wxScrolledWindow ) ) ||
+ parent->IsKindOf( CLASSINFO( wxSashLayoutWindow ) ) ||
+ ( parent->GetParent() && parent->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow ) ) )
+ ) )
+ {
+ SetRectRgn( tempRgn ,
+ x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
+ x + size.x - parent->MacGetRightBorderSize(),
+ y + size.y - parent->MacGetBottomBorderSize()) ;
- SectRgn( visRgn , tempRgn , visRgn ) ;
+ SectRgn( visRgn , tempRgn , visRgn ) ;
+ }
if ( parent->IsTopLevel() )
break ;
child = parent ;
wxWindowDC dc(this) ;
dc.SetClippingRegion(wxRegion(updatergn));
wxMacPortSetter helper(&dc) ;
- OffsetRect( &childRect , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
- DrawThemeFocusRect( &childRect , true ) ;
+ Rect r = childRect ;
+ OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
+ DrawThemeFocusRect( &r , true ) ;
}
}
}