File indexing completed on 2024-05-12 15:56:51
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2006-2010 Thomas Zander <zander@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOTEXTSHAPEDATABASE_H 0008 #define KOTEXTSHAPEDATABASE_H 0009 0010 #include "kritaflake_export.h" 0011 0012 #include "KoShapeUserData.h" 0013 0014 class KoTextShapeDataBasePrivate; 0015 #include <QDomDocument> 0016 class KoShapeLoadingContext; 0017 class KoShapeSavingContext; 0018 struct KoInsets; 0019 0020 class QTextDocument; 0021 0022 /** 0023 * \internal 0024 */ 0025 class KRITAFLAKE_EXPORT KoTextShapeDataBase : public KoShapeUserData 0026 { 0027 Q_OBJECT 0028 public: 0029 /// constructor 0030 KoTextShapeDataBase(); 0031 ~KoTextShapeDataBase() override; 0032 0033 /// return the document 0034 QTextDocument *document() const; 0035 0036 /** 0037 * Set the margins that will make the shapes text area smaller. 0038 * The shape that owns this textShapeData object will layout text in an area 0039 * confined by the shape size made smaller by the margins set here. 0040 * @param margins the margins that shrink the text area. 0041 */ 0042 void setShapeMargins(const KoInsets &margins); 0043 /** 0044 * returns the currently set margins for the shape. 0045 */ 0046 KoInsets shapeMargins() const; 0047 0048 /** Sets the vertical alignment of all the text inside the shape. */ 0049 void setVerticalAlignment(Qt::Alignment alignment); 0050 0051 /** Returns the vertical alignment of all the text in the shape */ 0052 Qt::Alignment verticalAlignment() const; 0053 0054 /** 0055 * Enum to describe the text document's automatic resizing behaviour. 0056 */ 0057 enum ResizeMethod { 0058 /// Resize the shape to fit the content. This makes sure that the text shape takes op 0059 /// only as much space as absolutely necessary to fit the entire text into its boundaries. 0060 AutoResize, 0061 /// Specifies whether or not to automatically increase the width of the drawing object 0062 /// if text is added to fit the entire width of the text into its boundaries. 0063 /// Compared to AutoResize above this only applied to the width whereas the height is 0064 /// not resized. Also this only grows but does not shrink again if text is removed again. 0065 AutoGrowWidth, 0066 /// Specifies whether or not to automatically increase the height of the drawing object 0067 /// if text is added to fit the entire height of the text into its boundaries. 0068 AutoGrowHeight, 0069 /// This combines the AutoGrowWidth and AutoGrowHeight and automatically increase width 0070 /// and height to fit the entire text into its boundaries. 0071 AutoGrowWidthAndHeight, 0072 /// Shrink the content displayed within the shape to match into the shape's boundaries. This 0073 /// will scale the content down as needed to display the whole document. 0074 ShrinkToFitResize, 0075 /// Deactivates auto-resizing. This is the default resizing method. 0076 NoResize 0077 }; 0078 0079 /** 0080 * Specifies how the document should be resized upon a change in the document. 0081 * 0082 * If auto-resizing is turned on, text will not be wrapped unless enforced by e.g. a newline. 0083 * 0084 * By default, NoResize is set. 0085 */ 0086 void setResizeMethod(ResizeMethod method); 0087 0088 /** 0089 * Returns the auto-resizing mode. By default, this is NoResize. 0090 * 0091 * @see setResizeMethod 0092 */ 0093 ResizeMethod resizeMethod() const; 0094 0095 protected: 0096 /// constructor 0097 KoTextShapeDataBase(KoTextShapeDataBasePrivate *); 0098 0099 KoTextShapeDataBasePrivate *d_ptr; 0100 0101 private: 0102 Q_DECLARE_PRIVATE(KoTextShapeDataBase) 0103 }; 0104 0105 #endif 0106