File indexing completed on 2024-05-12 16:35:43
0001 /* This file is part of the KDE project 0002 Copyright 2006-2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0003 Copyright 1999-2002,2004 Laurent Montel <montel@kde.org> 0004 Copyright 2002-2005 Ariya Hidayat <ariya@kde.org> 0005 Copyright 1999-2001,2003 David Faure <faure@kde.org> 0006 Copyright 2001-2003 Philipp Mueller <philipp.mueller@gmx.de> 0007 Copyright 2002-2003 Norbert Andres <nandres@web.de> 0008 Copyright 2000-2001 Werner Trobin <trobin@kde.org> 0009 Copyright 2002 Harri Porten <porten@kde.org> 0010 Copyright 2002 John Dailey <dailey@vt.edu> 0011 Copyright 1999-2000 Torben Weis <weis@kde.org> 0012 Copyright 2000 Wilco Greven <greven@kde.org> 0013 Copyright 1999 Boris Wedl <boris.wedl@kfunigraz.ac.at> 0014 Copyright 1999 Reginald Stadlbauer <reggie@kde.org> 0015 0016 This library is free software; you can redistribute it and/or 0017 modify it under the terms of the GNU Library General Public 0018 License as published by the Free Software Foundation; either 0019 version 2 of the License, or (at your option) any later version. 0020 0021 This library is distributed in the hope that it will be useful, 0022 but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0024 Library General Public License for more details. 0025 0026 You should have received a copy of the GNU Library General Public License 0027 along with this library; see the file COPYING.LIB. If not, write to 0028 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0029 Boston, MA 02110-1301, USA. 0030 */ 0031 0032 #ifndef CALLIGRA_SHEETS_CANVAS 0033 #define CALLIGRA_SHEETS_CANVAS 0034 0035 #include <QList> 0036 #include <QWidget> 0037 #include <QVariant> 0038 0039 #include <KoCanvasBase.h> 0040 0041 #include "sheets_common_export.h" 0042 #include "../Global.h" 0043 #include "CanvasBase.h" 0044 0045 class QDragLeaveEvent; 0046 class QDragMoveEvent; 0047 class QDropEvent; 0048 class QEvent; 0049 class QFocusEvent; 0050 class QKeyEvent; 0051 class QMouseEvent; 0052 class QPaintEvent; 0053 0054 namespace Calligra 0055 { 0056 namespace Sheets 0057 { 0058 class Cell; 0059 class Canvas; 0060 class ColumnHeader; 0061 class Doc; 0062 class Sheet; 0063 class RowHeader; 0064 class Selection; 0065 class View; 0066 0067 0068 /** 0069 * The scrollable area showing the cells. 0070 */ 0071 class CALLIGRA_SHEETS_COMMON_EXPORT Canvas : public QWidget, public CanvasBase 0072 { 0073 friend class ColumnHeader; 0074 friend class RowHeader; 0075 friend class View; 0076 friend class CellTool; 0077 0078 Q_OBJECT 0079 0080 public: 0081 explicit Canvas(View* view); 0082 ~Canvas() override; 0083 0084 View* view() const; 0085 0086 /// reimplemented method from KoCanvasBase 0087 QWidget* canvasWidget() override { 0088 return this; 0089 } 0090 const QWidget* canvasWidget() const override { 0091 return this; 0092 } 0093 0094 Sheet* activeSheet() const override; 0095 Calligra::Sheets::Selection* selection() const override; 0096 void setCursor(const QCursor &cursor) override; 0097 0098 public Q_SLOTS: 0099 void setDocumentOffset(const QPoint& offset) { 0100 CanvasBase::setDocumentOffset(offset); 0101 } 0102 void setDocumentSize(const QSizeF& size) { 0103 CanvasBase::setDocumentSize(size); 0104 } 0105 0106 Q_SIGNALS: 0107 /* virtual */ void documentSizeChanged(const QSize&) override; 0108 0109 protected: 0110 bool event(QEvent *e) override; 0111 void keyPressEvent(QKeyEvent* _ev) override { 0112 CanvasBase::keyPressed(_ev); 0113 } 0114 void paintEvent(QPaintEvent* _ev) override; 0115 void mousePressEvent(QMouseEvent* _ev) override; 0116 void mouseReleaseEvent(QMouseEvent* _ev) override; 0117 void mouseMoveEvent(QMouseEvent* _ev) override; 0118 void mouseDoubleClickEvent(QMouseEvent*) override; 0119 void focusInEvent(QFocusEvent* _ev) override { 0120 CanvasBase::focusIn(_ev); 0121 QWidget::focusInEvent(_ev); 0122 } 0123 void dragEnterEvent(QDragEnterEvent*) override; 0124 void dragMoveEvent(QDragMoveEvent*) override; 0125 void dragLeaveEvent(QDragLeaveEvent*) override; 0126 void dropEvent(QDropEvent*) override; 0127 /// reimplemented method from superclass 0128 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override { 0129 return CanvasBase::inputMethodQuery(query); 0130 } 0131 /// reimplemented method from superclass 0132 void inputMethodEvent(QInputMethodEvent *event) override { 0133 CanvasBase::inputMethodEvent(event); 0134 } 0135 /// reimplemented method from superclass 0136 void tabletEvent(QTabletEvent *e) override { 0137 CanvasBase::tabletEvent(e); 0138 } 0139 0140 public: 0141 void update() override { 0142 QWidget::update(); 0143 } 0144 void update(const QRectF& rect) override { 0145 QWidget::update(rect.toRect()); 0146 } 0147 Qt::LayoutDirection layoutDirection() const override { 0148 return QWidget::layoutDirection(); 0149 } 0150 QRectF rect() const override { 0151 return QWidget::rect(); 0152 } 0153 QSizeF size() const override { 0154 return QWidget::size(); 0155 } 0156 QPoint mapToGlobal(const QPointF& point) const override { 0157 return QWidget::mapToGlobal(point.toPoint()); 0158 } 0159 void updateMicroFocus() override { 0160 QWidget::updateMicroFocus(); 0161 } 0162 0163 KoZoomHandler* zoomHandler() const override; 0164 bool isViewLoading() const override; 0165 SheetView* sheetView(const Sheet* sheet) const override; 0166 void enableAutoScroll() override; 0167 void disableAutoScroll() override; 0168 void showContextMenu(const QPoint& globalPos) override; 0169 ColumnHeader* columnHeader() const override; 0170 RowHeader* rowHeader() const override; 0171 private: 0172 void setVertScrollBarPos(qreal pos) override; 0173 void setHorizScrollBarPos(qreal pos) override; 0174 0175 bool eventFilter(QObject *o, QEvent *e) override { 0176 return CanvasBase::eventFilter(o, e); 0177 } 0178 0179 private: 0180 Q_DISABLE_COPY(Canvas) 0181 0182 class Private; 0183 Private * const cd; 0184 }; 0185 0186 } // namespace Sheets 0187 } // namespace Calligra 0188 0189 #endif // CALLIGRA_SHEETS_CANVAS