2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
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.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
29 #include "RenderStyle.h"
30 #include "KRenderingDeviceQt.h"
31 #include "KCanvasRenderingStyle.h"
32 #include "KRenderingFillPainter.h"
33 #include "KRenderingStrokePainter.h"
34 #include "KRenderingPaintServerSolidQt.h"
38 KRenderingPaintServerSolidQt::KRenderingPaintServerSolidQt()
39 : KRenderingPaintServerSolid()
40 , KRenderingPaintServerQt()
44 KRenderingPaintServerSolidQt::~KRenderingPaintServerSolidQt()
49 void KRenderingPaintServerSolidQt::draw(KRenderingDeviceContext* context, const RenderPath* path, KCPaintTargetType type) const
51 if (!setup(context, path, type))
54 renderPath(context, path, type);
55 teardown(context, path, type);
58 bool KRenderingPaintServerSolidQt::setup(KRenderingDeviceContext* context, const RenderObject* object, KCPaintTargetType type) const
60 KRenderingDeviceContextQt* qtContext = static_cast<KRenderingDeviceContextQt*>(context);
62 RenderStyle* renderStyle = object->style();
63 // TODO? qtContext->painter().setOpacity(renderStyle->opacity());
67 if ((type & APPLY_TO_FILL) && renderStyle->svgStyle()->hasFill()) {
68 KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
69 c.setAlphaF(fillPainter.opacity());
72 qtContext->painter().setBrush(brush);
73 qtContext->setFillRule(fillPainter.fillRule());
75 /* if(isPaintingText()) ... */
78 if((type & APPLY_TO_STROKE) && renderStyle->svgStyle()->hasStroke()) {
79 KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
80 c.setAlphaF(strokePainter.opacity());
83 setPenProperties(strokePainter, pen);
84 qtContext->painter().setPen(pen);
86 /* if(isPaintingText()) ... */
92 void KRenderingPaintServerSolidQt::teardown(KRenderingDeviceContext*, const RenderObject*, KCPaintTargetType) const
96 void KRenderingPaintServerSolidQt::renderPath(KRenderingDeviceContext* context, const RenderPath* path, KCPaintTargetType type) const
98 RenderStyle* renderStyle = path->style();
99 KRenderingDeviceContextQt* qtContext = static_cast<KRenderingDeviceContextQt*>(context);
101 if ((type & APPLY_TO_FILL) && renderStyle->svgStyle()->hasFill())
102 qtContext->fillPath();
104 if ((type & APPLY_TO_STROKE) && renderStyle->svgStyle()->hasStroke())
105 qtContext->strokePath();