The Gnome Chemistry Utils  0.14.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gcp::Tool Class Reference

#include <tool.h>

Public Member Functions

 Tool (gcp::Application *App, std::string Id)
virtual ~Tool ()
bool OnClicked (View *pView, gcu::Object *pObject, double x, double y, unsigned int state)
void OnDrag (double x, double y, unsigned int state)
void OnMotion (View *pView, gcu::Object *pObject, double x, double y, unsigned int state)
void OnLeaveNotify (View *pView, unsigned int state)
void OnRelease (double x, double y, unsigned int state)
bool OnRightButtonClicked (View *pView, gcu::Object *pObject, double x, double y, gcu::UIManager *UIManager)
bool Activate (bool bState)
std::string & GetName ()
virtual bool OnRightButtonClicked (gcu::UIManager *UIManager)
virtual void Activate ()
virtual bool Deactivate ()
void OnKeyPressed (unsigned int code)
void OnKeyReleased (unsigned int code)
virtual bool OnKeyPress (GdkEventKey *event)
virtual bool OnKeyRelease (GdkEventKey *event)
virtual bool NotifyViewChange ()
virtual bool DeleteSelection ()
virtual bool CopySelection (GtkClipboard *clipboard)
virtual bool CutSelection (GtkClipboard *clipboard)
virtual bool PasteSelection (GtkClipboard *clipboard)
virtual void AddSelection (WidgetData *data)
virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type)
virtual bool OnUndo ()
virtual bool OnRedo ()
virtual void PushNode (xmlNodePtr node)
virtual GtkWidget * GetPropertyPage ()
virtual char const * GetHelpTag ()
ApplicationGetApplication ()
virtual void OnConfigChanged ()
bool GetOwnStatus (void)

Protected Member Functions

virtual bool OnClicked ()
virtual void OnDrag ()
virtual void OnMotion ()
virtual void OnLeaveNotify ()
virtual void OnRelease ()
virtual void OnChangeState ()

Protected Attributes

double m_x0
double m_y0
double m_x1
double m_y1
double m_x
double m_y
gcu::Objectm_pObject
gcu::Objectm_pObjectGroup
Viewm_pView
WidgetDatam_pData
GtkWidget * m_pWidget
gccv::Itemm_Item
double m_dZoomFactor
bool m_bChanged
unsigned int m_nState
gcp::Applicationm_pApp
std::set< std::string > ModifiedObjects
bool m_bAllowed
bool m_OwnStatus

Detailed Description

Base clas for GChemPaint tools.

Definition at line 56 of file tool.h.

Constructor & Destructor Documentation

gcp::Tool::Tool ( gcp::Application App,
std::string  Id 
)
Parameters
Appthe GChemPaint application.
Idthe name of the tool.

Constructs a new tool.

virtual gcp::Tool::~Tool ( )
virtual

The destructor.

Member Function Documentation

bool gcp::Tool::Activate ( bool  bState)
Parameters
bStatewhether to activate or deactivate the tool.

When bState is true, the tool is activated, otherwise it is deactivated. Activate() or Deactivate() is called for this instance.

Returns
true on success, and false otherwise. Activation always succeeds.
virtual void gcp::Tool::Activate ( )
virtual

Virtual method called when the tool is activated. This method should be overriden for all tools which need some initialization when activated. Default does nothing.

virtual void gcp::Tool::AddSelection ( WidgetData data)
virtual

Called by the framework to paste data. Tools for which it is meaningful must have an overriden version of this method.

virtual bool gcp::Tool::CopySelection ( GtkClipboard *  clipboard)
virtual

Called by the framework to delete the selection. Tools for which it is meaningful must have an overriden version of this method.

virtual bool gcp::Tool::CutSelection ( GtkClipboard *  clipboard)
virtual

Called by the framework to copy the selection. Tools for which it is meaningful must have an oveeriden version of this method.

