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);
00115         bool Activate (bool bState);
00119         std::string& GetName () {return name;}
00128         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
00134         virtual void Activate ();
00141         virtual bool Deactivate ();
00149         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
00157         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
00164         virtual bool OnEvent (GdkEvent* event);
00174         virtual bool NotifyViewChange ();
00179         virtual bool DeleteSelection ();
00184         virtual bool CopySelection (GtkClipboard *clipboard);
00189         virtual bool CutSelection (GtkClipboard *clipboard);
00194         virtual bool PasteSelection (GtkClipboard *clipboard);
00199         virtual void AddSelection (WidgetData* data);
00204         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
00210         virtual bool OnUndo ();
00216         virtual bool OnRedo ();
00222         virtual void PushNode (xmlNodePtr node);
00228         virtual GtkWidget *GetPropertyPage ();
00236         virtual char const *GetHelpTag () {return "";}
00241         Application * GetApplication () {return m_pApp;}
00242 
00243 protected:
00253         virtual bool OnClicked ();
00260         virtual void OnDrag ();
00267         virtual void OnRelease ();
00272         virtual void OnChangeState ();
00273 
00274 protected:
00278         double m_x0;
00282         double m_y0;
00287         double m_x1;
00292         double m_y1;
00296         double m_x;
00300         double m_y;
00304         gcu::Object *m_pObject;
00308         gcu::Object *m_pObjectGroup;
00312         View *m_pView;
00316         WidgetData *m_pData;
00320         GtkWidget *m_pWidget;
00324         GnomeCanvasGroup *m_pGroup;
00328         GnomeCanvasItem *m_pItem;
00332         GnomeCanvasItem *m_pBackground;
00336         double m_dZoomFactor;
00341         bool m_bChanged;
00345         unsigned int m_nState;
00349         gcp::Application *m_pApp;
00353         std::set<std::string> ModifiedObjects;
00358         bool m_bAllowed;
00359 
00360 private:
00361         double lastx, lasty;
00362         std::string name;
00363         bool m_bPressed;
00364 };
00365 
00366 }       // namespace gcp
00367 
00368 #endif // GCHEMPAINT_TOOL_H

Generated on Thu Sep 3 16:07:52 2009 for The Gnome Chemistry Utils by  doxygen 1.6.1