Code

A simple layout document as to what, why and how is cppification.
[inkscape.git] / src / sp-shape.h
1 #ifndef __SP_SHAPE_H__
2 #define __SP_SHAPE_H__
4 /*
5  * Base class for shapes, including <path> element
6  *
7  * Author:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *
10  * Copyright (C) 1999-2002 Lauris Kaplinski
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  * Copyright (C) 2008 Johan Engelen
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include "display/display-forward.h"
18 #include "sp-lpe-item.h"
19 #include "sp-marker-loc.h"
20 #include <2geom/forward.h>
22 #include <sigc++/connection.h>
24 #define SP_TYPE_SHAPE (SPShape::getType ())
25 #define SP_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SHAPE, SPShape))
26 #define SP_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SHAPE, SPShapeClass))
27 #define SP_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SHAPE))
28 #define SP_IS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SHAPE))
30 #define SP_SHAPE_WRITE_PATH (1 << 2)
32 struct SPDesktop;
34 //struct SPShape : public SPLPEItem {
35 class SPShape : public SPLPEItem {
36         public:
37         SPCurve *curve;
39         SPObject *marker[SP_MARKER_LOC_QTY];
40         sigc::connection release_connect [SP_MARKER_LOC_QTY];
41         sigc::connection modified_connect [SP_MARKER_LOC_QTY];
42         
43                 static GType getType (void);
44                 void setShape ();
45                 SPCurve * getCurve ();
46                 void setCurve (SPCurve *curve, unsigned int owner);
47                 void setCurveInsync (SPCurve *curve, unsigned int owner);
48                 int hasMarkers () const;
49                 int numberOfMarkers (int type);
50         private:
51                 static void sp_shape_init (SPShape *shape);
52                 static void sp_shape_finalize (GObject *object);
54                 static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
55                 static void sp_shape_release (SPObject *object);
57                 static void sp_shape_set(SPObject *object, unsigned key, gchar const *value);
58                 static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags);
59                 static void sp_shape_modified (SPObject *object, unsigned int flags);
60                 static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
62                 static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
63                 static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
64                 static void sp_shape_hide (SPItem *item, unsigned int key);
65                 static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
67                 static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
71         friend class SPShapeClass;      
72 };
74 //struct SPShapeClass {
75 class SPShapeClass {
76         public:
77         SPLPEItemClass item_class;
79         /* Build bpath from extra shape attributes */
80         void (* set_shape) (SPShape *shape);
82         private:
83                 static SPLPEItemClass *parent_class;
84                 static void sp_shape_class_init (SPShapeClass *klass);
86         friend class SPShape;
87 };
89 //GType sp_shape_get_type (void);
91 //void sp_shape_set_shape (SPShape *shape);
93 /* Return duplicate of curve or NULL */
94 //SPCurve *sp_shape_get_curve (SPShape *shape);
96 // sets a curve, updates display
97 //void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner);
99 // same as sp_shape_set_curve, but without updating display
100 //void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner);
102 // markers API
103 void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value);
104 //int sp_shape_has_markers (SPShape const *shape);
105 //int sp_shape_number_of_markers (SPShape* Shape, int type);
107 Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2);
108 Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c);
109 Geom::Matrix sp_shape_marker_get_transform_at_end(Geom::Curve const & c);
111 #endif