1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Base class for gradients and patterns
4  *
5  * Author:
6  *   Lauris Kaplinski <lauris@kaplinski.com>
7  *   Jon A. Cruz <jon@joncruz.org>
8  *
9  * Copyright (C) 1999-2002 Lauris Kaplinski
10  * Copyright (C) 2000-2001 Ximian, Inc.
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  * Copyright (C) 2010 Authors
13  *
14  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15  */
16 
17 #include "sp-paint-server-reference.h"
18 #include "sp-paint-server.h"
19 
20 #include "sp-gradient.h"
21 #include "xml/node.h"
22 
getObject() const23 SPPaintServer *SPPaintServerReference::getObject() const
24 {
25     return static_cast<SPPaintServer *>(URIReference::getObject());
26 }
27 
_acceptObject(SPObject * obj) const28 bool SPPaintServerReference::_acceptObject(SPObject *obj) const
29 {
30     return SP_IS_PAINT_SERVER(obj) && URIReference::_acceptObject(obj);
31 }
32 
SPPaintServer()33 SPPaintServer::SPPaintServer() : SPObject() {
34 	this->swatch = false;
35 }
36 
37 SPPaintServer::~SPPaintServer() = default;
38 
isSwatch() const39 bool SPPaintServer::isSwatch() const
40 {
41     return swatch;
42 }
43 
44 
45 // TODO: So a solid brush is a gradient with a swatch and zero stops?
46 // Should we derive a new class for that? Or at least make this method
47 // virtual and move it out of the way?
isSolid() const48 bool SPPaintServer::isSolid() const
49 {
50     bool solid = false;
51     if (swatch && SP_IS_GRADIENT(this)) {
52         SPGradient *grad = SP_GRADIENT(this);
53         if ( grad->hasStops() && (grad->getStopCount() == 0) ) {
54             solid = true;
55         }
56     }
57     return solid;
58 }
59 
isValid() const60 bool SPPaintServer::isValid() const
61 {
62     return true;
63 }
64 
show(Inkscape::Drawing &,unsigned int,Geom::OptRect)65 Inkscape::DrawingPattern *SPPaintServer::show(Inkscape::Drawing &/*drawing*/, unsigned int /*key*/, Geom::OptRect /*bbox*/)
66 {
67     return nullptr;
68 }
69 
hide(unsigned int)70 void SPPaintServer::hide(unsigned int /*key*/)
71 {
72 }
73 
setBBox(unsigned int,Geom::OptRect const &)74 void SPPaintServer::setBBox(unsigned int /*key*/, Geom::OptRect const &/*bbox*/)
75 {
76 }
77 
pattern_new(cairo_t *,Geom::OptRect const &,double)78 cairo_pattern_t* SPPaintServer::pattern_new(cairo_t * /*ct*/, Geom::OptRect const &/*bbox*/, double /*opacity*/)
79 {
80     return nullptr;
81 }
82 
83 /*
84   Local Variables:
85   mode:c++
86   c-file-style:"stroustrup"
87   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
88   indent-tabs-mode:nil
89   fill-column:99
90   End:
91 */
92 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
93