1 /***************************************************************************
2 * Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef KTOOLTIPDELEGATE_H
21 #define KTOOLTIPDELEGATE_H
23 #include <QFontMetrics>
31 class KStyleOptionToolTip
;
36 class KStyleOptionToolTip
39 KStyleOptionToolTip();
40 enum Corner
{ TopLeftCorner
, TopRightCorner
, BottomLeftCorner
, BottomRightCorner
, NoCorner
};
42 Qt::LayoutDirection direction
;
43 QFontMetrics fontMetrics
;
53 * KToolTipDelegate is responsible for providing the size hint and
54 * painting the tooltips.
56 class KToolTipDelegate
: public QObject
61 virtual ~KToolTipDelegate();
63 virtual QSize
sizeHint(const KStyleOptionToolTip
&option
, const KToolTipItem
&item
) const;
66 * If haveAlphaChannel() returns true, the paint device will be filled with
67 * Qt::transparent when this function is called, otherwise the content is
70 virtual void paint(QPainter
*painter
,
71 const KStyleOptionToolTip
&option
,
72 const KToolTipItem
&item
) const;
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.
79 * The default implementation returns a region containing the
80 * bounding rect of the tooltip.
82 * This function will only be called if haveAlphaChannel()
85 virtual QRegion
inputShape(const KStyleOptionToolTip
&option
) const;
88 * Reimplement this function to specify a shape mask for the tooltip.
90 * The default implementation returns a region containing the
91 * bounding rect of the tooltip.
93 * This function will only be called if haveAlphaChannel()
96 virtual QRegion
shapeMask(const KStyleOptionToolTip
&option
) const;
100 * Returns true if the tooltip has an alpha channel, and false
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.
107 bool haveAlphaChannel() const;