X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b573fb839d791af52be6c7edb8d51c4b58962b8..7fcb33e5f7911aca4540a2d8a4a9834419c34dd6:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 184148f5f3..444bb432dd 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -9,11 +9,12 @@ // 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" @@ -24,7 +25,6 @@ #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" @@ -37,8 +37,6 @@ #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" @@ -47,9 +45,6 @@ #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 @@ -86,7 +81,9 @@ extern wxList wxPendingDelete; BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) EVT_NC_PAINT(wxWindowMac::OnNcPaint) EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) -// TODO EVT_PAINT(wxWindowMac::OnPaint) +#if TARGET_API_MAC_OSX + EVT_PAINT(wxWindowMac::OnPaint) +#endif EVT_SET_FOCUS(wxWindowMac::OnSetFocus) EVT_KILL_FOCUS(wxWindowMac::OnSetFocus) EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent) @@ -223,9 +220,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl #if 0 // in case we would need a coregraphics compliant background erase first // now usable to track redraws - CGContextRef cgContext = cEvent.GetParameter(kEventParamCGContextRef) ; if ( thisWindow->MacIsUserPane() ) { + CGContextRef cgContext = cEvent.GetParameter(kEventParamCGContextRef) ; static float color = 0.5 ; static channel = 0 ; HIRect bounds; @@ -242,9 +239,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl channel = 0 ; } } +#endif +#if wxMAC_USE_CORE_GRAPHICS + CGContextRef cgContext = cEvent.GetParameter(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 ) ; } @@ -411,6 +415,8 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler ) +#if !TARGET_API_MAC_OSX + // --------------------------------------------------------------------------- // UserPane events for non OSX builds // --------------------------------------------------------------------------- @@ -522,10 +528,13 @@ ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ; ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ; ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ; +#endif + // =========================================================================== // implementation // =========================================================================== +#if KEY_wxList_DEPRECATED wxList wxWinMacControlList(wxKEY_INTEGER); wxWindow *wxFindControlFromMacControl(ControlRef inControl ) @@ -550,6 +559,42 @@ void wxRemoveMacControlAssociation(wxWindow *control) { 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 ; @@ -658,9 +703,12 @@ void wxWindowMac::Init() 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 ) ; @@ -672,6 +720,7 @@ void wxWindowMac::Init() gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ; gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ; } +#endif if ( wxMacLiveScrollbarActionUPP == NULL ) { wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc ); @@ -813,8 +862,6 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return FALSE; - parent->AddChild(this); - m_windowVariant = parent->GetWindowVariant() ; if ( m_macIsUserPane ) @@ -863,17 +910,32 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, 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") ) ; m_peer->SetReference( (long) this ) ; + GetParent()->AddChild(this); MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ); 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 ) ; @@ -1354,12 +1416,12 @@ void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , in 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 @@ -1382,12 +1444,12 @@ wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const 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 @@ -1414,12 +1476,12 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const 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 ) ; @@ -1724,10 +1786,12 @@ wxSize wxWindowMac::DoGetBestSize() const { bestsize.bottom = 16 ; } +#if wxUSE_SPINBTN else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) { bestsize.bottom = 24 ; } +#endif // wxUSE_SPINBTN else { // return wxWindowBase::DoGetBestSize() ; @@ -1872,11 +1936,14 @@ bool wxWindowMac::Show(bool show) return FALSE; // TODO use visibilityChanged Carbon Event for OSX - bool former = MacIsReallyShown() ; + if ( m_peer ) + { + bool former = MacIsReallyShown() ; - m_peer->SetVisibility( show , true ) ; - if ( former != MacIsReallyShown() ) - MacPropagateVisibilityChanged() ; + m_peer->SetVisibility( show , true ) ; + if ( former != MacIsReallyShown() ) + MacPropagateVisibilityChanged() ; + } return TRUE; } @@ -1903,7 +1970,7 @@ void wxWindowMac::MacPropagateVisibilityChanged() #if !TARGET_API_MAC_OSX MacVisibilityChanged() ; - wxWindowListNode *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindowMac *child = node->GetData(); @@ -1919,7 +1986,7 @@ void wxWindowMac::MacPropagateEnabledStateChanged( ) #if !TARGET_API_MAC_OSX MacEnabledStateChanged() ; - wxWindowListNode *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindowMac *child = node->GetData(); @@ -1935,7 +2002,7 @@ void wxWindowMac::MacPropagateHiliteChanged( ) #if !TARGET_API_MAC_OSX MacHiliteChanged() ; - wxWindowListNode *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindowMac *child = node->GetData(); @@ -1969,6 +2036,9 @@ void wxWindowMac::MacEnabledStateChanged() 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(); @@ -2157,24 +2227,6 @@ void wxWindowMac::Thaw() #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) { @@ -2201,6 +2253,13 @@ void wxWindowMac::OnEraseBackground(wxEraseEvent& event) { event.Skip() ; } + else if ( m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme ) + { + if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) + { + CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; + } + } else #endif { @@ -2342,8 +2401,8 @@ void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, { 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 @@ -2359,8 +2418,8 @@ void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, { 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() ; @@ -2429,12 +2488,33 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) 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; @@ -2460,36 +2540,36 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) 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); } } // Get the window with the focus -wxWindowMac *wxWindowBase::FindFocus() +wxWindowMac *wxWindowBase::DoFindFocus() { ControlRef control ; GetKeyboardFocus( GetUserFocusWindow() , &control ) ; @@ -2511,6 +2591,7 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event) if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) { + #if !wxMAC_USE_CORE_GRAPHICS wxMacWindowStateSaver sv( this ) ; int w , h ; @@ -2542,6 +2623,9 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event) DisposeRgn(updateOuter) ; DisposeRgn(updateInner) ; } +#else + GetParent()->Refresh() ; +#endif } event.Skip(); @@ -2621,11 +2705,19 @@ wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) return wxEmptyString ; } +void wxWindowMac::ClearBackground() +{ + Refresh() ; + Update() ; +} + void wxWindowMac::Update() { #if TARGET_API_MAC_OSX - WindowRef window = (WindowRef)MacGetTopLevelWindowRef() ; + #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 + WindowRef window = (WindowRef)MacGetTopLevelWindowRef() ; + // for composited windows this also triggers a redraw of all // invalid views in the window if( UMAGetSystemVersion() >= 0x1030 ) @@ -2680,7 +2772,7 @@ wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) 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() ; @@ -2730,9 +2822,8 @@ wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) MacRootWindowToWindow( &x , &y ) ; if ( !includeOuterStructures || ( - parent->IsKindOf( CLASSINFO( wxScrolledWindow ) ) || - parent->IsKindOf( CLASSINFO( wxSashLayoutWindow ) ) || - ( parent->GetParent() && parent->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow ) ) ) + parent->MacClipChildren() || + ( parent->GetParent() && parent->GetParent()->MacClipGrandChildren() ) ) ) { SetRectRgn( tempRgn , @@ -2765,6 +2856,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) 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) ) { @@ -2791,21 +2883,12 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) if ( !m_updateRegion.Empty() ) { // paint the window itself + wxPaintEvent event; - event.m_timeStamp = time ; + event.SetTimestamp(time); event.SetEventObject(this); - handled = GetEventHandler()->ProcessEvent(event); - - // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards - if ( !handled ) - { - if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) - { - CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; - handled = true ; - } - } - + GetEventHandler()->ProcessEvent(event); + handled = true ; } // now we cannot rely on having its borders drawn by a window itself, as it does not @@ -2814,7 +2897,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) // 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; @@ -2832,6 +2915,36 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) { if ( RectInRgn( &childRect , updatergn ) ) { +#if wxMAC_USE_CORE_GRAPHICS +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 + if ( HIThemeDrawFrame ) + { + Rect srect = childRect ; + HIThemeFrameDrawInfo info ; + info.version = 0 ; + info.kind = 0 ; + info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ; + if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) + { + SInt32 border = 0 ; + GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ; + InsetRect( &srect , border , border ); + info.kind = kHIThemeFrameTextFieldSquare ; + } + else if (HasFlag(wxSIMPLE_BORDER)) + { + SInt32 border = 0 ; + GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; + InsetRect( &srect , border , border ); + info.kind = kHIThemeFrameListBox ; + } + + CGRect rect = CGRectMake( srect.left , srect.top , srect.right - srect.left , + srect.bottom - srect.top ) ; + HIThemeDrawFrame( &rect , &info , (CGContextRef) MacGetCGContextRef() , kHIThemeOrientationNormal ) ; + } +#endif +#else // paint custom borders wxNcPaintEvent eventNc( child->GetId() ); eventNc.SetEventObject( child ); @@ -2842,54 +2955,34 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) 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 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 + if ( HIThemeDrawFocusRect ) + { + CGRect rect = CGRectMake( childRect.left , childRect.top , childRect.right - childRect.left , + childRect.bottom - childRect.top ) ; + HIThemeDrawFocusRect( &rect , true , (CGContextRef) MacGetCGContextRef() , kHIThemeOrientationNormal ) ; + } +#endif +#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 { @@ -2933,13 +3026,13 @@ void wxWindowMac::MacCreateScrollBars( long style ) 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); } } @@ -3037,7 +3130,7 @@ void wxWindowMac::MacSuperChangedPosition() { // 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(); @@ -3050,7 +3143,7 @@ void wxWindowMac::MacTopLevelWindowChangedPosition() { // 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(); @@ -3144,6 +3237,19 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) } } +void wxWindowMac::OnPaint( wxPaintEvent & event ) +{ + // in the other case we already have drawn from the OnEraseBackground Handler + if ( !m_macBackgroundBrush.Ok() || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT || + m_macBackgroundBrush.MacGetBrushKind() != kwxMacBrushTheme ) + { + if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) + { + CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; + } + } +} + void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { }