2007-03-05 05:13:22 +01:00
|
|
|
/*
|
2007-03-13 01:32:17 +01:00
|
|
|
* Copyright (C) 2007 by Siraj Razick siraj@kde.org
|
2007-03-05 05:13:22 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* 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 PUSHBUTTON_H
|
|
|
|
#define PUSHBUTTON_H
|
|
|
|
|
2007-04-22 11:35:04 +02:00
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsTextItem>
|
|
|
|
#include <QtGui/QLayoutItem>
|
2007-03-05 05:13:22 +01:00
|
|
|
#include <kdemacros.h>
|
|
|
|
|
|
|
|
#include "datavisualization.h"
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
//Please Document this class
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-03-13 04:00:09 +01:00
|
|
|
class KDE_EXPORT PushButton : public DataVisualization,
|
|
|
|
public QGraphicsItem,
|
|
|
|
public QLayoutItem
|
2007-03-05 05:13:22 +01:00
|
|
|
{
|
2007-03-13 04:25:19 +01:00
|
|
|
Q_OBJECT
|
2007-03-05 05:13:22 +01:00
|
|
|
public:
|
2007-03-13 04:00:09 +01:00
|
|
|
enum ButtonShape
|
|
|
|
{
|
|
|
|
Rectangle = 0,
|
|
|
|
Round,
|
|
|
|
Custom
|
|
|
|
};
|
2007-03-05 05:13:22 +01:00
|
|
|
|
2007-03-13 04:00:09 +01:00
|
|
|
enum ButtonState
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Hover,
|
|
|
|
Pressed,
|
|
|
|
Released
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2007-03-05 05:13:22 +01:00
|
|
|
PushButton(QGraphicsItem *parent = 0);
|
2007-03-13 01:32:17 +01:00
|
|
|
virtual ~PushButton();
|
2007-03-05 05:13:22 +01:00
|
|
|
|
2007-03-13 04:00:09 +01:00
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &name);
|
|
|
|
|
|
|
|
QSize size() const;
|
2007-03-05 05:13:22 +01:00
|
|
|
void setSize(QSize size);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
|
|
|
int height() const;
|
2007-03-05 05:13:22 +01:00
|
|
|
void setHeight(int height);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
|
|
|
int width() const;
|
|
|
|
void setWidth(int width);
|
|
|
|
|
|
|
|
void setIcon(const QString& path);
|
2007-03-05 05:13:22 +01:00
|
|
|
void setMaximumWidth(int maxwidth);
|
|
|
|
|
2007-03-13 04:00:09 +01:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
|
|
virtual QRectF boundingRect() const;
|
|
|
|
|
2007-03-12 20:16:17 +01:00
|
|
|
//layout stufff
|
2007-03-13 04:00:09 +01:00
|
|
|
virtual QSize sizeHint() const ;
|
|
|
|
virtual QSize minimumSize() const;
|
|
|
|
virtual QSize maximumSize() const ;
|
|
|
|
virtual Qt::Orientations expandingDirections() const;
|
|
|
|
virtual void setGeometry(const QRect& r);
|
|
|
|
virtual QRect geometry() const ;
|
|
|
|
virtual bool isEmpty() const {return false;}
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2007-03-05 05:13:22 +01:00
|
|
|
void clicked();
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-03-13 04:25:19 +01:00
|
|
|
public Q_SLOTS:
|
|
|
|
virtual void data(const DataSource::Data &);
|
|
|
|
|
2007-03-05 05:13:22 +01:00
|
|
|
protected:
|
|
|
|
bool isDown();
|
2007-03-13 04:00:09 +01:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2007-03-13 04:25:19 +01:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-03-05 05:13:22 +01:00
|
|
|
private:
|
|
|
|
class Private ;
|
|
|
|
Private * const d;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|