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 <vector>
00029 #include <string>
00030 #include "widgetdata.h"
00031 #include "view.h"
00032 #include "operation.h"
00033 #include <gcu/dialog.h>
00034 
00036 namespace gcp {
00037 
00038 class Application;
00039 
00043 class Tool
00044 {
00045 public:
00052         Tool (gcp::Application *App, std::string Id);
00056         virtual ~Tool ();
00057         
00074         bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
00075 
00084         void OnDrag (double x, double y, unsigned int state);
00093         void OnRelease (double x, double y, unsigned int state);
00107         bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager);
00110         bool Activate (bool bState);
00113         std::string& GetName () {return name;}
00116         virtual bool OnClicked ();
00119         virtual void OnDrag ();
00122         virtual void OnRelease ();
00131         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00134         virtual void Activate ();
00137         virtual bool Deactivate ();
00140         virtual void OnChangeState ();
00143         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00146         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00149         virtual bool OnEvent (GdkEvent* event);
00152         virtual bool NotifyViewChange ();
00155         virtual bool DeleteSelection ();
00158         virtual bool CopySelection (GtkClipboard *clipboard);
00161         virtual bool CutSelection (GtkClipboard *clipboard);
00164         virtual bool PasteSelection (GtkClipboard *clipboard);
00167         virtual void AddSelection (WidgetData* data);
00170         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00173         virtual bool OnUndo ();
00176         virtual bool OnRedo ();
00179         virtual void PushNode (xmlNodePtr node);
00182         virtual GtkWidget *GetPropertyPage ();
00185         virtual char const *GetHelpTag () {return "";}
00186         
00187 protected:
00188         gdouble m_x0, m_y0, m_x1, m_y1, m_x, m_y;
00189         gcu::Object *m_pObject;
00190         gcu::Object *m_pObjectGroup;
00191         View *m_pView;
00192         WidgetData *m_pData;
00193         gcu::Dialog *m_OptionDialog;
00194         GtkWidget *m_pWidget;
00195         GnomeCanvasGroup *m_pGroup;
00196         GnomeCanvasItem *m_pItem;
00197         GnomeCanvasItem *m_pBackground;
00198         double m_dZoomFactor;
00199         bool m_bChanged, m_bPressed;
00200         unsigned int m_nState;
00201         gcp::Application *m_pApp;
00202         std::set<std::string> ModifiedObjects;
00207         bool m_bAllowed;
00208 
00209 private:
00210         double lastx, lasty;
00211         std::string name;
00212 };
00213 
00214 }       // namespace gcp
00215 
00216 #endif // GCHEMPAINT_TOOL_H

Generated on Mon Aug 25 17:46:34 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6