File indexing completed on 2024-05-05 08:41:18
0001 /* 0002 * Copyright (C) 2010-2015 by Stephen Allewell 0003 * steve.allewell@gmail.com 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 */ 0010 0011 #ifndef PageLayoutEditor_H 0012 #define PageLayoutEditor_H 0013 0014 #include <QWidget> 0015 0016 #include "Boundary.h" 0017 0018 class Document; 0019 class PagePreviewListWidgetItem; 0020 class QMouseEvent; 0021 0022 class PageLayoutEditor : public QWidget 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 PageLayoutEditor(QWidget *, Document *); 0028 virtual ~PageLayoutEditor() = default; 0029 0030 double zoomFactor() const; 0031 int gridSize() const; 0032 bool showGrid() const; 0033 0034 void setPagePreview(PagePreviewListWidgetItem *); 0035 void updatePagePreview(); 0036 void setZoomFactor(double); 0037 void setGridSize(int); 0038 void setShowGrid(bool); 0039 void setSelecting(bool); 0040 0041 int scale(int) const; 0042 int unscale(int) const; 0043 QPoint scale(const QPoint &) const; 0044 QPoint unscale(const QPoint &) const; 0045 QRect scale(const QRect &) const; 0046 QRect unscale(const QRect &) const; 0047 0048 signals: 0049 void selectionMade(QRect); 0050 void elementGeometryChanged(); 0051 0052 protected: 0053 virtual void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; 0054 virtual void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; 0055 virtual void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; 0056 virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; 0057 0058 private slots: 0059 void contextMenuRequestedOn(const QPoint &); 0060 0061 private: 0062 QPoint toSnap(const QPoint &) const; 0063 0064 Document *m_document; 0065 PagePreviewListWidgetItem *m_pagePreview; 0066 Element *m_elementUnderCursor; 0067 0068 int m_paperWidth; 0069 int m_paperHeight; 0070 0071 bool m_selecting; 0072 bool m_resizing; 0073 bool m_moved; 0074 Boundary m_boundary; 0075 QRect m_rubberBand; 0076 QPoint m_start; 0077 QPoint m_end; 0078 const QPoint *m_node; 0079 0080 bool m_showGrid; 0081 int m_gridSize; 0082 double m_zoomFactor; 0083 }; 0084 0085 #endif // PageLayoutEditor_H