#define TOOLTIP_SHOW_DELAY 0500
#define TOOLTIP_HIDE_DELAY 7000
+/*!
+ Constructor
+*/
QtxToolTip::QtxToolTip( QWidget* parent )
: QLabel( parent, "", WStyle_Customize | WStyle_NoBorder | WX11BypassWM | WStyle_Tool | WStyle_StaysOnTop | WType_TopLevel )
{
myShowDelayTime = 5000;
}
+/*!
+ Destructor
+*/
QtxToolTip::~QtxToolTip()
{
}
+/*!
+ Custom event filter
+*/
bool QtxToolTip::eventFilter( QObject* o, QEvent* e )
{
if ( ( e->type() == QEvent::Destroy ) || ( e->type() == QEvent::Close ) || ( e->type() == QEvent::Hide ) )
return false;
}
+/*!
+ Shows tool tip
+ \param aPos - position
+ \param text - tooltip text
+ \param aWidgetRegion - rectangle
+*/
void QtxToolTip::showTip( const QPoint& aPos, const QString& text, const QRect& aWidgetRegion )
{
QFontMetrics theFM = fontMetrics();
showTip( QRect( QPoint( aPos.x(), aPos.y() + 10 ), QSize( theWidth, theHeight ) ), text, aWidgetRegion );
}
+/*!
+ Shows tool tip
+ \param aRegion - tooltip region
+ \param text - tooltip text
+ \param aWidgetRegion - widget rectangle
+*/
void QtxToolTip::showTip( const QRect& aRegion, const QString& text, const QRect& aWidgetRegion )
{
setText( text );
show();
}
+/*!
+ Hides tooltip
+*/
void QtxToolTip::hideTip()
{
hide();
mySleepTimer->stop();
}
+/*!
+ It is called when there is a possibility that a tool tip should be shown and
+ must decide whether there is a tool tip for the point p in the widget that this QToolTip object relates to
+ \param pos - position
+*/
void QtxToolTip::maybeTip( const QPoint& pos )
{
QString text;
}
}
+/*!
+ SLOT: called when sleep time is out
+*/
void QtxToolTip::onSleepTimeOut()
{
mySleepTimer->stop();
hideTip();
}
+/*!
+ SLOT: called when wake time is out
+*/
void QtxToolTip::onWakeUpTimeOut()
{
myWakeUpTimer->stop();
maybeTip( pos );
}
+/*!
+ Custom mouse press event handler
+*/
void QtxToolTip::mousePressEvent( QMouseEvent* e )
{
hideTip();
QApplication::sendEvent( reciever, me );
}
+/*!
+ Custom mouse double click event handler
+*/
void QtxToolTip::mouseDoubleClickEvent( QMouseEvent* e )
{
hideTip();
QApplication::sendEvent( reciever, me );
}
+/*!
+ Sets wake delay time
+ \param theTime
+*/
void QtxToolTip::setWakeUpDelayTime( int theTime )
{
if( !(theTime < 0) )
myWakeUpDelayTime = theTime;
}
+/*!
+ Sets show delay time
+ \param theTime
+*/
void QtxToolTip::setShowDelayTime( int theTime )
{
if( !(theTime < 0) )
myShowDelayTime = theTime;
}
+/*!
+ \return timer measuring time of sleeping
+*/
QTimer* QtxToolTip::sleepTimer() const
{
return mySleepTimer;
}
+/*!
+ \return timer measuring time of waking up
+*/
QTimer* QtxToolTip::wakeUpTimer() const
{
return myWakeUpTimer;