#if wxUSE_GUI
+// ----------------------------------------------------------------------------
+// Native Struct Conversions
+// ----------------------------------------------------------------------------
+
+
+void wxMacRectToNative( const wxRect *wx , Rect *n )
+{
+ n->left = wx->x ;
+ n->top = wx->y ;
+ n->right = wx->x + wx->width ;
+ n->bottom = wx->y + wx->height ;
+}
+
+void wxMacNativeToRect( const Rect *n , wxRect* wx )
+{
+ wx->x = n->left ;
+ wx->y = n->top ;
+ wx->width = n->right - n->left ;
+ wx->height = n->bottom - n->top ;
+}
+
+void wxMacPointToNative( const wxPoint* wx , Point *n )
+{
+ n->h = wx->x ;
+ n->v = wx->y ;
+}
+
+void wxMacNativeToPoint( const Point *n , wxPoint* wx )
+{
+ wx->x = n->h ;
+ wx->y = n->v ;
+}
// ----------------------------------------------------------------------------
// Carbon Event Support
// Control Access Support
// ----------------------------------------------------------------------------
-wxMacControl::wxMacControl(wxWindow* peer)
+wxMacControl::wxMacControl(wxWindow* peer , bool isRootControl )
{
Init() ;
m_peer = peer ;
+ m_isRootControl = isRootControl ;
m_isCompositing = peer->MacGetTopLevelWindow()->MacUsesCompositing() ;
}
m_controlRef = NULL ;
m_needsFocusRect = false ;
m_isCompositing = false ;
+ m_isRootControl = false ;
}
void wxMacControl::Dispose()
return false ;
#endif
}
+#endif
-void wxMacControl::SetNeedsDisplay( bool needsDisplay , RgnHandle where )
+void wxMacControl::SetNeedsDisplay( RgnHandle where )
{
+ if ( !IsVisible() )
+ return ;
+
#if TARGET_API_MAC_OSX
- if ( where != NULL )
- HIViewSetNeedsDisplayInRegion( m_controlRef , where , needsDisplay ) ;
+ if ( m_isCompositing )
+ {
+ HIViewSetNeedsDisplayInRegion( m_controlRef , where , true ) ;
+ }
else
- HIViewSetNeedsDisplay( m_controlRef , needsDisplay ) ;
#endif
+ {
+ Rect controlBounds ;
+ GetControlBounds( m_controlRef, &controlBounds ) ;
+ RgnHandle update = NewRgn() ;
+ CopyRgn( where , update ) ;
+ OffsetRgn( update , controlBounds.left , controlBounds.top ) ;
+ InvalWindowRgn( GetControlOwner( m_controlRef) , update ) ;
+ }
}
+
+void wxMacControl::SetNeedsDisplay( Rect* where )
+{
+ if ( !IsVisible() )
+ return ;
+
+#if TARGET_API_MAC_OSX
+ if ( m_isCompositing )
+ {
+ if ( where != NULL )
+ {
+ RgnHandle update = NewRgn() ;
+ RectRgn( update , where ) ;
+ HIViewSetNeedsDisplayInRegion( m_controlRef , update , true ) ;
+ DisposeRgn( update ) ;
+ }
+ else
+ HIViewSetNeedsDisplay( m_controlRef , true ) ;
+ }
+ else
#endif
+ {
+ Rect controlBounds ;
+ GetControlBounds( m_controlRef, &controlBounds ) ;
+ if ( where )
+ {
+ Rect whereLocal = *where ;
+ OffsetRect( &whereLocal , controlBounds.left , controlBounds.top ) ;
+ SectRect( &controlBounds , &whereLocal, &controlBounds ) ;
+ }
+ InvalWindowRect( GetControlOwner( m_controlRef) , &controlBounds ) ;
+ }
+}
void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to )
{
{
Rect fromRect ;
Rect toRect ;
- from->GetRect( &fromRect ) ;
- to->GetRect( &toRect ) ;
+ GetControlBounds( from->m_controlRef , &fromRect ) ;
+ GetControlBounds( to->m_controlRef , &toRect ) ;
+ if ( from->m_isRootControl )
+ fromRect.left = fromRect.top = 0 ;
+ if ( to->m_isRootControl )
+ toRect.left = toRect.top = 0 ;
pt->x = pt->x + fromRect.left - toRect.left ;
pt->y = pt->y + fromRect.top - toRect.top ;
else
#endif
{
- Rect former ;
- GetControlBounds( m_controlRef , &former ) ;
- InvalWindowRect( GetControlOwner( m_controlRef ) , &former ) ;
- SetControlBounds( m_controlRef , r ) ;
- InvalWindowRect( GetControlOwner( m_controlRef ) , r ) ;
+ bool vis = IsVisible() ;
+ if ( vis )
+ {
+ Rect former ;
+ GetControlBounds( m_controlRef , &former ) ;
+ InvalWindowRect( GetControlOwner( m_controlRef ) , &former ) ;
+ }
+
+ Rect controlBounds = *r ;
+
+ wxMacControl* parent = m_peer->GetParent()->GetPeer() ;
+ if( parent->m_isRootControl == false )
+ {
+ Rect superRect ;
+ GetControlBounds( parent->m_controlRef , &superRect ) ;
+ OffsetRect( &controlBounds , superRect.left , superRect.top ) ;
+ }
+
+ SetControlBounds( m_controlRef , &controlBounds ) ;
+ if ( vis )
+ {
+ InvalWindowRect( GetControlOwner( m_controlRef ) , &controlBounds ) ;
+ }
}
}
void wxMacControl::GetRect( Rect *r )
{
GetControlBounds( m_controlRef , r ) ;
- // correct the case of the root control
- if ( r->left == -32768 && r->top == -32768 && r->bottom == 32767 && r->right == 32767)
+ if ( m_isCompositing == false )
{
- WindowRef wr = GetControlOwner( m_controlRef ) ;
- GetWindowBounds( wr , kWindowContentRgn , r ) ;
- r->right -= r->left ;
- r->bottom -= r->top ;
- r->left = 0 ;
- r->top = 0 ;
+ // correct the case of the root control
+ if ( m_isRootControl )
+ {
+ WindowRef wr = GetControlOwner( m_controlRef ) ;
+ GetWindowBounds( wr , kWindowContentRgn , r ) ;
+ r->right -= r->left ;
+ r->bottom -= r->top ;
+ r->left = 0 ;
+ r->top = 0 ;
+ }
+ else
+ {
+ wxMacControl* parent = m_peer->GetParent()->GetPeer() ;
+ if( parent->m_isRootControl == false )
+ {
+ Rect superRect ;
+ GetControlBounds( parent->m_controlRef , &superRect ) ;
+ OffsetRect( r , -superRect.left , -superRect.top ) ;
+ }
+ }
}
}
OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region )
{
- return GetControlRegion( m_controlRef , partCode , region ) ;
+ OSStatus err = GetControlRegion( m_controlRef , partCode , region ) ;
+ if ( m_isCompositing == false )
+ {
+ if ( !m_isRootControl )
+ {
+ Rect r ;
+ GetControlBounds(m_controlRef, &r ) ;
+ if ( !EmptyRgn( region ) )
+ OffsetRgn( region , -r.left , -r.top ) ;
+ }
+ }
+ return err ;
}
OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other )
{
if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 )
{
+ // as this update region is in native window locals we must adapt it to wx window local
allocatedRgn = NewRgn() ;
CopyRgn( updateRgn , allocatedRgn ) ;
// hide the given region by the new region that must be shifted
}
}
-#if 0
- // in case we would need a coregraphics compliant background erase first
- // now usable to track redraws
+#if wxMAC_DEBUG_REDRAW
if ( thisWindow->MacIsUserPane() )
{
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
if ( win )
win->MacControlUserPaneDrawProc(part) ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneDrawUPP , wxMacControlUserPaneDrawProc ) ;
static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where)
{
else
return kControlNoPart ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneHitTestUPP , wxMacControlUserPaneHitTestProc ) ;
static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc)
{
else
return kControlNoPart ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneTrackingUPP , wxMacControlUserPaneTrackingProc ) ;
static pascal void wxMacControlUserPaneIdleProc(ControlRef control)
{
if ( win )
win->MacControlUserPaneIdleProc() ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneIdleUPP , wxMacControlUserPaneIdleProc ) ;
static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
{
else
return kControlNoPart ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneKeyDownUPP , wxMacControlUserPaneKeyDownProc ) ;
static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating)
{
if ( win )
win->MacControlUserPaneActivateProc(activating) ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneActivateUPP , wxMacControlUserPaneActivateProc ) ;
static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action)
{
else
return kControlNoPart ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneFocusUPP , wxMacControlUserPaneFocusProc ) ;
static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info)
{
if ( win )
win->MacControlUserPaneBackgroundProc(info) ;
}
+wxMAC_DEFINE_PROC_GETTER( ControlUserPaneBackgroundUPP , wxMacControlUserPaneBackgroundProc ) ;
void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part)
{
{
}
-ControlUserPaneDrawUPP gControlUserPaneDrawUPP = NULL ;
-ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP = NULL ;
-ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP = NULL ;
-ControlUserPaneIdleUPP gControlUserPaneIdleUPP = NULL ;
-ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP = NULL ;
-ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ;
-ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
-ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
-
#endif
+// ---------------------------------------------------------------------------
+// Scrollbar Tracking for all
+// ---------------------------------------------------------------------------
+
+pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) ;
+pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode )
+{
+ if ( partCode != 0)
+ {
+ wxWindow* wx = wxFindControlFromMacControl( control ) ;
+ if ( wx )
+ {
+ wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ;
+ }
+ }
+}
+wxMAC_DEFINE_PROC_GETTER( ControlActionUPP , wxMacLiveScrollbarActionProc ) ;
+
// ===========================================================================
// implementation
// ===========================================================================
}
#endif // deprecated wxList
-// UPP functions
-ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
-
-ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ;
-
-// we have to setup the brush in the current port and return noErr
-// or return an error code so that the control manager walks further up the
-// hierarchy to find a correct background
-
-pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor )
-{
- OSStatus status = paramErr ;
- switch( iMessage )
- {
- case kControlMsgApplyTextColor :
- break ;
- case kControlMsgSetUpBackground :
- {
- wxWindow* wx = (wxWindow*) wxFindControlFromMacControl( iControl ) ;
- if ( wx != NULL )
- {
- /*
- const wxBrush &brush = wx->MacGetBackgroundBrush() ;
- if ( brush.Ok() )
- {
- wxDC::MacSetupBackgroundForCurrentPort( brush ) ;
- */
- // this clipping is only needed for non HIView
-
- RgnHandle clip = NewRgn() ;
- int x = 0 , y = 0;
-
- wx->MacWindowToRootWindow( &x,&y ) ;
- CopyRgn( (RgnHandle) wx->MacGetVisibleRegion().GetWXHRGN() , clip ) ;
- OffsetRgn( clip , x , y ) ;
- SetClip( clip ) ;
- DisposeRgn( clip ) ;
-
- status = noErr ;
- /*
- }
- else if ( wx->MacIsUserPane() )
- {
- // if we don't have a valid brush for such a control, we have to call the
- // setup of our parent ourselves
- status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ;
- }
- */
- }
- }
- break ;
- default :
- break ;
- }
- return status ;
-}
-
-
-pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) ;
-pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode )
-{
- if ( partCode != 0)
- {
- wxWindow* wx = wxFindControlFromMacControl( control ) ;
- if ( wx )
- {
- wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ;
- }
- }
-}
-
// ----------------------------------------------------------------------------
// constructors and such
// ----------------------------------------------------------------------------
#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 ) ;
- gControlUserPaneHitTestUPP = NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc ) ;
- gControlUserPaneTrackingUPP = NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc ) ;
- gControlUserPaneIdleUPP = NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc ) ;
- gControlUserPaneKeyDownUPP = NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc ) ;
- gControlUserPaneActivateUPP = NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc ) ;
- gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
- gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
- }
-#endif
- if ( wxMacLiveScrollbarActionUPP == NULL )
- {
- wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
- }
-
- if ( wxMacSetupControlBackgroundUPP == NULL )
- {
- wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ;
- }
-
// we need a valid font for the encodings
wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
}
#if !TARGET_API_MAC_OSX
if ( (ControlRef) control == m_peer->GetControlRef() )
{
- m_peer->SetData<ControlUserPaneDrawUPP>(kControlEntireControl,kControlUserPaneDrawProcTag,&gControlUserPaneDrawUPP) ;
- m_peer->SetData<ControlUserPaneHitTestUPP>(kControlEntireControl,kControlUserPaneHitTestProcTag,&gControlUserPaneHitTestUPP) ;
- m_peer->SetData<ControlUserPaneTrackingUPP>(kControlEntireControl,kControlUserPaneTrackingProcTag,&gControlUserPaneTrackingUPP) ;
- m_peer->SetData<ControlUserPaneIdleUPP>(kControlEntireControl,kControlUserPaneIdleProcTag,&gControlUserPaneIdleUPP) ;
- m_peer->SetData<ControlUserPaneKeyDownUPP>(kControlEntireControl,kControlUserPaneKeyDownProcTag,&gControlUserPaneKeyDownUPP) ;
- m_peer->SetData<ControlUserPaneActivateUPP>(kControlEntireControl,kControlUserPaneActivateProcTag,&gControlUserPaneActivateUPP) ;
- m_peer->SetData<ControlUserPaneFocusUPP>(kControlEntireControl,kControlUserPaneFocusProcTag,&gControlUserPaneFocusUPP) ;
- m_peer->SetData<ControlUserPaneBackgroundUPP>(kControlEntireControl,kControlUserPaneBackgroundProcTag,&gControlUserPaneBackgroundUPP) ;
+ m_peer->SetData<ControlUserPaneDrawUPP>(kControlEntireControl,kControlUserPaneDrawProcTag,GetwxMacControlUserPaneDrawProc()) ;
+ m_peer->SetData<ControlUserPaneHitTestUPP>(kControlEntireControl,kControlUserPaneHitTestProcTag,GetwxMacControlUserPaneHitTestProc()) ;
+ m_peer->SetData<ControlUserPaneTrackingUPP>(kControlEntireControl,kControlUserPaneTrackingProcTag,GetwxMacControlUserPaneTrackingProc()) ;
+ m_peer->SetData<ControlUserPaneIdleUPP>(kControlEntireControl,kControlUserPaneIdleProcTag,GetwxMacControlUserPaneIdleProc()) ;
+ m_peer->SetData<ControlUserPaneKeyDownUPP>(kControlEntireControl,kControlUserPaneKeyDownProcTag,GetwxMacControlUserPaneKeyDownProc()) ;
+ m_peer->SetData<ControlUserPaneActivateUPP>(kControlEntireControl,kControlUserPaneActivateProcTag,GetwxMacControlUserPaneActivateProc()) ;
+ m_peer->SetData<ControlUserPaneFocusUPP>(kControlEntireControl,kControlUserPaneFocusProcTag,GetwxMacControlUserPaneFocusProc()) ;
+ m_peer->SetData<ControlUserPaneBackgroundUPP>(kControlEntireControl,kControlUserPaneBackgroundProcTag,GetwxMacControlUserPaneBackgroundProc()) ;
}
#endif
UInt32 features = 0
| kControlSupportsEmbedding
-// | kControlSupportsLiveFeedback
+ | kControlSupportsLiveFeedback
+ | kControlGetsFocusOnClick
// | kControlHasSpecialBackground
// | kControlSupportsCalcBestRect
-// | kControlHandlesTracking
+ | kControlHandlesTracking
| kControlSupportsFocus
-// | kControlWantsActivate
-// | kControlWantsIdle
+ | kControlWantsActivate
+ | kControlWantsIdle
;
m_peer = new wxMacControl(this) ;
// adjust font, controlsize etc
DoSetWindowVariant( m_windowVariant ) ;
-#if !TARGET_API_MAC_OSX
- // eventually we can fix some clipping issues be reactivating this hook
- //if ( m_macIsUserPane )
- // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ;
-#endif
m_peer->SetTitle( wxStripMenuCodes(m_label) ) ;
if (!m_macIsUserPane)
void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y,
int& w, int& h) const
{
- Rect bounds ;
- m_peer->GetRect( &bounds ) ;
-
-
- x = bounds.left ;
- y = bounds.top ;
- w = bounds.right - bounds.left ;
- h = bounds.bottom - bounds.top ;
+ wxFAIL_MSG( wxT("Not supported anymore") ) ;
}
// From a wx position / size calculate the appropriate size of the native control
// Get window size (not client size)
void wxWindowMac::DoGetSize(int *x, int *y) const
{
- // take the size of the control and add the borders that have to be drawn outside
- int x1 , y1 , w1 , h1 ;
-
- MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ;
-
- w1 += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
- h1 += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
+ Rect bounds ;
+ m_peer->GetRect( &bounds ) ;
- if(x) *x = w1 ;
- if(y) *y = h1 ;
+ if(x) *x = bounds.right - bounds.left + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
+ if(y) *y = bounds.bottom - bounds.top + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
}
// get the position of the bounds of this window in client coordinates of its parent
void wxWindowMac::DoGetPosition(int *x, int *y) const
{
- bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
+ Rect bounds ;
+ m_peer->GetRect( &bounds ) ;
- int x1 , y1 , w1 ,h1 ;
- MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ;
- x1 -= MacGetLeftBorderSize() ;
- y1 -= MacGetTopBorderSize() ;
- // to non-client
-
- if ( !isCompositing && !GetParent()->IsTopLevel() )
- {
- Rect bounds ;
- GetControlBounds( (ControlRef) GetParent()->GetHandle() , &bounds ) ;
- x1 -= bounds.left ;
- y1 -= bounds.top ;
- }
+ int x1 = bounds.left ;
+ int y1 = bounds.top ;
if ( !IsTopLevel() )
{
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
RgnHandle rgn = NewRgn() ;
- Rect content ;
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
+ Rect structure ;
+ Rect content ;
GetRegionBounds( rgn , &content ) ;
+ m_peer->GetRect( &structure ) ;
+ OffsetRect( &structure, -structure.left , -structure.top ) ;
+
+ left = content.left - structure.left ;
+ top = content.top - structure.top ;
+ right = structure.right - content.right ;
+ bottom = structure.bottom - content.bottom ;
}
else
{
- m_peer->GetRect( &content ) ;
+ left = top = right = bottom = 0 ;
}
DisposeRgn( rgn ) ;
- Rect structure ;
- m_peer->GetRect( &structure ) ;
-
- if ( !isCompositing )
- OffsetRect( &content , -structure.left , -structure.top ) ;
-
- left = content.left - structure.left ;
- top = content.top - structure.top ;
- right = structure.right - content.right ;
- bottom = structure.bottom - content.bottom ;
}
wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const
{
- bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
wxSize sizeTotal = size;
RgnHandle rgn = NewRgn() ;
- Rect content ;
-
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
{
+ Rect content ;
+ Rect structure ;
GetRegionBounds( rgn , &content ) ;
- }
- else
- {
- m_peer->GetRect( &content ) ;
- }
- DisposeRgn( rgn ) ;
- Rect structure ;
- m_peer->GetRect( &structure ) ;
- if ( !isCompositing )
- OffsetRect( &content , -structure.left , -structure.top ) ;
+ m_peer->GetRect( &structure ) ;
+ // structure is in parent coordinates, but we only need width and height, so it's ok
- sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ;
- sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ;
+ sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ;
+ sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ;
+ }
+ DisposeRgn( rgn ) ;
sizeTotal.x += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
sizeTotal.y += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
}
DisposeRgn( rgn ) ;
- if ( !isCompositing )
- {
- Rect structure ;
- m_peer->GetRect( &structure ) ;
- OffsetRect( &content , -structure.left , -structure.top ) ;
- }
ww = content.right - content.left ;
hh = content.bottom - content.top ;
- /*
- ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
- hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
- */
- /*
- if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
- {
- int x1 = 0 ;
- int y1 = 0 ;
- int w ;
- int h ;
- GetSize( &w , &h ) ;
-
- MacClientToRootWindow( &x1 , &y1 ) ;
- MacClientToRootWindow( &w , &h ) ;
-
- wxWindowMac *iter = (wxWindowMac*)this ;
-
- int totW = 10000 , totH = 10000;
- while( iter )
- {
- if ( iter->IsTopLevel() )
- {
- iter->GetSize( &totW , &totH ) ;
- break ;
- }
- iter = iter->GetParent() ;
- }
-
- if (m_hScrollBar && m_hScrollBar->IsShown() )
- {
- hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
- if ( h-y1 >= totH )
- {
- hh += 1 ;
- }
- }
- if (m_vScrollBar && m_vScrollBar->IsShown() )
- {
- ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE;
- if ( w-x1 >= totW )
- {
- ww += 1 ;
- }
- }
- }
- */
if (m_hScrollBar && m_hScrollBar->IsShown() )
{
hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ;
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner ,updateOuter ) ;
#ifdef __WXMAC_OSX__
- GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
+ GetParent()->m_peer->SetNeedsDisplay( updateOuter ) ;
#else
WindowRef tlw = (WindowRef) MacGetTopLevelWindowRef() ;
if ( tlw )
*/
UnionRgn( updateOuter , updateTotal , updateTotal ) ;
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ GetParent()->m_peer->SetNeedsDisplay( updateTotal ) ;
DisposeRgn(updateOuter) ;
DisposeRgn(updateInner) ;
DisposeRgn(updateTotal) ;
if ( doMove || doResize )
{
- // we don't adjust twice for the origin
- Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
+ // as the borders are drawn outside the native control, we adjust now
+
+ wxRect bounds( wxPoint( actualX + MacGetLeftBorderSize() ,actualY + MacGetTopBorderSize() ),
+ wxSize( actualWidth - (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
+ actualHeight - (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
+
+ Rect r ;
+ wxMacRectToNative( &bounds , &r ) ;
+
+ if ( !GetParent()->IsTopLevel() )
+ {
+ wxMacWindowToNative( GetParent() , &r ) ;
+ }
MacInvalidateBorders() ;
m_peer->GetRegion( kControlContentMetaPart , rgn ) ;
GetRegionBounds( rgn , &content ) ;
DisposeRgn( rgn ) ;
-
- if ( !isCompositing )
- {
- // if the content rgn is empty / not supported
- // don't attempt to correct the coordinates to wxWindow relative ones
- if (!::EmptyRect( &content ) )
- {
- Rect structure ;
- m_peer->GetRect( &structure ) ;
- OffsetRect( &content , -structure.left , -structure.top ) ;
- }
- }
-
return wxPoint( content.left + MacGetLeftBorderSize( ) , content.top + MacGetTopBorderSize( ) );
}
if ( m_peer == NULL )
return ;
+ if ( !MacIsReallyShown() )
+ return ;
- bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
-// if ( isCompositing )
+ if ( rect )
{
-#ifdef __WXMAC_OSX__
- if ( rect == NULL && isCompositing )
- m_peer->SetNeedsDisplay( true ) ;
- else
-#endif
- {
-
- Rect controlBounds ;
- m_peer->GetRect( &controlBounds ) ;
- InvalWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &controlBounds ) ;
- /*
- RgnHandle update = NewRgn() ;
- if ( rect == NULL )
- {
- CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update ) ;
- }
- else
- {
- SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
- SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
- }
-
- wxPoint origin = GetClientAreaOrigin() ;
- OffsetRgn( update, origin.x , origin.y ) ;
- // right now this is wx' window coordinates, as our native peer does not have borders, this is
- // inset
- if ( isCompositing )
- {
- OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
- m_peer->SetNeedsDisplay( true , update) ;
- }
- else
- {
- int x = 0 ;
- int y = 0 ;
- MacWindowToRootWindow( &x , &y ) ;
- OffsetRgn( update , x , y ) ;
- InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , update ) ;
- }
- DisposeRgn( update ) ;
- */
- }
+ Rect r ;
+ wxMacRectToNative( rect , &r ) ;
+ m_peer->SetNeedsDisplay( &r ) ;
}
-
- if ( 0 )
+ else
{
- if ( MacIsReallyShown() )
- {
- /*
- m_peer->SetVisibility( false , false ) ;
- m_peer->SetVisibility( true , true ) ;
- */
- }
+ m_peer->SetNeedsDisplay() ;
}
}
else
#endif
{
- // as the non OSX Version is already working in window relative coordinates, it's not needed
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
- if (top && top->MacUsesCompositing())
+ 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 ;
+ OffsetRect( &rect , pt.x , pt.y ) ;
}
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
// either immediate redraw or full invalidate
#if 1
// is the better overall solution, as it does not slow down scrolling
- m_peer->SetNeedsDisplay( true ) ;
+ m_peer->SetNeedsDisplay() ;
#else
// this would be the preferred version for fast drawing controls
if( UMAGetSystemVersion() < 0x1030 )
Rect rect ;
m_peer->GetRect( &rect ) ;
InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
-#ifdef __WXMAC_OSX__
- // as the non OSX Version is already working in window relative coordinates, it's not needed
+
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
- if (top && top->MacUsesCompositing() )
+ if (top )
{
wxPoint pt(0,0) ;
wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
rect.top += pt.y ;
rect.bottom += pt.y ;
}
-#endif
if ( event.GetEventType() == wxEVT_SET_FOCUS )
DrawThemeFocusRect( &rect , true ) ;
status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
}
else
- m_peer->SetNeedsDisplay( true ) ;
+ m_peer->SetNeedsDisplay() ;
}
#else
::Draw1Control( m_peer->GetControlRef() ) ;
r.bottom += MacGetBottomBorderSize() ;
r.right += MacGetRightBorderSize() ;
- if (! MacGetTopLevelWindow()->MacUsesCompositing() )
- {
- MacRootWindowToWindow( &r.left , & r.top ) ;
- MacRootWindowToWindow( &r.right , & r.bottom ) ;
- }
- else
- {
- r.right -= r.left ;
- r.bottom -= r.top ;
- r.left = 0 ;
- r.top = 0 ;
- }
+ r.right -= r.left ;
+ r.bottom -= r.top ;
+ r.left = 0 ;
+ r.top = 0 ;
+
if ( includeOuterStructures )
InsetRect( &r , -4 , -4 ) ;
RectRgn( visRgn , &r ) ;