File indexing completed on 2024-05-12 16:35:46

0001 /* This file is part of the KDE project
0002    Copyright 2006 - Robert Knight <robertknight@gmail.com>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef CALLIGRA_SHEETS_HEADERWIDGETS
0021 #define CALLIGRA_SHEETS_HEADERWIDGETS
0022 
0023 #include <QWidget>
0024 #include "Headers.h"
0025 
0026 class QRubberBand;
0027 
0028 
0029 namespace Calligra
0030 {
0031 namespace Sheets
0032 {
0033 class Canvas;
0034 class View;
0035 
0036 /**
0037  * The widget above the cells showing the column headers.
0038  */
0039 class ColumnHeaderWidget : public QWidget, public ColumnHeader
0040 {
0041     Q_OBJECT
0042 public:
0043     ColumnHeaderWidget(QWidget *_parent, Canvas *_canvas, View *_view);
0044     ~ColumnHeaderWidget() override;
0045 
0046     void updateColumns(int from, int to) override;
0047     QSizeF size() const override { return QWidget::size(); }
0048     void setCursor(const QCursor& cursor) override { QWidget::setCursor(cursor); }
0049     void scroll(qreal dx, qreal dy) override { QWidget::scroll(dx, dy); }
0050     QPalette palette() const override { return QWidget::palette(); }
0051     void update() override { QWidget::update(); }
0052 private Q_SLOTS:
0053     void slotAutoScroll(const QPoint& distance);
0054 
0055 protected:
0056     void paintEvent(QPaintEvent* _ev) override;
0057     void mousePressEvent(QMouseEvent* _ev) override;
0058     void mouseReleaseEvent(QMouseEvent* _ev) override;
0059     void mouseDoubleClickEvent(QMouseEvent* _ev) override;
0060     void mouseMoveEvent(QMouseEvent* _ev) override;
0061     void wheelEvent(QWheelEvent*) override;
0062     void focusOutEvent(QFocusEvent* ev) override;
0063     void resizeEvent(QResizeEvent * _ev) override;
0064 
0065     void paintSizeIndicator(int mouseX) override;
0066     void removeSizeIndicator() override;
0067     
0068 private Q_SLOTS:
0069     void toolChanged(const QString& toolId);
0070 
0071 private:
0072     QRubberBand* m_rubberband;
0073 };
0074 
0075 /**
0076  * The widget left to the cells showing the row headers.
0077  */
0078 class RowHeaderWidget : public QWidget, public RowHeader
0079 {
0080     Q_OBJECT
0081 public:
0082     RowHeaderWidget(QWidget *_parent, Canvas *_canvas, View *_view);
0083     ~RowHeaderWidget() override;
0084 
0085     void updateRows(int from, int to) override;
0086     QSizeF size() const override { return QWidget::size(); }
0087     void setCursor(const QCursor& cursor) override { QWidget::setCursor(cursor); }
0088     void scroll(qreal dx, qreal dy) override { QWidget::scroll(dx, dy); }
0089     QPalette palette() const override { return QWidget::palette(); }
0090     void update() override { QWidget::update(); }
0091 private Q_SLOTS:
0092     void slotAutoScroll(const QPoint& distance);
0093 
0094 protected:
0095     void paintEvent(QPaintEvent* _ev) override;
0096     void mousePressEvent(QMouseEvent* _ev) override;
0097     void mouseReleaseEvent(QMouseEvent* _ev) override;
0098     void mouseMoveEvent(QMouseEvent* _ev) override;
0099     void mouseDoubleClickEvent(QMouseEvent* _ev) override;
0100     void wheelEvent(QWheelEvent*) override;
0101     void focusOutEvent(QFocusEvent* ev) override;
0102     
0103     void paintSizeIndicator(int mouseY) override;
0104     void removeSizeIndicator() override;
0105 private Q_SLOTS:
0106     void toolChanged(const QString& toolId);
0107 
0108 private:
0109     QRubberBand* m_rubberband;
0110 };
0111 
0112 /**
0113  * The widget in the top left corner of the canvas,
0114  * responsible for selecting all cells in a sheet.
0115  */
0116 class SelectAllButtonWidget : public QWidget, public SelectAllButton
0117 {
0118     Q_OBJECT
0119 public:
0120     explicit SelectAllButtonWidget(CanvasBase* canvasBase);
0121     ~SelectAllButtonWidget() override;
0122 
0123     QPalette palette() const override { return QWidget::palette(); }
0124     void update() override { QWidget::update(); }
0125 protected:
0126     void paintEvent(QPaintEvent* event) override;
0127     void mousePressEvent(QMouseEvent* event) override;
0128     void mouseReleaseEvent(QMouseEvent* event) override;
0129     void wheelEvent(QWheelEvent*) override;
0130 
0131 private Q_SLOTS:
0132     void toolChanged(const QString& toolId);
0133 };
0134 
0135 } // namespace Sheets
0136 } // namespace Calligra
0137 
0138 #endif