]> cloud.milkyroute.net Git - dolphin.git/blob - src/tooltips/ktooltipdelegate.h
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / tooltips / ktooltipdelegate.h
1 /***************************************************************************
2 * Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KTOOLTIPDELEGATE_H
21 #define KTOOLTIPDELEGATE_H
22
23 #include <QFontMetrics>
24 #include <QFont>
25 #include <QObject>
26 #include <QPalette>
27 #include <QRect>
28 #include <QStyle>
29 #include <QSize>
30
31 class KStyleOptionToolTip;
32 class KToolTipItem;
33 class QPainter;
34 class QRegion;
35
36 class KStyleOptionToolTip
37 {
38 public:
39 KStyleOptionToolTip();
40 enum Corner { TopLeftCorner, TopRightCorner, BottomLeftCorner, BottomRightCorner, NoCorner };
41
42 Qt::LayoutDirection direction;
43 QFontMetrics fontMetrics;
44 QPalette palette;
45 QRect rect;
46 QStyle::State state;
47 QFont font;
48 QSize decorationSize;
49 Corner activeCorner;
50 };
51
52 /**
53 * KToolTipDelegate is responsible for providing the size hint and
54 * painting the tooltips.
55 */
56 class KToolTipDelegate : public QObject
57 {
58 Q_OBJECT
59 public:
60 KToolTipDelegate();
61 virtual ~KToolTipDelegate();
62
63 virtual QSize sizeHint(const KStyleOptionToolTip &option, const KToolTipItem &item) const;
64
65 /**
66 * If haveAlphaChannel() returns true, the paint device will be filled with
67 * Qt::transparent when this function is called, otherwise the content is
68 * undefined.
69 */
70 virtual void paint(QPainter *painter,
71 const KStyleOptionToolTip &option,
72 const KToolTipItem &item) const;
73
74 /**
75 * Reimplement this function to specify the region of the tooltip
76 * that accepts input. Any mouse events that occur outside this
77 * region will be sent to the widget below the tooltip.
78 *
79 * The default implementation returns a region containing the
80 * bounding rect of the tooltip.
81 *
82 * This function will only be called if haveAlphaChannel()
83 * returns true.
84 */
85 virtual QRegion inputShape(const KStyleOptionToolTip &option) const;
86
87 /**
88 * Reimplement this function to specify a shape mask for the tooltip.
89 *
90 * The default implementation returns a region containing the
91 * bounding rect of the tooltip.
92 *
93 * This function will only be called if haveAlphaChannel()
94 * returns false.
95 */
96 virtual QRegion shapeMask(const KStyleOptionToolTip &option) const;
97
98 protected:
99 /**
100 * Returns true if the tooltip has an alpha channel, and false
101 * otherwise.
102 *
103 * Implementors should assume that this condition may change at
104 * any time during the runtime of the application, as compositing
105 * can be enabled or disabled in the window manager.
106 */
107 bool haveAlphaChannel() const;
108 };
109
110 #endif