00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef FLOWCANVAS_CONNECTION_HPP
00019 #define FLOWCANVAS_CONNECTION_HPP
00020
00021 #include <stdint.h>
00022 #include <list>
00023 #include <boost/weak_ptr.hpp>
00024 #include <libgnomecanvasmm.h>
00025 #include <libgnomecanvasmm/bpath.h>
00026 #include <libgnomecanvasmm/path-def.h>
00027
00028 namespace FlowCanvas {
00029
00030 class Canvas;
00031 class Connectable;
00032
00033
00038 class Connection : public Gnome::Canvas::Group
00039 {
00040 public:
00041 Connection(boost::shared_ptr<Canvas> canvas,
00042 boost::shared_ptr<Connectable> source,
00043 boost::shared_ptr<Connectable> dest,
00044 uint32_t color,
00045 bool show_arrow_head = false);
00046
00047 virtual ~Connection();
00048
00049 virtual void move(double , double )
00050 { }
00051
00052 virtual void zoom(double);
00053
00054 bool selected() const { return _selected; }
00055 void set_selected(bool b);
00056
00057 virtual double length_hint() const { return 0.0; }
00058
00059 void set_label(const std::string& str);
00060 void show_handle(bool show);
00061
00062 void set_color(uint32_t color);
00063 void set_highlighted(bool b);
00064 void raise_to_top();
00065
00066 void select_tick();
00067
00068 const boost::weak_ptr<Connectable> source() const { return _source; }
00069 const boost::weak_ptr<Connectable> dest() const { return _dest; }
00070
00071 enum HandleStyle {
00072 HANDLE_NONE,
00073 HANDLE_RECT,
00074 HANDLE_CIRCLE,
00075 };
00076
00077 void set_handle_style(HandleStyle s) { _handle_style = s; }
00078
00079 protected:
00080 friend class Canvas;
00081 friend class Connectable;
00082 void update_location();
00083
00084 const boost::weak_ptr<Canvas> _canvas;
00085 const boost::weak_ptr<Connectable> _source;
00086 const boost::weak_ptr<Connectable> _dest;
00087 uint32_t _color;
00088 bool _selected;
00089 bool _show_arrowhead;
00090
00091 Gnome::Canvas::Bpath _bpath;
00092 GnomeCanvasPathDef* _path;
00093
00094 HandleStyle _handle_style;
00095
00096 struct Handle : public Gnome::Canvas::Group {
00097 Handle(Gnome::Canvas::Group& parent)
00098 : Gnome::Canvas::Group(parent), shape(NULL), text(NULL) {}
00099 ~Handle() { delete shape; delete text; }
00100 Gnome::Canvas::Shape* shape;
00101 Gnome::Canvas::Text* text;
00102 }* _handle;
00103 };
00104
00105 typedef std::list<boost::shared_ptr<Connection> > ConnectionList;
00106
00107
00108 }
00109
00110 #endif // FLOWCANVAS_CONNECTION_HPP