Warning, file /office/calligra/libs/text/KoTextBlockBorderData.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 Thomas Zander <zander@kde.org>
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 #ifndef KOTEXTBLOCKBORDERDATA_H
0020 #define KOTEXTBLOCKBORDERDATA_H
0021 
0022 #include "styles/KoParagraphStyle.h"
0023 
0024 #include "kotext_export.h"
0025 
0026 class QRectF;
0027 class QPainter;
0028 
0029 /**
0030  * This class holds data for paragraph-borders.
0031  * All the information needed to paint the borders, but also to calculate the insets that the borders
0032  * cause on text-layout is stored in here.
0033  * An instance of this class is owned by the KoTextBlockData and this class is being refcounted
0034  * to allow multiple paragraphs to share one border.
0035  *
0036  */
0037 class KOTEXT_EXPORT KoTextBlockBorderData
0038 {
0039 public:
0040     /// Enum used to differentiate between the 4 types of borders this class maintains
0041     enum Side {
0042         Top = 0, ///< References the border at the top of the paragraph
0043         Left,   ///< References the border at the left side of the paragraph
0044         Bottom, ///< References the border at the bottom of the paragraph
0045         Right   ///< References the border at the right side of the paragraph
0046     };
0047     /**
0048      * Constructor for the border data.
0049      * Will create a border-set with the param rectangle but all the borders will
0050      * be turned off.
0051      * @param paragRect the rectangle that will be used to paint the border inside of.
0052      * @see setEdge() to set the actual border properties.
0053      */
0054     explicit KoTextBlockBorderData(const QRectF &paragRect);
0055 
0056     /**
0057      * Copy constructor for the border data.
0058      * @param other the original object which will be duplicated.
0059      */
0060     explicit KoTextBlockBorderData(const KoTextBlockBorderData &other);
0061 
0062     ~KoTextBlockBorderData();
0063 
0064     /**
0065      * Increments the use-value.
0066      * Returns true if the new value is non-zero, false otherwise.
0067      */
0068     bool ref();
0069     /**
0070      * Decrements the use-value.
0071      * Returns true if the new value is non-zero, false otherwise.
0072      */
0073     bool deref();
0074     /// return the usage count
0075     int useCount() const;
0076 
0077     /**
0078      * Set the properties of an edge based on a paragraph-format.
0079      * @param side defines which edge this is for.
0080      * @param bf the format of the paragraph See QTextBlock.blockFormat()
0081      * @param style the border style for this side.
0082      * @param width the thickness of the border-line.
0083      * @param color the property for the color of the border-line(s).
0084      * @param space the amount of spacing between the outer border and the inner border in case of style being double
0085      * @param innerWidth the thickness of the inner border-line in case of style being double
0086      */
0087     void setEdge(Side side, const QTextBlockFormat &bf, KoParagraphStyle::Property style,
0088                  KoParagraphStyle::Property width, KoParagraphStyle::Property color,
0089                  KoParagraphStyle::Property space, KoParagraphStyle::Property innerWidth);
0090 
0091     /**
0092      * Set if this border should possibly be merged with the next.
0093      */
0094     void setMergeWithNext(bool merge);
0095 
0096     /**
0097      * @return true if there has been at least one border set.
0098      */
0099     bool hasBorders() const;
0100 
0101     /**
0102      * Find the inset that a border causes for a specific side.
0103      * @see applyInsets()
0104      */
0105     qreal inset(Side side) const;
0106 
0107     /// returns true if the borders of param border are the same as this one.
0108     bool operator==(const KoTextBlockBorderData &border) const;
0109     bool equals(const KoTextBlockBorderData &border) const;
0110 
0111     /**
0112      * Paint the borders.
0113      */
0114     void paint(QPainter &painter, const QRectF &clip) const;
0115 
0116 private:
0117     class Private;
0118     Private * const d;
0119 };
0120 
0121 #endif