The Gnome Chemistry Utils  0.14.0
tool.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * tool.h
6  *
7  * Copyright (C) 2001-2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_TOOL_H
26 #define GCHEMPAINT_TOOL_H
27 
28 #include <gcu/macros.h>
29 #include <gtk/gtk.h>
30 #include <libxml/tree.h>
31 #include <vector>
32 #include <set>
33 #include <string>
34 
35 namespace gcu {
36  class Dialog;
37  class Object;
38  class UIManager;
39 }
40 
41 namespace gccv {
42  class Item;
43 }
44 
46 namespace gcp {
47 
48 class Application;
49 class View;
50 class WidgetData;
51 class Operation;
52 
56 class Tool
57 {
58 public:
65  Tool (gcp::Application *App, std::string Id);
69  virtual ~Tool ();
70 
87  bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
88 
97  void OnDrag (double x, double y, unsigned int state);
108  void OnMotion (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
116  void OnLeaveNotify (View* pView, unsigned int state);
125  void OnRelease (double x, double y, unsigned int state);
139  bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, gcu::UIManager *UIManager);
147  bool Activate (bool bState);
151  std::string& GetName () {return name;}
160  virtual bool OnRightButtonClicked (gcu::UIManager *UIManager);
166  virtual void Activate ();
173  virtual bool Deactivate ();
181  void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
189  void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
196  virtual bool OnKeyPress (GdkEventKey *event);
203  virtual bool OnKeyRelease (GdkEventKey *event);
213  virtual bool NotifyViewChange ();
218  virtual bool DeleteSelection ();
223  virtual bool CopySelection (GtkClipboard *clipboard);
228  virtual bool CutSelection (GtkClipboard *clipboard);
233  virtual bool PasteSelection (GtkClipboard *clipboard);
238  virtual void AddSelection (WidgetData* data);
243  virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
249  virtual bool OnUndo ();
255  virtual bool OnRedo ();
261  virtual void PushNode (xmlNodePtr node);
267  virtual GtkWidget *GetPropertyPage ();
275  virtual char const *GetHelpTag () {return "";}
285  virtual void OnConfigChanged () {}
286 
287 protected:
297  virtual bool OnClicked ();
304  virtual void OnDrag ();
311  virtual void OnMotion ();
318  virtual void OnLeaveNotify ();
325  virtual void OnRelease ();
330  virtual void OnChangeState ();
331 
332 protected:
336  double m_x0;
340  double m_y0;
345  double m_x1;
350  double m_y1;
354  double m_x;
358  double m_y;
378  GtkWidget *m_pWidget;
395  unsigned int m_nState;
403  std::set<std::string> ModifiedObjects;
409 
410 private:
411  double lastx, lasty;
412  std::string name;
413  bool m_bPressed;
414 
421 GCU_PROT_PROP (bool, OwnStatus)
422 };
423 
424 } // namespace gcp
425 
426 #endif // GCHEMPAINT_TOOL_H