// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "window.h"
#endif
-#include "wx/setup.h"
+#include "wx/wxprec.h"
+
#include "wx/menu.h"
#include "wx/window.h"
#include "wx/dc.h"
#if 0
// in case we would need a coregraphics compliant background erase first
// now usable to track redraws
- CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
if ( thisWindow->MacIsUserPane() )
{
+ CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
static float color = 0.5 ;
static channel = 0 ;
HIRect bounds;
channel = 0 ;
}
}
+#endif
+#if wxMAC_USE_CORE_GRAPHICS
+ CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
+ thisWindow->MacSetCGContextRef( cgContext ) ;
#endif
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
result = noErr ;
+#if wxMAC_USE_CORE_GRAPHICS
+ thisWindow->MacSetCGContextRef( NULL ) ;
+#endif
if ( allocatedRgn )
DisposeRgn( allocatedRgn ) ;
}
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
+#if !TARGET_API_MAC_OSX
+
// ---------------------------------------------------------------------------
// UserPane events for non OSX builds
// ---------------------------------------------------------------------------
ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
+#endif
+
// ===========================================================================
// implementation
// ===========================================================================
m_macBackgroundBrush = wxNullBrush ;
m_macIsUserPane = TRUE;
-
+#if wxMAC_USE_CORE_GRAPHICS
+ m_cgContextRef = NULL ;
+#endif
// make sure all proc ptrs are available
+#if !TARGET_API_MAC_OSX
if ( gControlUserPaneDrawUPP == NULL )
{
gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ;
gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
}
+#endif
if ( wxMacLiveScrollbarActionUPP == NULL )
{
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
bool wxWindowMac::MacIsReallyShown()
{
// only under OSX the visibility of the TLW is taken into account
+ if ( m_isBeingDeleted )
+ return false ;
+
#if TARGET_API_MAC_OSX
if ( m_peer && m_peer->Ok() )
return m_peer->IsVisible();
#endif
}
-void wxWindowMac::MacRedrawControl()
-{
-/*
- if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
- {
-#if TARGET_API_MAC_CARBON
- Update() ;
-#else
- wxClientDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
- wxMacWindowClipper clipper(this) ;
- wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
- UMADrawControl( *m_peer ) ;
-#endif
- }
-*/
-}
-
/* TODO
void wxWindowMac::OnPaint(wxPaintEvent& event)
{
{
if ( !m_hScrollBar->IsShown() )
m_hScrollBar->Show(true) ;
- m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
+ m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
}
else
{
if ( !m_vScrollBar->IsShown() )
m_vScrollBar->Show(true) ;
- m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
+ m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
}
}
MacRepositionScrollBars() ;
SectRect( &scrollrect , &r , &scrollrect ) ;
}
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
+
+ // now scroll the former update region as well and add the new update region
+
+ WindowRef rootWindow = (WindowRef) MacGetTopLevelWindowRef() ;
+ RgnHandle formerUpdateRgn = NewRgn() ;
+ RgnHandle scrollRgn = NewRgn() ;
+ RectRgn( scrollRgn , &scrollrect ) ;
+ GetWindowUpdateRgn( rootWindow , formerUpdateRgn ) ;
+ Point pt = {0,0} ;
+ LocalToGlobal( &pt ) ;
+ OffsetRgn( formerUpdateRgn , -pt.h , -pt.v ) ;
+ SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
+ if ( !EmptyRgn( formerUpdateRgn ) )
+ {
+ MacOffsetRgn( formerUpdateRgn , dx , dy ) ;
+ SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
+ InvalWindowRgn(rootWindow , formerUpdateRgn ) ;
+ }
+ InvalWindowRgn(rootWindow , updateRgn ) ;
+ DisposeRgn( updateRgn ) ;
+ DisposeRgn( formerUpdateRgn ) ;
+ DisposeRgn( scrollRgn ) ;
}
- // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
#endif
}
void wxWindowMac::MacOnScroll(wxScrollEvent &event )
{
- if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar )
+ if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
{
wxScrollWinEvent wevent;
wevent.SetPosition(event.GetPosition());
wevent.SetOrientation(event.GetOrientation());
- wevent.m_eventObject = this;
-
- if (event.m_eventType == wxEVT_SCROLL_TOP)
- wevent.m_eventType = wxEVT_SCROLLWIN_TOP;
- else if (event.m_eventType == wxEVT_SCROLL_BOTTOM)
- wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
- else if (event.m_eventType == wxEVT_SCROLL_LINEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
- else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
+ wevent.SetEventObject(this);
+
+ if (event.GetEventType() == wxEVT_SCROLL_TOP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_TOP );
+ else if (event.GetEventType() == wxEVT_SCROLL_BOTTOM)
+ wevent.SetEventType( wxEVT_SCROLLWIN_BOTTOM );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBTRACK)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE );
GetEventHandler()->ProcessEvent(wevent);
}
Rect r ;
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
- if ( m_peer->IsVisible())
+ if ( !m_isBeingDeleted && m_peer->IsVisible())
{
m_peer->GetRect( &r ) ;
r.left -= MacGetLeftBorderSize() ;
bool handled = false ;
Rect updatebounds ;
GetRegionBounds( updatergn , &updatebounds ) ;
+
// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
if ( !EmptyRgn(updatergn) )
{
{
// paint the window itself
wxPaintEvent event;
- event.m_timeStamp = time ;
+ event.SetTimestamp(time);
event.SetEventObject(this);
handled = GetEventHandler()->ProcessEvent(event);
{
if ( RectInRgn( &childRect , updatergn ) )
{
+#if wxMAC_USE_CORE_GRAPHICS
+#else
// paint custom borders
wxNcPaintEvent eventNc( child->GetId() );
eventNc.SetEventObject( child );
wxMacPortSetter helper(&dc) ;
child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ;
}
+#endif
}
}
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
{
+#if wxMAC_USE_CORE_GRAPHICS
+#else
wxWindowDC dc(this) ;
dc.SetClippingRegion(wxRegion(updatergn));
wxMacPortSetter helper(&dc) ;
Rect r = childRect ;
OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
DrawThemeFocusRect( &r , true ) ;
+#endif
}
}
}
return handled ;
}
-void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
-{
- RgnHandle updatergn = (RgnHandle) updatergnr ;
- // updatergn is always already clipped to our boundaries
- // if we are in compositing mode then it is in relative to the upper left of the control
- // if we are in non-compositing, then it is relatvie to the uppder left of the content area
- // of the toplevel window
- // it is in window coordinates, not in client coordinates
-
- // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
- RgnHandle ownUpdateRgn = NewRgn() ;
- CopyRgn( updatergn , ownUpdateRgn ) ;
-
- if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
- {
- Rect bounds;
- m_peer->GetRectInWindowCoords( &bounds );
- RgnHandle controlRgn = NewRgn();
- RectRgn( controlRgn, &bounds );
- //KO: This sets the ownUpdateRgn to the area of this control that is inside
- // the window update region
- SectRgn( ownUpdateRgn, controlRgn, ownUpdateRgn );
- DisposeRgn( controlRgn );
-
- //KO: convert ownUpdateRgn to local coordinates
- OffsetRgn( ownUpdateRgn, -bounds.left, -bounds.top );
- }
-
- MacDoRedraw( ownUpdateRgn , time ) ;
- DisposeRgn( ownUpdateRgn ) ;
-
-}
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
{