virtual bool gcp::Tool::Deactivate ( )
virtual

Virtual method called when the tool is deactivated. This method should be overriden for all tools which need some cleaning when deactivated. Default does nothing.

Returns
true on success, false otherwise.
virtual bool gcp::Tool::DeleteSelection ( )
virtual

Called by the framework to delete the selection. Tools for which it is meaningful must have an overriden version of this method.

Application* gcp::Tool::GetApplication ( void  )
inline

Gets the Application instance owning the tool.

Returns
the Application instance.

Definition at line 280 of file tool.h.

References m_pApp.

virtual char const* gcp::Tool::GetHelpTag ( )
inlinevirtual

Gets the tag used to display the appropriate help topic when the user presses the help button in the tools box. The framework will prefix the result with the application name. The text tool in GChemPaint returns "text" which becomes "gchempaint-text".

Returns
the help tag for the tool.

Definition at line 275 of file tool.h.

std::string& gcp::Tool::GetName ( void  )
inline
Returns
the tool name.

Definition at line 151 of file tool.h.

gcp::Tool::GetOwnStatus ( void  )
inline
Returns
whether the tool owns the status bar text.

Definition at line 421 of file tool.h.

virtual GtkWidget* gcp::Tool::GetPropertyPage ( )
virtual

Gets the property page for the tool. Called the first time the tool becomes active.

Returns
the new tool property page.
virtual bool gcp::Tool::NotifyViewChange ( )
virtual

Virtual method called by the framework whenthe active view, and hence the active document has changed, so that the tool can finish its current operation in the previously active document and update its options box according to the new active document settings.

Returns
true to accept the document change, false if something went wrong and the active document should not change, as in the case of the fragment tool when the symbols entered can't be interpreted.
virtual void gcp::Tool::OnChangeState ( )
protectedvirtual

Called when a modifier key has been pressed or released, and fires a drag event so that the tool can update things if necessary.

Referenced by OnKeyPressed(), and OnKeyReleased().

bool gcp::Tool::OnClicked ( View pView,
gcu::Object pObject,
double  x,
double  y,
unsigned int  state 
)
Parameters
pViewthe view instance owning the event.
pObjectthe Object on which the click occured.
xthe horizontal position of the mouse when the click occured.
ythe vertical position of the mouse when the click occured.
statea bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType in GDK documentation.

This method is called by the framework when the tool is active and a click occurs. It initialize some members and then calls the virtual OnClicked() method. It might be called to simulate a click in some instances (e.g. from a contextual menu handler).

Returns
true if the mouse drag and button release evens are significative for this tool in the current context, false otherwise. If true, a mouse move will fire the OnDrag method, and a button release will result in an OnRelease call. If false, nothing happens for these events.
virtual bool gcp::Tool::OnClicked ( )
protectedvirtual

Called from OnClicked(View*,gcu::Object*,double,doubl,unsigned int) when a click occured. This method must be overriden in derived classes, and return true if the drag and release events are meaningful for the tool in the current context. Default implementation does nothing and returns false.

Returns
true if drag and release events are needed, false otherwise.
virtual void gcp::Tool::OnConfigChanged ( )
inlinevirtual

Callback for a settings change event. Only tools which are dependent on some configuration key need to override this method. Default does nothing.

Definition at line 285 of file tool.h.

void gcp::Tool::OnDrag ( double  x,
double  y,
unsigned int  state 
)
Parameters
xthe horizontal position of the mouse when the event occured.
ythe vertical position of the mouse when the event occured.
statea bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType in GDK documentation.

This method is called by the framework when the tool is active, the first mouse button is pressed and the mouse is moved.

virtual void gcp::Tool::OnDrag ( )
protectedvirtual

Called from OnDrag(double,double,unsigned int) when a drag event occured occured. This method must be overriden in derived classes if drag events are meaningful for the tool. Default implementation does nothing.

