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

Generated on Tue Mar 18 16:06:03 2008 for The Gnome Chemistry Utils by  doxygen 1.5.5