2007-03-01 20:58:19 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Alexander Wiedenbruch <mail@wiedenbruch.de>
|
2007-05-22 18:48:34 +02:00
|
|
|
* and Matias Valdenegro <mvaldenegro@informatica.utem.cl>
|
2007-03-01 20:58:19 +01: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-03-01 20:58:19 +01: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 WIDGET_H_
|
|
|
|
#define WIDGET_H_
|
|
|
|
|
2008-04-13 15:23:39 +02:00
|
|
|
#include <QtGui/QGraphicsWidget>
|
2007-12-23 20:20:22 +01:00
|
|
|
#include <QtGui/QPixmap>
|
2007-03-01 20:58:19 +01:00
|
|
|
|
2007-05-22 18:48:34 +02:00
|
|
|
#include <QtCore/QRectF>
|
|
|
|
#include <QtCore/QSizeF>
|
2007-12-21 06:33:17 +01:00
|
|
|
#include <QtCore/QString>
|
2007-05-22 18:48:34 +02:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2007-03-02 15:34:41 +01:00
|
|
|
|
2007-12-08 04:35:11 +01:00
|
|
|
class QGraphicsView;
|
2007-12-21 06:33:17 +01:00
|
|
|
class QGraphicsSceneHoverEvent;
|
2007-12-08 04:35:11 +01:00
|
|
|
|
2007-03-02 06:27:33 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-12-21 06:33:17 +01:00
|
|
|
struct PLASMA_EXPORT ToolTipData
|
|
|
|
{
|
2008-01-03 12:35:42 +01:00
|
|
|
ToolTipData() : windowToPreview( 0 ) {}
|
2007-12-21 06:33:17 +01:00
|
|
|
QString mainText; //Important information
|
|
|
|
QString subText; //Elaborates on the Main Text
|
|
|
|
QPixmap image; // Icon to show;
|
2008-01-03 12:35:42 +01:00
|
|
|
WId windowToPreview; // Id of window to show preview
|
2007-12-21 06:33:17 +01:00
|
|
|
};
|
|
|
|
|
2007-05-22 18:48:34 +02:00
|
|
|
class Layout;
|
|
|
|
|
2007-12-21 06:33:17 +01:00
|
|
|
|
2007-05-20 18:25:07 +02:00
|
|
|
/**
|
2007-07-23 00:16:40 +02:00
|
|
|
* Base class for all Widgets in Plasma.
|
|
|
|
*
|
2007-08-03 18:00:10 +02:00
|
|
|
* @author Alexander Wiedenbruch
|
|
|
|
* @author Matias Valdenegro
|
2007-07-23 00:16:40 +02:00
|
|
|
*
|
|
|
|
* Widgets are the basis for User Interfaces inside Plasma.
|
|
|
|
* Widgets are rectangular, but can be in any visible shape by just using transparency to mask
|
|
|
|
* out non-rectangular areas.
|
|
|
|
*
|
2007-10-11 21:16:01 +02:00
|
|
|
* To implement a Widget, just subclass Plasma::Widget and implement at minimum,
|
|
|
|
* sizeHint() and paintWidget()
|
2007-05-20 18:25:07 +02:00
|
|
|
*/
|
2008-04-13 15:23:39 +02:00
|
|
|
class PLASMA_EXPORT Widget : public QGraphicsWidget
|
2007-03-01 20:58:19 +01:00
|
|
|
{
|
2007-08-03 18:00:10 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
/**
|
2007-08-03 20:56:14 +02:00
|
|
|
* Creates a new Plasma::Widget.
|
|
|
|
* @param parent the QGraphicsItem this icon is parented to.
|
|
|
|
*/
|
2008-02-29 18:50:57 +01:00
|
|
|
explicit Widget(QGraphicsItem *parent = 0 , QObject *parentObject = 0);
|
2007-08-03 18:00:10 +02:00
|
|
|
|
|
|
|
/**
|
2007-08-03 20:56:14 +02:00
|
|
|
* Destroys a Plasma::Widget.
|
|
|
|
*/
|
2007-08-03 18:00:10 +02:00
|
|
|
virtual ~Widget();
|
|
|
|
|
2008-04-14 18:02:23 +02:00
|
|
|
|
2008-04-14 16:50:02 +02:00
|
|
|
#ifdef TOOLTIPMANAGER
|
2007-12-21 06:33:17 +01:00
|
|
|
/**
|
|
|
|
* The Data from the tooltip
|
|
|
|
* @returns A ToolTip::Data object with current information
|
|
|
|
*/
|
2008-02-05 19:26:17 +01:00
|
|
|
const ToolTipData* toolTip() const;
|
2007-12-21 06:33:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setter for data shown in tooltip
|
|
|
|
* @param data a ToolTip::Data object containing icon and text
|
|
|
|
*/
|
2008-03-18 02:39:28 +01:00
|
|
|
void setToolTip(const ToolTipData &dt);
|
|
|
|
|
|
|
|
/**
|
2008-04-02 01:01:52 +02:00
|
|
|
* Called when the tooltip is going to be shown or just after hiding
|
|
|
|
* it. This lets updating data right before a tooltip is shown or
|
|
|
|
* tracking current visibility. That allows e.g. tips that are more
|
|
|
|
* expensive to create ahead of time to be set at the last possible
|
|
|
|
* moment.
|
|
|
|
* @param update visibility of tooltip
|
2008-03-18 02:39:28 +01:00
|
|
|
*/
|
2008-04-02 01:01:52 +02:00
|
|
|
virtual void updateToolTip(bool update);
|
2007-12-25 06:34:43 +01:00
|
|
|
|
2008-04-14 16:50:02 +02:00
|
|
|
#endif
|
2008-01-23 00:39:15 +01:00
|
|
|
|
2007-12-25 06:34:43 +01:00
|
|
|
protected:
|
2008-04-14 16:50:02 +02:00
|
|
|
#ifdef TOOLTIPMANAGER
|
|
|
|
virtual bool sceneEvent(QEvent *event);
|
|
|
|
#endif
|
2007-07-12 19:54:58 +02:00
|
|
|
private:
|
2008-04-14 18:02:23 +02:00
|
|
|
|
2007-07-12 19:54:58 +02:00
|
|
|
class Private;
|
|
|
|
Private *const d;
|
2007-03-01 20:58:19 +01:00
|
|
|
};
|
|
|
|
|
2007-03-02 06:27:33 +01:00
|
|
|
} // Plasma namespace
|
|
|
|
|
2007-03-01 20:58:19 +01:00
|
|
|
#endif
|