Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Qtx::BackgroundData Class Reference

Stores background data. More...

#include <Qtx.h>

Public Member Functions

 BackgroundData ()
 Default constructor. Creates invalid background data. More...
 
 BackgroundData (const QColor &)
 Constructor. Creates background data initialized with the specified color. More...
 
 BackgroundData (int, const QColor &, const QColor &)
 Constructor. Creates background data initialized with the specified two-color gradient. More...
 
 BackgroundData (const QGradient &)
 Constructor. Creates background data initialized with the arbirtary gradient data. More...
 
virtual ~BackgroundData ()
 Destructor. More...
 
bool operator== (const BackgroundData &) const
 Compares two background data objects. More...
 
bool operator!= (const BackgroundData &other) const
 
bool isValid () const
 Returns false if background data is not set (invalid) More...
 
BackgroundMode mode () const
 Get background mode. More...
 
void setMode (const BackgroundMode)
 Set background mode. More...
 
TextureMode texture (QString &) const
 Get file name used as a texture image. More...
 
void setTexture (const QString &, TextureMode=Qtx::CenterTexture)
 Set file name to be used as a texture image. More...
 
bool isTextureShown () const
 Check if "show texture" flag is switched on. More...
 
void setTextureShown (bool)
 Specify if texture should be shown on the background or no. More...
 
QColor color () const
 Get background color. Returns null QColor if color is not set. More...
 
void setColor (const QColor &)
 Set background color and switch to the Qtx::ColorBackground mode. More...
 
int gradient (QColor &, QColor &) const
 Get simple gradient data. Returns -1 and null QColor for c1 and c2 if gradient data is not set. More...
 
void setGradient (int, const QColor &, const QColor &)
 Set simple background gradient data and switch to the Qtx::SimpleGradientBackground mode. More...
 
const QGradient * gradient () const
 Get complex gradient data. Returns QGradient of QGradient::NoGradient if gradient data is not set. More...
 
void setGradient (const QGradient &)
 Set complex background gradient data and switch to the Qtx::CustomGradientBackground mode. More...
 

Private Attributes

BackgroundMode myMode
 
TextureMode myTextureMode
 
QString myFileName
 
QColorList myColors
 
int myGradientType
 
QGradient myGradient
 
bool myTextureShown
 

Detailed Description

This class is used to store background data. Depending on the mode, the background can be specified by:

The class stores all the data passed to it, so switching between different modes can be done just by calling setMode() function.

Note
Texture is used with combination of the background mode.
Two-color gradient is specified by two colors and integer identifier. The interpretation of this identifier should be done in the calling code.
bg.setColor( QColor(100, 100, 100) ); // bg is switched to Qtx::ColorBackground mode
bg.setGradient( Qt::Horizontal, Qt::gray, Qt::white ); // bg is switched to Qtx::ColorBackground mode
QLinearGradient grad( 0,0,1,1 );
grad.setColorAt( 0.0, Qt::gray );
grad.setColorAt( 0.5, Qt::white );
grad.setColorAt( 1.0, Qt::green );
grad.setSpread( QGradient::PadSpread );
bg.setGradient( grad ); // bg is switched to Qtx::CustomGradientBackground mode
bg.setMode( Qtx::ColorBackground ); // bg is switched back to Qtx::ColorBackground mode
bg.setTexture( "/data/images/background.png" ); // specify texture (in the centered mode by default)
bg.setTextureShown( true ); // draw texture on the solid color background

Constructor & Destructor Documentation

Qtx::BackgroundData::BackgroundData ( )

References Qtx::NoBackground, and setMode().

Qtx::BackgroundData::BackgroundData ( const QColor &  c)
Parameters
ccolor

References setColor().

Qtx::BackgroundData::BackgroundData ( int  type,
const QColor &  c1,
const QColor &  c2 
)
Parameters
typegradient type identifier
c1first gradient color
c2second gradient color
Note
the interpretation of the gradient identifier should be done in the calling code

References setGradient().

Qtx::BackgroundData::BackgroundData ( const QGradient &  grad)
Parameters
gradgradient data

References setGradient().

Qtx::BackgroundData::~BackgroundData ( )
virtual

Member Function Documentation

QColor Qtx::BackgroundData::color ( ) const
Returns
solid background color
See Also
setColor(), mode()
int Qtx::BackgroundData::gradient ( QColor &  c1,
QColor &  c2 
) const
Parameters
c1first gradient color is returned via this parameter
c2second gradient color is returned via this parameter
Returns
current two-colored gradient mode type identifier
Note
the interpretation of the gradient identifier should be done in the calling code
See Also
setGradient(int, const QColor&, const QColor&), mode()
const QGradient * Qtx::BackgroundData::gradient ( ) const
Note
This function does not transform simple gradient data set with setGradient( const QString&, const QColor&, const QColor& ) to QGradient class
Returns
gradient data
See Also
setGradient(const QGradient&), mode()
bool Qtx::BackgroundData::isTextureShown ( ) const
Returns
true if "show texture" flag is set or false otherwise
See Also
setTextureShown(), texture()
bool Qtx::BackgroundData::isValid ( ) const
Returns
true if background data is valid or false otherwise
See Also
mode()

References Qtx::NoBackground.

Qtx::BackgroundMode Qtx::BackgroundData::mode ( ) const
Returns
current background mode
See Also
setMode()
bool Qtx::BackgroundData::operator!= ( const BackgroundData other) const
inline

References operator==().

bool Qtx::BackgroundData::operator== ( const BackgroundData other) const
void Qtx::BackgroundData::setColor ( const QColor &  c)
Parameters
ccolor
See Also
color(), mode()

References Qtx::ColorBackground.

void Qtx::BackgroundData::setGradient ( int  type,
const QColor &  c1,
const QColor &  c2 
)
Parameters
typetwo-colored gradient mode type identifier
c1first gradient color is returned via this parameter
c2second gradient color is returned via this parameter
Note
the interpretation of the gradient identifier should be done in the calling code
See Also
gradient(QColor&, QColor&), mode()

References Qtx::SimpleGradientBackground.

void Qtx::BackgroundData::setGradient ( const QGradient &  grad)
Parameters
gradgradient data (QLinearGradient, QRadialGradient or QConicalGradient)
See Also
gradient(), mode()

References Qtx::CustomGradientBackground.

void Qtx::BackgroundData::setMode ( const BackgroundMode  m)
Parameters
mbackground mode being set
See Also
mode()
void Qtx::BackgroundData::setTexture ( const QString &  fileName,
const Qtx::TextureMode  m = Qtx::CenterTexture 
)
Note
To show texture image on the background it is necessary to call additionally setTextureShown() method.
Parameters
fileNamepath to the texture image file name
mtexture mode (Qtx::CenterTexture by default)
See Also
texture(), setTextureShown()
void Qtx::BackgroundData::setTextureShown ( bool  on)
Parameters
ontrue if texture should be shown or false otherwise
See Also
isTextureShown(), texture()
Qtx::TextureMode Qtx::BackgroundData::texture ( QString &  fileName) const
Returns
path to the texture image file
See Also
setTexture(), setTextureShown()

Member Data Documentation

QColorList Qtx::BackgroundData::myColors
private
QString Qtx::BackgroundData::myFileName
private
QGradient Qtx::BackgroundData::myGradient
private
int Qtx::BackgroundData::myGradientType
private
BackgroundMode Qtx::BackgroundData::myMode
private
TextureMode Qtx::BackgroundData::myTextureMode
private
bool Qtx::BackgroundData::myTextureShown
private

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