User interface update
[qtmeetings] / src / UserInterface / Components / BorderedBarWidget.h
diff --git a/src/UserInterface/Components/BorderedBarWidget.h b/src/UserInterface/Components/BorderedBarWidget.h
new file mode 100644 (file)
index 0000000..c97b18a
--- /dev/null
@@ -0,0 +1,131 @@
+#ifndef BORDEREDBARWIDGET_H_
+#define BORDEREDBARWIDGET_H_
+
+#include <QtGui/QWidget>
+#include <QtGui/QLabel>
+
+//! Userinterface class. Displays text or images with a gradient border.
+/*!
+ * Userinterface class. Displays text or images with a gradient border. Inherits QWidget and
+ * diplays content in QLabel.
+ */
+class BorderedBarWidget : public QWidget {
+
+       Q_OBJECT;
+
+public:
+       enum TextPosition
+       {
+               LeftAlign, /*!< Indicates that the item inserted should be aligned to the left. */
+               CenterAlign, /*!< Indicates that the item inserted should be aligned to the center. */
+               RightAlign /*!< Indicates that the item inserted should be aligned to the right. */
+       };
+
+public:
+       //! Constructor.
+       /*!
+        * Constructor to initialize a BorderedBarWidget instance.
+        * \param aParent Parent widget. Optional.
+        */
+       BorderedBarWidget( QWidget *aParent = 0 );
+       //! Destructor.
+       virtual ~BorderedBarWidget();
+
+       //! Returns background color.
+       /*!
+        * \return The background color of the widget.
+        */
+       QColor backgroundColor();
+       //! Returns face color.
+       /*!
+        * \return The text and border color.
+        */
+    QColor faceColor();
+       //! Returns border width.
+       /*!
+        * \return The border width.
+        */
+    int borderWidth();
+       //! Returns text.
+       /*!
+        * \param aPos Text position. Optional.
+        * \return The text at a position.
+        */
+    QString text( TextPosition aPos = CenterAlign );
+
+       //! Sets background color.
+       /*!
+        * Sets the background color of the widget.
+        * \param aColor The new color.
+        */
+    void setBackgroundColor( QColor aColor);
+       //! Sets face color.
+       /*!
+        * Sets the text and border color of the widget.
+        * \param aColor The new color.
+        */
+    void setFaceColor( QColor aColor );
+       //! Sets border width.
+       /*!
+        * Sets the width of the border.
+        * \param aWidth The new width in pixels.
+        */
+    void setBorderWidth( int aWidth );
+       //! Sets text.
+       /*!
+        * Sets text to a certain position in a bar.
+        * \param aText The new text.
+        * \param aPos The position of the text. Optional.
+        */
+    void setText( QString aText, TextPosition aPos = CenterAlign );
+       //! Sets pixmap.
+       /*!
+        * Sets pixmap to a certain position in a bar.
+        * \param aPixmap The new pixmap.
+        * \param aPos The position of the pixmap. Optional.
+        */
+    void setPixmap( QPixmap aPixmap, TextPosition aPos = RightAlign );
+
+private:
+       //! Draws the borders.
+       /*!
+        * Handles drawing of the borders.
+        */
+       void drawBorder();
+       //! Draws corner.
+       /*!
+        * Handles drawing of a corner.
+        * \param aPainter Painter used for drawing.
+        * \param aCenter Inner corner of the widget.
+        */
+       void drawCorner( QPainter &aPainter, QPoint &aCenter );
+       //! Draws side.
+       /*!
+        * Handles drawing of a single side.
+        * \param aPainter Painter used for drawing.
+        * \param aStartPoint Start point of drawing area.
+        * \param aEndPoint End point of drawing area.
+        */
+       void drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint );
+
+protected:
+       //! Handles drawing of the widget.
+       /*!
+        * Handles drawing of the widget.
+        */
+    virtual void paintEvent(QPaintEvent *);
+
+private:
+       //! Palette for storing colors.
+    QPalette iPalette;
+       //! Border width.
+    int iBorderWidth;
+       //! Label for left aligned content.
+       QLabel *iLeftLabel;
+       //! Label for center aligned content.
+    QLabel *iCenterLabel;
+       //! Label for right aligned content.
+       QLabel *iRightLabel;
+};
+
+#endif /* BORDEREDBARWIDGET_H_ */