Reviewed by eseidel.
[WebKit-https.git] / WebCore / ksvg2 / svg / SVGSVGElement.h
1 /*
2     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3                   2004, 2005 Rob Buis <buis@kde.org>
4
5     This file is part of the KDE project
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Library General Public
9     License as published by the Free Software Foundation; either
10     version 2 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Library General Public License for more details.
16
17     You should have received a copy of the GNU Library General Public License
18     along with this library; see the file COPYING.LIB.  If not, write to
19     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20     Boston, MA 02111-1307, USA.
21 */
22
23 #ifndef SVGSVGElement_H
24 #define SVGSVGElement_H
25 #ifdef SVG_SUPPORT
26
27 #include "SVGTests.h"
28 #include "SVGLangSpace.h"
29 #include "SVGFitToViewBox.h"
30 #include "SVGZoomAndPan.h"
31 #include "SVGStyledLocatableElement.h"
32 #include "SVGExternalResourcesRequired.h"
33
34 namespace WebCore
35 {
36     class DocumentPtr;
37     class SVGAngle;
38     class SVGLength;
39     class SVGMatrix;
40     class SVGTransform;
41     class SVGLength;
42     class TimeScheduler;
43     class SVGSVGElement : public SVGStyledLocatableElement,
44                               public SVGTests,
45                               public SVGLangSpace,
46                               public SVGExternalResourcesRequired,
47                               public SVGFitToViewBox,
48                               public SVGZoomAndPan
49     {
50     public:
51         enum SVGZoomAndPanType {
52             SVG_ZOOMANDPAN_UNKNOWN = 0,
53             SVG_ZOOMANDPAN_DISABLE = 1,
54             SVG_ZOOMANDPAN_MAGNIFY = 2
55         };
56
57         SVGSVGElement(const QualifiedName&, Document*);
58         virtual ~SVGSVGElement();
59
60         virtual bool isSVG() const { return true; }
61         
62         virtual bool isValid() const { return SVGTests::isValid(); }
63
64         // 'SVGSVGElement' functions
65         AtomicString contentScriptType() const;
66         void setContentScriptType(const AtomicString& type);
67
68         AtomicString contentStyleType() const;
69         void setContentStyleType(const AtomicString& type);
70
71         FloatRect viewport() const;
72
73         float pixelUnitToMillimeterX() const;
74         float pixelUnitToMillimeterY() const;
75         float screenPixelToMillimeterX() const;
76         float screenPixelToMillimeterY() const;
77
78         bool useCurrentView() const;
79         void setUseCurrentView(bool currentView);
80
81         // SVGViewSpec *currentView() const;
82
83         float currentScale() const;
84         void setCurrentScale(float scale);
85
86         FloatPoint currentTranslate() const;
87         
88         TimeScheduler* timeScheduler() { return m_timeScheduler; }
89         
90         void pauseAnimations();
91         void unpauseAnimations();
92         bool animationsPaused() const;
93
94         float getCurrentTime() const;
95         void setCurrentTime(float seconds);
96
97         unsigned long suspendRedraw(unsigned long max_wait_milliseconds);
98         void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode&);
99         void unsuspendRedrawAll();
100         void forceRedraw();
101
102         NodeList* getIntersectionList(const FloatRect&, SVGElement *referenceElement);
103         NodeList* getEnclosureList(const FloatRect&, SVGElement *referenceElement);
104         bool checkIntersection(SVGElement*, const FloatRect&);
105         bool checkEnclosure(SVGElement*, const FloatRect&);
106         void deselectAll();
107
108         static float createSVGNumber();
109         static SVGLength* createSVGLength();
110         static SVGAngle* createSVGAngle();
111         static FloatPoint createSVGPoint(const IntPoint &p = IntPoint());
112         static SVGMatrix* createSVGMatrix();
113         static FloatRect createSVGRect();
114         static SVGTransform* createSVGTransform();
115         static SVGTransform* createSVGTransformFromMatrix(SVGMatrix*);
116
117         virtual void parseMappedAttribute(MappedAttribute *attr);
118
119         // 'virtual SVGLocatable' functions
120         virtual SVGMatrix *getCTM() const;
121         virtual SVGMatrix *getScreenCTM() const;
122
123         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
124         virtual RenderObject* createRenderer(RenderArena *arena, RenderStyle *style);
125         
126         virtual void insertedIntoDocument();
127         virtual void removedFromDocument();
128
129         // 'virtual SVGZoomAndPan functions
130         virtual void setZoomAndPan(unsigned short zoomAndPan);
131
132         virtual void attributeChanged(Attribute*, bool preserveDecls = false);
133
134     protected:
135         virtual const SVGElement* contextElement() const { return this; }
136
137     private:
138         void addSVGWindowEventListner(const AtomicString& eventType, const Attribute* attr);   
139
140         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
141         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, FloatRect, ViewBox, viewBox)
142         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio)
143
144         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength*, RefPtr<SVGLength>, X, x)
145         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength*, RefPtr<SVGLength>, Y, y)
146         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength*, RefPtr<SVGLength>, Width, width)
147         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGLength*, RefPtr<SVGLength>, Height, height)
148
149         bool m_useCurrentView;
150         TimeScheduler* m_timeScheduler;
151     };
152
153 } // namespace WebCore
154
155 #endif // SVG_SUPPORT
156 #endif
157
158 // vim:ts=4:noet