• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

/builddir/build/BUILD/flowcanvas-0.6.4/flowcanvas/Connection.hpp

Go to the documentation of this file.
00001 /* This file is part of FlowCanvas.
00002  * Copyright (C) 2007-2009 David Robillard <http://drobilla.net>
00003  *
00004  * FlowCanvas is free software; you can redistribute it and/or modify it under the
00005  * terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  *
00009  * FlowCanvas is distributed in the hope that it will be useful, but WITHOUT ANY
00010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
00012  *
00013  * You should have received a copy of the GNU General Public License along
00014  * with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
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 /*dx*/, double /*dy*/)
00050     { /* ignore, src/dst take care of it */ }
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 } // namespace FlowCanvas
00109 
00110 #endif // FLOWCANVAS_CONNECTION_HPP

Generated on Thu Sep 30 2010 for FlowCanvas by  doxygen 1.7.1