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 <gtk/gtk.h>
00029 #include <libxml/tree.h>
00030 #include <vector>
00031 #include <set>
00032 #include <string>
00033 
00034 namespace gcu {
00035         class Dialog;
00036         class Object;
00037 }
00038 
00039 namespace gccv {
00040         class Item;
00041 }
00042 
00044 namespace gcp {
00045 
00046 class Application;
00047 class View;
00048 class WidgetData;
00049 class Operation;
00050 
00054 class Tool
00055 {
00056 public:
00063         Tool (gcp::Application *App, std::string Id);
00067         virtual ~Tool ();
00068         
00085         bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
00086 
00095         void OnDrag (double x, double y, unsigned int state);
00106         void OnMotion (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
00115         void OnRelease (double x, double y, unsigned int state);
00129         bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager);
00137         bool Activate (bool bState);
00141         std::string& GetName () {return name;}
00150         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00156         virtual void Activate ();
00163         virtual bool Deactivate ();
00171         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00179         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00186         virtual bool OnEvent (GdkEvent* event);
00196         virtual bool NotifyViewChange ();
00201         virtual bool DeleteSelection ();
00206         virtual bool CopySelection (GtkClipboard *clipboard);
00211         virtual bool CutSelection (GtkClipboard *clipboard);
00216         virtual bool PasteSelection (GtkClipboard *clipboard);
00221         virtual void AddSelection (WidgetData* data);
00226         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00232         virtual bool OnUndo ();
00238         virtual bool OnRedo ();
00244         virtual void PushNode (xmlNodePtr node);
00250         virtual GtkWidget *GetPropertyPage ();
00258         virtual char const *GetHelpTag () {return "";}
00263         Application * GetApplication () {return m_pApp;}
00264 
00265 protected:
00275         virtual bool OnClicked ();
00282         virtual void OnDrag ();
00289         virtual void OnMotion ();
00296         virtual void OnRelease ();
00301         virtual void OnChangeState ();
00302 
00303 protected:
00307         double m_x0;
00311         double m_y0;
00316         double m_x1;
00321         double m_y1;
00325         double m_x;
00329         double m_y;
00333         gcu::Object *m_pObject;
00337         gcu::Object *m_pObjectGroup;
00341         View *m_pView;
00345         WidgetData *m_pData;
00349         GtkWidget *m_pWidget;
00353         gccv::Item *m_Item;
00357         double m_dZoomFactor;
00362         bool m_bChanged;
00366         unsigned int m_nState;
00370         gcp::Application *m_pApp;
00374         std::set<std::string> ModifiedObjects;
00379         bool m_bAllowed;
00380 
00381 private:
00382         double lastx, lasty;
00383         std::string name;
00384         bool m_bPressed;
00385 };
00386 
00387 }       // namespace gcp
00388 
00389 #endif // GCHEMPAINT_TOOL_H

Generated on Wed Mar 25 12:27:20 2009 for The Gnome Chemistry Utils by  doxygen 1.5.8