/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef SELECTTOOL_H
#define SELECTTOOL_H

#include <generictool.h>

class Matrix;
/**
@author Hans Oischinger
*/
class SelectTool : public GenericTool
{
public:
  SelectTool();

  virtual ~SelectTool();

  virtual void activate();

  virtual QString name() const;
  virtual QString icon() const { return "14_select"; }
  virtual QString category() const { return "manipulation"; }
  virtual QString statusText() const;
  virtual uint priority() const { return 1; }
  virtual QString contextHelp() const;

protected:
  virtual void setCursor() const;

  virtual void mouseButtonPress();
  virtual void mouseButtonRelease();
  virtual void mouseDrag();
  virtual void mouseDragRelease();
  //   virtual void mouseDragCtrlPressed();
  //   virtual void mouseDragCtrlReleased();
  //   virtual void mouseDragShiftPressed();
  //   virtual void mouseDragShiftReleased();
  //   virtual void arrowKeyReleased( Qt::Key );

  //   virtual void cancel();

  /**
   * Call in mousePressEvent.
   * Will either set m_selectedHandle to the Selection's HandleNode that has been
   * clicked or else select the item under the mouse
   */
  void selectElementsUnderPoint( const QPoint& pos );

  /**
   * Call after moving elements with the mouse (usually in mouseReleaseEvent).
   * Don't forget to set m_dragOffset on mousePressEvent.
   * @param p the position the element has been dropped
   */
  void fireMoveCMD( const QPoint& p );

  void fireScaleCMD();


  void updateStatusBar() const;

private:
  QRect m_selbbox;

  unsigned int m_selectedHandle;
  Matrix *m_currentMatrix;     // The matrix for the current mouse transformation
  double m_scalex, m_scaley;  // Scale factors for mouse transformations
  int m_tx, m_ty;             // Relative Translatiom factors for mouse transformations
  /*
   
    enum { normal, moving, scaling, rotating } m_state;
    bool m_lock;
   
    double m_s1;
    double m_s2;
    double m_distx;
    double m_disty;
    KoPoint m_sp;
    KoPoint m_current;*/
};

#endif
