papyrus logo

translator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSTRANSLATOR_H
00021 #define PAPYRUSTRANSLATOR_H
00022 
00023 #include <papyrus/affinecontroller.h>
00024 
00025 namespace Papyrus
00026 {
00027 
00031   class Translator : public AffineController
00032   {
00033     protected:
00034 
00035       Translator ( const Glib::ustring& id, DrawableSet::pointer drawables, unsigned transforms = TRANSLATE_X|TRANSLATE_Y );
00036 
00037     public:
00038 
00039       typedef PapyrusPointer<Translator> pointer;
00040 
00041       static Translator::pointer create ( unsigned transforms = TRANSLATE_X|TRANSLATE_Y );
00042 
00043       static Translator::pointer create ( const Glib::ustring& id, DrawableSet::pointer drawables, unsigned transforms = TRANSLATE_X|TRANSLATE_Y );
00044 
00045       static Translator::pointer create ( const Glib::ustring& id, unsigned transforms = TRANSLATE_X|TRANSLATE_Y );
00046 
00047       static Translator::pointer create ( DrawableSet::pointer drawables, unsigned transforms = TRANSLATE_X|TRANSLATE_Y );
00048 
00049       virtual ~Translator();
00050 
00051       unsigned transforms();
00052 
00053       void set_transforms ( unsigned transforms );
00054 
00055       void enable_transforms ( unsigned transforms );
00056 
00057       void disable_transforms ( unsigned transforms );
00058 
00060       void grid ( double& x, double& y );
00061 
00066       void set_grid ( double x, double y );
00067 
00068       void set_grid_x ( double x );
00069 
00070       void set_grid_y ( double y );
00071 
00072     protected:
00073       double m_last_position[2], m_original_position[2];
00074       unsigned m_transforms;
00075       double m_grid[2];
00076 
00077       virtual bool on_motion ( const Event::Motion& event );
00078       virtual bool on_button_press ( const Event::ButtonPress& event );
00079 
00080   };
00081 
00082 }
00083 
00084 #endif

Generated on Fri Apr 16 12:40:11 2010 for papyrus by doxygen 1.6.1