1 // SPDX-License-Identifier: GPL-2.0-or-later 2 #ifndef SEEN_SP_RECT_H 3 #define SEEN_SP_RECT_H 4 5 /* 6 * SVG <rect> implementation 7 * 8 * Authors: 9 * Lauris Kaplinski <lauris@kaplinski.com> 10 * Abhishek Sharma 11 * 12 * Copyright (C) 1999-2002 Lauris Kaplinski 13 * Copyright (C) 2000-2001 Ximian, Inc. 14 * 15 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 16 */ 17 18 #include <2geom/forward.h> 19 20 #include "svg/svg-length.h" 21 #include "sp-shape.h" 22 23 #define SP_RECT(obj) (dynamic_cast<SPRect*>((SPObject*)obj)) 24 #define SP_IS_RECT(obj) (dynamic_cast<const SPRect*>((SPObject*)obj) != NULL) 25 26 class SPRect : public SPShape { 27 public: 28 SPRect(); 29 ~SPRect() override; 30 31 void setPosition(double x, double y, double width, double height); 32 33 /* If SET if FALSE, VALUE is just ignored */ 34 void setRx(bool set, double value); 35 void setRy(bool set, double value); 36 37 double getVisibleRx() const; 38 void setVisibleRx(double rx); 39 40 double getVisibleRy() const; 41 void setVisibleRy(double ry); 42 43 Geom::Rect getRect() const; 44 45 double getVisibleWidth() const; 46 void setVisibleWidth(double rx); 47 48 double getVisibleHeight() const; 49 void setVisibleHeight(double ry); 50 51 void compensateRxRy(Geom::Affine xform); 52 53 void build(SPDocument* doc, Inkscape::XML::Node* repr) override; 54 55 void set(SPAttr key, char const *value) override; 56 void update(SPCtx* ctx, unsigned int flags) override; 57 void modified(unsigned int flags) override; 58 bool set_rect_path_attribute(Inkscape::XML::Node *repr); 59 60 Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override; 61 const char* displayName() const override; 62 void update_patheffect(bool write) override; 63 void set_shape() override; 64 Geom::Affine set_transform(Geom::Affine const& xform) override; 65 66 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override; 67 void convert_to_guides() const override; 68 69 SVGLength x; 70 SVGLength y; 71 SVGLength width; 72 SVGLength height; 73 SVGLength rx; 74 SVGLength ry; 75 76 private: 77 static double vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform); 78 }; 79 80 #endif // SEEN_SP_RECT_H 81 82 /* 83 Local Variables: 84 mode:c++ 85 c-file-style:"stroustrup" 86 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 87 indent-tabs-mode:nil 88 fill-column:99 89 End: 90 */ 91 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 92