Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_text.h
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_text.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_text.h
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 12 12 13 13 #include "qwt_global.h" 14 #include <qstring.h>15 #include <qsize.h>16 #include <qfont.h>17 14 #include <qmetatype.h> 18 15 16 class QFont; 17 class QString; 19 18 class QColor; 20 19 class QPen; 21 20 class QBrush; 21 class QSizeF; 22 22 class QRectF; 23 23 class QPainter; … … 25 25 26 26 /*! 27 \brief A class representing a text 28 29 A QwtText is a text including a set of attributes how to render it. 30 31 - Format\n 27 \brief A class representing a text 28 29 A QwtText is a text including a set of attributes how to render it. 30 31 - Format\n 32 32 A text might include control sequences (f.e tags) describing 33 33 how to render it. Each format (f.e MathML, TeX, Qt Rich Text) 34 34 has its own set of control sequences, that can be handles by 35 35 a special QwtTextEngine for this format. 36 - Background\n 36 - Background\n 37 37 A text might have a background, defined by a QPen and QBrush 38 38 to improve its visibility. The corners of the background might 39 39 be rounded. 40 - Font\n 40 - Font\n 41 41 A text might have an individual font. 42 - Color\n 42 - Color\n 43 43 A text might have an individual color. 44 - Render Flags\n 44 - Render Flags\n 45 45 Flags from Qt::AlignmentFlag and Qt::TextFlag used like in 46 46 QPainter::drawText(). 47 47 48 \sa QwtTextEngine, QwtTextLabel 49 */ 48 \sa QwtTextEngine, QwtTextLabel 49 */ 50 50 51 51 class QWT_EXPORT QwtText 52 52 { 53 public: 53 public: 54 54 55 55 /*! 56 \brief Text format 57 58 The text format defines the QwtTextEngine, that is used to render 59 the text. 60 61 \sa QwtTextEngine, setTextEngine() 62 */ 56 \brief Text format 57 58 The text format defines the QwtTextEngine, that is used to render 59 the text. 60 61 \sa QwtTextEngine, setTextEngine() 62 */ 63 63 64 64 enum TextFormat 65 65 { 66 66 /*! 67 The text format is determined using QwtTextEngine::mightRender() for 68 all available text engines in increasing order > PlainText. 69 If none of the text engines can render the text is rendered 70 like QwtText::PlainText. 67 The text format is determined using QwtTextEngine::mightRender() for 68 all available text engines in increasing order > PlainText. 69 If none of the text engines can render the text is rendered 70 like QwtText::PlainText. 71 71 */ 72 72 AutoText = 0, … … 79 79 80 80 /*! 81 Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine 82 to display the text. The Qwt MathML extension offers such an engine 83 based on the MathML renderer of the former Qt solutions package. 84 To enable MathML support the following code needs to be added to the 85 application: 86 87 \code 81 Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine 82 to display the text. In earlier versions of Qwt such an engine 83 was included - since Qwt 6.2 it can be found here: 84 https://github.com/uwerat/qwt-mml-dev 85 86 To enable MathML support the following code needs to be added to the 87 application: 88 89 \code 88 90 QwtText::setTextEngine( QwtText::MathMLText, new QwtMathMLTextEngine() ); 89 \endcode 91 \endcode 90 92 */ 91 93 MathMLText, 92 94 93 95 /*! 94 Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine 95 to display the text ( not implemented yet ). 96 Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine 97 to display the text ( not implemented yet ). 96 98 */ 97 99 TeXText, 98 100 99 101 /*! 100 The number of text formats can be extended using setTextEngine. 101 Formats >= QwtText::OtherFormat are not used by Qwt. 102 The number of text formats can be extended using setTextEngine. 103 Formats >= QwtText::OtherFormat are not used by Qwt. 102 104 */ 103 105 OtherFormat = 100 … … 105 107 106 108 /*! 107 \brief Paint Attributes 108 109 Font and color and background are optional attributes of a QwtText. 110 The paint attributes hold the information, if they are set. 111 */ 109 \brief Paint Attributes 110 111 Font and color and background are optional attributes of a QwtText. 112 The paint attributes hold the information, if they are set. 113 */ 112 114 enum PaintAttribute 113 115 { … … 122 124 }; 123 125 124 //! Paint attributes 125 typedef QFlags<PaintAttribute> PaintAttributes; 126 Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) 126 127 127 128 /*! 128 \brief Layout Attributes 129 The layout attributes affects some aspects of the layout of the text. 130 */ 129 \brief Layout Attributes 130 The layout attributes affects some aspects of the layout of the text. 131 */ 131 132 enum LayoutAttribute 132 133 { 133 134 /*! 134 Layout the text without its margins. This mode is useful if a 135 text needs to be aligned accurately, like the tick labels of a scale. 136 If QwtTextEngine::textMargins is not implemented for the format 137 of the text, MinimumLayout has no effect. 135 Layout the text without its margins. This mode is useful if a 136 text needs to be aligned accurately, like the tick labels of a scale. 137 If QwtTextEngine::textMargins is not implemented for the format 138 of the text, MinimumLayout has no effect. 138 139 */ 139 140 MinimumLayout = 0x01 140 141 }; 141 142 142 //!Layoutattributes143 typedef QFlags<LayoutAttribute> LayoutAttributes; 144 145 QwtText( const QString & = QString(),146 TextFormat textFormat = AutoText);147 QwtText( const QwtText & ); 143 Q_DECLARE_FLAGS( LayoutAttributes, LayoutAttribute ) 144 145 QwtText(); 146 QwtText( const QString&, TextFormat textFormat = AutoText ); 147 QwtText( const QwtText& ); 148 148 149 ~QwtText(); 149 150 150 QwtText &operator=( const QwtText& );151 152 bool operator==( const QwtText & ) const;153 bool operator!=( const QwtText & ) const;154 155 void setText( const QString &,151 QwtText& operator=( const QwtText& ); 152 153 bool operator==( const QwtText& ) const; 154 bool operator!=( const QwtText& ) const; 155 156 void setText( const QString&, 156 157 QwtText::TextFormat textFormat = AutoText ); 157 158 QString text() const; … … 160 161 bool isEmpty() const; 161 162 162 void setFont( const QFont & );163 void setFont( const QFont& ); 163 164 QFont font() const; 164 165 165 QFont usedFont( const QFont & ) const;166 QFont usedFont( const QFont& ) const; 166 167 167 168 void setRenderFlags( int ); 168 169 int renderFlags() const; 169 170 170 void setColor( const QColor & );171 void setColor( const QColor& ); 171 172 QColor color() const; 172 173 173 QColor usedColor( const QColor & ) const;174 QColor usedColor( const QColor& ) const; 174 175 175 176 void setBorderRadius( double ); 176 177 double borderRadius() const; 177 178 178 void setBorderPen( const QPen & );179 void setBorderPen( const QPen& ); 179 180 QPen borderPen() const; 180 181 181 void setBackgroundBrush( const QBrush & );182 void setBackgroundBrush( const QBrush& ); 182 183 QBrush backgroundBrush() const; 183 184 … … 188 189 bool testLayoutAttribute( LayoutAttribute ) const; 189 190 190 double heightForWidth( double width, const QFont & = QFont() ) const; 191 QSizeF textSize( const QFont & = QFont() ) const; 192 193 void draw( QPainter *painter, const QRectF &rect ) const; 194 195 static const QwtTextEngine *textEngine( 196 const QString &text, QwtText::TextFormat = AutoText ); 197 198 static const QwtTextEngine *textEngine( QwtText::TextFormat ); 199 static void setTextEngine( QwtText::TextFormat, QwtTextEngine * ); 200 201 private: 191 double heightForWidth( double width ) const; 192 double heightForWidth( double width, const QFont& ) const; 193 194 QSizeF textSize() const; 195 QSizeF textSize( const QFont& ) const; 196 197 void draw( QPainter* painter, const QRectF& rect ) const; 198 199 static const QwtTextEngine* textEngine( 200 const QString& text, QwtText::TextFormat = AutoText ); 201 202 static const QwtTextEngine* textEngine( QwtText::TextFormat ); 203 static void setTextEngine( QwtText::TextFormat, QwtTextEngine* ); 204 205 private: 202 206 class PrivateData; 203 PrivateData *d_data;207 PrivateData* m_data; 204 208 205 209 class LayoutCache; 206 LayoutCache *d_layoutCache;210 LayoutCache* m_layoutCache; 207 211 }; 208 209 //! \return text().isNull()210 inline bool QwtText::isNull() const211 {212 return text().isNull();213 }214 215 //! \return text().isEmpty()216 inline bool QwtText::isEmpty() const217 {218 return text().isEmpty();219 }220 212 221 213 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
Note:
See TracChangeset
for help on using the changeset viewer.
