KHTML
Path.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef Path_h
00028 #define Path_h
00029
00030 #include "wtf/Platform.h"
00031
00032 #if PLATFORM(CG)
00033 typedef struct CGPath PlatformPath;
00034 #elif PLATFORM(QT)
00035 #include <qglobal.h>
00036 QT_BEGIN_NAMESPACE
00037 class QPainterPath;
00038 QT_END_NAMESPACE
00039 typedef QPainterPath PlatformPath;
00040 #elif PLATFORM(WX) && USE(WXGC)
00041 class wxGraphicsPath;
00042 typedef wxGraphicsPath PlatformPath;
00043 #elif PLATFORM(CAIRO)
00044 namespace WebCore {
00045 struct CairoPath;
00046 }
00047 typedef WebCore::CairoPath PlatformPath;
00048 #else
00049 typedef void PlatformPath;
00050 #endif
00051
00052
00053 #include "Document.h"
00054
00055 namespace WebCore {
00056
00057 class AffineTransform;
00058 class FloatPoint;
00059 class FloatSize;
00060 class FloatRect;
00061
00062
00063 enum WindRule {
00064 RULE_NONZERO = 0,
00065 RULE_EVENODD = 1
00066 };
00067
00068 enum PathElementType {
00069 PathElementMoveToPoint,
00070 PathElementAddLineToPoint,
00071 PathElementAddQuadCurveToPoint,
00072 PathElementAddCurveToPoint,
00073 PathElementCloseSubpath
00074 };
00075
00076 struct PathElement {
00077 PathElementType type;
00078 FloatPoint* points;
00079 };
00080
00081 typedef void (*PathApplierFunction) (void* info, const PathElement*);
00082
00083 class Path {
00084 public:
00085 Path();
00086 ~Path();
00087
00088 Path(const Path&);
00089 Path& operator=(const Path&);
00090
00091 bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
00092 FloatRect boundingRect() const;
00093
00094 float length();
00095 FloatPoint pointAtLength(float length, bool& ok);
00096 float normalAngleAtLength(float length, bool& ok);
00097
00098 void clear();
00099 bool isEmpty() const;
00100
00101 void moveTo(const FloatPoint&);
00102 void addLineTo(const FloatPoint&);
00103 void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
00104 void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
00105 void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
00106 void closeSubpath();
00107
00108 void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise);
00109 void addRect(const FloatRect&);
00110 void addEllipse(const FloatRect&);
00111
00112 void translate(const FloatSize&);
00113
00114 void setWindingRule(WindRule rule) { m_rule = rule; }
00115 WindRule windingRule() const { return m_rule; }
00116
00117 String debugString() const;
00118
00119 PlatformPath* platformPath() const { return m_path; }
00120
00121 static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);
00122 static Path createRoundedRectangle(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
00123 static Path createRectangle(const FloatRect&);
00124 static Path createEllipse(const FloatPoint& center, float rx, float ry);
00125 static Path createCircle(const FloatPoint& center, float r);
00126 static Path createLine(const FloatPoint&, const FloatPoint&);
00127
00128 void apply(void* info, PathApplierFunction) const;
00129 void transform(const AffineTransform&);
00130
00131 private:
00132 PlatformPath* m_path;
00133 WindRule m_rule;
00134 };
00135
00136 }
00137
00138 #endif