// 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"
#include "wx/caret.h"
#endif // wxUSE_CARET
-#define wxWINDOW_HSCROLL 5998
-#define wxWINDOW_VSCROLL 5997
-
#define MAC_SCROLLBAR_SIZE 15
#define MAC_SMALL_SCROLLBAR_SIZE 11
#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
// ===========================================================================
+#if KEY_wxList_DEPRECATED
wxList wxWinMacControlList(wxKEY_INTEGER);
wxWindow *wxFindControlFromMacControl(ControlRef inControl )
{
wxWinMacControlList.DeleteObject(control);
}
+#else
+
+WX_DECLARE_HASH_MAP(ControlRef, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap);
+
+static MacControlMap wxWinMacControlList;
+
+wxWindow *wxFindControlFromMacControl(ControlRef inControl )
+{
+ MacControlMap::iterator node = wxWinMacControlList.find(inControl);
+
+ return (node == wxWinMacControlList.end()) ? NULL : node->second;
+}
+
+void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control)
+{
+ // adding NULL ControlRef is (first) surely a result of an error and
+ // (secondly) breaks native event processing
+ wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
+
+ wxWinMacControlList[inControl] = control;
+}
+
+void wxRemoveMacControlAssociation(wxWindow *control)
+{
+ // iterate over all the elements in the class
+ MacControlMap::iterator it;
+ for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it )
+ {
+ if ( it->second == control )
+ {
+ wxWinMacControlList.erase(it);
+ break;
+ }
+ }
+}
+#endif // deprecated wxList
// UPP functions
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
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 );
return TRUE;
}
+void wxWindowMac::MacChildAdded()
+{
+ if ( m_vScrollBar )
+ {
+ m_vScrollBar->Raise() ;
+ }
+ if ( m_hScrollBar )
+ {
+ m_hScrollBar->Raise() ;
+ }
+
+}
+
void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
{
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
ControlRef container = (ControlRef) GetParent()->GetHandle() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( m_peer->GetControlRef() , container ) ;
+ GetParent()->MacChildAdded() ;
// adjust font, controlsize etc
DoSetWindowVariant( m_windowVariant ) ;
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
#if !TARGET_API_MAC_OSX
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
#if !TARGET_API_MAC_OSX
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
GetRegionBounds( rgn , &content ) ;
- DisposeRgn( rgn ) ;
}
else
{
m_peer->GetRect( &content ) ;
}
+ DisposeRgn( rgn ) ;
#if !TARGET_API_MAC_OSX
Rect structure ;
m_peer->GetRect( &structure ) ;
#if !TARGET_API_MAC_OSX
MacVisibilityChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
#if !TARGET_API_MAC_OSX
MacEnabledStateChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
#if !TARGET_API_MAC_OSX
MacHiliteChanged() ;
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
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
}
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
{
wxWindowMac *child = node->GetData();
if (child == m_vScrollBar) continue;
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);
// in Composited windowing
wxPoint clientOrigin = GetClientAreaOrigin() ;
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
{
wxWindowMac *child = node->GetData();
if (child == m_vScrollBar) continue;
{
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
{
if ( style & wxVSCROLL )
{
- m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint,
+ m_vScrollBar = new wxScrollBar(this, wxID_ANY, vPoint,
vSize , wxVERTICAL);
}
if ( style & wxHSCROLL )
{
- m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint,
+ m_hScrollBar = new wxScrollBar(this, wxID_ANY, hPoint,
hSize , wxHORIZONTAL);
}
}
{
// only window-absolute structures have to be moved i.e. controls
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();
{
// only screen-absolute structures have to be moved i.e. glcanvas
- wxWindowListNode *node = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
{
wxWindowMac *child = node->GetData();