1 #ifndef XGUI_ViewBackground_H
2 #define XGUI_ViewBackground_H
5 #include "XGUI_Constants.h"
12 typedef QList<QColor> QColorList; //!< list of colors
15 \class XGUI_ViewBackground
16 \brief Stores background data
18 This class is used to store background data. Depending on the mode,
19 the background can be specified by:
20 - image (by assigning the file name to be used as background texture), see setTexture(), setTextureShown()
21 - single color (by assigning any color), see setColor()
22 - simple two-color gradient (with the gradient type id and two colors), see setGradient( int, const QColor&, const QColor& )
23 - complex gradient (by assigning arbitrary gradient data), see setGradient( const QGradient& )
25 The class stores all the data passed to it, so switching between different modes can be done
26 just by calling setMode() function.
28 \note Texture is used with combination of the background mode.
30 \note Two-color gradient is specified by two colors and integer identifier. The interpretation of
31 this identifier should be done in the calling code.
34 XGUI_ViewBackground bg;
35 bg.setColor( QColor(100, 100, 100) ); // bg is switched to ColorBackground mode
36 bg.setGradient( Qt::Horizontal, Qt::gray, Qt::white ); // bg is switched to ColorBackground mode
37 QLinearGradient grad( 0,0,1,1 );
38 grad.setColorAt( 0.0, Qt::gray );
39 grad.setColorAt( 0.5, Qt::white );
40 grad.setColorAt( 1.0, Qt::green );
41 grad.setSpread( QGradient::PadSpread );
42 bg.setGradient( grad ); // bg is switched to CustomGradientBackground mode
43 bg.setMode( ColorBackground ); // bg is switched back to ColorBackground mode
44 bg.setTexture( "/data/images/background.png" ); // specify texture (in the centered mode by default)
45 bg.setTextureShown( true ); // draw texture on the solid color background
48 class XGUI_EXPORT XGUI_ViewBackground
51 XGUI_ViewBackground();
52 XGUI_ViewBackground(const QColor& theColor);
53 XGUI_ViewBackground(XGUI::GradientType type, const QColor& theColor1, const QColor& theColor2);
54 XGUI_ViewBackground(const QGradient&);
55 virtual ~XGUI_ViewBackground();
57 bool operator==(const XGUI_ViewBackground&) const;
58 inline bool operator!=(const XGUI_ViewBackground& other) const
60 return !operator==(other);
66 \brief Get background mode
67 \return current background mode
70 XGUI::BackgroundMode mode() const
76 \brief Set background mode
77 \param m background mode being set
80 void setMode(const XGUI::BackgroundMode m)
85 XGUI::TextureMode texture(QString&) const;
86 void setTexture(const QString&, XGUI::TextureMode = XGUI::CenterTexture);
87 bool isTextureShown() const;
88 void setTextureShown(bool);
91 void setColor(const QColor&);
93 int gradient(QColor&, QColor&) const;
94 void setGradient(XGUI::GradientType, const QColor&, const QColor&);
96 const QGradient* gradient() const;
97 void setGradient(const QGradient&);
100 XGUI::BackgroundMode myMode;
101 XGUI::TextureMode myTextureMode;
104 XGUI::GradientType myGradientType;
105 QGradient myGradient;