implement propert background style semantics for OS X

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-06-18 15:33:51 +00:00
parent 443c594a75
commit 69ce9cea39
2 changed files with 46 additions and 76 deletions

View File

@@ -131,8 +131,6 @@ public:
// event handlers
// --------------
void OnNcPaint( wxNcPaintEvent& event );
void OnEraseBackground(wxEraseEvent& event );
void OnMouseEvent( wxMouseEvent &event );
void MacOnScroll( wxScrollEvent&event );

View File

@@ -83,8 +83,6 @@
#endif
BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
EVT_NC_PAINT(wxWindowMac::OnNcPaint)
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
END_EVENT_TABLE()
@@ -1182,39 +1180,6 @@ void wxWindowMac::WarpPointer(int WXUNUSED(x_pos), int WXUNUSED(y_pos))
// We really don't move the mouse programmatically under Mac.
}
void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
{
if ( MacGetTopLevelWindow() == NULL )
return ;
/*
#if TARGET_API_MAC_OSX
if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
{
}
else
#endif
*/
if ( GetBackgroundStyle() == wxBG_STYLE_COLOUR )
{
event.GetDC()->Clear() ;
}
else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
{
// don't skip the event here, custom background means that the app
// is drawing it itself in its OnPaint(), so don't draw it at all
// now to avoid flicker
}
else
{
event.Skip() ;
}
}
void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
{
event.Skip() ;
}
int wxWindowMac::GetScrollPos(int orient) const
{
if ( orient == wxHORIZONTAL )
@@ -1784,33 +1749,40 @@ bool wxWindowMac::MacDoRedraw( long time )
wxRegion formerUpdateRgn = m_updateRegion;
wxRegion clientUpdateRgn = formerUpdateRgn;
wxSize sz = GetClientSize() ;
wxPoint origin = GetClientAreaOrigin() ;
const wxRect clientRect = GetClientRect();
clientUpdateRgn.Intersect(origin.x , origin.y , origin.x + sz.x , origin.y + sz.y);
clientUpdateRgn.Intersect(clientRect);
// first send an erase event to the entire update area
const wxBackgroundStyle bgStyle = GetBackgroundStyle();
if ( bgStyle == wxBG_STYLE_ERASE )
{
// for the toplevel window this really is the entire area
// for all the others only their client area, otherwise they
// might be drawing with full alpha and eg put blue into
// the grow-box area of a scrolled window (scroll sample)
wxDC* dc = new wxWindowDC(this);
wxWindowDC dc(this);
if ( IsTopLevel() )
dc->SetDeviceClippingRegion(formerUpdateRgn);
dc.SetDeviceClippingRegion(formerUpdateRgn);
else
dc->SetDeviceClippingRegion(clientUpdateRgn);
dc.SetDeviceClippingRegion(clientUpdateRgn);
wxEraseEvent eevent( GetId(), dc );
wxEraseEvent eevent( GetId(), &dc );
eevent.SetEventObject( this );
HandleWindowEvent( eevent );
delete dc ;
if ( !ProcessWindowEvent( eevent ) )
{
if ( bgStyle == wxBG_STYLE_SYSTEM && MacGetTopLevelWindow() )
{
dc.Clear();
}
}
}
MacPaintGrowBox();
// calculate a client-origin version of the update rgn and set m_updateRegion to that
clientUpdateRgn.Offset( -origin.x , -origin.y );
// calculate a client-origin version of the update rgn and set
// m_updateRegion to that
clientUpdateRgn.Offset(-clientRect.GetPosition());
m_updateRegion = clientUpdateRgn ;
if ( !m_updateRegion.Empty() )