Warning, file /office/calligra/braindump/src/Canvas.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2006,2007 Thorsten Zachmann <zachmann@kde.org> 0003 * Copyright (c) 2009,2010 Cyrille Berger <cberger@cberger.net> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; 0008 * either version 2, or (at your option) any later version of the License. 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 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public License 0016 * along with this library; see the file COPYING. 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 _CANVAS_H 0022 #define _CANVAS_H 0023 0024 #include <QWidget> 0025 #include <QList> 0026 0027 #include <KoCanvasBase.h> 0028 0029 class View; 0030 class RootSection; 0031 class Section; 0032 0033 /// Widget that shows a KoPAPage 0034 class Canvas : public QWidget, public KoCanvasBase 0035 { 0036 Q_OBJECT 0037 public: 0038 explicit Canvas(View * view, RootSection * doc, Section* currentSection); 0039 ~Canvas(); 0040 0041 /// Returns pointer to the KoPADocument 0042 RootSection* rootSection() const { 0043 return m_doc; 0044 } 0045 0046 /// reimplemented method 0047 virtual void addCommand(KUndo2Command *command); 0048 /// reimplemented method 0049 virtual KoShapeManager * shapeManager() const; 0050 /// reimplemented method 0051 virtual void updateCanvas(const QRectF& rc); 0052 /// reimplemented method 0053 virtual void updateInputMethodInfo(); 0054 0055 KoToolProxy * toolProxy() const { 0056 return m_toolProxy; 0057 } 0058 KoViewConverter *viewConverter() const; 0059 QWidget* canvasWidget() { 0060 return this; 0061 } 0062 const QWidget* canvasWidget() const { 0063 return this; 0064 } 0065 KoUnit unit() const; 0066 const QPoint & documentOffset() const; 0067 QPoint documentOrigin() const; 0068 0069 View* koPAView() const { 0070 return m_view; 0071 } 0072 0073 virtual void gridSize(qreal *horizontal, qreal *vertical) const; 0074 virtual bool snapToGrid() const; 0075 virtual void setCursor(const QCursor &cursor); 0076 public Q_SLOTS: 0077 /** 0078 * Update the origin of the document. 0079 */ 0080 void updateOriginAndSize(); 0081 0082 void setDocumentOffset(const QPoint &offset); 0083 0084 protected: 0085 virtual void focusInEvent(QFocusEvent * event); 0086 0087 Q_SIGNALS: 0088 void documentRect(const QRectF&); 0089 void canvasReceivedFocus(); 0090 0091 /** 0092 * Emitted when the entire controller size changes 0093 * @param size the size in widget pixels. 0094 */ 0095 void sizeChanged(const QSize & size); 0096 0097 /// Emitted when updateCanvas has been called. 0098 void canvasUpdated(); 0099 0100 protected: 0101 /// reimplemented method from superclass 0102 void paintEvent(QPaintEvent* event); 0103 /// reimplemented method from superclass 0104 void tabletEvent(QTabletEvent *event); 0105 /// reimplemented method from superclass 0106 void mousePressEvent(QMouseEvent *event); 0107 /// reimplemented method from superclass 0108 void mouseDoubleClickEvent(QMouseEvent *event); 0109 /// reimplemented method from superclass 0110 void mouseMoveEvent(QMouseEvent *event); 0111 /// reimplemented method from superclass 0112 void mouseReleaseEvent(QMouseEvent *event); 0113 /// reimplemented method from superclass 0114 void keyPressEvent(QKeyEvent *event); 0115 /// reimplemented method from superclass 0116 void keyReleaseEvent(QKeyEvent *event); 0117 /// reimplemented method from superclass 0118 void wheelEvent(QWheelEvent * event); 0119 /// reimplemented method from superclass 0120 void closeEvent(QCloseEvent * event); 0121 /// reimplemented method from superclass 0122 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; 0123 /// reimplemented method from superclass 0124 virtual void inputMethodEvent(QInputMethodEvent *event); 0125 0126 /// reimplemented method from superclass 0127 virtual void resizeEvent(QResizeEvent * event); 0128 0129 private: 0130 void updateOffset(); 0131 /** 0132 * Shows the default context menu 0133 * @param globalPos global position to show the menu at. 0134 * @param actionList action list to be inserted into the menu 0135 */ 0136 void showContextMenu(const QPoint& globalPos, const QList<QAction*>& actionList); 0137 /// Sets the canvas background color to the given color 0138 void setBackgroundColor(const QColor &color); 0139 0140 QPoint widgetToView(const QPoint& p) const; 0141 QRect widgetToView(const QRect& r) const; 0142 QPoint viewToWidget(const QPoint& p) const; 0143 QRect viewToWidget(const QRect& r) const; 0144 private: 0145 QPoint m_origin; 0146 View * m_view; 0147 RootSection* m_doc; 0148 KoShapeManager * m_shapeManager; 0149 KoToolProxy * m_toolProxy; 0150 QPoint m_documentOffset; 0151 QPoint m_originalOffset; 0152 QRectF m_oldDocumentRect; 0153 QRect m_oldViewDocumentRect; 0154 0155 }; 0156 0157 #endif /* KOPACANVAS_H */