2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
2007-07-23 00:16:40 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 22:17:11 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
2007-09-14 21:06:18 +02:00
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLASMA_LABEL__
|
|
|
|
#define __PLASMA_LABEL__
|
|
|
|
|
|
|
|
#include <plasma/widgets/widget.h>
|
2007-09-03 19:16:40 +02:00
|
|
|
#include <QtGui/QPen>
|
2007-10-17 17:11:29 +02:00
|
|
|
#include <QtGui/QFont>
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
class QGraphicsTextItem;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple Text Label.
|
|
|
|
*
|
|
|
|
* @author Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
|
|
|
|
*
|
|
|
|
* This class is a simple text label, it just draws plain text.
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT Label : public Plasma::Widget
|
|
|
|
{
|
2007-08-04 15:14:57 +02:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY( QString text READ text WRITE setText )
|
|
|
|
Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment )
|
2007-09-02 19:49:34 +02:00
|
|
|
Q_PROPERTY( QPen pen READ pen WRITE setPen )
|
2007-11-04 06:34:10 +01:00
|
|
|
Q_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth )
|
2007-08-04 15:14:57 +02:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
Label(Widget *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~Label();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Labels can expand in Horizontal and Vertical directions.
|
|
|
|
*/
|
|
|
|
Qt::Orientations expandingDirections() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Labels can use height-for-width geometry management.
|
|
|
|
*/
|
|
|
|
bool hasHeightForWidth() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from Plasma::Widget.
|
|
|
|
*/
|
|
|
|
qreal heightForWidth(qreal w) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from Plasma::Widget.
|
|
|
|
*/
|
|
|
|
QSizeF sizeHint() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the text to be displayed.
|
|
|
|
*/
|
|
|
|
void setText(const QString& text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the displayed text.
|
|
|
|
*/
|
|
|
|
QString text() const;
|
|
|
|
|
2007-07-26 09:25:21 +02:00
|
|
|
/**
|
|
|
|
* Sets the alignment of the displayed text.
|
|
|
|
*/
|
|
|
|
void setAlignment(Qt::Alignment align);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the alignment of the displayed text.
|
|
|
|
*/
|
|
|
|
Qt::Alignment alignment() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the pen used to paint the text.
|
|
|
|
*/
|
|
|
|
void setPen(const QPen& pen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the pen used to paint the text.
|
|
|
|
*/
|
|
|
|
QPen pen() const;
|
|
|
|
|
2007-11-04 06:34:10 +01:00
|
|
|
/**
|
|
|
|
* Sets the maximum width that this label should extend to
|
|
|
|
*
|
|
|
|
* @arg width the new maximum width in pixels
|
|
|
|
*/
|
|
|
|
void setMaximumWidth(int width);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The width in pixels that this label is constrained to
|
|
|
|
*/
|
|
|
|
int maximumWidth() const;
|
|
|
|
|
2007-10-17 17:11:29 +02:00
|
|
|
/**
|
|
|
|
* Sets the font used for the text.
|
|
|
|
*/
|
|
|
|
void setFont(const QFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the font used for the text.
|
|
|
|
*/
|
|
|
|
QFont font() const;
|
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Paint function.
|
|
|
|
*/
|
2007-08-01 22:51:27 +02:00
|
|
|
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
2007-07-28 11:22:20 +02:00
|
|
|
Private * const d;
|
2007-07-23 00:16:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __PLASMA_LABEL__ */
|