# tool.h

Go to the documentation of this file.

    00001 // -*- C++ -*-
    00002
    00003 /*
    00004  * GChemPaint library
    00005  * tool.h
    00006  *
    00007  * Copyright (C) 2001-2008 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 <vector>
    00029 #include <string>
    00030 #include "widgetdata.h"
    00031 #include "view.h"
    00032 #include "operation.h"
    00033 #include <gcu/dialog.h>
    00034
    00036 namespace gcp {
    00037
    00038 class Application;
    00039
    00043 class Tool
    00044 {
    00045 public:
    00052         Tool (gcp::Application *App, std::string Id);
    00056         virtual ~Tool ();
    00057
    00074         bool OnClicked (View* pView, gcu::Object* pObject, double x, double y, unsigned int state);
    00075
    00084         void OnDrag (double x, double y, unsigned int state);
    00093         void OnRelease (double x, double y, unsigned int state);
    00107         bool OnRightButtonClicked (View* pView, gcu::Object* pObject, double x, double y, GtkUIManager *UIManager);
    00115         bool Activate (bool bState);
    00119         std::string& GetName () {return name;}
    00128         virtual bool OnRightButtonClicked (GtkUIManager *UIManager);
    00134         virtual void Activate ();
    00141         virtual bool Deactivate ();
    00149         void OnKeyPressed (unsigned int code) {m_nState |= code; OnChangeState ();}
    00157         void OnKeyReleased (unsigned int code) {if (m_nState & code) m_nState -= code; OnChangeState ();}
    00164         virtual bool OnEvent (GdkEvent* event);
    00174         virtual bool NotifyViewChange ();
    00179         virtual bool DeleteSelection ();
    00184         virtual bool CopySelection (GtkClipboard *clipboard);
    00189         virtual bool CutSelection (GtkClipboard *clipboard);
    00194         virtual bool PasteSelection (GtkClipboard *clipboard);
    00199         virtual void AddSelection (WidgetData* data);
    00204         virtual bool OnReceive (GtkClipboard *clipboard, GtkSelectionData *data, int type);
    00210         virtual bool OnUndo ();
    00216         virtual bool OnRedo ();
    00222         virtual void PushNode (xmlNodePtr node);
    00228         virtual GtkWidget *GetPropertyPage ();
    00236         virtual char const *GetHelpTag () {return "";}
    00237
    00238 protected:
    00248         virtual bool OnClicked ();
    00255         virtual void OnDrag ();
    00262         virtual void OnRelease ();
    00267         virtual void OnChangeState ();
    00268
    00269 protected:
    00273         double m_x0;
    00277         double m_y0;
    00282         double m_x1;
    00287         double m_y1;
    00291         double m_x;
    00295         double m_y;
    00299         gcu::Object *m_pObject;
    00303         gcu::Object *m_pObjectGroup;
    00307         View *m_pView;
    00311         WidgetData *m_pData;
    00315         GtkWidget *m_pWidget;
    00319         GnomeCanvasGroup *m_pGroup;
    00323         GnomeCanvasItem *m_pItem;
    00327         GnomeCanvasItem *m_pBackground;
    00331         double m_dZoomFactor;
    00336         bool m_bChanged;
    00340         unsigned int m_nState;
    00344         gcp::Application *m_pApp;
    00348         std::set<std::string> ModifiedObjects;
    00353         bool m_bAllowed;
    00354
    00355 private:
    00356         double lastx, lasty;
    00357         std::string name;
    00358         bool m_bPressed;
    00359 };
    00360
    00361 }       // namespace gcp
    00362
    00363 #endif // GCHEMPAINT_TOOL_H