selector.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef PAPYRUSSELECTOR_H
00020 #define PAPYRUSSELECTOR_H
00021 
00022 #include <list>
00023 
00024 #include <papyrus/enums.h>
00025 #include <papyrus/smart_pointer.h>
00026 #include <papyrus/controller.h>
00027 #include <papyrus/group.h>
00028 
00029 namespace Papyrus
00030 {
00031 
00037   class Selector : public Controller
00038   {
00039     public:
00040 
00041       typedef PapyrusSmartPointer<Selector> pointer;
00042 
00050       typedef std::list<Drawable::pointer> Selection;
00051 
00052       Selector( Group::pointer select_from_group = Group::pointer(),
00053                 SelectionMode mode = SELECT_PRESS,
00054                 int selection_depth = 1 );
00055 
00056       Selector( Group::pointer select_from_group,
00057                 Group::pointer selection_group,
00058                 SelectionMode mode = SELECT_PRESS,
00059                 int selection_depth = 1,
00060                 bool add_drawable_only = true );
00061 
00062       static Selector::pointer create( Group::pointer select_from_group = Group::pointer(),
00063                                        SelectionMode mode = SELECT_PRESS,
00064                                        int selection_depth = 1 );
00065 
00066       static Selector::pointer create( Group::pointer select_from_group,
00067                                        Group::pointer selection_group,
00068                                        SelectionMode mode = SELECT_PRESS,
00069                                        int selection_depth = 1,
00070                                        bool add_drawable_only = true );
00071 
00072       virtual ~Selector();
00073 
00074       Group::pointer select_from_group();
00075 
00076       void set_select_from_group( Group::pointer select_from_group );
00077 
00078       Group::pointer selection_group();
00079 
00080       virtual void set_selection_group( Group::pointer selection_group, bool add_drawable_only = true );
00081 
00082       void set_select_mode( unsigned mode );
00083 
00084       void enable_select_mode( unsigned mode );
00085 
00086       void disable_select_mode( unsigned mode );
00087 
00088       unsigned select_mode();
00089 
00090       int selection_depth();
00091 
00092       void set_selection_depth( int selection_depth );
00093 
00094       void clear();
00095 
00096       const Selection& selection();
00097 
00098       void add_to_selection( Drawable::pointer drawable );
00099 
00100       void remove_from_selection( Drawable::pointer drawable );
00101 
00102       bool in_selection( Drawable::pointer drawable );
00103 
00104       const Region& extents();
00105 
00106       sigc::signal<void, Drawable::pointer> signal_selected();
00107 
00108       sigc::signal<void, Drawable::pointer> signal_deselected();
00109 
00110       sigc::signal<void> signal_cleared();
00111 
00112     protected:
00113       unsigned m_select_mode;
00114       Selection m_selection;
00115       int m_selection_depth;
00116       Group::pointer m_select_from_group;
00117       Group::pointer m_selection_group;
00118       bool m_add_drawable_only;
00119       Drawable::pointer m_picked;
00120       double m_last_position[ 2 ];
00121       Region m_extents;
00122 
00123       sigc::signal<void, Drawable::pointer> m_signal_selected;
00124 
00125       sigc::signal<void, Drawable::pointer> m_signal_deselected;
00126 
00127       sigc::signal<void> m_signal_cleared;
00128 
00129       virtual bool on_button_press( const Event::ButtonPress& event );
00130       virtual bool on_button_release( const Event::ButtonRelease& event );
00131       virtual bool on_motion( const Event::Motion& event );
00132 
00133   };
00134 
00135 }
00136 
00137 #endif

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1