Source Code (Use browser search to find items of interest.)
Class Index
qt'QBrush (./qt-2.1.0/src/kernel/qbrush.h:35)
class Q_EXPORT QBrush: public Qt
{
friend class QPainter;
public:
QBrush();
QBrush( BrushStyle );
QBrush( const QColor &, BrushStyle=SolidPattern );
QBrush( const QColor &, const QPixmap & );
QBrush( const QBrush & );
~QBrush();
QBrush &operator=( const QBrush & );
BrushStyle style() const { return data->style; }
void setStyle( BrushStyle );
const QColor &color()const { return data->color; }
void setColor( const QColor & );
QPixmap *pixmap() const { return data->pixmap; }
void setPixmap( const QPixmap & );
bool operator==( const QBrush &p ) const;
bool operator!=( const QBrush &b ) const
{ return !(operator==(b)); }
private:
QBrush copy() const;
void detach();
void init( const QColor &, BrushStyle );
struct QBrushData : public QShared { // brush data
BrushStyle style;
QColor color;
QPixmap *pixmap;
} *data;
};
/*****************************************************************************
QBrush stream functions
*****************************************************************************/
qt'QBrush::init() (./qt-2.1.0/src/kernel/qpainter.cpp:2987)
void QBrush::init( const QColor &color, BrushStyle style )
{
data = new QBrushData;
CHECK_PTR( data );
data->style = style;
data->color = color;
data->pixmap = 0;
}
/*!
Constructs a default black brush with the style \c NoBrush (will not fill
shapes).
*/
qt'QBrush::QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3001)
QBrush::QBrush()
{
init( Qt::black, NoBrush );
}
/*!
Constructs a black brush with the specified style.
\sa setStyle()
*/
qt'QBrush::QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3011)
QBrush::QBrush( BrushStyle style )
{
init( Qt::black, style );
}
/*!
Constructs a brush with a specified color and style.
\sa setColor(), setStyle()
*/
qt'QBrush::QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3021)
QBrush::QBrush( const QColor &color, BrushStyle style )
{
init( color, style );
}
/*!
Constructs a brush with a specified color and a custom pattern.
The color will only have an effect for monochrome pixmaps, i.e.
QPixmap::depth() == 1.
\sa setColor(), setPixmap()
*/
qt'QBrush::QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3035)
QBrush::QBrush( const QColor &color, const QPixmap &pixmap )
{
init( color, CustomPattern );
setPixmap( pixmap );
}
/*!
Constructs a brush which is a
\link shclass.html shallow copy\endlink of \e b.
*/
qt'QBrush::QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3046)
QBrush::QBrush( const QBrush &b )
{
data = b.data;
data->ref();
}
/*!
Destructs the brush.
*/
qt'QBrush::~QBrush() (./qt-2.1.0/src/kernel/qpainter.cpp:3056)
QBrush::~QBrush()
{
if ( data->deref() ) {
delete data->pixmap;
delete data;
}
}
/*!
Detaches from shared brush data to makes sure that this brush is the only
one referring the data.
If multiple brushes share common data, this pen dereferences the data
and gets a copy of the data. Nothing is done if there is just a single
reference.
*/
qt'QBrush::detach() (./qt-2.1.0/src/kernel/qpainter.cpp:3074)
void QBrush::detach()
{
if ( data->count != 1 )
*this = copy();
}
/*!
Assigns \e b to this brush and returns a reference to this brush.
*/
qt'QBrush::copy() (./qt-2.1.0/src/kernel/qpainter.cpp:3102)
QBrush QBrush::copy() const
{
if ( data->style == CustomPattern ) { // brush has pixmap
QBrush b( data->color, *data->pixmap );
return b;
} else { // brush has std pattern
QBrush b( data->color, data->style );
return b;
}
}
/*!
\fn BrushStyle QBrush::style() const
Returns the brush style.
\sa setStyle()
*/
/*!
Sets the brush style to \e s.
The brush styles are:
<ul>
<li> \c NoBrush will not fill shapes (default).
<li> \c SolidPattern solid (100%) fill pattern.
<li> \c Dense1Pattern 94% fill pattern.
<li> \c Dense2Pattern 88% fill pattern.
<li> \c Dense3Pattern 63% fill pattern.
<li> \c Dense4Pattern 50% fill pattern.
<li> \c Dense5Pattern 37% fill pattern.
<li> \c Dense6Pattern 12% fill pattern.
<li> \c Dense7Pattern 6% fill pattern.
<li> \c HorPattern horizontal lines pattern.
<li> \c VerPattern vertical lines pattern.
<li> \c CrossPattern crossing lines pattern.
<li> \c BDiagPattern diagonal lines (directed / ) pattern.
<li> \c FDiagPattern diagonal lines (directed \ ) pattern.
<li> \c DiagCrossPattern diagonal crossing lines pattern.
<li> \c CustomPattern set when a pixmap pattern is being used.
</ul>
\sa style()
*/
qt'QBrush::setStyle() (./qt-2.1.0/src/kernel/qpainter.cpp:3146)
void QBrush::setStyle( BrushStyle s ) // set brush style
{
if ( data->style == s )
return;
#if defined(CHECK_RANGE)
if ( s == CustomPattern )
qWarning( "QBrush::setStyle: CustomPattern is for internal use" );
#endif
detach();
data->style = s;
}
/*!
\fn const QColor &QBrush::color() const
Returns the brush color.
\sa setColor()
*/
/*!
Sets the brush color to \e c.
\sa color(), setStyle()
*/
qt'QBrush::setColor() (./qt-2.1.0/src/kernel/qpainter.cpp:3170)
void QBrush::setColor( const QColor &c )
{
detach();
data->color = c;
}
/*!
\fn QPixmap *QBrush::pixmap() const
Returns a pointer to the custom brush pattern.
A null pointer is returned if no custom brush pattern has been set.
\sa setPixmap()
*/
/*!
Sets the brush pixmap. The style is set to \c CustomPattern.
The current brush color will only have an effect for monochrome pixmaps,
i.e. QPixmap::depth() == 1.
\sa pixmap(), color()
*/
qt'QBrush::setPixmap() (./qt-2.1.0/src/kernel/qpainter.cpp:3195)
void QBrush::setPixmap( const QPixmap &pixmap )
{
detach();
if ( data->pixmap )
delete data->pixmap;
if ( pixmap.isNull() ) {
data->style = NoBrush;
data->pixmap = 0;
} else {
data->style = CustomPattern;
data->pixmap = new QPixmap( pixmap );
if ( data->pixmap->optimization() == QPixmap::MemoryOptim )
data->pixmap->setOptimization( QPixmap::NormalOptim );
}
}
/*!
\fn bool QBrush::operator!=( const QBrush &b ) const
Returns TRUE if the brush is different from \e b, or FALSE if the brushes are
equal.
Two brushes are different if they have different styles, colors or pixmaps.
\sa operator==()
*/
/*!
Returns TRUE if the brush is equal to \e b, or FALSE if the brushes are
different.
Two brushes are equal if they have equal styles, colors and pixmaps.
\sa operator!=()
*/