don't assign NULLs to bools and floats, this is confusing (and also the usual: deTABified; corrected double to int cast)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-30 23:22:42 +00:00
parent 8a438f46b5
commit 783d8bdf57

View File

@@ -433,7 +433,7 @@ void wxMacCoreGraphicsPenData::Init()
{
m_lengths = NULL;
m_userLengths = NULL;
m_width = NULL;
m_width = 0;
m_count = 0;
m_patternColorComponents = NULL;
m_isPattern = false;
@@ -701,27 +701,27 @@ wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
class WXDLLIMPEXP_CORE wxMacCoreGraphicsMatrixData : public wxGraphicsMatrixData
{
public :
wxMacCoreGraphicsMatrixData(wxGraphicsRenderer* renderer) ;
wxMacCoreGraphicsMatrixData(wxGraphicsRenderer* renderer) ;
virtual ~wxMacCoreGraphicsMatrixData() ;
virtual ~wxMacCoreGraphicsMatrixData() ;
virtual wxGraphicsObjectRefData *Clone() const ;
// concatenates the matrix
virtual void Concat( const wxGraphicsMatrixData *t );
// concatenates the matrix
virtual void Concat( const wxGraphicsMatrixData *t );
// sets the matrix to the respective values
virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
wxDouble tx=0.0, wxDouble ty=0.0);
// sets the matrix to the respective values
virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
wxDouble tx=0.0, wxDouble ty=0.0);
// makes this the inverse matrix
virtual void Invert();
// makes this the inverse matrix
virtual void Invert();
// returns true if the elements of the transformation matrix are equal ?
// returns true if the elements of the transformation matrix are equal ?
virtual bool IsEqual( const wxGraphicsMatrixData* t) const ;
// return true if this is the identity matrix
virtual bool IsIdentity() const;
// return true if this is the identity matrix
virtual bool IsIdentity() const;
//
// transformation
@@ -740,14 +740,14 @@ public :
// apply the transforms
//
// applies that matrix to the point
virtual void TransformPoint( wxDouble *x, wxDouble *y ) const;
// applies that matrix to the point
virtual void TransformPoint( wxDouble *x, wxDouble *y ) const;
// applies the matrix except for translations
virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const;
// applies the matrix except for translations
virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const;
// returns the native representation
virtual void * GetNativeMatrix() const;
// returns the native representation
virtual void * GetNativeMatrix() const;
private :
CGAffineTransform m_matrix;
@@ -914,22 +914,22 @@ public :
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r );
// adds another path
virtual void AddPath( const wxGraphicsPathData* path );
// adds another path
virtual void AddPath( const wxGraphicsPathData* path );
// returns the native path
virtual void * GetNativePath() const { return m_path; }
// returns the native path
virtual void * GetNativePath() const { return m_path; }
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
virtual void UnGetNativePath(void *p) const {}
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
virtual void UnGetNativePath(void *p) const {}
// transforms each point of this path by the matrix
virtual void Transform( const wxGraphicsMatrixData* matrix );
// transforms each point of this path by the matrix
virtual void Transform( const wxGraphicsMatrixData* matrix );
// gets the bounding box enclosing all points (possibly including control points)
virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *y) const;
// gets the bounding box enclosing all points (possibly including control points)
virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *y) const;
virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const;
virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const;
private :
CGMutablePathRef m_path;
};
@@ -940,10 +940,10 @@ private :
wxMacCoreGraphicsPathData::wxMacCoreGraphicsPathData( wxGraphicsRenderer* renderer, CGMutablePathRef path) : wxGraphicsPathData(renderer)
{
if ( path )
m_path = path;
else
m_path = CGPathCreateMutable();
if ( path )
m_path = path;
else
m_path = CGPathCreateMutable();
}
wxMacCoreGraphicsPathData::~wxMacCoreGraphicsPathData()
@@ -953,8 +953,8 @@ wxMacCoreGraphicsPathData::~wxMacCoreGraphicsPathData()
wxGraphicsObjectRefData* wxMacCoreGraphicsPathData::Clone() const
{
wxMacCoreGraphicsPathData* clone = new wxMacCoreGraphicsPathData(GetRenderer(),CGPathCreateMutableCopy(m_path));
return clone ;
wxMacCoreGraphicsPathData* clone = new wxMacCoreGraphicsPathData(GetRenderer(),CGPathCreateMutableCopy(m_path));
return clone ;
}
@@ -1004,7 +1004,7 @@ void wxMacCoreGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDoub
void wxMacCoreGraphicsPathData::AddPath( const wxGraphicsPathData* path )
{
CGPathAddPath( m_path , NULL, (CGPathRef) path->GetNativePath() );
CGPathAddPath( m_path , NULL, (CGPathRef) path->GetNativePath() );
}
// closes the current subpath
@@ -1024,25 +1024,25 @@ void wxMacCoreGraphicsPathData::GetCurrentPoint( wxDouble* x, wxDouble* y) const
// transforms each point of this path by the matrix
void wxMacCoreGraphicsPathData::Transform( const wxGraphicsMatrixData* matrix )
{
CGMutablePathRef p = CGPathCreateMutable() ;
CGPathAddPath( p, (CGAffineTransform*) matrix->GetNativeMatrix() , m_path );
CGPathRelease( m_path );
m_path = p;
CGMutablePathRef p = CGPathCreateMutable() ;
CGPathAddPath( p, (CGAffineTransform*) matrix->GetNativeMatrix() , m_path );
CGPathRelease( m_path );
m_path = p;
}
// gets the bounding box enclosing all points (possibly including control points)
void wxMacCoreGraphicsPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const
{
CGRect bounds = CGPathGetBoundingBox( m_path ) ;
*x = bounds.origin.x;
*y = bounds.origin.y;
*w = bounds.size.width;
*h = bounds.size.height;
CGRect bounds = CGPathGetBoundingBox( m_path ) ;
*x = bounds.origin.x;
*y = bounds.origin.y;
*w = bounds.size.width;
*h = bounds.size.height;
}
bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, int fillStyle) const
{
return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE );
return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE );
}
//
@@ -1068,7 +1068,7 @@ public:
~wxMacCoreGraphicsContext();
void Init();
void Init();
// push the current state of the context, ie the transformation matrix on a stack
virtual void PushState();
@@ -1100,14 +1100,14 @@ public:
// rotate (radians)
virtual void Rotate( wxDouble angle );
// concatenates this transform with the current transform of this context
virtual void ConcatTransform( const wxGraphicsMatrix& matrix );
// concatenates this transform with the current transform of this context
virtual void ConcatTransform( const wxGraphicsMatrix& matrix );
// sets the transform of this context
virtual void SetTransform( const wxGraphicsMatrix& matrix );
// sets the transform of this context
virtual void SetTransform( const wxGraphicsMatrix& matrix );
// gets the matrix of this context
virtual wxGraphicsMatrix GetTransform() const;
// gets the matrix of this context
virtual wxGraphicsMatrix GetTransform() const;
//
// setting the paint
//
@@ -1126,7 +1126,7 @@ public:
int penwidth = 0 ;
if ( !m_pen.IsNull() )
{
penwidth = ((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->GetWidth();
penwidth = (int)((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->GetWidth();
if ( penwidth == 0 )
penwidth = 1;
}
@@ -1162,11 +1162,11 @@ private:
void EnsureIsValid();
CGContextRef m_cgContext;
WindowRef m_windowRef;
bool m_releaseContext;
WindowRef m_windowRef;
bool m_releaseContext;
CGAffineTransform m_windowTransform;
wxMacCFRefHolder<HIShapeRef> m_clipRgn;
wxMacCFRefHolder<HIShapeRef> m_clipRgn;
};
//-----------------------------------------------------------------------------
@@ -1190,7 +1190,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsContext, wxGraphicsContext)
void wxMacCoreGraphicsContext::Init()
{
m_cgContext = NULL;
m_releaseContext = false;
m_releaseContext = false;
m_windowRef = NULL;
HIRect r = CGRectMake(0,0,0,0);
@@ -1199,20 +1199,20 @@ void wxMacCoreGraphicsContext::Init()
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext ) : wxGraphicsContext(renderer)
{
Init();
Init();
SetNativeContext(cgcontext);
}
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, WindowRef window ): wxGraphicsContext(renderer)
{
Init();
m_windowRef = window;
Init();
m_windowRef = window;
}
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, wxWindow* window ): wxGraphicsContext(renderer)
{
Init();
m_windowRef = (WindowRef) window->MacGetTopLevelWindowRef();
Init();
m_windowRef = (WindowRef) window->MacGetTopLevelWindowRef();
int originX , originY;
originX = originY = 0;
window->MacWindowToRootWindow( &originX , &originY );
@@ -1226,12 +1226,12 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext(wxGraphicsRenderer* renderer) : wxGraphicsContext(renderer)
{
Init();
Init();
}
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext() : wxGraphicsContext(NULL)
{
Init();
Init();
wxLogDebug(wxT("Illegal Constructor called"));
}
@@ -1242,65 +1242,65 @@ wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
void wxMacCoreGraphicsContext::EnsureIsValid()
{
if ( !m_cgContext )
{
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") );
if ( !m_cgContext )
{
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") );
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSaveGState( m_cgContext );
m_releaseContext = true;
if ( !HIShapeIsEmpty(m_clipRgn) )
{
HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext );
CGContextClip( m_cgContext );
}
}
CGContextSaveGState( m_cgContext );
m_releaseContext = true;
if ( !HIShapeIsEmpty(m_clipRgn) )
{
HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext );
CGContextClip( m_cgContext );
}
}
}
void wxMacCoreGraphicsContext::Clip( const wxRegion &region )
{
if( m_cgContext )
{
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
HIShapeReplacePathInCGContext( shape, m_cgContext );
CGContextClip( m_cgContext );
CFRelease( shape );
}
else
{
m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
}
if( m_cgContext )
{
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
HIShapeReplacePathInCGContext( shape, m_cgContext );
CGContextClip( m_cgContext );
CFRelease( shape );
}
else
{
m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
}
}
// clips drawings to the rect
void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
HIRect r = CGRectMake( x , y , w , h );
if ( m_cgContext )
{
CGContextClipToRect( m_cgContext, r );
}
else
{
m_clipRgn.Set(HIShapeCreateWithRect(&r));
}
HIRect r = CGRectMake( x , y , w , h );
if ( m_cgContext )
{
CGContextClipToRect( m_cgContext, r );
}
else
{
m_clipRgn.Set(HIShapeCreateWithRect(&r));
}
}
// resets the clipping to original extent
// resets the clipping to original extent
void wxMacCoreGraphicsContext::ResetClip()
{
if ( m_cgContext )
{
CGContextRestoreGState( m_cgContext );
CGContextSaveGState( m_cgContext );
}
else
{
if ( m_cgContext )
{
CGContextRestoreGState( m_cgContext );
CGContextSaveGState( m_cgContext );
}
else
{
HIRect r = CGRectMake(0,0,0,0);
m_clipRgn.Set(HIShapeCreateWithRect(&r));
}
}
}
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath &path )
@@ -1308,7 +1308,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath &path )
if ( m_pen.IsNull() )
return ;
EnsureIsValid();
EnsureIsValid();
bool offset = ShouldOffset();
if ( offset )
@@ -1358,7 +1358,7 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath &path , int fillSt
}
}
EnsureIsValid();
EnsureIsValid();
if ( !m_brush.IsNull() )
((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
@@ -1382,7 +1382,7 @@ void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath &path , int fillSt
if ( m_brush.IsNull() )
return;
EnsureIsValid();
EnsureIsValid();
if ( ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() )
{
@@ -1434,13 +1434,13 @@ void wxMacCoreGraphicsContext::SetNativeContext( CGContextRef cg )
CGContextRetain(m_cgContext);
CGContextSaveGState( m_cgContext );
CGContextSaveGState( m_cgContext );
m_releaseContext = NULL;
m_releaseContext = false;
}
}
void wxMacCoreGraphicsContext::Translate( wxDouble dx , wxDouble dy )
{
if ( m_cgContext )
if ( m_cgContext )
CGContextTranslateCTM( m_cgContext, dx, dy );
else
m_windowTransform = CGAffineTransformTranslate(m_windowTransform,dx,dy);
@@ -1448,7 +1448,7 @@ void wxMacCoreGraphicsContext::Translate( wxDouble dx , wxDouble dy )
void wxMacCoreGraphicsContext::Scale( wxDouble xScale , wxDouble yScale )
{
if ( m_cgContext )
if ( m_cgContext )
CGContextScaleCTM( m_cgContext , xScale , yScale );
else
m_windowTransform = CGAffineTransformScale(m_windowTransform,xScale,yScale);
@@ -1456,7 +1456,7 @@ void wxMacCoreGraphicsContext::Scale( wxDouble xScale , wxDouble yScale )
void wxMacCoreGraphicsContext::Rotate( wxDouble angle )
{
if ( m_cgContext )
if ( m_cgContext )
CGContextRotateCTM( m_cgContext , angle );
else
m_windowTransform = CGAffineTransformRotate(m_windowTransform,angle);
@@ -1464,7 +1464,7 @@ void wxMacCoreGraphicsContext::Rotate( wxDouble angle )
void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
EnsureIsValid();
EnsureIsValid();
CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
HIRect r = CGRectMake( x , y , w , h );
@@ -1474,7 +1474,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDo
void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
EnsureIsValid();
EnsureIsValid();
CGRect r = CGRectMake( 00 , 00 , w , h );
CGContextSaveGState( m_cgContext );
@@ -1487,14 +1487,14 @@ void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDoubl
void wxMacCoreGraphicsContext::PushState()
{
EnsureIsValid();
EnsureIsValid();
CGContextSaveGState( m_cgContext );
}
void wxMacCoreGraphicsContext::PopState()
{
EnsureIsValid();
EnsureIsValid();
CGContextRestoreGState( m_cgContext );
}
@@ -1509,7 +1509,7 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
if ( m_font.IsNull() )
return;
EnsureIsValid();
EnsureIsValid();
OSStatus status = noErr;
ATSUTextLayout atsuLayout;
@@ -1756,7 +1756,7 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
void * wxMacCoreGraphicsContext::GetNativeContext()
{
return m_cgContext;
return m_cgContext;
}
// concatenates this transform with the current transform of this context
@@ -1808,24 +1808,24 @@ public :
virtual ~wxMacCoreGraphicsRenderer() {}
// Context
// Context
virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
virtual wxGraphicsContext * CreateContext( wxWindow* window );
virtual wxGraphicsContext * CreateContext( wxWindow* window );
// Path
// Path
virtual wxGraphicsPath CreatePath();
// Matrix
// Matrix
virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
wxDouble tx=0.0, wxDouble ty=0.0);
virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
wxDouble tx=0.0, wxDouble ty=0.0);
virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
@@ -1858,7 +1858,7 @@ static wxMacCoreGraphicsRenderer gs_MacCoreGraphicsRenderer;
wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer()
{
return &gs_MacCoreGraphicsRenderer;
return &gs_MacCoreGraphicsRenderer;
}
wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc)
@@ -1879,7 +1879,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContextFromNativeWindow( vo
wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( wxWindow* window )
{
return new wxMacCoreGraphicsContext(this, window );
return new wxMacCoreGraphicsContext(this, window );
}
// Path
@@ -1895,7 +1895,7 @@ wxGraphicsPath wxMacCoreGraphicsRenderer::CreatePath()
// Matrix
wxGraphicsMatrix wxMacCoreGraphicsRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble c, wxDouble d,
wxDouble tx, wxDouble ty)
wxDouble tx, wxDouble ty)
{
wxGraphicsMatrix m;
wxMacCoreGraphicsMatrixData* data = new wxMacCoreGraphicsMatrixData( this );