summaryrefslogtreecommitdiffstats
path: root/ksvg/impl/SVGMarkerElementImpl.h
blob: f027805288c93866024947e95e6f9029a9d2f13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
    Copyright (C) 2001-2003 KSVG Team
    This file is part of the KDE project

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef SVGMarkerElementImpl_H
#define SVGMarkerElementImpl_H

#include "ksvg_lookup.h"

#include "SVGStylableImpl.h"
#include "SVGLangSpaceImpl.h"
#include "SVGContainerImpl.h"
#include "SVGFitToViewBoxImpl.h"
#include "SVGExternalResourcesRequiredImpl.h"
#include "KSVGHelper.h"

namespace KSVG
{

class SVGAngleImpl;
class SVGAnimatedAngleImpl;
class SVGAnimatedLengthImpl;
class SVGAnimatedEnumerationImpl;
class SVGMarkerElementImpl : public SVGContainerImpl,
							 public SVGLangSpaceImpl,
							 public SVGExternalResourcesRequiredImpl,
							 public SVGStylableImpl,
							 public SVGFitToViewBoxImpl
{
public:
	SVGMarkerElementImpl(DOM::ElementImpl *);
	virtual ~SVGMarkerElementImpl();

	SVGAnimatedLengthImpl *refX() const;
	SVGAnimatedLengthImpl *refY() const;
	SVGAnimatedEnumerationImpl *markerUnits() const;
	SVGAnimatedLengthImpl *markerWidth() const;
	SVGAnimatedLengthImpl *markerHeight() const;
	SVGAnimatedEnumerationImpl *orientType() const;
	SVGAnimatedAngleImpl *orientAngle() const;

	void setOrientToAuto();
	void setOrientToAngle(SVGAngleImpl *angle);

	virtual void setAttributes();
	virtual void createItem(KSVGCanvas *c = 0);
	
	void draw(SVGShapeImpl *referencingElement, double x, double y, double lwidth, double angle);
	
	KSVGPolygon clipShape() const { return m_clipShape; }

	virtual bool directRender() { return false; }
	virtual bool isContainer() const { return false; }

private:
	SVGAnimatedLengthImpl *m_refX;
	SVGAnimatedLengthImpl *m_refY;
	SVGAnimatedEnumerationImpl *m_markerUnits;
	SVGAnimatedLengthImpl *m_markerWidth;
	SVGAnimatedLengthImpl *m_markerHeight;
	SVGAnimatedEnumerationImpl *m_orientType;
	SVGAnimatedAngleImpl *m_orientAngle;
	
	KSVGPolygon m_clipShape;

public:
	KSVG_GET
	KSVG_PUT
	KSVG_BRIDGE
	
	enum
	{
		// Properties
		RefX, RefY, MarkerUnits, MarkerWidth, MarkerHeight, OrientType, OrientAngle,
		Orient, ViewBox, PreserveAspectRatio,
		// Functions
		SetOrientToAuto, SetOrientToAngle
	};

	KJS::Value getValueProperty(KJS::ExecState *exec, int token) const;
	void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr);
};

class SVGMarkerElementImplConstructor : public KJS::ObjectImp
{
public:
	SVGMarkerElementImplConstructor(KJS::ExecState *) { }
	KJS::Value getValueProperty(KJS::ExecState *, int token) const;

	// no put - all read-only
	KSVG_GET
};

KJS::Value getSVGMarkerElementImplConstructor(KJS::ExecState *exec);

KSVG_REGISTER_ELEMENT(SVGMarkerElementImpl, "marker")

}

KSVG_DEFINE_PROTOTYPE(SVGMarkerElementImplProto)
KSVG_IMPLEMENT_PROTOFUNC(SVGMarkerElementImplProtoFunc, SVGMarkerElementImpl)

#endif