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

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
  • graphics
  • qt
RenderPathQt.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
3  2004, 2005, 2006 Rob Buis <buis@kde.org>
4  2005 Eric Seidel <eric.seidel@kdemail.net>
5 
6  This file is part of the KDE project
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  aint with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include "config.h"
25 #include "RenderPath.h"
26 #include "SVGRenderStyle.h"
27 #include "SVGPaintServer.h"
28 
29 #include <QDebug>
30 #include <QPainterPathStroker>
31 
32 namespace WebCore {
33 
34 bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
35 {
36  if (path().isEmpty())
37  return false;
38 
39  if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
40  return false;
41 
42  return false;
43 }
44 
45 static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject* object, const RenderStyle* style)
46 {
47  QPainterPathStroker s;
48  s.setWidth(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
49 
50  if (style->svgStyle()->capStyle() == ButtCap)
51  s.setCapStyle(Qt::FlatCap);
52  else if (style->svgStyle()->capStyle() == RoundCap)
53  s.setCapStyle(Qt::RoundCap);
54 
55  if (style->svgStyle()->joinStyle() == MiterJoin) {
56  s.setJoinStyle(Qt::MiterJoin);
57  s.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
58  } else if(style->svgStyle()->joinStyle() == RoundJoin)
59  s.setJoinStyle(Qt::RoundJoin);
60 
61  const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
62  double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
63 
64  unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
65  if(dashLength) {
66  QVector<qreal> pattern;
67  unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
68 
69  for(unsigned int i = 0; i < count; i++)
70  pattern.append(dashes[i % dashLength] / (float)s.width());
71 
72  s.setDashPattern(pattern);
73 
74  Q_UNUSED(dashOffset);
75  // TODO: dash-offset, does/will qt4 API allow it? (Rob)
76  }
77 
78  return s.createStroke(path);
79 }
80 
81 FloatRect RenderPath::strokeBBox() const
82 {
83  QPainterPath outline = getPathStroke(*(path().platformPath()), this, style());
84  return outline.boundingRect();
85 }
86 
87 }
88 
89 // vim:ts=4:noet
WebCore::getPathStroke
static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject *object, const RenderStyle *style)
Definition: RenderPathQt.cpp:45
QVector
Definition: khtmlview.h:36
pattern
QString pattern(Mode mode=Reading)
SVGPaintServer.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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