adding focus and border quartz support
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31981 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -82,6 +82,9 @@ public:
|
|||||||
virtual void Freeze() ;
|
virtual void Freeze() ;
|
||||||
virtual void Thaw() ;
|
virtual void Thaw() ;
|
||||||
|
|
||||||
|
virtual void Update() ;
|
||||||
|
virtual void ClearBackground() ;
|
||||||
|
|
||||||
virtual bool SetCursor( const wxCursor &cursor );
|
virtual bool SetCursor( const wxCursor &cursor );
|
||||||
virtual bool SetFont( const wxFont &font ) ;
|
virtual bool SetFont( const wxFont &font ) ;
|
||||||
virtual bool SetBackgroundColour( const wxColour &colour );
|
virtual bool SetBackgroundColour( const wxColour &colour );
|
||||||
@@ -193,7 +196,6 @@ public:
|
|||||||
|
|
||||||
bool MacIsUserPane() { return m_macIsUserPane; }
|
bool MacIsUserPane() { return m_macIsUserPane; }
|
||||||
|
|
||||||
virtual void Update() ;
|
|
||||||
virtual bool MacSetupCursor( const wxPoint& pt ) ;
|
virtual bool MacSetupCursor( const wxPoint& pt ) ;
|
||||||
|
|
||||||
virtual void MacSetBackgroundBrush( const wxBrush &brush ) ;
|
virtual void MacSetBackgroundBrush( const wxBrush &brush ) ;
|
||||||
|
@@ -168,13 +168,7 @@ CGPathRef wxMacCGPath::GetPath() const
|
|||||||
wxMacCGContext::wxMacCGContext( CGrafPtr port )
|
wxMacCGContext::wxMacCGContext( CGrafPtr port )
|
||||||
{
|
{
|
||||||
m_qdPort = port ;
|
m_qdPort = port ;
|
||||||
Rect bounds ;
|
m_cgContext = NULL ;
|
||||||
GetPortBounds( (CGrafPtr) port , &bounds ) ;
|
|
||||||
OSStatus status = QDBeginCGContext( (CGrafPtr) port , &m_cgContext ) ;
|
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") ) ;
|
|
||||||
CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top ) ;
|
|
||||||
CGContextScaleCTM( m_cgContext , 1 , -1 ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCGContext::wxMacCGContext( CGContextRef cgcontext )
|
wxMacCGContext::wxMacCGContext( CGContextRef cgcontext )
|
||||||
@@ -247,12 +241,44 @@ void wxMacCGContext::FillPath( const wxGraphicPath *p , const wxColor &fillColor
|
|||||||
CGContextRestoreGState( m_cgContext ) ;
|
CGContextRestoreGState( m_cgContext ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicPath* wxMacCGContext::CreatePath() { return new wxMacCGPath() ; }
|
wxGraphicPath* wxMacCGContext::CreatePath()
|
||||||
CGContextRef wxMacCGContext::GetNativeContext() { return m_cgContext ; }
|
{
|
||||||
void wxMacCGContext::SetNativeContext( CGContextRef cg ) { m_cgContext = cg ; }
|
CGContextRef cg = GetNativeContext() ;
|
||||||
|
// make sure that we now have a real cgref, before doing
|
||||||
|
// anything with paths
|
||||||
|
return new wxMacCGPath() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case we only got a QDPort only create a cgref now
|
||||||
|
|
||||||
|
CGContextRef wxMacCGContext::GetNativeContext()
|
||||||
|
{
|
||||||
|
if( m_cgContext == NULL )
|
||||||
|
{
|
||||||
|
Rect bounds ;
|
||||||
|
GetPortBounds( (CGrafPtr) m_qdPort , &bounds ) ;
|
||||||
|
OSStatus status = QDBeginCGContext( (CGrafPtr) m_qdPort , &m_cgContext ) ;
|
||||||
|
|
||||||
|
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") ) ;
|
||||||
|
CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top ) ;
|
||||||
|
CGContextScaleCTM( m_cgContext , 1 , -1 ) ;
|
||||||
|
|
||||||
|
SetPen( m_pen ) ;
|
||||||
|
SetBrush( m_brush ) ;
|
||||||
|
}
|
||||||
|
return m_cgContext ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMacCGContext::SetNativeContext( CGContextRef cg )
|
||||||
|
{
|
||||||
|
m_cgContext = cg ;
|
||||||
|
}
|
||||||
|
|
||||||
void wxMacCGContext::SetPen( const wxPen &pen )
|
void wxMacCGContext::SetPen( const wxPen &pen )
|
||||||
{
|
{
|
||||||
|
m_pen = pen ;
|
||||||
|
if ( m_cgContext == NULL )
|
||||||
|
return ;
|
||||||
bool fill = m_brush.GetStyle() != wxTRANSPARENT ;
|
bool fill = m_brush.GetStyle() != wxTRANSPARENT ;
|
||||||
bool stroke = pen.GetStyle() != wxTRANSPARENT ;
|
bool stroke = pen.GetStyle() != wxTRANSPARENT ;
|
||||||
|
|
||||||
@@ -373,6 +399,10 @@ void wxMacCGContext::SetPen( const wxPen &pen )
|
|||||||
}
|
}
|
||||||
void wxMacCGContext::SetBrush( const wxBrush &brush )
|
void wxMacCGContext::SetBrush( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
|
m_brush = brush ;
|
||||||
|
if ( m_cgContext == NULL )
|
||||||
|
return ;
|
||||||
|
|
||||||
bool fill = brush.GetStyle() != wxTRANSPARENT ;
|
bool fill = brush.GetStyle() != wxTRANSPARENT ;
|
||||||
bool stroke = m_pen.GetStyle() != wxTRANSPARENT ;
|
bool stroke = m_pen.GetStyle() != wxTRANSPARENT ;
|
||||||
|
|
||||||
|
@@ -118,7 +118,26 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_graphicContext = NULL ;
|
{
|
||||||
|
// as out of order redraw is not supported under CQ, we have to create a qd port for these
|
||||||
|
// situations
|
||||||
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
|
if (!rootwindow)
|
||||||
|
return;
|
||||||
|
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||||
|
wxSize size = window->GetClientSize() ;
|
||||||
|
int x , y ;
|
||||||
|
x = y = 0 ;
|
||||||
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
|
m_macLocalOrigin.x = x ;
|
||||||
|
m_macLocalOrigin.y = y ;
|
||||||
|
CGrafPtr port = UMAGetWindowPort( windowref ) ;
|
||||||
|
|
||||||
|
m_graphicContext = new wxMacCGContext( port ) ;
|
||||||
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
|
}
|
||||||
// there is no out-of-order drawing on OSX
|
// there is no out-of-order drawing on OSX
|
||||||
#else
|
#else
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
@@ -172,7 +191,8 @@ wxClientDC::wxClientDC(wxWindow *window)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
// as out of order redraw is not supported under CQ, we have to create a qd port for these
|
||||||
|
// situations
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
if (!rootwindow)
|
if (!rootwindow)
|
||||||
return;
|
return;
|
||||||
@@ -191,9 +211,7 @@ wxClientDC::wxClientDC(wxWindow *window)
|
|||||||
m_graphicContext->SetPen( m_pen ) ;
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
m_graphicContext->SetBrush( m_brush ) ;
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
m_ok = TRUE ;
|
}
|
||||||
*/
|
|
||||||
}
|
|
||||||
m_ok = TRUE ;
|
m_ok = TRUE ;
|
||||||
#else
|
#else
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||||
|
@@ -2692,6 +2692,12 @@ wxString wxWindowMac::MacGetToolTipString( wxPoint &pt )
|
|||||||
return wxEmptyString ;
|
return wxEmptyString ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWindowMac::ClearBackground()
|
||||||
|
{
|
||||||
|
Refresh() ;
|
||||||
|
Update() ;
|
||||||
|
}
|
||||||
|
|
||||||
void wxWindowMac::Update()
|
void wxWindowMac::Update()
|
||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
@@ -2906,6 +2912,34 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
if ( RectInRgn( &childRect , updatergn ) )
|
if ( RectInRgn( &childRect , updatergn ) )
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#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
|
#else
|
||||||
// paint custom borders
|
// paint custom borders
|
||||||
wxNcPaintEvent eventNc( child->GetId() );
|
wxNcPaintEvent eventNc( child->GetId() );
|
||||||
@@ -2923,6 +2957,14 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
|
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#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
|
#else
|
||||||
wxWindowDC dc(this) ;
|
wxWindowDC dc(this) ;
|
||||||
dc.SetClippingRegion(wxRegion(updatergn));
|
dc.SetClippingRegion(wxRegion(updatergn));
|
||||||
|
Reference in New Issue
Block a user