virtual bool gcp::Tool::OnKeyPress ( GdkEventKey *  event)
virtual

Called by the framework for the active tool when a key press event occurs. Default just returns false.

Returns
true to stop any further propagation of the event, false otherwise.
void gcp::Tool::OnKeyPressed ( unsigned int  code)
inline
Parameters
codethe state of the mofifier keys as given inthe state field or some GdkEvent derived structures.

Called by the framework when a modifier key has been pressed, updates m_nState, and calls Tool::OnChangeState ().

Definition at line 181 of file tool.h.

References m_nState, and OnChangeState().

virtual bool gcp::Tool::OnKeyRelease ( GdkEventKey *  event)
virtual

Called by the framework for the active tool when a key release event occurs. Default just returns false.

Returns
true to stop any further propagation of the event, false otherwise.
void gcp::Tool::OnKeyReleased ( unsigned int  code)
inline
Parameters
codethe state of the mofifier keys as given inthe state field or some GdkEvent derived structures.

Called by the framework when a modifier key has been released, updates m_nState, and calls Tool::OnChangeState ().

Definition at line 189 of file tool.h.

References m_nState, and OnChangeState().

void gcp::Tool::OnLeaveNotify ( View pView,
unsigned int  state 
)
Parameters
pViewthe view instance owning the event.
statea bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType in GDK documentation.

This method is called by the framework when the tool is active and the mouse is moved outside the current view.

virtual void gcp::Tool::OnLeaveNotify ( )
protectedvirtual

Called from OnLeaveNotify(gcp::View,unsigned int) when a leave notify event occured. This method must be overriden in derived classes if leave notify events are meaningful for the tool. Default implementation does nothing.

void gcp::Tool::OnMotion ( View pView,
gcu::Object pObject,
double  x,
double  y,
unsigned int  state 
)
Parameters
pViewthe view instance owning the event.
pObjectthe Object on which the click occured.
xthe horizontal position of the mouse when the event occured.
ythe vertical position of the mouse when the event occured.
statea bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType in GDK documentation.

This method is called by the framework when the tool is active, the first mouse button is not pressed and the mouse is moved.

virtual void gcp::Tool::OnMotion ( )
protectedvirtual

Called from OnMotion(gcp::View,double,double,unsigned int) when a motion event occured. This method must be overriden in derived classes if motion events are meaningful for the tool. Default implementation does nothing.

virtual bool gcp::Tool::OnReceive ( GtkClipboard *  clipboard,
GtkSelectionData *  data,
int  type 
)
virtual

Called by the framework when clipboard data are available. Tools for which this is meaningful must have an overriden version of this method.

virtual bool gcp::Tool::OnRedo ( )
virtual

Called by the framework when the user requests to redo the last undone change. Tools such as text editing tools for which this is meaningful must have an overriden version of this method.

void gcp::Tool::OnRelease ( double  x,
double  y,
unsigned int  state 
)
Parameters
xthe horizontal position of the mouse when the event occured.
ythe vertical position of the mouse when the event occured.
statea bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType in GDK documentation.

This method is called by the framework when the tool is active and the first mouse button is released.

virtual void gcp::Tool::OnRelease ( )
protectedvirtual

Called from OnRelease(double,double,unsigned int) when a button release event occured. This method must be overriden in derived classes if button release events are meaningful for the tool. Default implementation does nothing.

bool gcp::Tool::OnRightButtonClicked ( View pView,
gcu::Object pObject,
double  x,
double  y,
gcu::UIManager UIManager 
)
Parameters
pViewthe view where the event occured.
pObjectthe object on which the event occured.
xthe horizontal position of the mouse when the event occured.
ythe vertical position of the mouse when the event occured.
UIManagerthe gcu::UIManager in use.

This method is called by the framework when the tool is active and the right mouse button is pressed. It is used to add tool specific menu items to the contextual menu. It calls OnRightButtonClicked(gcu::UIManager*).

