FlowCanvas 0.7.1
Connection.hpp
Go to the documentation of this file.
1/* This file is part of FlowCanvas.
2 * Copyright (C) 2007-2009 David Robillard <http://drobilla.net>
3 *
4 * FlowCanvas is free software; you can redistribute it and/or modify it under the
5 * terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * FlowCanvas is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18#ifndef FLOWCANVAS_CONNECTION_HPP
19#define FLOWCANVAS_CONNECTION_HPP
20
21#include <stdint.h>
22
23#include <list>
24#include <string>
25
26#include <boost/weak_ptr.hpp>
27
28#include <libgnomecanvasmm.h>
29#include <libgnomecanvasmm/bpath.h>
30#include <libgnomecanvasmm/path-def.h>
31
32namespace FlowCanvas {
33
34class Canvas;
35class Connectable;
36
37
42class Connection : public Gnome::Canvas::Group
43{
44public:
45 Connection(boost::shared_ptr<Canvas> canvas,
46 boost::shared_ptr<Connectable> source,
47 boost::shared_ptr<Connectable> dest,
48 uint32_t color,
49 bool show_arrow_head = false);
50
51 virtual ~Connection();
52
53 virtual void move(double /*dx*/, double /*dy*/)
54 { /* ignore, src/dst take care of it */ }
55
56 virtual void zoom(double z);
57
58 bool selected() const { return _selected; }
59 void set_selected(bool b);
60
61 virtual double length_hint() const { return 0.0; }
62
63 void set_label(const std::string& str);
64 void show_handle(bool show);
65
66 void set_color(uint32_t color);
67 void set_highlighted(bool b);
69
71
72 const boost::weak_ptr<Connectable> source() const { return _source; }
73 const boost::weak_ptr<Connectable> dest() const { return _dest; }
74
79 };
80
82
83protected:
84 friend class Canvas;
85 friend class Connectable;
87
88 const boost::weak_ptr<Canvas> _canvas;
89 const boost::weak_ptr<Connectable> _source;
90 const boost::weak_ptr<Connectable> _dest;
91
92 Gnome::Canvas::Bpath _bpath;
93 GnomeCanvasPathDef* _path;
94
96 struct Handle : public Gnome::Canvas::Group {
97 explicit Handle(Gnome::Canvas::Group& parent)
98 : Gnome::Canvas::Group(parent), shape(NULL), text(NULL) {}
99 ~Handle() { delete shape; delete text; }
100 Gnome::Canvas::Shape* shape;
101 Gnome::Canvas::Text* text;
103
104 uint32_t _color;
106
107 bool _selected :1;
109};
110
111typedef std::list<boost::shared_ptr<Connection> > ConnectionList;
112
113
114} // namespace FlowCanvas
115
116#endif // FLOWCANVAS_CONNECTION_HPP
The 'master' canvas widget which contains all other objects.
Definition: Canvas.hpp:61
An object a Connection can connect to.
Definition: Connectable.hpp:32
A connection (line) between two canvas objects.
Definition: Connection.hpp:43
void set_handle_style(HandleStyle s)
Definition: Connection.hpp:81
void set_color(uint32_t color)
const boost::weak_ptr< Connectable > _dest
Definition: Connection.hpp:90
HandleStyle _handle_style
Definition: Connection.hpp:105
void set_label(const std::string &str)
Gnome::Canvas::Bpath _bpath
Definition: Connection.hpp:92
bool _show_arrowhead
Definition: Connection.hpp:108
bool _selected
Definition: Connection.hpp:107
const boost::weak_ptr< Connectable > _source
Definition: Connection.hpp:89
const boost::weak_ptr< Connectable > dest() const
Definition: Connection.hpp:73
HandleStyle
Definition: Connection.hpp:75
@ HANDLE_RECT
Definition: Connection.hpp:77
@ HANDLE_NONE
Definition: Connection.hpp:76
@ HANDLE_CIRCLE
Definition: Connection.hpp:78
virtual void move(double, double)
Definition: Connection.hpp:53
void show_handle(bool show)
void set_selected(bool b)
const boost::weak_ptr< Canvas > _canvas
Definition: Connection.hpp:88
uint32_t _color
Definition: Connection.hpp:104
bool selected() const
Definition: Connection.hpp:58
GnomeCanvasPathDef * _path
Definition: Connection.hpp:93
FlowCanvas::Connection::Handle * _handle
void set_highlighted(bool b)
Connection(boost::shared_ptr< Canvas > canvas, boost::shared_ptr< Connectable > source, boost::shared_ptr< Connectable > dest, uint32_t color, bool show_arrow_head=false)
virtual void zoom(double z)
const boost::weak_ptr< Connectable > source() const
Definition: Connection.hpp:72
virtual double length_hint() const
Definition: Connection.hpp:61
FlowCanvas namespace, everything is defined under this.
Definition: Canvas.hpp:38
std::list< boost::shared_ptr< Connection > > ConnectionList
Definition: Connection.hpp:111
A handle on a connection line to allow mouse interaction.
Definition: Connection.hpp:96
Gnome::Canvas::Shape * shape
Definition: Connection.hpp:100
~Handle()
Definition: Connection.hpp:99
Gnome::Canvas::Text * text
Definition: Connection.hpp:101
Handle(Gnome::Canvas::Group &parent)
Definition: Connection.hpp:97