home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / canvasgesture_linemove.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-01-11  |  3.1 KB  |  100 lines

  1. /*
  2.  For general Scribus (>=1.3.2) copyright and licensing information please refer
  3.  to the COPYING file provided with the program. Following this notice may exist
  4.  a copyright and/or license notice that predates the release of Scribus 1.3.2
  5.  for which a new license (GPL+exception) is in place.
  6.  */
  7. /***************************************************************************
  8. *                                                                         *
  9. *   This program is free software; you can redistribute it and/or modify  *
  10. *   it under the terms of the GNU General Public License as published by  *
  11. *   the Free Software Foundation; either version 2 of the License, or     *
  12. *   (at your option) any later version.                                   *
  13. *                                                                         *
  14. ***************************************************************************/
  15.  
  16.  
  17.  
  18. #ifndef CANVAS_GESTURE_LINEMOVE_H
  19. #define CANVAS_GESTURE_LINEMOVE_H
  20.  
  21. #include <QRectF>
  22.  
  23. #include "scribusapi.h"
  24. #include "canvasgesture.h"
  25. #include "canvasmode.h"
  26.  
  27. class QDragEnterEvent;
  28. class QDragMoveEvent;
  29. class QDragLeaveEvent;
  30. class QDropEvent;
  31. class QEvent;
  32. class QInputMethodEvent;
  33. class QMouseEvent;
  34. class QKeyEvent;
  35. class QPainter;
  36. class QRubberBand;
  37. class PageItem;
  38. class PageItem_Line;
  39.  
  40. /**
  41.   This class realizes moving the endpoints of a line on behalf of its parent mode.
  42.   The user presses the mousebutton at one endpoint of the line, drags it to a new position
  43.   and releases the mousebutton.
  44.  
  45.   When the parent mode becomes active again, it can retrieve the new line with endPoint().
  46.  
  47.   If the constructur with a pageitem is used, the gesture will change the item directly.
  48.  */
  49. class SCRIBUS_API LineMove : public CanvasGesture
  50. {
  51. public:
  52.     LineMove (CanvasMode* parent): CanvasGesture(parent), m_haveLineItem(false), m_bounds(0,0,0,0) {};
  53.     ~LineMove() {}
  54.     
  55.     /**
  56.         Prepare a LineMove without attached PageItem
  57.      */
  58.     void prepare(QPointF start, QPointF end);
  59.     
  60.     /** Prepare a LineMove gesture for a PageItem_Line. 
  61.         useOriginAsEndpoint allows to drag the origin (topleft) in the same way as the other end.
  62.     */
  63.     void prepare(PageItem_Line* line, bool useOriginAsEndpoint = false);
  64.     
  65.     void clear();
  66.     
  67.     virtual void activate(bool);
  68.     virtual void deactivate(bool);
  69.     virtual void mouseReleaseEvent(QMouseEvent *m);
  70.     virtual void mouseMoveEvent(QMouseEvent *m);
  71.     /**
  72.         prepares the LineMove for the the current selection. Sets 'haveLineItem'
  73.         to false if the current selection is not a single lineitem.
  74.      */
  75.     virtual void mousePressEvent(QMouseEvent *m);
  76.     virtual void drawControls(QPainter*);
  77.     
  78.     void setStartPoint(QPointF canvasStart);
  79.     void setEndPoint(QPointF canvasEnd);
  80.  
  81.     QPointF startPoint() const { return m_bounds.topLeft(); }
  82.     QPointF endPoint() const { return m_bounds.bottomRight(); }
  83.  
  84.     bool haveLineItem() const { return m_haveLineItem; }
  85.     
  86. private:
  87.     bool m_haveLineItem;
  88.     bool m_useOriginAsEndpoint;
  89.     QRectF m_bounds;
  90.     PageItem* m_line;
  91.     void adjustBounds(QMouseEvent* m);
  92.     void doResize();
  93.     void setRotation(double rot);
  94.     double rotation() const;
  95.     double length() const;
  96. };
  97.  
  98.  
  99. #endif
  100.