Change NSBezierPath to use NSInteger and CGFloat and adjust uses to

this.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36054 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2013-02-01 14:03:08 +00:00
parent a2aa2001da
commit e62fddeea0
6 changed files with 104 additions and 135 deletions

View file

@ -1,3 +1,11 @@
2013-02-01 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSBezierPath.h
* Source/GSThemeTools.m
* Source/NSBezierPath.m
* Source/NSGraphicsContext.m
* Source/NSLayoutManager.m: More NSInteger/NSUInteger/CGFloat cleanup
2013-01-30 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSBrowser.h

View file

@ -77,12 +77,12 @@ typedef enum {
NSWindingRule _windingRule;
NSLineCapStyle _lineCapStyle;
NSLineJoinStyle _lineJoinStyle;
float _lineWidth;
float _flatness;
float _miterLimit;
int _dash_count;
float _dash_phase;
float *_dash_pattern;
CGFloat _lineWidth;
CGFloat _flatness;
CGFloat _miterLimit;
NSInteger _dash_count;
CGFloat _dash_phase;
CGFloat *_dash_pattern;
NSRect _bounds;
NSRect _controlPointBounds;
NSImage *_cacheImage;
@ -128,18 +128,18 @@ typedef enum {
//
// Default path rendering parameters
//
+ (void)setDefaultMiterLimit:(float)limit;
+ (float)defaultMiterLimit;
+ (void)setDefaultFlatness:(float)flatness;
+ (float)defaultFlatness;
+ (void)setDefaultMiterLimit:(CGFloat)limit;
+ (CGFloat)defaultMiterLimit;
+ (void)setDefaultFlatness:(CGFloat)flatness;
+ (CGFloat)defaultFlatness;
+ (void)setDefaultWindingRule:(NSWindingRule)windingRule;
+ (NSWindingRule)defaultWindingRule;
+ (void)setDefaultLineCapStyle:(NSLineCapStyle)lineCapStyle;
+ (NSLineCapStyle)defaultLineCapStyle;
+ (void)setDefaultLineJoinStyle:(NSLineJoinStyle)lineJoinStyle;
+ (NSLineJoinStyle)defaultLineJoinStyle;
+ (void)setDefaultLineWidth:(float)lineWidth;
+ (float)defaultLineWidth;
+ (void)setDefaultLineWidth:(CGFloat)lineWidth;
+ (CGFloat)defaultLineWidth;
//
// Path construction
@ -164,20 +164,20 @@ typedef enum {
//
// Path rendering parameters
//
- (float)lineWidth;
- (void)setLineWidth:(float)lineWidth;
- (CGFloat)lineWidth;
- (void)setLineWidth:(CGFloat)lineWidth;
- (NSLineCapStyle)lineCapStyle;
- (void)setLineCapStyle:(NSLineCapStyle)lineCapStyle;
- (NSLineJoinStyle)lineJoinStyle;
- (void)setLineJoinStyle:(NSLineJoinStyle)lineJoinStyle;
- (NSWindingRule)windingRule;
- (void)setWindingRule:(NSWindingRule)windingRule;
- (void)setFlatness:(float)flatness;
- (float)flatness;
- (void)setMiterLimit:(float)limit;
- (float)miterLimit;
- (void)getLineDash:(float *)pattern count:(int *)count phase:(float *)phase;
- (void)setLineDash:(const float *)pattern count:(int)count phase:(float)phase;
- (void)setFlatness:(CGFloat)flatness;
- (CGFloat)flatness;
- (void)setMiterLimit:(CGFloat)limit;
- (CGFloat)miterLimit;
- (void)getLineDash:(CGFloat *)pattern count:(NSInteger *)count phase:(CGFloat *)phase;
- (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase;
//
// Path operations
@ -209,34 +209,34 @@ typedef enum {
//
// Elements
//
- (int)elementCount;
- (NSBezierPathElement)elementAtIndex:(int)index
- (NSInteger)elementCount;
- (NSBezierPathElement)elementAtIndex:(NSInteger)index
associatedPoints:(NSPoint *)points;
- (NSBezierPathElement)elementAtIndex:(int)index;
- (void)setAssociatedPoints:(NSPoint *)points atIndex:(int)index;
- (NSBezierPathElement)elementAtIndex:(NSInteger)index;
- (void)setAssociatedPoints:(NSPoint *)points atIndex:(NSInteger)index;
//
// Appending common paths
//
- (void)appendBezierPath:(NSBezierPath *)aPath;
- (void)appendBezierPathWithRect:(NSRect)aRect;
- (void)appendBezierPathWithPoints:(NSPoint *)points count:(int)count;
- (void)appendBezierPathWithPoints:(NSPoint *)points count:(NSInteger)count;
- (void)appendBezierPathWithOvalInRect:(NSRect)aRect;
- (void)appendBezierPathWithArcWithCenter:(NSPoint)center
radius:(float)radius
startAngle:(float)startAngle
endAngle:(float)endAngle
radius:(CGFloat)radius
startAngle:(CGFloat)startAngle
endAngle:(CGFloat)endAngle
clockwise:(BOOL)clockwise;
- (void)appendBezierPathWithArcWithCenter:(NSPoint)center
radius:(float)radius
startAngle:(float)startAngle
endAngle:(float)endAngle;
radius:(CGFloat)radius
startAngle:(CGFloat)startAngle
endAngle:(CGFloat)endAngle;
- (void)appendBezierPathWithArcFromPoint:(NSPoint)point1
toPoint:(NSPoint)point2
radius:(float)radius;
radius:(CGFloat)radius;
- (void)appendBezierPathWithGlyph:(NSGlyph)glyph inFont:(NSFont *)font;
- (void)appendBezierPathWithGlyphs:(NSGlyph *)glyphs
count:(int)count
count:(NSInteger)count
inFont:(NSFont *)font;
- (void)appendBezierPathWithPackedGlyphs:(const char *)packedGlyphs;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)

View file

@ -411,7 +411,7 @@
{
NSBezierPath *p = [NSBezierPath bezierPath];
NSPoint point;
float radius;
CGFloat radius;
// make smaller than enclosing frame
cellFrame = NSInsetRect(cellFrame, 4, floor(cellFrame.size.height * 0.1875));

View file

@ -69,14 +69,14 @@ typedef struct _PathElement
#define KAPPA 0.5522847498
#define INVALIDATE_CACHE() [self _invalidateCache]
static void flatten(NSPoint coeff[], float flatness, NSBezierPath *path);
static void flatten(NSPoint coeff[], CGFloat flatness, NSBezierPath *path);
static NSWindingRule default_winding_rule = NSNonZeroWindingRule;
static float default_line_width = 1.0;
static float default_flatness = 0.6;
static CGFloat default_line_width = 1.0;
static CGFloat default_flatness = 0.6;
static NSLineJoinStyle default_line_join_style = NSMiterLineJoinStyle;
static NSLineCapStyle default_line_cap_style = NSButtLineCapStyle;
static float default_miter_limit = 10.0;
static CGFloat default_miter_limit = 10.0;
@interface NSBezierPath (PrivateMethods)
- (void)_invalidateCache;
@ -182,25 +182,25 @@ static float default_miter_limit = 10.0;
//
// Default path rendering parameters
//
+ (void)setDefaultMiterLimit:(float)limit
+ (void)setDefaultMiterLimit:(CGFloat)limit
{
default_miter_limit = limit;
// Do we need this?
PSsetmiterlimit(limit);
}
+ (float)defaultMiterLimit
+ (CGFloat)defaultMiterLimit
{
return default_miter_limit;
}
+ (void)setDefaultFlatness:(float)flatness
+ (void)setDefaultFlatness:(CGFloat)flatness
{
default_flatness = flatness;
PSsetflat(flatness);
}
+ (float)defaultFlatness
+ (CGFloat)defaultFlatness
{
return default_flatness;
}
@ -237,13 +237,13 @@ static float default_miter_limit = 10.0;
return default_line_join_style;
}
+ (void)setDefaultLineWidth:(float)lineWidth
+ (void)setDefaultLineWidth:(CGFloat)lineWidth
{
default_line_width = lineWidth;
PSsetlinewidth(lineWidth);
}
+ (float)defaultLineWidth
+ (CGFloat)defaultLineWidth
{
return default_line_width;
}
@ -397,12 +397,12 @@ static float default_miter_limit = 10.0;
//
// Path rendering parameters
//
- (float)lineWidth
- (CGFloat)lineWidth
{
return _lineWidth;
}
- (void)setLineWidth:(float)lineWidth
- (void)setLineWidth:(CGFloat)lineWidth
{
_lineWidth = lineWidth;
}
@ -437,27 +437,27 @@ static float default_miter_limit = 10.0;
_windingRule = windingRule;
}
- (void)setFlatness:(float)flatness
- (void)setFlatness:(CGFloat)flatness
{
_flatness = flatness;
}
- (float)flatness
- (CGFloat)flatness
{
return _flatness;
}
- (void)setMiterLimit:(float)limit
- (void)setMiterLimit:(CGFloat)limit
{
_miterLimit = limit;
}
- (float)miterLimit
- (CGFloat)miterLimit
{
return _miterLimit;
}
- (void)getLineDash:(float *)pattern count:(int *)count phase:(float *)phase
- (void)getLineDash:(CGFloat *)pattern count:(NSInteger *)count phase:(CGFloat *)phase
{
// FIXME: How big is the pattern array?
// We assume that this value is in count!
@ -474,10 +474,10 @@ static float default_miter_limit = 10.0;
if (phase != NULL)
*phase = _dash_phase;
memcpy(pattern, _dash_pattern, _dash_count * sizeof(float));
memcpy(pattern, _dash_pattern, _dash_count * sizeof(CGFloat));
}
- (void)setLineDash:(const float *)pattern count:(int)count phase:(float)phase
- (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase
{
NSZone *myZone = [self zone];
@ -494,13 +494,13 @@ static float default_miter_limit = 10.0;
}
if (_dash_pattern == NULL)
_dash_pattern = NSZoneMalloc(myZone, count * sizeof(float));
_dash_pattern = NSZoneMalloc(myZone, count * sizeof(CGFloat));
else
NSZoneRealloc(myZone, _dash_pattern, count * sizeof(float));
NSZoneRealloc(myZone, _dash_pattern, count * sizeof(CGFloat));
_dash_count = count;
_dash_phase = phase;
memcpy(_dash_pattern, pattern, _dash_count * sizeof(float));
memcpy(_dash_pattern, pattern, _dash_count * sizeof(CGFloat));
}
//
@ -601,7 +601,7 @@ static float default_miter_limit = 10.0;
NSPoint pts[3];
NSPoint coeff[4];
NSPoint p, last_p;
int i, count;
NSInteger i, count;
BOOL first = YES;
if (_flat)
@ -663,7 +663,7 @@ static float default_miter_limit = 10.0;
NSBezierPathElement type, last_type;
NSPoint pts[3];
NSPoint p, cp1, cp2;
int i, j, count;
NSInteger i, j, count;
BOOL closed = NO;
/* Silence compiler warnings. */
@ -743,7 +743,7 @@ static float default_miter_limit = 10.0;
{
NSBezierPathElement type;
NSPoint pts[3];
int i, count;
NSInteger i, count;
SEL transformPointSel = @selector(transformPoint:);
NSPoint (*transformPointImp)(NSAffineTransform*, SEL, NSPoint);
@ -792,7 +792,7 @@ static float default_miter_limit = 10.0;
{
NSBezierPathElement type;
NSPoint points[3];
int i, count;
NSInteger i, count;
count = [self elementCount];
if (!count)
@ -842,12 +842,12 @@ static float default_miter_limit = 10.0;
//
// Elements
//
- (int) elementCount
- (NSInteger) elementCount
{
return GSIArrayCount(_pathElements);
}
- (NSBezierPathElement) elementAtIndex: (int)index
- (NSBezierPathElement) elementAtIndex: (NSInteger)index
associatedPoints: (NSPoint *)points
{
PathElement elm = GSIArrayItemAtIndex(_pathElements, index).ext;
@ -870,12 +870,12 @@ static float default_miter_limit = 10.0;
return type;
}
- (NSBezierPathElement) elementAtIndex: (int)index
- (NSBezierPathElement) elementAtIndex: (NSInteger)index
{
return [self elementAtIndex: index associatedPoints: NULL];
}
- (void)setAssociatedPoints:(NSPoint *)points atIndex:(int)index
- (void)setAssociatedPoints:(NSPoint *)points atIndex:(NSInteger)index
{
PathElement elm = GSIArrayItemAtIndex(_pathElements, index).ext;
NSBezierPathElement type = elm.type;
@ -908,7 +908,7 @@ static float default_miter_limit = 10.0;
{
NSBezierPathElement type;
NSPoint points[3];
int i, count;
NSInteger i, count;
count = [aPath elementCount];
for (i = 0; i < count; i++)
@ -953,9 +953,9 @@ static float default_miter_limit = 10.0;
[self closePath];
}
- (void)appendBezierPathWithPoints:(NSPoint *)points count:(int)count
- (void)appendBezierPathWithPoints:(NSPoint *)points count:(NSInteger)count
{
int i;
NSInteger i;
if (!count)
return;
@ -1012,12 +1012,12 @@ static float default_miter_limit = 10.0;
/* startAngle and endAngle are in degrees, counterclockwise, from the
x axis */
- (void) appendBezierPathWithArcWithCenter: (NSPoint)center
radius: (float)radius
startAngle: (float)startAngle
endAngle: (float)endAngle
radius: (CGFloat)radius
startAngle: (CGFloat)startAngle
endAngle: (CGFloat)endAngle
clockwise: (BOOL)clockwise
{
float startAngle_rad, endAngle_rad, diff;
CGFloat startAngle_rad, endAngle_rad, diff;
NSPoint p0, p1, p2, p3;
/* We use the Postscript prescription for managing the angles and
@ -1079,9 +1079,9 @@ static float default_miter_limit = 10.0;
if ((clockwise) ? (startAngle_rad + diff >= endAngle_rad)
: (startAngle_rad + diff <= endAngle_rad))
{
float sin_start = sin (startAngle_rad);
float cos_start = cos (startAngle_rad);
float sign = (clockwise) ? -1.0 : 1.0;
CGFloat sin_start = sin (startAngle_rad);
CGFloat cos_start = cos (startAngle_rad);
CGFloat sign = (clockwise) ? -1.0 : 1.0;
p1 = NSMakePoint (center.x
+ radius * (cos_start - KAPPA * sin_start * sign),
@ -1113,16 +1113,16 @@ static float default_miter_limit = 10.0;
*/
NSPoint ps = [self currentPoint];
/* tangent is the tangent of half the angle */
float tangent = tan ((endAngle_rad - startAngle_rad) / 2);
CGFloat tangent = tan ((endAngle_rad - startAngle_rad) / 2);
/* trad is the distance from either tangent point to the
intersection of the tangents */
float trad = radius * tangent;
CGFloat trad = radius * tangent;
/* pt is the intersection of the tangents */
NSPoint pt = NSMakePoint (ps.x - trad * sin (startAngle_rad),
ps.y + trad * cos (startAngle_rad));
/* This is F - in this expression we need to compute
(trad/radius)^2, which is simply tangent^2 */
float f = (4.0 / 3.0) / (1.0 + sqrt (1.0 + (tangent * tangent)));
CGFloat f = (4.0 / 3.0) / (1.0 + sqrt (1.0 + (tangent * tangent)));
p1 = NSMakePoint (ps.x + (pt.x - ps.x) * f, ps.y + (pt.y - ps.y) * f);
p3 = NSMakePoint(center.x + radius * cos (endAngle_rad),
@ -1135,9 +1135,9 @@ static float default_miter_limit = 10.0;
}
- (void) appendBezierPathWithArcWithCenter: (NSPoint)center
radius: (float)radius
startAngle: (float)startAngle
endAngle: (float)endAngle
radius: (CGFloat)radius
startAngle: (CGFloat)startAngle
endAngle: (CGFloat)endAngle
{
[self appendBezierPathWithArcWithCenter: center radius: radius
startAngle: startAngle endAngle: endAngle clockwise: NO];
@ -1145,11 +1145,11 @@ static float default_miter_limit = 10.0;
- (void) appendBezierPathWithArcFromPoint: (NSPoint)point1
toPoint: (NSPoint)point2
radius: (float)radius
radius: (CGFloat)radius
{
float x1, y1;
float dx1, dy1, dx2, dy2;
float l, a1, a2;
CGFloat x1, y1;
CGFloat dx1, dy1, dx2, dy2;
CGFloat l, a1, a2;
NSPoint p;
p = [self currentPoint];
@ -1247,7 +1247,7 @@ static float default_miter_limit = 10.0;
}
- (void)appendBezierPathWithGlyphs:(NSGlyph *)glyphs
count:(int)count
count:(NSInteger)count
inFont:(NSFont *)font
{
[[font fontInfo] appendBezierPathWithGlyphs: glyphs
@ -1519,11 +1519,11 @@ static int winding_curve(double_point from, double_point to, double_point c1,
{
int total;
NSBezierPathElement type;
int count;
NSInteger count;
BOOL first;
NSPoint pts[3];
NSPoint first_p, last_p;
int i;
NSInteger i;
/* We trace a line from (-INF, point.y) to (point) and count the
intersections. Simple, really. ;)
@ -1787,9 +1787,9 @@ static int winding_curve(double_point from, double_point to, double_point c1,
if (_dash_pattern != NULL)
{
float *pattern = NSZoneMalloc(zone, _dash_count * sizeof(float));
CGFloat *pattern = NSZoneMalloc(zone, _dash_count * sizeof(CGFloat));
memcpy(pattern, _dash_pattern, _dash_count * sizeof(float));
memcpy(pattern, _dash_pattern, _dash_count * sizeof(CGFloat));
_dash_pattern = pattern;
}
@ -1980,7 +1980,7 @@ static NSPoint point_on_curve(double t, NSPoint a, NSPoint b, NSPoint c,
@end // GSBezierPath
#endif
static void flatten(NSPoint coeff[], float flatness, NSBezierPath *path)
static void flatten(NSPoint coeff[], CGFloat flatness, NSBezierPath *path)
{
// Check if the Bezier path defined by the four points has the given flatness.
// If not split it up in the middle and recurse.

View file

@ -1427,46 +1427,7 @@ NSGraphicsContext *GSCurrentContext(void)
/** Set the bezier path as the current path */
- (void) GSSendBezierPath: (NSBezierPath *)path
{
NSBezierPathElement type;
NSPoint pts[3];
int i, count;
float pattern[10];
float phase;
DPSnewpath(self);
DPSsetlinewidth(self, [path lineWidth]);
DPSsetlinejoin(self, [path lineJoinStyle]);
DPSsetlinecap(self, [path lineCapStyle]);
DPSsetmiterlimit(self, [path miterLimit]);
DPSsetflat(self, [path flatness]);
[path getLineDash: pattern count: &count phase: &phase];
// Always sent the dash pattern. When NULL this will reset to a solid line.
DPSsetdash(self, pattern, count, phase);
count = [path elementCount];
for (i = 0; i < count; i++)
{
type = [path elementAtIndex: i associatedPoints: pts];
switch(type)
{
case NSMoveToBezierPathElement:
DPSmoveto(self, pts[0].x, pts[0].y);
break;
case NSLineToBezierPathElement:
DPSlineto(self, pts[0].x, pts[0].y);
break;
case NSCurveToBezierPathElement:
DPScurveto(self, pts[0].x, pts[0].y,
pts[1].x, pts[1].y, pts[2].x, pts[2].y);
break;
case NSClosePathBezierPathElement:
DPSclosepath(self);
break;
default:
break;
}
}
[self subclassResponsibility: _cmd];
}
/** Append the array of rects to the current clip path (DPS, Quartz). */

View file

@ -2017,22 +2017,22 @@ static void GSDrawPatternLine(NSPoint start, NSPoint end, NSInteger pattern, CGF
// FIXME: setLineDash should take CGFloat
if ((pattern & NSUnderlinePatternDot) == NSUnderlinePatternDot)
{
const float dot[2] = {2.5 * thickness, 2.5 * thickness};
const CGFloat dot[2] = {2.5 * thickness, 2.5 * thickness};
[path setLineDash: dot count: 2 phase: phase];
}
else if ((pattern & NSUnderlinePatternDash) == NSUnderlinePatternDash)
{
const float dash[2] = {10 * thickness, 5 * thickness};
const CGFloat dash[2] = {10 * thickness, 5 * thickness};
[path setLineDash: dash count: 2 phase: phase];
}
else if ((pattern & NSUnderlinePatternDashDot) == NSUnderlinePatternDashDot)
{
const float dashdot[4] = {10 * thickness, 3 * thickness, 3 * thickness, 3 * thickness};
const CGFloat dashdot[4] = {10 * thickness, 3 * thickness, 3 * thickness, 3 * thickness};
[path setLineDash: dashdot count: 4 phase: phase];
}
else if ((pattern & NSUnderlinePatternDashDotDot) == NSUnderlinePatternDashDotDot)
{
const float dashdotdot[6] = {10 * thickness, 3 * thickness, 3 * thickness, 3 * thickness, 3 * thickness, 3 * thickness};
const CGFloat dashdotdot[6] = {10 * thickness, 3 * thickness, 3 * thickness, 3 * thickness, 3 * thickness, 3 * thickness};
[path setLineDash: dashdotdot count: 6 phase: phase];
}
@ -2190,7 +2190,7 @@ static void GSDrawPatternLine(NSPoint start, NSPoint end, NSInteger pattern, CGF
containerOrigin: (NSPoint)containerOrigin
{
NSBezierPath *path;
const float pattern[2] = {2.5, 1.0};
const CGFloat pattern[2] = {2.5, 1.0};
NSFont *largestFont = [self effectiveFontForGlyphAtIndex: range.location // NOTE: GS private method
range: NULL];
NSPoint start = [self locationForGlyphAtIndex: range.location];