# QwTextSprite Class Reference

A text object on a QwSpriteField. More...

`#include <QwSpriteField.h>`

Inherits QwSpriteFieldGraphic.

List of all member functions.

## Public Members

- QwTextSprite ()
- QwTextSprite ( const char * )
- QwTextSprite ( const char *, QFont )
- virtual ~QwTextSprite ()
- void setText ( const char * )
- void setFont ( const QFont & )
- void setColor ( const QColor & )
- void x ( int )
- void y ( int )
- void z ( int )
- void moveBy ( int dx, int dy )
- void moveTo ( int x, int y )
- int x () const
- int y () const
- virtual int z () const
- int textFlags () const
- void setTextFlags ( int )
- const QRect& boundingRect ()
- virtual bool at ( int, int ) const
- bool at ( const class QRect & ) const
- virtual int rtti () const

## Protected Members

- virtual void makeVisible ( bool yes )
- virtual void draw ( QPainter & )
- void addToChunks ()
- void removeFromChunks ()

## Detailed Description

A text object on a QwSpriteField.

A QwTextSprite has text, a font, color, and position.

## Member Function Documentation

### QwTextSprite::QwTextSprite ()

Construct a QwTextSprite with the text "<text>".

### QwTextSprite::QwTextSprite ( const char * t )

Construct a QwTextSprite with the text t.

The text should not contain newlines.

### QwTextSprite::QwTextSprite ( const char * t, QFont f )

Construct a QwTextSprite with the text t and font f.

The text should not contain newlines.

### QwTextSprite::~QwTextSprite () `[virtual]`

Destruct the sprite.

### void QwTextSprite::addToChunks () `[protected]`

Adds the sprite to the appropriate chunks.

### bool QwTextSprite::at ( const class QRect & r ) const

For collision detection.

### bool QwTextSprite::at ( int x, int y ) const `[virtual]`

For collision detection.

Reimplemented from QwSpriteFieldGraphic.

### const QRect& QwTextSprite::boundingRect ()

Returns the bounding rectangle of the text.

### void QwTextSprite::draw ( QPainter & painter ) `[virtual protected]`

Draws the text.

### void QwTextSprite::makeVisible ( bool yes ) `[virtual protected]`

Toggles visibility.

### void QwTextSprite::moveBy ( int dx, int dy )

Moves text by the given displacements.

### void QwTextSprite::moveTo ( int x, int y )

Sets the position of the bottom-left corner of the text.

### void QwTextSprite::removeFromChunks () `[protected]`

Removes the sprite to the appropriate chunks.

### int QwTextSprite::rtti () const `[virtual]`

Returns 3.

See also: QwSpriteFieldGraphic::rtti().

### void QwTextSprite::setColor ( const QColor & c )

Sets the color of the text.

### void QwTextSprite::setFont ( const QFont & f )

Sets the font in which the text is drawn.

### void QwTextSprite::setText ( const char * t )

Sets the text to be displayed. The text may contain newlines.

### void QwTextSprite::setTextFlags ( int f )

Sets the alignment flags. These are a bitwise OR or some of the flags available to QPainter::drawText().

- AlignLeft aligns to the left border.
- AlignRight aligns to the right border.
- AlignHCenter aligns horizontally centered.
- AlignTop aligns to the top border.
- AlignBottom aligns to the bottom border.
- AlignVCenter aligns vertically centered
- AlignCenter (= AlignHCenter | AlignVCenter)
- SingleLine ignores newline characters in the text.
- ExpandTabs expands tabulators.
- ShowPrefix displays "&x" as "x" underlined.
- GrayText grays out the text.

The DontClip and WordBreak flags are not supported.

### int QwTextSprite::textFlags () const

Returns the currently set alignment flags.

See also: setTextFlags().

### int QwTextSprite::x () const

Returns the X-position of the left edge of the text.

### void QwTextSprite::x ( int c )

Sets the X-positions of the bottom-left corner of the text.

### int QwTextSprite::y () const

Returns the Y-position of the top edge of the text.

### void QwTextSprite::y ( int c )

Sets the Y-positions of the bottom-left corner of the text.

### int QwTextSprite::z () const `[virtual]`

Return the altitude of the text.

Reimplemented from QwSpriteFieldGraphic.

### void QwTextSprite::z ( int a )

Sets the altitude of the text.

This file is copyright © 1995-97 Warwick Allison.

It was generated from the following files:

- QwSpriteField.h
- QwSpriteField-double.cpp
- QwSpriteField-int.cpp
- QwSpriteField-mobdouble.cpp
- QwSpriteField-mobint.cpp
- QwSpriteField-template.cpp
- QwSpriteField.cpp