kexi

kexitooltip.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "kexitooltip.h"
21
22#include <tqpixmap.h>
23#include <tqbitmap.h>
24#include <tqpainter.h>
25#include <tqimage.h>
26#include <tqtooltip.h>
27#include <tqfont.h>
28#include <tqfontmetrics.h>
29#include <tqtimer.h>
30
31
32KexiToolTip::KexiToolTip(const TQVariant& value, TQWidget* parent)
33 : TQWidget(parent, "KexiToolTip", TQt::WStyle_Customize | TQt::WType_Popup | TQt::WStyle_NoBorder
34 | TQt::WX11BypassWM | TQt::WDestructiveClose)
35 , m_value(value)
36{
37 setPalette( TQToolTip::palette() );
38 setFocusPolicy(TQWidget::NoFocus);
39}
40
41KexiToolTip::~KexiToolTip()
42{
43}
44
45TQSize KexiToolTip::sizeHint() const
46{
47 TQSize sz(fontMetrics().boundingRect(m_value.toString()).size());
48 return sz;
49}
50
51void KexiToolTip::show()
52{
53 updateGeometry();
54 TQWidget::show();
55}
56
57void KexiToolTip::paintEvent( TQPaintEvent *pev )
58{
59 TQWidget::paintEvent(pev);
60 TQPainter p(this);
61 drawFrame(p);
62 drawContents(p);
63}
64
65void KexiToolTip::drawFrame(TQPainter& p)
66{
67 p.setPen( TQPen(palette().active().foreground(), 1) );
68 p.drawRect(rect());
69}
70
71void KexiToolTip::drawContents(TQPainter& p)
72{
73 p.drawText(rect(), TQt::AlignCenter, m_value.toString());
74}
75
76#include "kexitooltip.moc"