tool.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * tool.h 
00006  *
00007  * Copyright (C) 2001-2007 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 
00035 using namespace std;
00036 using namespace gcu;
00037 
00038 class gcp::Application;
00039 
00040 namespace gcp {
00041 
00042 class Tool
00043 {
00044 public:
00045         Tool (gcp::Application *App, string Id);
00046         virtual ~Tool ();
00047         
00064         bool OnClicked (View* pView, Object* pObject, double x, double y, unsigned int state);
00065 
00066         void OnDrag (double x, double y, unsigned int state);
00067         void OnRelease (double x, double y, unsigned int state);
00068         bool OnRightButtonClicked (View* pView, Object* pObject, double x, double y, GtkUIManager *UIManager);
00069         bool Activate (bool bState);
00070         string& GetName () {return name;}
00071         virtual bool OnClicked ();
00072         virtual void OnDrag ();
00073         virtual void OnRelease ();
00074         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00075         virtual void Activate ();
00076         virtual bool Deactivate ();
00077         virtual void OnChangeState ();
00078         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00079         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00080         virtual bool OnEvent (GdkEvent* event);
00081         virtual bool NotifyViewChange ();
00082         virtual bool DeleteSelection ();
00083         virtual bool CopySelection (GtkClipboard *clipboard);
00084         virtual bool CutSelection (GtkClipboard *clipboard);
00085         virtual bool PasteSelection (GtkClipboard *clipboard);
00086         virtual void AddSelection (WidgetData* data);
00087         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00088         virtual bool OnUndo ();
00089         virtual bool OnRedo ();
00090         virtual void PushNode (xmlNodePtr node);
00091         virtual GtkWidget *GetPropertyPage ();
00092         virtual char const *GetHelpTag () {return "";}
00093         
00094 protected:
00095         gdouble m_x0, m_y0, m_x1, m_y1, m_x, m_y;
00096         Object *m_pObject;
00097         Object *m_pObjectGroup;
00098         View *m_pView;
00099         WidgetData *m_pData;
00100         Dialog *m_OptionDialog;
00101         GtkWidget *m_pWidget;
00102         GnomeCanvasGroup *m_pGroup;
00103         GnomeCanvasItem *m_pItem;
00104         GnomeCanvasItem *m_pBackground;
00105         double m_dZoomFactor;
00106         bool m_bChanged, m_bPressed;
00107         unsigned int m_nState;
00108         gcp::Application *m_pApp;
00109         set<string> ModifiedObjects;
00114         bool m_bAllowed;
00115 
00116 private:
00117         double lastx, lasty;
00118         string name;
00119 };
00120 
00121 }       // namespace gcp
00122 
00123 #endif // GCHEMPAINT_TOOL_H

Generated on Sun Sep 16 14:21:55 2007 for The Gnome Chemistry Utils by  doxygen 1.5.3