• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

GraphicsContext.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003, 2006, 2007 Apple Inc.  All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  *
00013  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00014  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00017  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00018  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00019  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00020  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00021  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00023  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00024  */
00025 
00026 #ifndef GraphicsContext_h
00027 #define GraphicsContext_h
00028 
00029 #include "FloatRect.h"
00030 //#include "Image.h"
00031 #include "IntRect.h"
00032 #include "Path.h"
00033 //#include "TextDirection.h"
00034 #include <wtf/Noncopyable.h>
00035 #include <wtf/Platform.h>
00036 
00037 #if PLATFORM(CG)
00038 typedef struct CGContext PlatformGraphicsContext;
00039 #elif PLATFORM(CAIRO)
00040 typedef struct _cairo PlatformGraphicsContext;
00041 #elif PLATFORM(QT)
00042 QT_BEGIN_NAMESPACE
00043 class QPainter;
00044 QT_END_NAMESPACE
00045 typedef QPainter PlatformGraphicsContext;
00046 #elif PLATFORM(WX)
00047 class wxGCDC;
00048 class wxWindowDC;
00049 
00050 // wxGraphicsContext allows us to support Path, etc. 
00051 // but on some platforms, e.g. Linux, it requires fairly 
00052 // new software.
00053 #if USE(WXGC)
00054 // On OS X, wxGCDC is just a typedef for wxDC, so use wxDC explicitly to make
00055 // the linker happy.
00056 #ifdef __APPLE__
00057     class wxDC;
00058     typedef wxDC PlatformGraphicsContext;
00059 #else
00060     typedef wxGCDC PlatformGraphicsContext;
00061 #endif
00062 #else
00063     typedef wxWindowDC PlatformGraphicsContext;
00064 #endif
00065 #else
00066 typedef void PlatformGraphicsContext;
00067 #endif
00068 
00069 #if PLATFORM(GTK)
00070 typedef struct _GdkDrawable GdkDrawable;
00071 typedef struct _GdkEventExpose GdkEventExpose;
00072 #endif
00073 
00074 #if PLATFORM(WIN)
00075 typedef struct HDC__* HDC;
00076 #endif
00077 
00078 namespace WebCore {
00079 
00080     const int cMisspellingLineThickness = 3;
00081     const int cMisspellingLinePatternWidth = 4;
00082     const int cMisspellingLinePatternGapWidth = 1;
00083 
00084     class AffineTransform;
00085     //class Font;
00086     class Generator;
00087     class GraphicsContextPrivate;
00088     class GraphicsContextPlatformPrivate;
00089     //class ImageBuffer;
00090     //class KURL;
00091     class Path;
00092     //class TextRun;
00093 
00094     // These bits can be ORed together for a total of 8 possible text drawing modes.
00095     const int cTextInvisible = 0;
00096     const int cTextFill = 1;
00097     const int cTextStroke = 2;
00098     const int cTextClip = 4;
00099     
00100     enum StrokeStyle {
00101         NoStroke,
00102         SolidStroke,
00103         DottedStroke,
00104         DashedStroke
00105     };
00106 
00107     class GraphicsContext : Noncopyable {
00108     public:
00109         GraphicsContext(PlatformGraphicsContext*);
00110         ~GraphicsContext();
00111        
00112         PlatformGraphicsContext* platformContext() const;
00113 
00114         /*const Font& font() const;
00115         void setFont(const Font&);*/
00116         
00117         /*float strokeThickness() const;
00118         void setStrokeThickness(float);
00119         StrokeStyle strokeStyle() const;
00120         void setStrokeStyle(const StrokeStyle& style);
00121         Color strokeColor() const;
00122         void setStrokeColor(const Color&);
00123 
00124         Color fillColor() const;
00125         void setFillColor(const Color&);*/
00126         
00127         void save();
00128         void restore();
00129         
00130         // These draw methods will do both stroking and filling.
00131         void drawRect(const IntRect&);
00132         void drawLine(const IntPoint&, const IntPoint&);
00133         void drawEllipse(const IntRect&);
00134         void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
00135 
00136         // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
00137         void strokeArc(const IntRect&, int startAngle, int angleSpan);
00138         
00139         /*void fillRect(const IntRect&, const Color&);
00140         void fillRect(const FloatRect&, const Color&);
00141         void fillRect(const FloatRect&, Generator&);
00142         void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
00143         void clearRect(const FloatRect&);
00144         void strokeRect(const FloatRect&, float lineWidth);*/
00145 
00146         /*void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceOver);
00147         void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
00148         void drawImage(Image*, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
00149         void drawImage(Image*, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
00150         void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
00151                        CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
00152         void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
00153                        CompositeOperator = CompositeSourceOver);
00154         void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, 
00155                             Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
00156                             CompositeOperator = CompositeSourceOver);*/
00157 
00158 /*#if PLATFORM(CG)
00159         void setUseLowQualityImageInterpolation(bool = true);
00160         bool useLowQualityImageInterpolation() const;
00161 #else
00162         void setUseLowQualityImageInterpolation(bool = true) {}
00163         bool useLowQualityImageInterpolation() const { return false; }
00164 #endif*/
00165 
00166         void clip(const FloatRect&);
00167         void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
00168         void addInnerRoundedRectClip(const IntRect&, int thickness);
00169         void clipOut(const IntRect&);
00170         void clipOutEllipseInRect(const IntRect&);
00171         /*void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
00172         void clipToImageBuffer(const FloatRect&, const ImageBuffer*);*/
00173 
00174         /*int textDrawingMode();
00175         void setTextDrawingMode(int);
00176 
00177         void drawText(const TextRun&, const IntPoint&, int from = 0, int to = -1);
00178         void drawBidiText(const TextRun&, const IntPoint&);
00179         void drawHighlightForText(const TextRun&, const IntPoint&, int h, const Color& backgroundColor, int from = 0, int to = -1);*/
00180 
00181         FloatRect roundToDevicePixels(const FloatRect&);
00182         
00183         void drawLineForText(const IntPoint&, int width, bool printing);
00184         void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar);
00185         
00186         bool paintingDisabled() const;
00187         void setPaintingDisabled(bool);
00188         
00189         bool updatingControlTints() const;
00190         void setUpdatingControlTints(bool);
00191 
00192         void beginTransparencyLayer(float opacity);
00193         void endTransparencyLayer();
00194 
00195         /*void setShadow(const IntSize&, int blur, const Color&);
00196         void getShadow(IntSize&, int&, Color&);
00197         void clearShadow();*/
00198 
00199         void initFocusRing(int width, int offset);
00200         void addFocusRingRect(const IntRect&);
00201         //void drawFocusRing(const Color&);
00202         void clearFocusRing();
00203         IntRect focusRingBoundingRect();
00204 
00205         /*void setLineCap(LineCap);
00206         void setLineJoin(LineJoin);*/
00207         void setMiterLimit(float);
00208 
00209         void setAlpha(float);
00210 
00211         //void setCompositeOperation(CompositeOperator);
00212 
00213         void beginPath();
00214         void addPath(const Path&);
00215 
00216         void clip(const Path&);
00217         void clipOut(const Path&);
00218 
00219         void scale(const FloatSize&);
00220         void rotate(float angleInRadians);
00221         void translate(float x, float y);
00222         IntPoint origin();
00223         
00224         /*void setURLForRect(const KURL&, const IntRect&);*/
00225 
00226         void concatCTM(const AffineTransform&);
00227         AffineTransform getCTM() const;
00228 
00229         void setUseAntialiasing(bool = true);
00230 
00231 #if PLATFORM(WIN)
00232         GraphicsContext(HDC); // FIXME: To be removed.
00233         bool inTransparencyLayer() const;
00234         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
00235         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);    // The passed in HDC should be the one handed back by getWindowsContext.
00236 
00237         class WindowsBitmap : public Noncopyable {
00238         public:
00239             WindowsBitmap(HDC, IntSize);
00240             ~WindowsBitmap();
00241 
00242             HDC hdc() const { return m_hdc; }
00243             UInt8* buffer() const { return m_bitmapBuffer; }
00244             unsigned bufferLength() const { return m_bitmapBufferLength; }
00245             IntSize size() const { return m_size; }
00246             unsigned bytesPerRow() const { return m_bytesPerRow; }
00247 
00248         private:
00249             HDC m_hdc;
00250             HBITMAP m_bitmap;
00251             UInt8* m_bitmapBuffer;
00252             unsigned m_bitmapBufferLength;
00253             IntSize m_size;
00254             unsigned m_bytesPerRow;
00255         };
00256 
00257         WindowsBitmap* createWindowsBitmap(IntSize);
00258         // The bitmap should be non-premultiplied.
00259         void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
00260 #endif
00261 
00262 #if PLATFORM(QT)
00263         void setFillRule(WindRule);
00264         PlatformPath* currentPath();
00265 #endif
00266 
00267 #if PLATFORM(GTK)
00268         void setGdkExposeEvent(GdkEventExpose*);
00269         GdkDrawable* gdkDrawable() const;
00270         GdkEventExpose* gdkExposeEvent() const;
00271         IntPoint translatePoint(const IntPoint&) const;
00272 #endif
00273 
00274     private:
00275         void savePlatformState();
00276         void restorePlatformState();
00277         void setPlatformTextDrawingMode(int);
00278         /*void setPlatformStrokeColor(const Color&);
00279         void setPlatformStrokeStyle(const StrokeStyle&);*/
00280         void setPlatformStrokeThickness(float);
00281         /*void setPlatformFillColor(const Color&);
00282         void setPlatformFont(const Font& font);
00283         void setPlatformShadow(const IntSize&, int blur, const Color&);*/
00284         void clearPlatformShadow();
00285 
00286         int focusRingWidth() const;
00287         int focusRingOffset() const;
00288         const Vector<IntRect>& focusRingRects() const;
00289 
00290         static GraphicsContextPrivate* createGraphicsContextPrivate();
00291         static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
00292 
00293         GraphicsContextPrivate* m_common;
00294         GraphicsContextPlatformPrivate* m_data; // Deprecated; m_commmon can just be downcasted. To be removed.
00295     };
00296 
00297 } // namespace WebCore
00298 
00299 #endif // GraphicsContext_h

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal