KHtml

borderarcstroker.h
1 /*
2  * Copyright (C) 2008-2009 Fredrik Höglund <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef BORDERARCSTROKER_H
21 #define BORDERARCSTROKER_H
22 
23 #include <QPainterPath>
24 #include <QRect>
25 
26 namespace khtml
27 {
28 
29 class BorderArcStroker
30 {
31 public:
32  BorderArcStroker();
33  ~BorderArcStroker();
34 
35  void setArc(const QRectF &r, qreal startAngle, qreal _sweepLength)
36  {
37  rect = r;
38  angle = startAngle;
39  sweepLength = _sweepLength;
40  }
41  void setPenWidth(qreal leftRight, qreal topBottom);
42  void setDashPattern(qreal dashLength, qreal spaceLength);
43  void setDashOffset(qreal offset)
44  {
45  patternOffset = offset;
46  }
47 
48  QPainterPath createStroke(qreal *nextOffset = nullptr) const;
49 
50 private:
51  QRectF rect;
52  qreal angle;
53  qreal hlw;
54  qreal vlw;
55  qreal sweepLength;
56  qreal patternOffset;
57  qreal pattern[2];
58 };
59 
60 inline void BorderArcStroker::setPenWidth(qreal leftRight, qreal topBottom)
61 {
62  hlw = qMax(qreal(0.1), leftRight);
63  vlw = qMax(qreal(0.1), topBottom);
64 }
65 
66 inline void BorderArcStroker::setDashPattern(qreal dashLength, qreal spaceLength)
67 {
68  pattern[0] = qMax(qreal(0.1), dashLength);
69  pattern[1] = qMax(qreal(0.1), spaceLength);
70 }
71 
72 } // namespace khtml
73 
74 #endif
This file is part of the HTML rendering engine for KDE.
QString pattern(Mode mode=Reading)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.