Version: 9.15.0
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

Stores background data.

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
@ Horizontal
Horizontal orientation.
Definition: SalomePyQt.h:138
Stores background data.
Definition: Qtx.h:178
void setTexture(const QString &, TextureMode=Qtx::CenterTexture)
Set file name to be used as a texture image.
Definition: Qtx.cxx:1987
void setGradient(int, const QColor &, const QColor &)
Set simple background gradient data and switch to the Qtx::SimpleGradientBackground mode.
Definition: Qtx.cxx:2059
void setColor(const QColor &)
Set background color and switch to the Qtx::ColorBackground mode.
Definition: Qtx.cxx:2028
void setMode(const BackgroundMode)
Set background mode.
Definition: Qtx.cxx:1961
void setTextureShown(bool)
Specify if texture should be shown on the background or no.
Definition: Qtx.cxx:2008
@ ColorBackground
Definition: Qtx.h:138

Constructor & Destructor Documentation

◆ BackgroundData() [1/4]

Qtx::BackgroundData::BackgroundData ( )

Default constructor. Creates invalid background data.

References Qtx::NoBackground, and setMode().

◆ BackgroundData() [2/4]

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

Constructor. Creates background data initialized with the specified color.

Parameters
ccolor

References setColor().

◆ BackgroundData() [3/4]

Qtx::BackgroundData::BackgroundData ( int  type,
const QColor &  c1,
const QColor &  c2 
)

Constructor. Creates background data initialized with the specified two-color gradient.

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().

◆ BackgroundData() [4/4]

Qtx::BackgroundData::BackgroundData ( const QGradient &  grad)

Constructor. Creates background data initialized with the arbirtary gradient data.

Parameters
gradgradient data

References setGradient().

◆ ~BackgroundData()

Qtx::BackgroundData::~BackgroundData ( )
virtual

Destructor.

Member Function Documentation

◆ color()

QColor Qtx::BackgroundData::color ( ) const

Get background color. Returns null QColor if color is not set.

Returns
solid background color
See also
setColor(), mode()

◆ gradient() [1/2]

const QGradient * Qtx::BackgroundData::gradient ( ) const

Get complex gradient data. Returns QGradient of QGradient::NoGradient if gradient data is not set.

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()

◆ gradient() [2/2]

int Qtx::BackgroundData::gradient ( QColor &  c1,
QColor &  c2 
) const

Get simple gradient data. Returns -1 and null QColor for c1 and c2 if gradient data is not set.

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()

◆ isTextureShown()

bool Qtx::BackgroundData::isTextureShown ( ) const

Check if "show texture" flag is switched on.

Returns
true if "show texture" flag is set or false otherwise
See also
setTextureShown(), texture()

◆ isValid()

bool Qtx::BackgroundData::isValid ( ) const

Returns false if background data is not set (invalid)

Returns
true if background data is valid or false otherwise
See also
mode()

References Qtx::NoBackground.

◆ mode()

Qtx::BackgroundMode Qtx::BackgroundData::mode ( ) const

Get background mode.

Returns
current background mode
See also
setMode()

◆ operator!=()

bool Qtx::BackgroundData::operator!= ( const BackgroundData other) const
inline

References operator==().

◆ operator==()

bool Qtx::BackgroundData::operator== ( const BackgroundData other) const

Compares two background data objects.

References myColors, myFileName, myGradient, myGradientType, myMode, myTextureMode, and myTextureShown.

◆ setColor()

void Qtx::BackgroundData::setColor ( const QColor &  c)

Set background color and switch to the Qtx::ColorBackground mode.

Parameters
ccolor
See also
color(), mode()

References Qtx::ColorBackground.

◆ setGradient() [1/2]

void Qtx::BackgroundData::setGradient ( const QGradient &  grad)

Set complex background gradient data and switch to the Qtx::CustomGradientBackground mode.

Parameters
gradgradient data (QLinearGradient, QRadialGradient or QConicalGradient)
See also
gradient(), mode()

References Qtx::CustomGradientBackground.

◆ setGradient() [2/2]

void Qtx::BackgroundData::setGradient ( int  type,
const QColor &  c1,
const QColor &  c2 
)

Set simple background gradient data and switch to the Qtx::SimpleGradientBackground mode.

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.

◆ setMode()

void Qtx::BackgroundData::setMode ( const  BackgroundMode)

Set background mode.

Parameters
mbackground mode being set
See also
mode()

◆ setTexture()

void Qtx::BackgroundData::setTexture ( const QString &  fileName,
const Qtx::TextureMode  m = Qtx::CenterTexture 
)

Set file name to be used as a texture image.

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()

◆ setTextureShown()

void Qtx::BackgroundData::setTextureShown ( bool  on)

Specify if texture should be shown on the background or no.

Parameters
ontrue if texture should be shown or false otherwise
See also
isTextureShown(), texture()

◆ texture()

Qtx::TextureMode Qtx::BackgroundData::texture ( QString &  fileName) const

Get file name used as a texture image.

Returns
path to the texture image file
See also
setTexture(), setTextureShown()

Member Data Documentation

◆ myColors

QColorList Qtx::BackgroundData::myColors
private

◆ myFileName

QString Qtx::BackgroundData::myFileName
private

◆ myGradient

QGradient Qtx::BackgroundData::myGradient
private

◆ myGradientType

int Qtx::BackgroundData::myGradientType
private

◆ myMode

BackgroundMode Qtx::BackgroundData::myMode
private

◆ myTextureMode

TextureMode Qtx::BackgroundData::myTextureMode
private

◆ myTextureShown

bool Qtx::BackgroundData::myTextureShown
private

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