00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PAPYRUSGROUP_H
00020 #define PAPYRUSGROUP_H
00021
00022 #include <list>
00023 #include <map>
00024 #include <vector>
00025
00026 #include <papyrus/drawable.h>
00027
00057 namespace Papyrus
00058 {
00059
00081 class Group : public Drawable
00082 {
00083 public:
00084 typedef PapyrusSmartPointer<Group> pointer;
00085
00086 Group();
00087
00088 static pointer create();
00089
00090 typedef std::list<Drawable::pointer> Children;
00091
00092 friend class Canvas;
00093
00094 virtual ~Group();
00095
00096 virtual bool add( Drawable::pointer item, bool drawing_only=false );
00097
00098 virtual bool remove( Drawable::pointer object );
00099
00104 virtual bool remove( Drawable* object );
00105
00106 virtual bool clear();
00107
00108 virtual bool raise( Drawable::pointer item );
00109 virtual bool raise_to_top( Drawable::pointer item );
00110 virtual bool lower( Drawable::pointer item );
00111 virtual bool lower_to_bottom( Drawable::pointer item );
00112
00113 Children& get_children();
00114
00121 virtual bool inside( double x, double y );
00122
00123 virtual std::vector<Drawable::pointer> select( double x, double y, unsigned depth = 1 );
00124
00125 sigc::signal<void, Drawable::pointer>& signal_child_added();
00126
00127 sigc::signal<void, Drawable::pointer>& signal_child_removed();
00128
00129 virtual bool is_group();
00130
00131 PAPYRUS_CLASS_NAME("Group");
00132
00133 PAPYRUS_CLONE_METHOD( Group );
00134
00135 protected:
00136
00137
00138 Children m_children;
00139 typedef std::map<Drawable::pointer, sigc::connection> Connections;
00140 Connections m_redraw_connections;
00141 Connections m_changed_connections;
00142
00143 sigc::signal<void, Drawable::pointer> m_signal_child_added;
00144 sigc::signal<void, Drawable::pointer> m_signal_child_removed;
00145
00156 virtual void on_child_changed( Drawable::pointer child );
00157
00166 virtual void update_extents();
00167
00168 void on_child_need_redraw( double x, double y, double w, double h, Drawable::pointer child );
00169 virtual void draw( Cairo::RefPtr<Cairo::Context> cairo );
00170
00171 void rebuild_extents();
00172
00173 };
00174
00175 }
00176
00177 #endif