Warning, file /office/calligra/libs/flake/KoCanvasControllerWidgetViewport_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 0003 * Copyright (C) 2007-2010 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KOCANVASCONTROLLERWIDGETVIEWPORT_P_H 0022 #define KOCANVASCONTROLLERWIDGETVIEWPORT_P_H 0023 0024 #include "KoCanvasControllerWidget.h" 0025 0026 #include <QWidget> 0027 0028 class Viewport; 0029 0030 class Viewport : public QWidget 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 0036 explicit Viewport(KoCanvasControllerWidget *parent); 0037 ~Viewport() override {} 0038 0039 void setCanvas(QWidget *canvas); 0040 QWidget *canvas() const { 0041 return m_canvas; 0042 } 0043 void setDocumentSize(const QSize &size); 0044 0045 /** 0046 * When true, a shadow is drawn around the canvas widet. 0047 */ 0048 void setDrawShadow(bool drawShadow); 0049 0050 public Q_SLOTS: 0051 void documentOffsetMoved(const QPoint &); 0052 0053 Q_SIGNALS: 0054 void sizeChanged(); 0055 0056 public: 0057 0058 void handleDragEnterEvent(QDragEnterEvent *event); 0059 void handleDropEvent(QDropEvent *event); 0060 void handleDragMoveEvent(QDragMoveEvent *event); 0061 void handleDragLeaveEvent(QDragLeaveEvent *event); 0062 void handlePaintEvent(QPainter &gc, QPaintEvent *event); 0063 void setMargin(int margin) { m_margin = margin; resetLayout(); } 0064 0065 private: 0066 0067 QPointF correctPosition(const QPoint &point) const; 0068 void repaint(KoShape *shape); 0069 0070 /** 0071 Decides whether the containing canvas widget should be as 0072 big as the viewport (i.e., no margins are visible) or whether 0073 there are margins to be left blank, and then places the canvas 0074 widget accordingly. 0075 */ 0076 void resetLayout(); 0077 0078 private: 0079 0080 KoCanvasControllerWidget *m_parent; 0081 KoShape *m_draggedShape; 0082 0083 bool m_drawShadow; 0084 QWidget *m_canvas; 0085 QSize m_documentSize; // Size in pixels of the document 0086 QPoint m_documentOffset; // Place where the canvas widget should 0087 int m_margin; // The viewport margin around the document 0088 }; 0089 0090 #endif