tool.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * tool.h 
00006  *
00007  * Copyright (C) 2001-2009 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCHEMPAINT_TOOL_H
00026 #define GCHEMPAINT_TOOL_H
00027 
00028 #include <gcu/macros.h>
00029 #include <gtk/gtk.h>
00030 #include <libxml/tree.h>
00031 #include <vector>
00032 #include <set>
00033 #include <string>
00034 
00035 namespace gcu {
00036         class Dialog;
00037         class Object;
00038 }
00039 
00040 namespace gccv {
00041         class Item;
00042 }
00043 
00045 namespace gcp {
00046 
00047 class Application;
00048 class View;
00049 class WidgetData;
00050 class Operation;
00051 
00055 class Tool
00056 {
00057 public:
00064         Tool (gcp::Application *App, std::string Id);
00068         virtual ~Tool ();
00069         
00086         bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
00087 
00096         void OnDrag (double x, double y, unsigned int state);
00107         void OnMotion (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
00116         void OnRelease (double x, double y, unsigned int state);
00130         bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager);
00138         bool Activate (bool bState);
00142         std::string& GetName () {return name;}
00151         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00157         virtual void Activate ();
00164         virtual bool Deactivate ();
00172         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00180         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00187         virtual bool OnKeyPress (GdkEventKey *event);
00194         virtual bool OnKeyRelease (GdkEventKey *event);
00204         virtual bool NotifyViewChange ();
00209         virtual bool DeleteSelection ();
00214         virtual bool CopySelection (GtkClipboard *clipboard);
00219         virtual bool CutSelection (GtkClipboard *clipboard);
00224         virtual bool PasteSelection (GtkClipboard *clipboard);
00229         virtual void AddSelection (WidgetData* data);
00234         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00240         virtual bool OnUndo ();
00246         virtual bool OnRedo ();
00252         virtual void PushNode (xmlNodePtr node);
00258         virtual GtkWidget *GetPropertyPage ();
00266         virtual char const *GetHelpTag () {return "";}
00271         Application * GetApplication () {return m_pApp;}
00272 
00273 protected:
00283         virtual bool OnClicked ();
00290         virtual void OnDrag ();
00297         virtual void OnMotion ();
00304         virtual void OnRelease ();
00309         virtual void OnChangeState ();
00310 
00311 protected:
00315         double m_x0;
00319         double m_y0;
00324         double m_x1;
00329         double m_y1;
00333         double m_x;
00337         double m_y;
00341         gcu::Object *m_pObject;
00345         gcu::Object *m_pObjectGroup;
00349         View *m_pView;
00353         WidgetData *m_pData;
00357         GtkWidget *m_pWidget;
00361         gccv::Item *m_Item;
00365         double m_dZoomFactor;
00370         bool m_bChanged;
00374         unsigned int m_nState;
00378         gcp::Application *m_pApp;
00382         std::set<std::string> ModifiedObjects;
00387         bool m_bAllowed;
00388 
00389 private:
00390         double lastx, lasty;
00391         std::string name;
00392         bool m_bPressed;
00393 
00394 GCU_PROT_PROP (bool, OwnStatus)
00395 };
00396 
00397 }       // namespace gcp
00398 
00399 #endif // GCHEMPAINT_TOOL_H

Generated on Sun Sep 6 18:29:26 2009 for The Gnome Chemistry Utils by  doxygen 1.6.1