Warning, file /office/calligra/libs/flake/KoGridData.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Laurent Montel <montel@kde.org> 0003 Copyright (C) 2007, 2009 Thomas Zander <zander@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 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 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. 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 KOGRIDDATA_H 0022 #define KOGRIDDATA_H 0023 0024 #include "flake_export.h" 0025 #include <KoXmlReaderForward.h> 0026 #include <QColor> 0027 #include <QWidget> 0028 0029 class QPainter; 0030 class QRectF; 0031 class KoViewConverter; 0032 class KoXmlWriter; 0033 class KToggleAction; 0034 0035 /** 0036 * This class stores application-data for display-grids. 0037 * Things like grid colors, distances and snap to grid are saved here. 0038 * \sa KoDocument::gridData() 0039 */ 0040 class FLAKE_EXPORT KoGridData 0041 { 0042 public: 0043 KoGridData(); 0044 ~KoGridData(); 0045 0046 /// return the grid width 0047 qreal gridX() const; 0048 /// return the grid height 0049 qreal gridY() const; 0050 /** 0051 * Set the size grid to a new value 0052 * @param x the width of a grid unit 0053 * @param y the height of a grid unit 0054 * @see snapToGrid() 0055 * @see gridX() 0056 * @see gridY() 0057 */ 0058 void setGrid(qreal x, qreal y); 0059 0060 /** 0061 * return if snap to grid is enabled. 0062 * @return if snap to grid is enabled. 0063 * @see setGrid() 0064 */ 0065 bool snapToGrid() const; 0066 /** 0067 * Set the snap to grid, forcing objects being moved/scaled to the grid. 0068 * @param on when true, all moving and scaling will be on the grid. 0069 * @see setGrid() 0070 */ 0071 void setSnapToGrid(bool on); 0072 0073 /** 0074 * return color of grid. 0075 * @return color of grid. 0076 * @see setGridColor() 0077 */ 0078 QColor gridColor() const; 0079 0080 /** 0081 * Set the color of grid. 0082 * @param color the color of grid. 0083 * @see gridColor() 0084 */ 0085 void setGridColor(const QColor & color); 0086 0087 /** 0088 * return if grid is visible. 0089 * @return if grid is visible. 0090 * @see setShowGrid() 0091 */ 0092 bool showGrid() const; 0093 0094 /** 0095 * Set the show grid status. 0096 * @param showGrid set if grid will be visible. 0097 * @see showGrid() 0098 */ 0099 void setShowGrid(bool showGrid); 0100 0101 /// return if grid is marked to be painted in the background 0102 bool paintGridInBackground() const; 0103 0104 /// set if grid is marked to be painted in the background 0105 void setPaintGridInBackground(bool inBackground); 0106 0107 /// Loads grid data from the given setting xml document 0108 bool loadOdfSettings(const KoXmlDocument & settingsDoc); 0109 0110 /// Saves grid data to the given settings xml writer 0111 void saveOdfSettings(KoXmlWriter &settingsWriter); 0112 0113 /** 0114 * Paint the grid 0115 * @param painter the painter 0116 * @param converter the view converter 0117 * @param area the area in need of updating 0118 */ 0119 void paintGrid(QPainter &painter, const KoViewConverter &converter, const QRectF &area) const; 0120 0121 /** 0122 * Returns a toggle action that can be added to the menu of your views. 0123 * @param by passing the canvas the toggle action will automatically update the canvas when its toggled. 0124 */ 0125 KToggleAction *gridToggleAction(QWidget* canvas = 0); 0126 0127 private: 0128 class Private; 0129 Private * const d; 0130 }; 0131 0132 0133 #endif 0134