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"
23 struct SPItem;
24 struct SPKnot;
25 namespace NR {
26 class Point;
27 }
29 class SPDesktop;
30 class KnotHolder;
32 typedef void (* SPKnotHolderSetFunc) (SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);
33 typedef NR::Point (* SPKnotHolderGetFunc) (SPItem *item);
34 /* fixme: Think how to make callbacks most sensitive (Lauris) */
35 typedef void (* SPKnotHolderReleasedFunc) (SPItem *item);
37 class KnotHolderEntity {
38 public:
39 KnotHolderEntity() {}
40 virtual ~KnotHolderEntity();
41 virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "",
42 SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND,
43 SPKnotModeType mode = SP_KNOT_MODE_XOR,
44 guint32 color = 0xffffff00);
46 /* derived classes like PointParam for LPEs use this, e.g., to indicate that we must not call
47 delete on their pointer when a knotholder is destroyed */
48 virtual bool isLPEParam() { return false; }
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*/) {}
55 virtual void onKnotUngrabbed() {}
57 void update_knot();
59 //private:
60 SPKnot *knot;
61 SPItem *item;
63 KnotHolder *parent_holder;
65 int my_counter;
66 static int counter;
68 /** Connection to \a knot's "moved" signal. */
69 guint handler_id;
70 /** Connection to \a knot's "clicked" signal. */
71 guint _click_handler_id;
72 /** Connection to \a knot's "ungrabbed" signal. */
73 guint _ungrab_handler_id;
75 sigc::connection _moved_connection;
76 sigc::connection _click_connection;
77 sigc::connection _ungrabbed_connection;
78 };
80 /* pattern manipulation */
82 class PatternKnotHolderEntityXY : public KnotHolderEntity {
83 public:
84 virtual NR::Point knot_get();
85 virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
86 };
88 class PatternKnotHolderEntityAngle : public KnotHolderEntity {
89 public:
90 virtual NR::Point knot_get();
91 virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
92 };
94 class PatternKnotHolderEntityScale : public KnotHolderEntity {
95 public:
96 virtual NR::Point knot_get();
97 virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
98 };
100 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
102 /*
103 Local Variables:
104 mode:c++
105 c-file-style:"stroustrup"
106 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
107 indent-tabs-mode:nil
108 fill-column:99
109 End:
110 */
111 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :