Code

Formerly static function used for snapping is now a private member of KnotHolderEntity
[inkscape.git] / src / knot-holder-entity.h
1 #ifndef SEEN_KNOT_HOLDER_ENTITY_H
2 #define SEEN_KNOT_HOLDER_ENTITY_H
4 /** \file 
5  * KnotHolderEntity definition. 
6  * 
7  * Authors:
8  *   Mitsuru Oka <oka326@parkcity.ne.jp>
9  *   Maximilian Albert <maximilian.albert@gmail.com>
10  *
11  * Copyright (C) 1999-2001 Lauris Kaplinski
12  * Copyright (C) 2000-2001 Ximian, Inc.
13  * Copyright (C) 2001 Mitsuru Oka
14  * Copyright (C) 2004 Monash University
15  * Copyright (C) 2008 Maximilian Albert
16  *
17  * Released under GNU GPL
18  */
20 #include <glib/gtypes.h>
21 #include "knot.h"
22 #include <libnr/nr-forward.h>
24 struct SPItem;
25 struct SPKnot;
27 class SPDesktop;
28 class KnotHolder;
30 typedef void (* SPKnotHolderSetFunc) (SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);
31 typedef NR::Point (* SPKnotHolderGetFunc) (SPItem *item);
32 /* fixme: Think how to make callbacks most sensitive (Lauris) */
33 typedef void (* SPKnotHolderReleasedFunc) (SPItem *item);
35 class KnotHolderEntity {
36 public:
37     KnotHolderEntity() {}
38     virtual ~KnotHolderEntity();
39     virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "", 
40                         SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND,
41                         SPKnotModeType mode = SP_KNOT_MODE_XOR,
42                         guint32 color = 0xffffff00);
44     /* derived classes used for LPE knotholder handles use this to indicate that they
45        must not be deleted when a knotholder is destroyed */
46     // TODO: it would be nice to ditch this but then we need to dynamically create instances of different
47     //       KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this???
48     virtual bool isDeletable() { return true; }
50     /* the get/set/click handlers are virtual functions; each handler class for a knot
51        should be derived from KnotHolderEntity and override these functions */
52     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state) = 0;
53     virtual NR::Point knot_get() = 0;
54     virtual void knot_click(guint /*state*/) {}
56     void update_knot();
58 //private:
59     NR::Point snap_knot_position(NR::Point const &p);
61     SPKnot *knot;
62     SPItem *item;
63     SPDesktop *desktop;
65     KnotHolder *parent_holder;
67     int my_counter;
68     static int counter;
70     /** Connection to \a knot's "moved" signal. */
71     guint   handler_id;
72     /** Connection to \a knot's "clicked" signal. */
73     guint   _click_handler_id;
74     /** Connection to \a knot's "ungrabbed" signal. */
75     guint   _ungrab_handler_id;
77     sigc::connection _moved_connection;
78     sigc::connection _click_connection;
79     sigc::connection _ungrabbed_connection;
80 };
82 // derived KnotHolderEntity class for LPEs
83 class LPEKnotHolderEntity : public KnotHolderEntity {
84     virtual bool isDeletable() { return false; }
85 };
87 /* pattern manipulation */
89 class PatternKnotHolderEntityXY : public KnotHolderEntity {
90 public:
91     virtual NR::Point knot_get();
92     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
93 };
95 class PatternKnotHolderEntityAngle : public KnotHolderEntity {
96 public:
97     virtual NR::Point knot_get();
98     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
99 };
101 class PatternKnotHolderEntityScale : public KnotHolderEntity {
102 public:
103     virtual NR::Point knot_get();
104     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
105 };
107 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
109 /*
110   Local Variables:
111   mode:c++
112   c-file-style:"stroustrup"
113   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
114   indent-tabs-mode:nil
115   fill-column:99
116   End:
117 */
118 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :