User interface update
[qtmeetings] / src / UserInterface / Components / BorderedBarWidget.h
1 #ifndef BORDEREDBARWIDGET_H_
2 #define BORDEREDBARWIDGET_H_
3
4 #include <QtGui/QWidget>
5 #include <QtGui/QLabel>
6
7 //! Userinterface class. Displays text or images with a gradient border.
8 /*!
9  * Userinterface class. Displays text or images with a gradient border. Inherits QWidget and
10  * diplays content in QLabel.
11  */
12 class BorderedBarWidget : public QWidget {
13
14         Q_OBJECT;
15
16 public:
17         enum TextPosition
18         {
19                 LeftAlign, /*!< Indicates that the item inserted should be aligned to the left. */
20                 CenterAlign, /*!< Indicates that the item inserted should be aligned to the center. */
21                 RightAlign /*!< Indicates that the item inserted should be aligned to the right. */
22         };
23
24 public:
25         //! Constructor.
26         /*!
27          * Constructor to initialize a BorderedBarWidget instance.
28          * \param aParent Parent widget. Optional.
29          */
30         BorderedBarWidget( QWidget *aParent = 0 );
31         //! Destructor.
32         virtual ~BorderedBarWidget();
33
34         //! Returns background color.
35         /*!
36          * \return The background color of the widget.
37          */
38         QColor backgroundColor();
39         //! Returns face color.
40         /*!
41          * \return The text and border color.
42          */
43     QColor faceColor();
44         //! Returns border width.
45         /*!
46          * \return The border width.
47          */
48     int borderWidth();
49         //! Returns text.
50         /*!
51          * \param aPos Text position. Optional.
52          * \return The text at a position.
53          */
54     QString text( TextPosition aPos = CenterAlign );
55
56         //! Sets background color.
57         /*!
58          * Sets the background color of the widget.
59          * \param aColor The new color.
60          */
61     void setBackgroundColor( QColor aColor);
62         //! Sets face color.
63         /*!
64          * Sets the text and border color of the widget.
65          * \param aColor The new color.
66          */
67     void setFaceColor( QColor aColor );
68         //! Sets border width.
69         /*!
70          * Sets the width of the border.
71          * \param aWidth The new width in pixels.
72          */
73     void setBorderWidth( int aWidth );
74         //! Sets text.
75         /*!
76          * Sets text to a certain position in a bar.
77          * \param aText The new text.
78          * \param aPos The position of the text. Optional.
79          */
80     void setText( QString aText, TextPosition aPos = CenterAlign );
81         //! Sets pixmap.
82         /*!
83          * Sets pixmap to a certain position in a bar.
84          * \param aPixmap The new pixmap.
85          * \param aPos The position of the pixmap. Optional.
86          */
87     void setPixmap( QPixmap aPixmap, TextPosition aPos = RightAlign );
88
89 private:
90         //! Draws the borders.
91         /*!
92          * Handles drawing of the borders.
93          */
94         void drawBorder();
95         //! Draws corner.
96         /*!
97          * Handles drawing of a corner.
98          * \param aPainter Painter used for drawing.
99          * \param aCenter Inner corner of the widget.
100          */
101         void drawCorner( QPainter &aPainter, QPoint &aCenter );
102         //! Draws side.
103         /*!
104          * Handles drawing of a single side.
105          * \param aPainter Painter used for drawing.
106          * \param aStartPoint Start point of drawing area.
107          * \param aEndPoint End point of drawing area.
108          */
109         void drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint );
110
111 protected:
112         //! Handles drawing of the widget.
113         /*!
114          * Handles drawing of the widget.
115          */
116     virtual void paintEvent(QPaintEvent *);
117
118 private:
119         //! Palette for storing colors.
120     QPalette iPalette;
121         //! Border width.
122     int iBorderWidth;
123         //! Label for left aligned content.
124         QLabel *iLeftLabel;
125         //! Label for center aligned content.
126     QLabel *iCenterLabel;
127         //! Label for right aligned content.
128         QLabel *iRightLabel;
129 };
130
131 #endif /* BORDEREDBARWIDGET_H_ */