The Gnome Chemistry Utils 0.12.10
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * GChemPaint library 00005 * tool.h 00006 * 00007 * Copyright (C) 2001-2009 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 <gcu/macros.h> 00029 #include <gtk/gtk.h> 00030 #include <libxml/tree.h> 00031 #include <vector> 00032 #include <set> 00033 #include <string> 00034 00035 namespace gcu { 00036 class Dialog; 00037 class Object; 00038 } 00039 00040 namespace gccv { 00041 class Item; 00042 } 00043 00045 namespace gcp { 00046 00047 class Application; 00048 class View; 00049 class WidgetData; 00050 class Operation; 00051 00055 class Tool 00056 { 00057 public: 00064 Tool (gcp::Application *App, std::string Id); 00068 virtual ~Tool (); 00069 00086 bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state); 00087 00096 void OnDrag (double x, double y, unsigned int state); 00107 void OnMotion (View* pView, gcu::Object* pObject, double x, double y, unsigned int state); 00115 void OnLeaveNotify (View* pView, unsigned int state); 00124 void OnRelease (double x, double y, unsigned int state); 00138 bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager); 00146 bool Activate (bool bState); 00150 std::string& GetName () {return name;} 00159 virtual bool OnRightButtonClicked (GtkUIManager *UIManager); 00165 virtual void Activate (); 00172 virtual bool Deactivate (); 00180 void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();} 00188 void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();} 00195 virtual bool OnKeyPress (GdkEventKey *event); 00202 virtual bool OnKeyRelease (GdkEventKey *event); 00212 virtual bool NotifyViewChange (); 00217 virtual bool DeleteSelection (); 00222 virtual bool CopySelection (GtkClipboard *clipboard); 00227 virtual bool CutSelection (GtkClipboard *clipboard); 00232 virtual bool PasteSelection (GtkClipboard *clipboard); 00237 virtual void AddSelection (WidgetData* data); 00242 virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type); 00248 virtual bool OnUndo (); 00254 virtual bool OnRedo (); 00260 virtual void PushNode (xmlNodePtr node); 00266 virtual GtkWidget *GetPropertyPage (); 00274 virtual char const *GetHelpTag () {return "";} 00279 Application * GetApplication () {return m_pApp;} 00284 virtual void OnConfigChanged () {} 00285 00286 protected: 00296 virtual bool OnClicked (); 00303 virtual void OnDrag (); 00310 virtual void OnMotion (); 00317 virtual void OnLeaveNotify (); 00324 virtual void OnRelease (); 00329 virtual void OnChangeState (); 00330 00331 protected: 00335 double m_x0; 00339 double m_y0; 00344 double m_x1; 00349 double m_y1; 00353 double m_x; 00357 double m_y; 00361 gcu::Object *m_pObject; 00365 gcu::Object *m_pObjectGroup; 00369 View *m_pView; 00373 WidgetData *m_pData; 00377 GtkWidget *m_pWidget; 00381 gccv::Item *m_Item; 00385 double m_dZoomFactor; 00390 bool m_bChanged; 00394 unsigned int m_nState; 00398 gcp::Application *m_pApp; 00402 std::set<std::string> ModifiedObjects; 00407 bool m_bAllowed; 00408 00409 private: 00410 double lastx, lasty; 00411 std::string name; 00412 bool m_bPressed; 00413 00420 GCU_PROT_PROP (bool, OwnStatus) 00421 }; 00422 00423 } // namespace gcp 00424 00425 #endif // GCHEMPAINT_TOOL_H