kspread

Headers.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright 2006 - Robert Knight <robertknight@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KSPREAD_HEADERS
00021 #define KSPREAD_HEADERS
00022 
00023 #include <QWidget>
00024 
00025 class QLabel;
00026 class QRubberBand;
00027 
00028 class KoCanvasBase;
00029 
00030 namespace KSpread
00031 {
00032 class Canvas;
00033 class Selection;
00034 class View;
00035 
00039 class ColumnHeader : public QWidget
00040 {
00041     Q_OBJECT
00042 public:
00043     ColumnHeader(QWidget *_parent, Canvas *_canvas, View *_view);
00044     virtual ~ColumnHeader();
00045 
00046     int markerColumn() const {
00047         return  m_iSelectionAnchor;
00048     }
00049     void equalizeColumn(double resize);
00050 
00051     void updateColumns(int from, int to);
00052 
00053 private slots:
00054     void slotAutoScroll(const QPoint& distance);
00055 
00056 protected:
00057     virtual void paintEvent(QPaintEvent* _ev);
00058     virtual void mousePressEvent(QMouseEvent* _ev);
00059     virtual void mouseReleaseEvent(QMouseEvent* _ev);
00060     virtual void mouseDoubleClickEvent(QMouseEvent* _ev);
00061     virtual void mouseMoveEvent(QMouseEvent* _ev);
00062     virtual void wheelEvent(QWheelEvent*);
00063     virtual void focusOutEvent(QFocusEvent* ev);
00064     virtual void resizeEvent(QResizeEvent * _ev);
00065     void paintSizeIndicator(int mouseX);
00066 
00067     void drawText(QPainter& painter, const QFont& font, const QPointF& location, const QString& text, double width) const;
00068 
00069 private Q_SLOTS:
00070     void toolChanged(const QString& toolId);
00071 
00072 private:
00073     Canvas *m_pCanvas;
00074     View *m_pView;
00075 
00082     bool m_bSelection;
00083 
00089     int m_iSelectionAnchor;
00090 
00096     bool m_bResize;
00097 
00104     int m_iResizedColumn;
00105 
00109     int m_iResizePos;
00110 
00114     QLabel *m_lSize;
00115 
00119     bool m_bMousePressed;
00120 
00121     QRubberBand* m_rubberband;
00122     bool m_cellToolIsActive;
00123 };
00124 
00125 
00126 
00130 class RowHeader : public QWidget
00131 {
00132     Q_OBJECT
00133 public:
00134     RowHeader(QWidget *_parent, Canvas *_canvas, View *_view);
00135     virtual ~RowHeader();
00136 
00137     int markerRow() const {
00138         return  m_iSelectionAnchor;
00139     }
00140     void equalizeRow(double resize);
00141     void updateRows(int from, int to);
00142 
00143 private slots:
00144     void slotAutoScroll(const QPoint& distance);
00145 
00146 protected:
00147     virtual void paintEvent(QPaintEvent* _ev);
00148     virtual void mousePressEvent(QMouseEvent* _ev);
00149     virtual void mouseReleaseEvent(QMouseEvent* _ev);
00150     virtual void mouseMoveEvent(QMouseEvent* _ev);
00151     virtual void mouseDoubleClickEvent(QMouseEvent* _ev);
00152     virtual void wheelEvent(QWheelEvent*);
00153     virtual void focusOutEvent(QFocusEvent* ev);
00154     void paintSizeIndicator(int mouseY);
00155 
00156     void drawText(QPainter& painter, const QFont& font, const QPointF& location, const QString& text) const;
00157 
00158 private Q_SLOTS:
00159     void toolChanged(const QString& toolId);
00160 
00161 private:
00162     Canvas *m_pCanvas;
00163     View *m_pView;
00164 
00165     bool m_bSelection;
00166     int m_iSelectionAnchor;
00167     bool m_bResize;
00168     int m_iResizedRow;
00169     int m_iResizePos;
00173     QLabel *m_lSize;
00174 
00178     bool m_bMousePressed;
00179 
00180     QRubberBand* m_rubberband;
00181     bool m_cellToolIsActive;
00182 };
00183 
00184 
00185 
00190 class SelectAllButton : public QWidget
00191 {
00192     Q_OBJECT
00193 public:
00194     explicit SelectAllButton(KoCanvasBase* canvasBase, Selection* selection);
00195     virtual ~SelectAllButton();
00196 
00197 protected:
00198     virtual void paintEvent(QPaintEvent* event);
00199     virtual void mousePressEvent(QMouseEvent* event);
00200     virtual void mouseReleaseEvent(QMouseEvent* event);
00201     virtual void wheelEvent(QWheelEvent*);
00202 
00203 private Q_SLOTS:
00204     void toolChanged(const QString& toolId);
00205 
00206 private:
00207     KoCanvasBase* m_canvasBase;
00208     Selection* m_selection;
00209     bool   m_mousePressed;
00210     bool m_cellToolIsActive;
00211 };
00212 
00213 } // namespace KSpread
00214 #endif