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

/builddir/build/BUILD/flowcanvas-0.6.4/flowcanvas/Port.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_PORT_HPP
00019 #define FLOWCANVAS_PORT_HPP
00020 
00021 #include <string>
00022 #include <list>
00023 #include <vector>
00024 #include <inttypes.h>
00025 #include <libgnomecanvasmm.h>
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/weak_ptr.hpp>
00028 #include "flowcanvas/Connectable.hpp"
00029 
00030 namespace FlowCanvas {
00031 
00032 class Connection;
00033 class Module;
00034 
00035 
00036 static const int PORT_LABEL_SIZE = 8000; // in thousandths of a point
00037 
00038 
00045 class Port : public Gnome::Canvas::Group, public Connectable
00046 {
00047 public:
00048     Port(boost::shared_ptr<Module> module,
00049          const std::string&        name,
00050          bool                      is_input,
00051          uint32_t                  color);
00052 
00053     virtual ~Port();
00054 
00055     void disconnect_all();
00056 
00057     virtual Gnome::Art::Point src_connection_point();
00058     virtual Gnome::Art::Point dst_connection_point(const Gnome::Art::Point& src);
00059     virtual Gnome::Art::Point connection_point_vector(double dx, double dy);
00060 
00061     boost::weak_ptr<Module> module() const { return _module; }
00062 
00063     void set_fill_color(uint32_t c) { _rect->property_fill_color_rgba() = c; }
00064 
00065     void show_label(bool b);
00066     void set_selected(bool b);
00067     bool selected() const { return _selected; }
00068 
00069     void set_highlighted(bool highlight,
00070                          bool highlight_parent=true,
00071                          bool highlight_connections=true,
00072                          bool raise_connections=true);
00073 
00074     void zoom(float z);
00075 
00076     void popup_menu(guint button, guint32 activate_time) {
00077         if ( ! _menu)
00078             create_menu();
00079         if (_menu)
00080             _menu->popup(button, activate_time);
00081     }
00082 
00083     virtual void create_menu();
00084     void         set_menu(Gtk::Menu* m);
00085 
00086     Gtk::Menu* menu() const { return _menu; }
00087 
00088     double width() const { return _width; }
00089     void   set_width(double w);
00090     void   set_height(double h);
00091 
00092     double border_width() const { return _border_width; }
00093     void   set_border_width(double w);
00094 
00095     double natural_width() const;
00096 
00097     const std::string& name() const { return _name; }
00098     virtual void       set_name(const std::string& n);
00099 
00100     bool     is_input()  const { return _is_input; }
00101     bool     is_output() const { return !_is_input; }
00102     uint32_t color()     const { return _color; }
00103     double   height()    const { return _height; }
00104 
00105     virtual bool is_toggled() const { return _toggled; }
00106     virtual void set_toggled(bool b) { _toggled = b; }
00107     virtual void toggle(bool signal=true);
00108 
00109     virtual void set_control(float value, bool signal=true);
00110     virtual void set_control_min(float min) { _control_min = min; set_control(_control_value, false);  }
00111     virtual void set_control_max(float max) { _control_max = max; set_control(_control_value, false);  }
00112 
00113     float control_value() { return _control_value; }
00114     float control_min()   { return _control_min; }
00115     float control_max()   { return _control_max; }
00116 
00117     void show_control();
00118     void hide_control();
00119 
00120     inline bool operator==(const std::string& name) { return (_name == name); }
00121 
00122     sigc::signal<void>       signal_renamed;
00123     sigc::signal<void,float> signal_control_changed;
00124 
00125 protected:
00126     friend class Canvas;
00127 
00128     void on_menu_hide();
00129 
00130     boost::weak_ptr<Module> _module;
00131     std::string             _name;
00132     bool                    _is_input;
00133     double                  _width;
00134     double                  _height;
00135     double                  _border_width;
00136     uint32_t                _color;
00137     bool                    _selected;
00138 
00139     bool  _toggled;
00140     float _control_value;
00141     float _control_min;
00142     float _control_max;
00143 
00144     Gnome::Canvas::Text* _label;
00145     Gnome::Canvas::Rect* _rect;
00146     Gnome::Canvas::Rect* _control_rect;
00147     Gtk::Menu*           _menu;
00148 };
00149 
00150 typedef std::vector<boost::shared_ptr<Port> > PortVector;
00151 
00152 
00153 } // namespace FlowCanvas
00154 
00155 #endif // FLOWCANVAS_PORT_HPP

Generated on Wed Sep 29 2010 for FlowCanvas by  doxygen 1.7.1