Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Removed forward header.
[inkscape.git] / src / connector-context.h
1 #ifndef SEEN_CONNECTOR_CONTEXT_H
2 #define SEEN_CONNECTOR_CONTEXT_H
4 /*
5  * Connector creation tool
6  *
7  * Authors:
8  *   Michael Wybrow <mjwybrow@users.sourceforge.net>
9  *
10  * Copyright (C) 2005 Michael Wybrow
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include <sigc++/sigc++.h>
16 #include <sigc++/connection.h>
17 #include "event-context.h"
18 #include <forward.h>
19 #include <2geom/point.h>
20 #include "libavoid/connector.h"
21 #include "connection-points.h"
22 #include <glibmm/i18n.h>
24 #define SP_TYPE_CONNECTOR_CONTEXT (sp_connector_context_get_type())
25 #define SP_CONNECTOR_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_CONNECTOR_CONTEXT, SPConnectorContext))
26 #define SP_CONNECTOR_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_CONNECTOR_CONTEXT, SPConnectorContextClass))
27 #define SP_IS_CONNECTOR_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_CONNECTOR_CONTEXT))
28 #define SP_IS_CONNECTOR_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_CONNECTOR_CONTEXT))
30 struct SPKnot;
31 struct SPCurve;
33 namespace Inkscape
34 {
35   class Selection;
36 }
38 enum {
39     SP_CONNECTOR_CONTEXT_IDLE,
40     SP_CONNECTOR_CONTEXT_DRAGGING,
41     SP_CONNECTOR_CONTEXT_CLOSE,
42     SP_CONNECTOR_CONTEXT_STOP,
43     SP_CONNECTOR_CONTEXT_REROUTING,
44     SP_CONNECTOR_CONTEXT_NEWCONNPOINT
45 };
47 enum {
48     SP_CONNECTOR_CONTEXT_DRAWING_MODE,
49     SP_CONNECTOR_CONTEXT_EDITING_MODE
50 };
52 typedef std::map<SPKnot *, ConnectionPoint>  ConnectionPointMap;
54 struct SPConnectorContext : public SPEventContext {
55     Inkscape::Selection *selection;
56     Geom::Point p[5];
58     /** \invar npoints in {0, 2}. */
59     gint npoints;
60     /* The tool mode can be connector drawing or
61        connection points editing.
62     */
63     unsigned int mode : 1;
64     unsigned int state : 4;
66     gchar* knot_tip;
68     // Red curve
69     SPCanvasItem *red_bpath;
70     SPCurve *red_curve;
71     guint32 red_color;
73     // Green curve
74     SPCurve *green_curve;
76     // The new connector
77     SPItem *newconn;
78     Avoid::ConnRef *newConnRef;
79     gdouble curvature;
80     bool isOrthogonal;
82     // The active shape
83     SPItem *active_shape;
84     Inkscape::XML::Node *active_shape_repr;
85     Inkscape::XML::Node *active_shape_layer_repr;
87     // Same as above, but for the active connector
88     SPItem *active_conn;
89     Inkscape::XML::Node *active_conn_repr;
90     sigc::connection sel_changed_connection;
93     // The activehandle
94     SPKnot *active_handle;
96     // The selected handle, used in editing mode
97     SPKnot *selected_handle;
99     SPItem *clickeditem;
100     SPKnot *clickedhandle;
102     ConnectionPointMap connpthandles;
103     SPKnot *endpt_handle[2];
104     guint  endpt_handler_id[2];
105     gchar *shref;
106     gchar *scpid;
107     gchar *ehref;
108     gchar *ecpid;
109     SPCanvasItem *c0, *c1, *cl0, *cl1;
110 };
112 struct SPConnectorContextClass : public SPEventContextClass { };
114 GType sp_connector_context_get_type();
116 void sp_connector_context_switch_mode(SPEventContext* ec, unsigned int newMode);
117 void cc_selection_set_avoid(bool const set_ignore);
118 void cc_create_connection_point(SPConnectorContext* cc);
119 void cc_remove_connection_point(SPConnectorContext* cc);
120 bool cc_item_is_connector(SPItem *item);
123 #endif /* !SEEN_CONNECTOR_CONTEXT_H */
125 /*
126   Local Variables:
127   mode:c++
128   c-file-style:"stroustrup"
129   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
130   indent-tabs-mode:nil
131   fill-column:99
132   End:
133 */
134 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :