kexi

kexitooltip.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kexitooltip.h"
00021 
00022 #include <qpixmap.h>
00023 #include <qbitmap.h>
00024 #include <qpainter.h>
00025 #include <qimage.h>
00026 #include <qtooltip.h>
00027 #include <qfont.h>
00028 #include <qfontmetrics.h>
00029 #include <qtimer.h>
00030 
00031 
00032 KexiToolTip::KexiToolTip(const QVariant& value, QWidget* parent)
00033  : QWidget(parent, "KexiToolTip", Qt::WStyle_Customize | Qt::WType_Popup | Qt::WStyle_NoBorder 
00034     | Qt::WX11BypassWM | Qt::WDestructiveClose)
00035  , m_value(value)
00036 {
00037     setPalette( QToolTip::palette() );
00038     setFocusPolicy(QWidget::NoFocus);
00039 }
00040 
00041 KexiToolTip::~KexiToolTip()
00042 {
00043 }
00044 
00045 QSize KexiToolTip::sizeHint() const
00046 {
00047     QSize sz(fontMetrics().boundingRect(m_value.toString()).size());
00048     return sz;
00049 }
00050 
00051 void KexiToolTip::show()
00052 {
00053     updateGeometry();
00054     QWidget::show();
00055 }
00056 
00057 void KexiToolTip::paintEvent( QPaintEvent *pev )
00058 {
00059     QWidget::paintEvent(pev);
00060     QPainter p(this);
00061     drawFrame(p);
00062     drawContents(p);
00063 }
00064 
00065 void KexiToolTip::drawFrame(QPainter& p)
00066 {
00067     p.setPen( QPen(palette().active().foreground(), 1) );
00068     p.drawRect(rect());
00069 }
00070 
00071 void KexiToolTip::drawContents(QPainter& p)
00072 {
00073     p.drawText(rect(), Qt::AlignCenter, m_value.toString());
00074 }
00075 
00076 #include "kexitooltip.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys