Code

LPE knotholder refactoring: PointParams are not knotholder entities any more; instead...
[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 like PointParam for LPEs use this, e.g., to indicate that we must not call
45        delete on their pointer when a knotholder is destroyed */
46     // TODO: purge this now that PointParams are not KnotHolderEntities any more!
47     virtual bool isLPEParam() { return false; }
49     /* the get/set/click handlers are virtual functions; each handler class for a knot
50        should be derived from KnotHolderEntity and override these functions */
51     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state) = 0;
52     virtual NR::Point knot_get() = 0;
53     virtual void knot_click(guint /*state*/) {}
55     void update_knot();
57 //private:
58     SPKnot *knot;
59     SPItem *item;
61     KnotHolder *parent_holder;
63     int my_counter;
64     static int counter;
66     /** Connection to \a knot's "moved" signal. */
67     guint   handler_id;
68     /** Connection to \a knot's "clicked" signal. */
69     guint   _click_handler_id;
70     /** Connection to \a knot's "ungrabbed" signal. */
71     guint   _ungrab_handler_id;
73     sigc::connection _moved_connection;
74     sigc::connection _click_connection;
75     sigc::connection _ungrabbed_connection;
76 };
78 /* pattern manipulation */
80 class PatternKnotHolderEntityXY : public KnotHolderEntity {
81 public:
82     virtual NR::Point knot_get();
83     virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
84 };
86 class PatternKnotHolderEntityAngle : 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 PatternKnotHolderEntityScale : 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 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
100 /*
101   Local Variables:
102   mode:c++
103   c-file-style:"stroustrup"
104   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
105   indent-tabs-mode:nil
106   fill-column:99
107   End:
108 */
109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :