Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
QwtText Class Reference

A class representing a text. More...

#include <qwt_text.h>

Classes

class  LayoutCache
 
class  PrivateData
 

Public Types

enum  LayoutAttribute { MinimumLayout = 0x01 }
 Layout Attributes The layout attributes affects some aspects of the layout of the text. More...
 
typedef QFlags< LayoutAttributeLayoutAttributes
 Layout attributes. More...
 
enum  PaintAttribute { PaintUsingTextFont = 0x01, PaintUsingTextColor = 0x02, PaintBackground = 0x04 }
 Paint Attributes. More...
 
typedef QFlags< PaintAttributePaintAttributes
 Paint attributes. More...
 
enum  TextFormat {
  AutoText = 0, PlainText, RichText, MathMLText,
  TeXText, OtherFormat = 100
}
 Text format. More...
 

Public Member Functions

QBrush backgroundBrush () const
 
QPen borderPen () const
 
double borderRadius () const
 
QColor color () const
 Return the pen color, used for painting the text. More...
 
void draw (QPainter *painter, const QRectF &rect) const
 
QFont font () const
 Return the font. More...
 
double heightForWidth (double width, const QFont &=QFont()) const
 
bool isEmpty () const
 
bool isNull () const
 
bool operator!= (const QwtText &) const
 Relational operator. More...
 
QwtTextoperator= (const QwtText &)
 Assignment operator. More...
 
bool operator== (const QwtText &) const
 Relational operator. More...
 
 QwtText (const QString &=QString(), TextFormat textFormat=AutoText)
 
 QwtText (const QwtText &)
 Copy constructor. More...
 
int renderFlags () const
 
void setBackgroundBrush (const QBrush &)
 
void setBorderPen (const QPen &)
 
void setBorderRadius (double)
 
void setColor (const QColor &)
 
void setFont (const QFont &)
 
void setLayoutAttribute (LayoutAttribute, bool on=true)
 
void setPaintAttribute (PaintAttribute, bool on=true)
 
void setRenderFlags (int flags)
 Change the render flags. More...
 
void setText (const QString &, QwtText::TextFormat textFormat=AutoText)
 
bool testLayoutAttribute (LayoutAttribute) const
 
bool testPaintAttribute (PaintAttribute) const
 
QString text () const
 
QSizeF textSize (const QFont &=QFont()) const
 
QColor usedColor (const QColor &) const
 
QFont usedFont (const QFont &) const
 
 ~QwtText ()
 Destructor. More...
 

Static Public Member Functions

static void setTextEngine (QwtText::TextFormat, QwtTextEngine *)
 
static const QwtTextEnginetextEngine (const QString &text, QwtText::TextFormat=AutoText)
 
static const QwtTextEnginetextEngine (QwtText::TextFormat)
 Find the text engine for a text format. More...
 

Private Attributes

PrivateDatad_data
 
LayoutCached_layoutCache
 

Detailed Description

A class representing a text.

A QwtText is a text including a set of attributes how to render it.

See also
QwtTextEngine, QwtTextLabel

Definition at line 51 of file qwt_text.h.

Member Typedef Documentation

Layout attributes.

Definition at line 140 of file qwt_text.h.

Paint attributes.

Definition at line 122 of file qwt_text.h.

Member Enumeration Documentation

Layout Attributes The layout attributes affects some aspects of the layout of the text.

Enumerator
MinimumLayout 

Layout the text without its margins. This mode is useful if a text needs to be aligned accurately, like the tick labels of a scale. If QwtTextEngine::textMargins is not implemented for the format of the text, MinimumLayout has no effect.

Definition at line 128 of file qwt_text.h.

Paint Attributes.

Font and color and background are optional attributes of a QwtText. The paint attributes hold the information, if they are set.

Enumerator
PaintUsingTextFont 

The text has an individual font.

PaintUsingTextColor 

The text has an individual color.

PaintBackground 

The text has an individual background.

Definition at line 109 of file qwt_text.h.

Text format.

The text format defines the QwtTextEngine, that is used to render the text.

See also
QwtTextEngine, setTextEngine()
Enumerator
AutoText 

The text format is determined using QwtTextEngine::mightRender() for all available text engines in increasing order > PlainText. If none of the text engines can render the text is rendered like QwtText::PlainText.

PlainText 

Draw the text as it is, using a QwtPlainTextEngine.

RichText 

Use the Scribe framework (Qt Rich Text) to render the text.

MathMLText 

Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine to display the text. The Qwt MathML extension offers such an engine based on the MathML renderer of the Qt solutions package. To enable MathML support the following code needs to be added to the application:

QwtText::setTextEngine(QwtText::MathMLText, new QwtMathMLTextEngine()); 
TeXText 

Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine to display the text ( not implemented yet ).

OtherFormat 

The number of text formats can be extended using setTextEngine. Formats >= QwtText::OtherFormat are not used by Qwt.

Definition at line 64 of file qwt_text.h.

Constructor & Destructor Documentation

QwtText::QwtText ( const QString &  text = QString(),
QwtText::TextFormat  textFormat = AutoText 
)

Constructor

Parameters
textText content
textFormatText format

Definition at line 182 of file qwt_text.cpp.

QwtText::QwtText ( const QwtText other)

Copy constructor.

Definition at line 192 of file qwt_text.cpp.

QwtText::~QwtText ( )

Destructor.

Definition at line 202 of file qwt_text.cpp.

Member Function Documentation

QBrush QwtText::backgroundBrush ( ) const
Returns
Background brush
See also
setBackgroundBrush(), borderPen()

Definition at line 418 of file qwt_text.cpp.

QPen QwtText::borderPen ( ) const
Returns
Background pen
See also
setBorderPen(), backgroundBrush()

Definition at line 397 of file qwt_text.cpp.

double QwtText::borderRadius ( ) const
Returns
Radius for the corners of the border frame
See also
setBorderRadius(), borderPen(), backgroundBrush()

Definition at line 376 of file qwt_text.cpp.

QColor QwtText::color ( ) const

Return the pen color, used for painting the text.

Definition at line 339 of file qwt_text.cpp.

void QwtText::draw ( QPainter *  painter,
const QRectF &  rect 
) const

Draw a text into a rectangle

Parameters
painterPainter
rectRectangle

Definition at line 560 of file qwt_text.cpp.

QFont QwtText::font ( ) const

Return the font.

Definition at line 303 of file qwt_text.cpp.

double QwtText::heightForWidth ( double  width,
const QFont &  defaultFont = QFont() 
) const

Find the height for a given width

Parameters
defaultFontFont, used for the calculation if the text has no font
widthWidth
Returns
Calculated height

Definition at line 490 of file qwt_text.cpp.

bool QwtText::isEmpty ( ) const
inline
Returns
text().isEmpty()

Definition at line 213 of file qwt_text.h.

bool QwtText::isNull ( ) const
inline
Returns
text().isNull()

Definition at line 207 of file qwt_text.h.

bool QwtText::operator!= ( const QwtText other) const

Relational operator.

Definition at line 231 of file qwt_text.cpp.

QwtText & QwtText::operator= ( const QwtText other)

Assignment operator.

Definition at line 209 of file qwt_text.cpp.

bool QwtText::operator== ( const QwtText other) const

Relational operator.

Definition at line 217 of file qwt_text.cpp.

int QwtText::renderFlags ( ) const
Returns
Render flags
See also
setRenderFlags()

Definition at line 284 of file qwt_text.cpp.

void QwtText::setBackgroundBrush ( const QBrush &  brush)

Set the background brush

Parameters
brushBackground brush
See also
backgroundBrush(), setBorderPen()

Definition at line 408 of file qwt_text.cpp.

void QwtText::setBorderPen ( const QPen &  pen)

Set the background pen

Parameters
penBackground pen
See also
borderPen(), setBackgroundBrush()

Definition at line 387 of file qwt_text.cpp.

void QwtText::setBorderRadius ( double  radius)

Set the radius for the corners of the border frame

Parameters
radiusRadius of a rounded corner
See also
borderRadius(), setBorderPen(), setBackgroundBrush()

Definition at line 367 of file qwt_text.cpp.

void QwtText::setColor ( const QColor &  color)

Set the pen color used for drawing the text.

Parameters
colorColor
Note
Setting the color might have no effect, when the text contains control sequences for setting colors.

Definition at line 332 of file qwt_text.cpp.

void QwtText::setFont ( const QFont &  font)

Set the font.

