tool.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * tool.h 
00006  *
00007  * Copyright (C) 2001-2008 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);
00104         void OnRelease (double x, double y, unsigned int state);
00118         bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager);
00126         bool Activate (bool bState);
00130         std::string& GetName () {return name;}
00139         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00145         virtual void Activate ();
00152         virtual bool Deactivate ();
00160         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00168         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00175         virtual bool OnEvent (GdkEvent* event);
00185         virtual bool NotifyViewChange ();
00190         virtual bool DeleteSelection ();
00195         virtual bool CopySelection (GtkClipboard *clipboard);
00200         virtual bool CutSelection (GtkClipboard *clipboard);
00205         virtual bool PasteSelection (GtkClipboard *clipboard);
00210         virtual void AddSelection (WidgetData* data);
00215         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00221         virtual bool OnUndo ();
00227         virtual bool OnRedo ();
00233         virtual void PushNode (xmlNodePtr node);
00239         virtual GtkWidget *GetPropertyPage ();
00247         virtual char const *GetHelpTag () {return "";}
00248 
00249 protected:
00259         virtual bool OnClicked ();
00266         virtual void OnDrag ();
00273         virtual void OnRelease ();
00278         virtual void OnChangeState ();
00279 
00280 protected:
00284         double m_x0;
00288         double m_y0;
00293         double m_x1;
00298         double m_y1;
00302         double m_x;
00306         double m_y;
00310         gcu::Object *m_pObject;
00314         gcu::Object *m_pObjectGroup;
00318         View *m_pView;
00322         WidgetData *m_pData;
00326         GtkWidget *m_pWidget;
00330         gccv::Item *m_Item;
00334         double m_dZoomFactor;
00339         bool m_bChanged;
00343         unsigned int m_nState;
00347         gcp::Application *m_pApp;
00351         std::set<std::string> ModifiedObjects;
00356         bool m_bAllowed;
00357 
00358 private:
00359         double lastx, lasty;
00360         std::string name;
00361         bool m_bPressed;
00362 };
00363 
00364 }       // namespace gcp
00365 
00366 #endif // GCHEMPAINT_TOOL_H

Generated on Wed Dec 17 13:43:18 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6