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 / canvasmode.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-12-02  |  4.6 KB  |  153 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_MODE_H
  19. #define CANVAS_MODE_H
  20.  
  21. #include "scribusapi.h"
  22.  
  23. #include <QMap>
  24. #include <QPen>
  25. #include <QBrush>
  26.  
  27. class QDragEnterEvent;
  28. class QDragMoveEvent;
  29. class QDragLeaveEvent;
  30. class QDropEvent;
  31. class QEvent;
  32. class QInputMethodEvent;
  33. class QImage;
  34. class QMouseEvent;
  35. class QKeyEvent;
  36. class QPainter;
  37.  
  38. class  Canvas;
  39. struct CanvasViewMode;
  40. class  PanGesture;
  41. class  ScribusDoc;
  42. class  ScribusView;
  43. class  ScribusMainWindow;
  44. class  PageItem;
  45. class  PageItemPreview;
  46.  
  47. /** These aren't real appmodes but open a new window or override behaviour for a short time */
  48. enum SubMode
  49. {
  50.     submodeFirstSubmode = 1000,
  51.     submodePaintingDone,    // return to normal mode
  52.     submodeEndNodeEdit,     // return from node/shape editing
  53.     submodeLoadPic,         // open GetImage dialog
  54.     submodeStatusPic,       // open ManageImages dialog
  55.     submodeEditExternal,    // open external image editor
  56.     submodeAnnotProps,      // open properties dialog
  57.     submodeLastSubmode
  58. };
  59.  
  60.  
  61. /**
  62.   This class is a superclass for all mode handlers.
  63.   By default, all events are ignored.
  64.  */
  65. class SCRIBUS_API CanvasMode : public QObject
  66. {
  67.     Q_OBJECT
  68. protected:
  69.     CanvasMode (ScribusView* view);
  70.     
  71. public:
  72.     static CanvasMode* createForAppMode(ScribusView* view, int appMode);
  73.     
  74.     /**
  75.       Is called when this mode becomes active, either because it was selected by the user
  76.       (fromgesture == false) or because a gesture completed and the canvas returns back to
  77.       this mode (fromGesture == true)
  78.      */
  79.     virtual void activate(bool fromGesture) {}
  80.     /**
  81.       Is called when this mode becomes inactive, either because the canvas switches to
  82.       another mode (forGesture == false) or because a gesture is activated (forGesture == true)
  83.      */
  84.     virtual void deactivate(bool forGesture) {}
  85.     
  86.     virtual void enterEvent(QEvent *) {}
  87.     virtual void leaveEvent(QEvent *) {}
  88.  
  89.     virtual void dragEnterEvent(QDragEnterEvent *e) {}
  90.     virtual void dragMoveEvent(QDragMoveEvent *e) {}
  91.     virtual void dragLeaveEvent(QDragLeaveEvent *e) {}
  92.     virtual void dropEvent(QDropEvent *e) {}
  93.     
  94.     virtual void mouseDoubleClickEvent(QMouseEvent *m) {}
  95.     virtual void mouseReleaseEvent(QMouseEvent *m) {}
  96.     virtual void mouseMoveEvent(QMouseEvent *m) {}
  97.     virtual void mousePressEvent(QMouseEvent *m) {}
  98.  
  99.     virtual void keyPressEvent(QKeyEvent *e) {}
  100.     virtual void keyReleaseEvent(QKeyEvent *e) {}
  101.     virtual void inputMethodEvent(QInputMethodEvent *e) {}
  102.  
  103.     /**
  104.         Sets appropiate values for this canvas mode
  105.      */
  106.     virtual void updateViewMode(CanvasViewMode* viewmode);
  107.     
  108.     /**
  109.         Draws the controls for this mode and the selection marker. 
  110.      If viewmode.drawSelectionWithControls is true, also draws the selection contents first.
  111.      */
  112.     virtual void drawControls(QPainter* p) { } 
  113.     
  114.  
  115.     /** Draws the regular selection marker */
  116.     void drawSelection(QPainter* psx, bool drawHandles);
  117.     /** Draws an outline of selected items */
  118.     void drawOutline(QPainter* p, double scalex=1.0, double scaley=1.0, double deltax=0.0, double deltay=0.0);
  119. #ifdef GESTURE_FRAME_PREVIEW
  120.     // I donΓÇÖt know why the methods above have been implemented here and left non-virtual.
  121.     // I need to setup some companion members - pm
  122.     private:
  123.     QMap<PageItem*, PageItemPreview*> m_pixmapCache;
  124.     public:
  125.     void clearPixmapCache();
  126. #endif // GESTURE_FRAME_PREVIEW
  127.     void setModeCursor();
  128.     
  129.     /** main canvas modes dont have a delegate */
  130.     virtual CanvasMode* delegate() { return 0; }
  131.     ScribusView* view() const { return m_view; }
  132.     virtual ~CanvasMode();
  133.     
  134.  
  135. protected:
  136.     ScribusView * const m_view;    
  137.     Canvas * const m_canvas;
  138.     ScribusDoc * const m_doc;
  139.     PanGesture * m_panGesture;
  140.     
  141.     void setResizeCursor(int how, double rot = 0.0);
  142.     bool commonMouseMove(QMouseEvent *m);
  143.     void commonDrawControls(QPainter* p, bool drawHandles);
  144.     
  145.     private:
  146.         QMap<QString,QPen> m_pen;
  147.         QMap<QString,QBrush> m_brush;
  148.         
  149. };
  150.  
  151.  
  152. #endif
  153.