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() {} // this is called 'manually' from KnotHolder; would it be
56 // more efficient to establish another signal connection?
58 void update_knot();
60 //private:
61 SPKnot *knot;
62 SPItem *item;
64 KnotHolder *parent_holder;
66 int my_counter;
67 static int counter;
69 /** Connection to \a knot's "moved" signal. */
70 guint handler_id;
71 /** Connection to \a knot's "clicked" signal. */
72 guint _click_handler_id;
73 /** Connection to \a knot's "ungrabbed" signal. */
74 guint _ungrab_handler_id;
76 sigc::connection _moved_connection;
77 sigc::connection _click_connection;
78 sigc::connection _ungrabbed_connection;
79 };
81 /* pattern manipulation */
83 class PatternKnotHolderEntityXY : public KnotHolderEntity {
84 public:
85 virtual NR::Point knot_get();
86 virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
87 };
89 class PatternKnotHolderEntityAngle : 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 PatternKnotHolderEntityScale : 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 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
103 /*
104 Local Variables:
105 mode:c++
106 c-file-style:"stroustrup"
107 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
108 indent-tabs-mode:nil
109 fill-column:99
110 End:
111 */
112 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :