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