• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • svg
  • graphics
  • qt
SVGPaintServerQt.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
3
4 This file is part of the KDE project
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 aint with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "config.h"
23#include "wtf/Platform.h"
24
25#if ENABLE(SVG)
26#include "SVGPaintServer.h"
27
28/*#include "GraphicsContext.h"*/
29#include "SVGRenderStyle.h"
30#include "RenderObject.h"
31#include "RenderPath.h"
32
33#include <QPainter>
34#include <QVector>
35
36namespace WebCore {
37
38void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const
39{
40 pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
41
42 /*if (style->svgStyle()->capStyle() == ButtCap)
43 pen.setCapStyle(Qt::FlatCap);
44 else if (style->svgStyle()->capStyle() == RoundCap)
45 pen.setCapStyle(Qt::RoundCap);
46
47 if (style->svgStyle()->joinStyle() == MiterJoin) {
48 pen.setJoinStyle(Qt::MiterJoin);
49 pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
50 } else if(style->svgStyle()->joinStyle() == RoundJoin)
51 pen.setJoinStyle(Qt::RoundJoin);*/
52
53 /*const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
54 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
55
56 unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
57 if(dashLength) {
58 QVector<qreal> pattern;
59 unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
60
61 for(unsigned int i = 0; i < count; i++)
62 pattern.append(dashes[i % dashLength] / (float)pen.widthF());
63
64 pen.setDashPattern(pattern);
65
66 Q_UNUSED(dashOffset);
67 // TODO: dash-offset, does/will qt4 API allow it? (Rob)
68 }*/
69}
70
71void SVGPaintServer::draw(QPainter* painter, QPainterPath* painterPath, const RenderObject* path, SVGPaintTargetType type) const
72{
73 if (!setup(painter, painterPath, path, type))
74 return;
75
76 renderPath(painter, painterPath, path, type);
77 teardown(painter, painterPath, path, type);
78}
79
80void SVGPaintServer::teardown(QPainter* painter, QPainterPath* painterPath, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
81{
82 Q_UNUSED(painter);
83 Q_UNUSED(painterPath);
84 Q_UNUSED(isPaintingText);
85 // no-op
86}
87
88void SVGPaintServer::renderPath(QPainter* painter, QPainterPath* painterPath, const RenderObject* path, SVGPaintTargetType type) const
89{
90 RenderStyle* renderStyle = path->style();
91
92 //QPainter* painter(context ? context->platformContext() : 0);
93 //Q_ASSERT(painter);
94
95 //QPainterPath* painterPath(context ? context->currentPath() : 0);
96 //Q_ASSERT(painterPath);
97
98 if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill())
99 painter->fillPath(*painterPath, painter->brush());
100
101 if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke())
102 painter->strokePath(*painterPath, painter->pen());
103}
104
105} // namespace WebCore
106
107#endif
108
109// vim:ts=4
RenderObject.h
SVGPaintServer.h
WebCore
Definition: CSSHelper.h:7
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal