The Gnome Chemistry Utils  0.14.6
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
virtual GtkWidget * GetPropertyPage()
gccv::Item * m_Item
Definition: tool.h:382
virtual bool OnRedo()
gcu::Object * m_pObjectGroup
Definition: tool.h:366
View * m_pView
Definition: tool.h:370
virtual bool CopySelection(GtkClipboard *clipboard)
virtual void PushNode(xmlNodePtr node)
unsigned int m_nState
Definition: tool.h:395
virtual bool OnClicked()
virtual void OnMotion()
double m_x0
Definition: tool.h:336
virtual void OnChangeState()
virtual void Activate()
virtual bool OnKeyRelease(GdkEventKey *event)
double m_y0
Definition: tool.h:340
virtual bool OnUndo()
virtual void AddSelection(WidgetData *data)
virtual void OnConfigChanged()
Definition: tool.h:285
virtual bool OnKeyPress(GdkEventKey *event)
std::string & GetName()
Definition: tool.h:151
base class for a user interface manager
Definition: ui-manager.h:33
virtual ~Tool()
Tool(gcp::Application *App, std::string Id)
#define GCU_PROT_PROP(type, member)
Definition: macros.h:174
void OnKeyReleased(unsigned int code)
Definition: tool.h:189
double m_y1
Definition: tool.h:350
virtual bool CutSelection(GtkClipboard *clipboard)
std::set< std::string > ModifiedObjects
Definition: tool.h:403
virtual bool PasteSelection(GtkClipboard *clipboard)
virtual void OnRelease()
virtual void OnLeaveNotify()
bool OnRightButtonClicked(View *pView, gcu::Object *pObject, double x, double y, gcu::UIManager *UIManager)
bool m_bAllowed
Definition: tool.h:408
double m_y
Definition: tool.h:358
GtkWidget * m_pWidget
Definition: tool.h:378
bool m_bChanged
Definition: tool.h:391
WidgetData * m_pData
Definition: tool.h:374
double m_dZoomFactor
Definition: tool.h:386
gcu::Object * m_pObject
Definition: tool.h:362
virtual bool DeleteSelection()
virtual bool Deactivate()
Definition: tool.h:56
virtual bool NotifyViewChange()
double m_x1
Definition: tool.h:345
Application * GetApplication()
Definition: tool.h:280
virtual void OnDrag()
gcp::Application * m_pApp
Definition: tool.h:399
virtual char const * GetHelpTag()
Definition: tool.h:275
GChemPaint application base class.
void OnKeyPressed(unsigned int code)
Definition: tool.h:181
The base class for the canvas contents.
Definition: item.h:100
virtual bool OnReceive(GtkClipboard *clipboard, GtkSelectionData *data, int type)
double m_x
Definition: tool.h:354