Parameters
fontFont
Note
Setting the font might have no effect, when the text contains control sequences for setting fonts.

Definition at line 296 of file qwt_text.cpp.

void QwtText::setLayoutAttribute ( LayoutAttribute  attribute,
bool  on = true 
)

Change a layout attribute

Parameters
attributeLayout attribute
onOn/Off
See also
testLayoutAttribute()

Definition at line 461 of file qwt_text.cpp.

void QwtText::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Change a paint attribute

Parameters
attributePaint attribute
onOn/Off
Note
Used by setFont(), setColor(), setBorderPen() and setBackgroundBrush()
See also
testPaintAttribute()

Definition at line 433 of file qwt_text.cpp.

void QwtText::setRenderFlags ( int  renderFlags)

Change the render flags.

The default setting is Qt::AlignCenter

Parameters
renderFlagsBitwise OR of the flags used like in QPainter::drawText()
See also
renderFlags(), QwtTextEngine::draw()
Note
Some renderFlags might have no effect, depending on the text format.

Definition at line 271 of file qwt_text.cpp.

void QwtText::setText ( const QString &  text,
QwtText::TextFormat  textFormat = AutoText 
)

Assign a new text content

Parameters
textText content
textFormatText format
See also
text()

Definition at line 244 of file qwt_text.cpp.

void QwtText::setTextEngine ( QwtText::TextFormat  format,
QwtTextEngine engine 
)
static

Assign/Replace a text engine for a text format

With setTextEngine it is possible to extend Qwt with other types of text formats.

For QwtText::PlainText it is not allowed to assign a engine == NULL.

Parameters
formatText format
engineText engine
See also
QwtMathMLTextEngine
Warning
Using QwtText::AutoText does nothing.

Definition at line 659 of file qwt_text.cpp.

bool QwtText::testLayoutAttribute ( LayoutAttribute  attribute) const

Test a layout attribute

Parameters
attributeLayout attribute
Returns
true, if attribute is enabled
See also
setLayoutAttribute()

Definition at line 477 of file qwt_text.cpp.

bool QwtText::testPaintAttribute ( PaintAttribute  attribute) const

Test a paint attribute

Parameters
attributePaint attribute
Returns
true, if attribute is enabled
See also
setPaintAttribute()

Definition at line 449 of file qwt_text.cpp.

QString QwtText::text ( ) const
Returns
Text as QString.
See also
setText()

Definition at line 256 of file qwt_text.cpp.

const QwtTextEngine * QwtText::textEngine ( const QString &  text,
QwtText::TextFormat  format = AutoText 
)
static

Find the text engine for a text format

In case of QwtText::AutoText the first text engine (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender returns true. If there is none QwtPlainTextEngine is returned.

If no text engine is registered for the format QwtPlainTextEngine is returnd.

Parameters
textText, needed in case of AutoText
formatText format
Returns
Corresponding text engine

Definition at line 639 of file qwt_text.cpp.

const QwtTextEngine * QwtText::textEngine ( QwtText::TextFormat  format)
static

Find the text engine for a text format.

textEngine can be used to find out if a text format is supported.

Parameters
formatText format
Returns
The text engine, or NULL if no engine is available.

Definition at line 673 of file qwt_text.cpp.

QSizeF QwtText::textSize ( const QFont &  defaultFont = QFont()) const

Returns the size, that is needed to render text

Parameters
defaultFontFont of the text
Returns
Calculated size

Definition at line 526 of file qwt_text.cpp.

QColor QwtText::usedColor ( const QColor &  defaultColor) const

Return the color of the text, if it has one. Otherwise return defaultColor.

Parameters
defaultColorDefault color
Returns
Color used for drawing the text
See also
setColor(), color(), PaintAttributes

Definition at line 353 of file qwt_text.cpp.

QFont QwtText::usedFont ( const QFont &  defaultFont) const

Return the font of the text, if it has one. Otherwise return defaultFont.

Parameters
defaultFontDefault font
Returns
Font used for drawing the text
See also
setFont(), font(), PaintAttributes

Definition at line 317 of file qwt_text.cpp.

Member Data Documentation

PrivateData* QwtText::d_data
private

Definition at line 199 of file qwt_text.h.

LayoutCache* QwtText::d_layoutCache
private

Definition at line 202 of file qwt_text.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:19