~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/knot-holder-entity.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SEEN_KNOT_HOLDER_ENTITY_H
 
2
#define SEEN_KNOT_HOLDER_ENTITY_H
 
3
 
 
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
 */
 
19
 
 
20
#include <glib/gtypes.h>
 
21
#include "knot.h"
 
22
#include <2geom/forward.h>
 
23
#include "snapper.h"
 
24
 
 
25
struct SPItem;
 
26
struct SPKnot;
 
27
 
 
28
class SPDesktop;
 
29
class KnotHolder;
 
30
 
 
31
typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state);
 
32
typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item);
 
33
/* fixme: Think how to make callbacks most sensitive (Lauris) */
 
34
typedef void (* SPKnotHolderReleasedFunc) (SPItem *item);
 
35
 
 
36
class KnotHolderEntity {
 
37
public:
 
38
    KnotHolderEntity() {}
 
39
    virtual ~KnotHolderEntity();
 
40
    virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "",
 
41
                        SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND,
 
42
                        SPKnotModeType mode = SP_KNOT_MODE_XOR,
 
43
                        guint32 color = 0xffffff00);
 
44
 
 
45
    /* derived classes used for LPE knotholder handles use this to indicate that they
 
46
       must not be deleted when a knotholder is destroyed */
 
47
    // TODO: it would be nice to ditch this but then we need to dynamically create instances of different
 
48
    //       KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this???
 
49
    virtual bool isDeletable() { return true; }
 
50
 
 
51
    /* the get/set/click handlers are virtual functions; each handler class for a knot
 
52
       should be derived from KnotHolderEntity and override these functions */
 
53
    virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0;
 
54
    virtual Geom::Point knot_get() = 0;
 
55
    virtual void knot_click(guint /*state*/) {}
 
56
 
 
57
    void update_knot();
 
58
 
 
59
//private:
 
60
    Geom::Point snap_knot_position(Geom::Point const &p);
 
61
    Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine const &constraint);
 
62
 
 
63
    SPKnot *knot;
 
64
    SPItem *item;
 
65
    SPDesktop *desktop;
 
66
 
 
67
    KnotHolder *parent_holder;
 
68
 
 
69
    int my_counter;
 
70
    static int counter;
 
71
 
 
72
    /** Connection to \a knot's "moved" signal. */
 
73
    guint   handler_id;
 
74
    /** Connection to \a knot's "clicked" signal. */
 
75
    guint   _click_handler_id;
 
76
    /** Connection to \a knot's "ungrabbed" signal. */
 
77
    guint   _ungrab_handler_id;
 
78
 
 
79
    sigc::connection _moved_connection;
 
80
    sigc::connection _click_connection;
 
81
    sigc::connection _ungrabbed_connection;
 
82
};
 
83
 
 
84
// derived KnotHolderEntity class for LPEs
 
85
class LPEKnotHolderEntity : public KnotHolderEntity {
 
86
    virtual bool isDeletable() { return false; }
 
87
};
 
88
 
 
89
/* pattern manipulation */
 
90
 
 
91
class PatternKnotHolderEntityXY : public KnotHolderEntity {
 
92
public:
 
93
    virtual Geom::Point knot_get();
 
94
    virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
 
95
};
 
96
 
 
97
class PatternKnotHolderEntityAngle : public KnotHolderEntity {
 
98
public:
 
99
    virtual Geom::Point knot_get();
 
100
    virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
 
101
};
 
102
 
 
103
class PatternKnotHolderEntityScale : public KnotHolderEntity {
 
104
public:
 
105
    virtual Geom::Point knot_get();
 
106
    virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
 
107
};
 
108
 
 
109
#endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
 
110
 
 
111
/*
 
112
  Local Variables:
 
113
  mode:c++
 
114
  c-file-style:"stroustrup"
 
115
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
116
  indent-tabs-mode:nil
 
117
  fill-column:99
 
118
  End:
 
119
*/
 
120
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :