pleyo.com

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

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003, 2006, 2007 Apple Inc.  All rights reserved.
00003  * Copyright (C) 2007 Pleyo.  All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00015  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025  */
00026 
00027 #ifndef BIGraphicsContext_h
00028 #define BIGraphicsContext_h
00029 
00030 #include "BINativeImage.h"
00031 #include "FloatRect.h"
00032 #include "GraphicsTypes.h"
00033 #include "Image.h"
00034 #include "IntRect.h"
00035 #include "Path.h"
00036 #include "TextDirection.h"
00037 #include <wtf/Noncopyable.h>
00038 #include <wtf/Platform.h>
00039 
00040 namespace WebCore {
00041 
00042     class AffineTransform;
00043     class GraphicsContextPrivate;
00044     class GraphicsContextPlatformPrivate;
00045     class KURL;
00046     class Path;
00047     class TextStyle;
00048 }
00049 
00050 using WebCore::LineCap;
00051 using WebCore::LineJoin;
00052 using WebCore::Color;
00053 using WebCore::CompositeOperator;
00054 using WebCore::CompositeSourceOver;
00055 using WebCore::FloatPoint;
00056 using WebCore::TextStyle;
00057 using WebCore::IntPoint;
00058 using WebCore::IntRect;
00059 using WebCore::Path;
00060 using WebCore::FloatRect;
00061 using WebCore::FloatSize;
00062 using WebCore::KURL;
00063 //using WebCore::AffineTransform;
00064 
00065 namespace BAL {
00066 
00067     class BINativeImage;
00068     class BTWidget;
00069     class BTFont;
00070     class TextRun;
00071     class AffineTransform;
00072 
00073     const int cMisspellingLineThickness = 3;
00074     const int cMisspellingLinePatternWidth = 4;
00075     const int cMisspellingLinePatternGapWidth = 1;
00076 
00077     // These bits can be ORed together for a total of 8 possible text drawing modes.
00078     const int cTextInvisible = 0;
00079     const int cTextFill = 1;
00080     const int cTextStroke = 2;
00081     const int cTextClip = 4;
00082 
00083     enum StrokeStyle {
00084         NoStroke,
00085         SolidStroke,
00086         DottedStroke,
00087         DashedStroke
00088     };
00089 
00090     class BIGraphicsContext {
00091     public:
00092 
00093         enum TileRule { StretchTile, RepeatTile };
00094 
00095         virtual ~BIGraphicsContext() {}
00096 
00101         virtual void setWidget(const BTWidget*) = 0;
00106         virtual const BTWidget* widget() = 0;
00107 
00112         virtual const BTFont& font() const = 0;
00117         virtual void setFont(const BTFont&) = 0;
00118 
00119         virtual float strokeThickness() const = 0;
00120         virtual void setStrokeThickness(float) = 0;
00121         virtual StrokeStyle strokeStyle() const = 0;
00122         virtual void setStrokeStyle(const StrokeStyle& style) = 0;
00123         virtual Color strokeColor() const = 0;
00124         virtual void setStrokeColor(const Color&) = 0;
00125 
00130         virtual Color fillColor() const = 0;
00135         virtual void setFillColor(const Color&) = 0;
00140         virtual uint8_t alphaLayer() const = 0;
00141 
00145         virtual void save() = 0;
00149         virtual void restore() = 0;
00150 
00151         // These draw methods will do both stroking and filling.
00156         virtual void drawRect(const IntRect&) = 0;
00162         virtual void drawLine(const IntPoint&, const IntPoint&) = 0;
00167         virtual void drawEllipse(const IntRect&) = 0;
00174         virtual void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false) = 0;
00175 
00176         // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
00184         virtual void strokeArc(const IntRect&, int startAngle, int angleSpan) = 0;
00185 
00191         virtual void fillRect(const IntRect&, const Color&) = 0;
00197         virtual void fillRect(const FloatRect&, const Color&) = 0;
00198         virtual void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&) = 0;
00202         virtual void clearRect(const FloatRect&) = 0;
00203         virtual void strokeRect(const FloatRect&, float lineWidth) = 0;
00204 
00208         virtual void drawImage(BINativeImage*, const IntPoint&, CompositeOperator = CompositeSourceOver) = 0;
00209         virtual void drawImage(BINativeImage*, const IntRect&, CompositeOperator = CompositeSourceOver) = 0;
00210         virtual void drawImage(BINativeImage*, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver) = 0;
00211         virtual void drawImage(BINativeImage*, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver) = 0;
00212         virtual void drawImage(BINativeImage*, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
00213                        CompositeOperator = CompositeSourceOver) = 0;
00214         virtual void drawTiledImage(BINativeImage*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
00215                        CompositeOperator = CompositeSourceOver) = 0;
00216         virtual void drawTiledImage(BINativeImage*, const IntRect& destRect, const IntRect& srcRect,
00217                             TileRule hRule = StretchTile, TileRule vRule = StretchTile,
00218                             CompositeOperator = CompositeSourceOver) = 0;
00219 
00223         virtual void clip(const IntRect&) = 0;
00224         virtual void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) = 0;
00225         virtual void addInnerRoundedRectClip(const IntRect&, int thickness) = 0;
00226         virtual void clipOut(const IntRect&) = 0;
00227         virtual void clipOutEllipseInRect(const IntRect&) = 0;
00228         virtual void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) = 0;
00229 
00230         // Functions to work around bugs in focus ring clipping on Mac.
00231         virtual void setFocusRingClip(const IntRect&) = 0;
00232         virtual void clearFocusRingClip() = 0;
00233 
00234         virtual int textDrawingMode() = 0;
00235         virtual void setTextDrawingMode(int) = 0;
00236 
00244         virtual void drawText(const TextRun&, const IntPoint&, int from = 0, int to = -1) = 0;
00253         virtual void drawText(const TextRun&, const IntPoint&, const TextStyle&, int from = 0, int to = -1) = 0;
00254         virtual void drawBidiText(const TextRun&, const IntPoint&, const TextStyle&) = 0;
00255         virtual void drawHighlightForText(const TextRun&, const IntPoint&, int h, const TextStyle&, const Color& backgroundColor, int from = 0, int to = -1) = 0;
00256 
00257         virtual FloatRect roundToDevicePixels(const FloatRect&) = 0;
00258 
00259         virtual void drawLineForText(const IntPoint&, int width, bool printing) = 0;
00260         virtual void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar) = 0;
00261 
00262         virtual bool paintingDisabled() const = 0;
00263         virtual void setPaintingDisabled(bool) = 0;
00264 
00265         virtual bool updatingControlTints() const = 0;
00266         virtual void setUpdatingControlTints(bool) = 0;
00267 
00268         virtual void beginTransparencyLayer(float opacity) = 0;
00269         virtual void endTransparencyLayer() = 0;
00270 
00271         virtual void setShadow(const IntSize&, int blur, const Color&) = 0;
00272         virtual void clearShadow() = 0;
00273 
00274         virtual void initFocusRing(int width, int offset) = 0;
00275         virtual void addFocusRingRect(const IntRect&) = 0;
00276         virtual void drawFocusRing(const Color&) = 0;
00277         virtual void clearFocusRing() = 0;
00278         virtual IntRect focusRingBoundingRect() = 0;
00279 
00280         virtual void setLineCap(LineCap) = 0;
00281         virtual void setLineJoin(LineJoin) = 0;
00282         virtual void setMiterLimit(float) = 0;
00283 
00287         virtual void setAlpha(float) = 0;
00288 
00289         virtual void setCompositeOperation(CompositeOperator) = 0;
00290 
00291         virtual void beginPath() = 0;
00292         virtual void addPath(const Path& path) = 0;
00293 
00294         virtual void clip(const Path&) = 0;
00295 
00296         virtual void scale(const FloatSize&) = 0;
00297         virtual void rotate(float angleInRadians) = 0;
00298         virtual void translate(float x, float y) = 0;
00299         virtual IntPoint origin() = 0;
00300 
00301         virtual void setURLForRect(const KURL&, const IntRect&) = 0;
00302 
00303         virtual void concatCTM(const AffineTransform&) = 0;
00304 
00305     };
00306 
00307 } // namespace BAL
00308 
00309 #define IMPLEMENT_BIGRAPHICSCONTEXT  \
00310     public: \
00311         virtual void setWidget(const BTWidget*); \
00312         virtual const BTWidget* widget(); \
00313         virtual const BTFont& font() const; \
00314         virtual void setFont(const BTFont&); \
00315         virtual float strokeThickness() const; \
00316         virtual void setStrokeThickness(float); \
00317         virtual StrokeStyle strokeStyle() const; \
00318         virtual void setStrokeStyle(const StrokeStyle& style); \
00319         virtual Color strokeColor() const; \
00320         virtual void setStrokeColor(const Color&); \
00321         virtual Color fillColor() const; \
00322         virtual void setFillColor(const Color&); \
00323         virtual uint8_t alphaLayer() const; \
00324         virtual void save(); \
00325         virtual void restore(); \
00326         virtual void drawRect(const IntRect&); \
00327         virtual void drawLine(const IntPoint&, const IntPoint&); \
00328         virtual void drawEllipse(const IntRect&); \
00329         virtual void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false); \
00330         virtual void strokeArc(const IntRect&, int startAngle, int angleSpan); \
00331         virtual void fillRect(const IntRect&, const Color&); \
00332         virtual void fillRect(const FloatRect&, const Color&); \
00333         virtual void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&); \
00334         virtual void clearRect(const FloatRect&); \
00335         virtual void strokeRect(const FloatRect&, float lineWidth); \
00336         virtual void drawImage(BINativeImage*, const IntPoint&, CompositeOperator = CompositeSourceOver); \
00337         virtual void drawImage(BINativeImage*, const IntRect&, CompositeOperator = CompositeSourceOver); \
00338         virtual void drawImage(BINativeImage*, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver); \
00339         virtual void drawImage(BINativeImage*, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver); \
00340         virtual void drawImage(BINativeImage*, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver); \
00341         virtual void drawTiledImage(BINativeImage*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator = CompositeSourceOver); \
00342         virtual void drawTiledImage(BINativeImage*, const IntRect& destRect, const IntRect& srcRect, TileRule hRule = StretchTile, TileRule vRule = StretchTile, CompositeOperator = CompositeSourceOver); \
00343         virtual void clip(const IntRect&); \
00344         virtual void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); \
00345         virtual void addInnerRoundedRectClip(const IntRect&, int thickness); \
00346         virtual void clipOut(const IntRect&); \
00347         virtual void clipOutEllipseInRect(const IntRect&); \
00348         virtual void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); \
00349         virtual void setFocusRingClip(const IntRect&); \
00350         virtual void clearFocusRingClip(); \
00351         virtual int textDrawingMode(); \
00352         virtual void setTextDrawingMode(int); \
00353         virtual void drawText(const TextRun&, const IntPoint&, int, int); \
00354         virtual void drawText(const TextRun&, const IntPoint&, const TextStyle&, int, int); \
00355         virtual void drawBidiText(const TextRun&, const IntPoint&, const TextStyle&); \
00356         virtual void drawHighlightForText(const TextRun&, const IntPoint&, int h, const TextStyle&, const Color& backgroundColor, int, int); \
00357         virtual FloatRect roundToDevicePixels(const FloatRect&); \
00358         virtual void drawLineForText(const IntPoint&, int width, bool printing); \
00359         virtual void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar); \
00360         virtual bool paintingDisabled() const; \
00361         virtual void setPaintingDisabled(bool); \
00362         virtual bool updatingControlTints() const; \
00363         virtual void setUpdatingControlTints(bool); \
00364         virtual void beginTransparencyLayer(float opacity); \
00365         virtual void endTransparencyLayer(); \
00366         virtual void setShadow(const IntSize&, int blur, const Color&); \
00367         virtual void clearShadow(); \
00368         virtual void initFocusRing(int width, int offset); \
00369         virtual void addFocusRingRect(const IntRect&); \
00370         virtual void drawFocusRing(const Color&); \
00371         virtual void clearFocusRing(); \
00372         virtual IntRect focusRingBoundingRect(); \
00373         virtual void setLineCap(LineCap); \
00374         virtual void setLineJoin(LineJoin); \
00375         virtual void setMiterLimit(float); \
00376         virtual void setAlpha(float); \
00377         virtual void setCompositeOperation(CompositeOperator); \
00378         virtual void beginPath(); \
00379         virtual void addPath(const Path& path); \
00380         virtual void clip(const Path&); \
00381         virtual void scale(const FloatSize&); \
00382         virtual void rotate(float angleInRadians); \
00383         virtual void translate(float x, float y); \
00384         virtual IntPoint origin(); \
00385         virtual void setURLForRect(const KURL&, const IntRect&); \
00386         virtual void concatCTM(const AffineTransform&);
00387 
00388 #endif // BIGraphicsContext_h

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

pleyo.com
pleyo.com