pleyo.com

/src/trunk2/BAL/Interfaces/graphics/Path.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
00003  *                     2006 Rob Buis <buis@kde.org>
00004  * Copyright (C) 2007 Pleyo.  All rights reserved.
00005  * 
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00016  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00018  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00019  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00022  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00023  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00026  */
00027 
00028 #ifndef Path_h
00029 #define Path_h
00030 
00031 #if PLATFORM(CG)
00032 typedef struct CGPath PlatformPath;
00033 #elif PLATFORM(QT)
00034 class QPainterPath;
00035 typedef QPainterPath PlatformPath;
00036 #elif PLATFORM(CAIRO)
00037 namespace WebCore {
00038     struct CairoPath;
00039 }
00040 typedef WebCore::CairoPath PlatformPath;
00041 #elif defined __OWB__
00042 #include "AffineTransform.h"
00043 typedef void PlatformPath;
00044 #else
00045 typedef void PlatformPath;
00046 #endif
00047 
00048 namespace WebCore {
00049 
00050     class AffineTransform;
00051     class FloatPoint;
00052     class FloatSize;
00053     class FloatRect;
00054     class String;
00055 
00056     enum WindRule {
00057         RULE_NONZERO = 0,
00058         RULE_EVENODD = 1
00059     };
00060 
00061     enum PathElementType {
00062         PathElementMoveToPoint,
00063         PathElementAddLineToPoint,
00064         PathElementAddQuadCurveToPoint,
00065         PathElementAddCurveToPoint,
00066         PathElementCloseSubpath
00067     };
00068 
00069     struct PathElement {
00070         PathElementType type;
00071         FloatPoint* points;
00072     };
00073 
00074     typedef void (*PathApplierFunction) (void* info, const PathElement*);
00075 
00076     class Path {
00077     public:
00078         Path();
00079         ~Path();
00080 
00081         Path(const Path&);
00082         Path& operator=(const Path&);
00083 
00084         bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
00085         FloatRect boundingRect() const;
00086         
00087         float length();
00088         FloatPoint pointAtLength(float length, bool& ok);
00089         float normalAngleAtLength(float length, bool& ok);
00090 
00091         void clear();
00092         bool isEmpty() const;
00093 
00094         void moveTo(const FloatPoint&);
00095         void addLineTo(const FloatPoint&);
00096         void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
00097         void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
00098         void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
00099         void closeSubpath();
00100 
00101         void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool clockwise);
00102         void addRect(const FloatRect&);
00103         void addEllipse(const FloatRect&);
00104 
00105         void translate(const FloatSize&);
00106 
00107         void setWindingRule(WindRule rule) { m_rule = rule; }
00108         WindRule windingRule() const { return m_rule; }
00109 
00110         String debugString() const;
00111 
00112         PlatformPath* platformPath() const { return m_path; }
00113 
00114         static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);
00115         static Path createRoundedRectangle(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
00116         static Path createRectangle(const FloatRect&);
00117         static Path createEllipse(const FloatPoint& center, float rx, float ry);
00118         static Path createCircle(const FloatPoint& center, float r);
00119         static Path createLine(const FloatPoint&, const FloatPoint&);
00120 
00121         void apply(void* info, PathApplierFunction) const;
00122         void transform(const AffineTransform&);
00123 
00124     private:
00125         PlatformPath* m_path;
00126         WindRule m_rule;
00127     };
00128 
00129 }
00130 
00131 #endif

Generated on Wed Nov 21 20:04:17 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com