adding iphone code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59924 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-03-29 20:48:05 +00:00
parent 421bb0184e
commit b4ff8b3e4e
4 changed files with 99 additions and 22 deletions

View File

@@ -72,10 +72,12 @@ int UMAGetSystemVersion()
#endif
#if wxOSX_USE_COCOA_OR_IPHONE
extern CGContextRef wxOSXGetContextFromCurrentNSContext() ;
extern CGContextRef wxOSXGetContextFromCurrentContext() ;
#if wxOSX_USE_COCOA
extern bool wxOSXLockFocus( WXWidget view) ;
extern void wxOSXUnlockFocus( WXWidget view) ;
#endif
#endif
#if 1 // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
@@ -1519,12 +1521,14 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer
#if wxOSX_USE_COCOA_OR_IPHONE
m_view = window->GetHandle();
if ( !((wxWidgetCocoaImpl*) window->GetPeer())->IsFlipped() )
#if wxOSX_USE_COCOA
if ( ! window->GetPeer()->IsFlipped() )
{
m_windowTransform = CGAffineTransformMakeTranslation( 0 , m_height );
m_windowTransform = CGAffineTransformScale( m_windowTransform , 1 , -1 );
}
else
#endif
{
m_windowTransform = CGAffineTransformIdentity;
}
@@ -1594,10 +1598,10 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
if (m_invisible)
return false;
#if wxOSX_USE_COCOA_OR_IPHONE
#if wxOSX_USE_COCOA
if ( wxOSXLockFocus(m_view) )
{
m_cgContext = wxOSXGetContextFromCurrentNSContext();
m_cgContext = wxOSXGetContextFromCurrentContext();
wxASSERT_MSG( m_cgContext != NULL, _T("Unable to retrieve drawing context from View"));
}
else
@@ -1605,6 +1609,13 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
m_invisible = true;
}
#endif
#if wxOSX_USE_IPHONE
m_cgContext = wxOSXGetContextFromCurrentContext();
if ( m_cgContext == NULL )
{
m_invisible = true;
}
#endif
#if wxOSX_USE_CARBON
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
if ( status != noErr )
@@ -1617,6 +1628,7 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSaveGState( m_cgContext );
m_contextSynthesized = true;
#if wxOSX_USE_COCOA_OR_CARBON
if ( m_clipRgn.get() )
{
// the clip region is in device coordinates, so we convert this again to user coordinates
@@ -1635,6 +1647,7 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
CGContextClip( m_cgContext );
}
}
#endif
CGContextSaveGState( m_cgContext );
#if 0 // turn on for debugging of clientdc
@@ -2016,7 +2029,7 @@ void wxMacCoreGraphicsContext::SetNativeContext( CGContextRef cg )
#if wxOSX_USE_CARBON
QDEndCGContext( GetWindowPort( m_windowRef ) , &m_cgContext);
#endif
#if wxOSX_USE_COCOA_OR_IPHONE
#if wxOSX_USE_COCOA
wxOSXUnlockFocus(m_view);
#endif
}