1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
/* This file is part of the KDE project
Copyright 2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CALLIGRA_SHEETS_SHEET_VIEW
#define CALLIGRA_SHEETS_SHEET_VIEW
#include <QObject>
#include <QPoint>
#include <QPointF>
#include <QRect>
#include "calligra_sheets_export.h"
class QPainter;
class QRect;
class QRectF;
class QSize;
class QSizeF;
class QColor;
class KoViewConverter;
namespace Calligra
{
namespace Sheets
{
class CellView;
class Region;
class Sheet;
class CanvasBase;
/**
* \ingroup Painting
* The SheetView controls the painting of the sheets' cells.
* It caches a set of CellViews.
*/
class CALLIGRA_SHEETS_COMMON_EXPORT SheetView : public QObject
{
Q_OBJECT
friend class CellView;
public:
/**
* Constructor.
*/
explicit SheetView(const Sheet* sheet);
/**
* Destructor.
*/
~SheetView();
/**
* \return the Sheet
*/
const Sheet* sheet() const;
/**
* Sets the KoViewConverter used by this SheetView.
*/
void setViewConverter(const KoViewConverter* viewConverter);
/**
* \return the view in which the Sheet is painted
*/
const KoViewConverter* viewConverter() const;
/**
* Looks up a CellView for the position \p col , \p row in the cache.
* If no CellView exists yet, one is created and inserted into the cache.
*
* \return the CellView for the position
*/
#ifdef CALLIGRA_SHEETS_MT
CellView cellView(int col, int row);
CellView cellView(const QPoint& pos);
#else
const CellView& cellView(int col, int row);
const CellView& cellView(const QPoint& pos);
#endif
/**
* Set the cell range, that should be painted to \p rect .
* It also adjusts the cache size linear to the size of \p rect .
*/
void setPaintCellRange(const QRect& rect);
/**
* Invalidates all cached CellViews in \p region .
*/
void invalidateRegion(const Region& region);
/**
* Invalidates all CellViews, the cached and the default.
*/
virtual void invalidate();
/**
* Paints the cells.
*/
virtual void paintCells(QPainter& painter, const QRectF& paintRect, const QPointF& topLeft, CanvasBase* canvas = 0, const QRect& visibleRect = QRect());
QPoint obscuringCell(const QPoint& obscuredCell) const;
QSize obscuredRange(const QPoint& obscuringCell) const;
QRect obscuredArea(const QPoint& cell) const;
bool isObscured(const QPoint& cell) const;
bool obscuresCells(const QPoint& cell) const;
QSize totalObscuredRange() const;
/*
* Highlighting cells.
*/
bool isHighlighted(const QPoint& cell) const;
void setHighlighted(const QPoint& cell, bool isHighlighted);
bool hasHighlightedCells() const;
void clearHighlightedCells();
QPoint activeHighlight() const;
void setActiveHighlight(const QPoint& cell);
void setHighlightMaskColor(const QColor& color);
void setHighlightColor(const QColor& color);
void setActiveHighlightColor(const QColor& color);
public Q_SLOTS:
void updateAccessedCellRange(const QPoint& location = QPoint());
Q_SIGNALS:
void visibleSizeChanged(const QSizeF&);
void obscuredRangeChanged(const QSize&);
protected:
virtual CellView* createDefaultCellView();
virtual CellView* createCellView(int col, int row);
QRect paintCellRange() const;
protected:
/**
* Helper method for invalidateRegion().
* Invalidates all cached CellViews in \p range .
* \internal
*/
virtual void invalidateRange(const QRect& range);
/**
* Marks other CellViews in \p range as obscured by the CellView at \p position .
* Used by CellView.
*/
void obscureCells(const QPoint& position, int numXCells, int numYCells);
/**
* Returns the default CellView.
* Used by CellView.
*/
#ifdef CALLIGRA_SHEETS_MT
CellView defaultCellView() const;
#else
const CellView& defaultCellView() const;
#endif
private:
Q_DISABLE_COPY(SheetView)
class Private;
Private * const d;
};
} // namespace Sheets
} // namespace Calligra
#endif // CALLIGRA_SHEETS_SHEET_VIEW
|