/////////////////////////////////////////////////////////////////////////////
-// Name: src/osx/carbon/dccg.cpp
+// Name: src/osx/carbon/graphics.cpp
// Purpose: wxDC class
// Author: Stefan Csomor
// Modified by:
{
// Start
out[0] = stops.comps[0].red;
- out[1] = stops.comps[1].green;
- out[2] = stops.comps[2].blue;
- out[3] = stops.comps[3].alpha;
+ out[1] = stops.comps[0].green;
+ out[2] = stops.comps[0].blue;
+ out[3] = stops.comps[0].alpha;
}
else if (f >= 1.0)
{
CGFloat fact = diff / range;
out[0] = stops.comps[i - 1].red + (stops.comps[i].red - stops.comps[i - 1].red) * fact;
- out[0] = stops.comps[i - 1].green + (stops.comps[i].green - stops.comps[i - 1].green) * fact;
- out[0] = stops.comps[i - 1].blue + (stops.comps[i].blue - stops.comps[i - 1].blue) * fact;
- out[0] = stops.comps[i - 1].alpha + (stops.comps[i].alpha - stops.comps[i - 1].alpha) * fact;
+ out[1] = stops.comps[i - 1].green + (stops.comps[i].green - stops.comps[i - 1].green) * fact;
+ out[2] = stops.comps[i - 1].blue + (stops.comps[i].blue - stops.comps[i - 1].blue) * fact;
+ out[3] = stops.comps[i - 1].alpha + (stops.comps[i].alpha - stops.comps[i - 1].alpha) * fact;
}
}
// concatenates the matrix
void wxMacCoreGraphicsMatrixData::Concat( const wxGraphicsMatrixData *t )
{
- m_matrix = CGAffineTransformConcat(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix()) );
+ m_matrix = CGAffineTransformConcat(*((CGAffineTransform*) t->GetNativeMatrix()), m_matrix );
}
// sets the matrix to the respective values
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;
+ virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const;
virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const;
private :
void Init();
- // returns the size of the graphics context in device coordinates
- virtual void GetSize( wxDouble* width, wxDouble* height);
-
virtual void StartPage( wxDouble width, wxDouble height );
virtual void EndPage();
#endif
bool m_contextSynthesized;
CGAffineTransform m_windowTransform;
- wxDouble m_width;
- wxDouble m_height;
bool m_invisible;
#if wxOSX_USE_COCOA_OR_CARBON
m_userOffset = CGContextConvertSizeToUserSpace( m_cg, CGSizeMake( 0.5 , 0.5 ) );
CGContextTranslateCTM( m_cg, m_userOffset.width , m_userOffset.height );
}
+ else
+ {
+ m_userOffset = CGSizeMake(0.0, 0.0);
+ }
+
}
~wxQuartzOffsetHelper( )
{
SetNativeContext(NULL);
}
-void wxMacCoreGraphicsContext::GetSize( wxDouble* width, wxDouble* height)
-{
- *width = m_width;
- *height = m_height;
-}
-
void wxMacCoreGraphicsContext::StartPage( wxDouble width, wxDouble height )
{
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
Rect rect;
- x += (int)(sin(angle) * FixedToInt(ascent));
- y += (int)(cos(angle) * FixedToInt(ascent));
+ x += (int)(sin(angle) * FixedToFloat(ascent));
+ y += (int)(cos(angle) * FixedToFloat(ascent));
status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
IntToFixed(x) , IntToFixed(y) , &rect );
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, attributes) );
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
- // round the returned extent: this is probably more correct anyhow but
- // we also need to do it to be consistent with GetPartialTextExtents()
- // below and avoid strange situation when the last partial extent
- // returned by it could have been greater than the full extent returned
- // by us
- CGFloat a, d, l;
- int w = CTLineGetTypographicBounds(line, &a, &d, &l) + 0.5;
+ CGFloat a, d, l, w;
+ w = CTLineGetTypographicBounds(line, &a, &d, &l);
if ( height )
*height = a+d+l;
&textBefore , &textAfter, &textAscent , &textDescent );
if ( height )
- *height = FixedToInt(textAscent + textDescent);
+ *height = FixedToFloat(textAscent + textDescent);
if ( descent )
- *descent = FixedToInt(textDescent);
+ *descent = FixedToFloat(textDescent);
if ( externalLeading )
*externalLeading = 0;
if ( width )
- *width = FixedToInt(textAfter - textBefore);
+ *width = FixedToFloat(textAfter - textBefore);
::ATSUDisposeTextLayout(atsuLayout);
*height = sz.height;
/*
if ( descent )
- *descent = FixedToInt(textDescent);
+ *descent = FixedToFloat(textDescent);
if ( externalLeading )
*externalLeading = 0;
*/
if (result != noErr || actualNumberOfBounds != 1 )
return;
- widths[pos] = FixedToInt( glyphBounds.upperRight.x - glyphBounds.upperLeft.x );
+ widths[pos] = FixedToFloat( glyphBounds.upperRight.x - glyphBounds.upperLeft.x );
//unsigned char uch = s[i];
}
#else
{
for ( int pos = 1; pos < (int)glyphCount ; pos ++ )
{
- widths[pos-1] = FixedToInt( layoutRecords[pos].realPos );
+ widths[pos-1] = FixedToFloat( layoutRecords[pos].realPos );
}
}
if ( m_cgContext )
CGContextConcatCTM( m_cgContext, *(CGAffineTransform*) matrix.GetNativeMatrix());
else
- m_windowTransform = CGAffineTransformConcat(m_windowTransform, *(CGAffineTransform*) matrix.GetNativeMatrix());
+ m_windowTransform = CGAffineTransformConcat(*(CGAffineTransform*) matrix.GetNativeMatrix(), m_windowTransform);
}
// sets the transform of this context
if (win_impl->GetWindow())
cgctx = (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef());
- if (cgctx != 0)
- return new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h );
+ // having a cgctx being NULL is fine (will be created on demand)
+ // this is the case for all wxWindowDCs except wxPaintDC
+ return new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h );
}
return NULL;
}