Code

Rename isLPEParam() to isDeletable(), create new class LPEKnotHolderEntity and make...
[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     SPKnot *knot;
60     SPItem *item;
62     KnotHolder *parent_holder;
64     int my_counter;
65     static int counter;
67     /** Connection to \a knot's "moved" signal. */
68     guint   handler_id;
69     /** Connection to \a knot's "clicked" signal. */
70     guint   _click_handler_id;
71     /** Connection to \a knot's "ungrabbed" signal. */
72     guint   _ungrab_handler_id;
74     sigc::connection _moved_connection;
75     sigc::connection _click_connection;
76     sigc::connection _ungrabbed_connection;
77 };
79 // derived KnotHolderEntity class for LPEs
80 class LPEKnotHolderEntity : public KnotHolderEntity {
81     virtual bool isDeletable() { return false; }
82 };
84 /* pattern manipulation */
86 class PatternKnotHolderEntityXY : public KnotHolderEntity {
87 public:
88     virtual NR::Point knot_get();
89     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
90 };
92 class PatternKnotHolderEntityAngle : public KnotHolderEntity {
93 public:
94     virtual NR::Point knot_get();
95     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
96 };
98 class PatternKnotHolderEntityScale : public KnotHolderEntity {
99 public:
100     virtual NR::Point knot_get();
101     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
102 };
104 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
106 /*
107   Local Variables:
108   mode:c++
109   c-file-style:"stroustrup"
110   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111   indent-tabs-mode:nil
112   fill-column:99
113   End:
114 */
115 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :