The Gnome Chemistry Utils 0.13.3
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * GChemPaint library 00005 * tool.h 00006 * 00007 * Copyright (C) 2001-2011 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 class UIManager; 00039 } 00040 00041 namespace gccv { 00042 class Item; 00043 } 00044 00046 namespace gcp { 00047 00048 class Application; 00049 class View; 00050 class WidgetData; 00051 class Operation; 00052 00056 class Tool 00057 { 00058 public: 00065 Tool (gcp::Application *App, std::string Id); 00069 virtual ~Tool (); 00070 00087 bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state); 00088 00097 void OnDrag (double x, double y, unsigned int state); 00108 void OnMotion (View* pView, gcu::Object* pObject, double x, double y, unsigned int state); 00116 void OnLeaveNotify (View* pView, unsigned int state); 00125 void OnRelease (double x, double y, unsigned int state); 00139 bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, gcu::UIManager *UIManager); 00147 bool Activate (bool bState); 00151 std::string& GetName () {return name;} 00160 virtual bool OnRightButtonClicked (gcu::UIManager *UIManager); 00166 virtual void Activate (); 00173 virtual bool Deactivate (); 00181 void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();} 00189 void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();} 00196 virtual bool OnKeyPress (GdkEventKey *event); 00203 virtual bool OnKeyRelease (GdkEventKey *event); 00213 virtual bool NotifyViewChange (); 00218 virtual bool DeleteSelection (); 00223 virtual bool CopySelection (GtkClipboard *clipboard); 00228 virtual bool CutSelection (GtkClipboard *clipboard); 00233 virtual bool PasteSelection (GtkClipboard *clipboard); 00238 virtual void AddSelection (WidgetData* data); 00243 virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type); 00249 virtual bool OnUndo (); 00255 virtual bool OnRedo (); 00261 virtual void PushNode (xmlNodePtr node); 00267 virtual GtkWidget *GetPropertyPage (); 00275 virtual char const *GetHelpTag () {return "";} 00280 Application * GetApplication () {return m_pApp;} 00285 virtual void OnConfigChanged () {} 00286 00287 protected: 00297 virtual bool OnClicked (); 00304 virtual void OnDrag (); 00311 virtual void OnMotion (); 00318 virtual void OnLeaveNotify (); 00325 virtual void OnRelease (); 00330 virtual void OnChangeState (); 00331 00332 protected: 00336 double m_x0; 00340 double m_y0; 00345 double m_x1; 00350 double m_y1; 00354 double m_x; 00358 double m_y; 00362 gcu::Object *m_pObject; 00366 gcu::Object *m_pObjectGroup; 00370 View *m_pView; 00374 WidgetData *m_pData; 00378 GtkWidget *m_pWidget; 00382 gccv::Item *m_Item; 00386 double m_dZoomFactor; 00391 bool m_bChanged; 00395 unsigned int m_nState; 00399 gcp::Application *m_pApp; 00403 std::set<std::string> ModifiedObjects; 00408 bool m_bAllowed; 00409 00410 private: 00411 double lastx, lasty; 00412 std::string name; 00413 bool m_bPressed; 00414 00421 GCU_PROT_PROP (bool, OwnStatus) 00422 }; 00423 00424 } // namespace gcp 00425 00426 #endif // GCHEMPAINT_TOOL_H