Returns
true if at least one menu item was added, false otherwise.
virtual bool gcp::Tool::OnRightButtonClicked ( gcu::UIManager UIManager)
virtual
Parameters
UIManagerthe gcu::UIManager in use.

Adds menu items to the contextual menu. Default implementation do not add any menu item and returns false. Derived classes for which menu items exist must override this method.

Returns
true if at least one menu item was added, false otherwise.
virtual bool gcp::Tool::OnUndo ( )
virtual

Called by the framework when the user requests to undo the last change. Tools such as text editing tools for which this is meaningful must have an overriden version of this method.

virtual bool gcp::Tool::PasteSelection ( GtkClipboard *  clipboard)
virtual

Called by the framework to cut the selection. Tools for which it is meaningful must have an overriden version of this method.

virtual void gcp::Tool::PushNode ( xmlNodePtr  node)
virtual
Parameters
nodean xml node to push on the tools private undo stack.

Used to store a node after a change while editing a text object by text tools.

Member Data Documentation

bool gcp::Tool::m_bAllowed
protected

if true, the intended operation is allowed. Default value is true, each tool must set this flag to false if necessary.

Definition at line 408 of file tool.h.

bool gcp::Tool::m_bChanged
protected

Flag that might be used by tools to store whether they changed something since the last click (and before releasing the button).

Definition at line 391 of file tool.h.

double gcp::Tool::m_dZoomFactor
protected

The zoom factor when the click occured.

Definition at line 386 of file tool.h.

gccv::Item* gcp::Tool::m_Item
protected

The item on which the last click occured if any.

Definition at line 382 of file tool.h.

unsigned int gcp::Tool::m_nState
protected

The state of modifier keys as a GdkModifierType values combination.

Definition at line 395 of file tool.h.

Referenced by OnKeyPressed(), and OnKeyReleased().

gcp::Tool::m_OwnStatus
protected

Whether the tool owns the status bar text.

Definition at line 421 of file tool.h.

gcp::Application* gcp::Tool::m_pApp
protected

The application owning the tool.

Definition at line 399 of file tool.h.

Referenced by GetApplication().

WidgetData* gcp::Tool::m_pData
protected

The widget data for the current active canvas.

Definition at line 374 of file tool.h.

gcu::Object* gcp::Tool::m_pObject
protected

The object on which the last click occured or NULL.

Definition at line 362 of file tool.h.

gcu::Object* gcp::Tool::m_pObjectGroup
protected

The group to which m_pObject belongs if any.

Definition at line 366 of file tool.h.

View* gcp::Tool::m_pView
protected

The active gcp::View.

Definition at line 370 of file tool.h.

GtkWidget* gcp::Tool::m_pWidget
protected

The active canvas widget.

Definition at line 378 of file tool.h.

double gcp::Tool::m_x
protected

The current x position of the mouse cursor.

Definition at line 354 of file tool.h.

double gcp::Tool::m_x0
protected

x coordinate for the last mouse click (unless the tool modified it).

Definition at line 336 of file tool.h.

double gcp::Tool::m_x1
protected

x coordinate for the last mouse click (unless the tool modified it). It might be used by tools necessitating two pairs of coordinates.

Definition at line 345 of file tool.h.

double gcp::Tool::m_y
protected

The current y position of the mouse cursor.

Definition at line 358 of file tool.h.

double gcp::Tool::m_y0
protected

y coordinate for the last mouse click (unless the tool modified it).

Definition at line 340 of file tool.h.

double gcp::Tool::m_y1
protected

y coordinate for the last mouse click (unless the tool modified it). It might be used by tools necessitating two pairs of coordinates.

Definition at line 350 of file tool.h.

std::set<std::string> gcp::Tool::ModifiedObjects
protected

A set of modified objects tools might use to track what they did modify.

Definition at line 403 of file tool.h.


The documentation for this class was generated from the following file: