1 /**************************************************************************** 2 ** $Id: qt/qtooltip.h 3.3.8 edited Jan 11 14:39 $ 3 ** 4 ** Definition of Tool Tips (or Balloon Help) for any widget or rectangle 5 ** 6 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 7 ** 8 ** This file is part of the widgets module of the Qt GUI Toolkit. 9 ** 10 ** This file may be distributed under the terms of the Q Public License 11 ** as defined by Trolltech ASA of Norway and appearing in the file 12 ** LICENSE.QPL included in the packaging of this file. 13 ** 14 ** This file may be distributed and/or modified under the terms of the 15 ** GNU General Public License version 2 as published by the Free Software 16 ** Foundation and appearing in the file LICENSE.GPL included in the 17 ** packaging of this file. 18 ** 19 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 20 ** licenses may use this file in accordance with the Qt Commercial License 21 ** Agreement provided with the Software. 22 ** 23 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 24 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 25 ** 26 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 27 ** information about Qt Commercial License Agreements. 28 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 29 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 30 ** 31 ** Contact info@trolltech.com if any conditions of this licensing are 32 ** not clear to you. 33 ** 34 **********************************************************************/ 35 36 #ifndef QTOOLTIP_H 37 #define QTOOLTIP_H 38 39 #ifndef QT_H 40 #include "qwidget.h" 41 #endif // QT_H 42 43 #ifndef QT_NO_TOOLTIP 44 45 #if __GNUC__ - 0 > 3 46 #pragma GCC system_header 47 #endif 48 49 class QTipManager; 50 class QIconViewToolTip; 51 class QListViewToolTip; 52 53 class Q_EXPORT QToolTipGroup: public QObject 54 { 55 Q_OBJECT 56 Q_PROPERTY( bool delay READ delay WRITE setDelay ) 57 Q_PROPERTY( bool enabled READ enabled WRITE setEnabled ) 58 59 public: 60 QToolTipGroup( QObject *parent, const char *name = 0 ); 61 ~QToolTipGroup(); 62 63 bool delay() const; 64 bool enabled() const; 65 66 public slots: 67 void setDelay( bool ); 68 void setEnabled( bool ); 69 70 signals: 71 void showTip( const QString &); 72 void removeTip(); 73 74 private: 75 uint del:1; 76 uint ena:1; 77 78 friend class QTipManager; 79 80 private: // Disabled copy constructor and operator= 81 #if defined(Q_DISABLE_COPY) 82 QToolTipGroup( const QToolTipGroup & ); 83 QToolTipGroup& operator=( const QToolTipGroup & ); 84 #endif 85 }; 86 87 88 class Q_EXPORT QToolTip: public Qt 89 { 90 public: 91 QToolTip( QWidget *, QToolTipGroup * = 0 ); 92 //### add virtual d'tor for 4.0 93 94 static void add( QWidget *, const QString &); 95 static void add( QWidget *, const QString &, 96 QToolTipGroup *, const QString& ); 97 static void remove( QWidget * ); 98 99 static void add( QWidget *, const QRect &, const QString &); 100 static void add( QWidget *, const QRect &, const QString &, 101 QToolTipGroup *, const QString& ); 102 static void remove( QWidget *, const QRect & ); 103 104 static QString textFor( QWidget *, const QPoint & pos = QPoint() ); 105 106 static void hide(); 107 108 static QFont font(); 109 static void setFont( const QFont & ); 110 static QPalette palette(); 111 static void setPalette( const QPalette & ); 112 113 #ifndef QT_NO_COMPAT setEnabled(bool enable)114 static void setEnabled( bool enable ) { setGloballyEnabled( enable ); } enabled()115 static bool enabled() { return isGloballyEnabled(); } 116 #endif 117 static void setGloballyEnabled( bool ); 118 static bool isGloballyEnabled(); 119 static void setWakeUpDelay(int); 120 121 protected: 122 virtual void maybeTip( const QPoint & ) = 0; 123 void tip( const QRect &, const QString &); 124 void tip( const QRect &, const QString& , const QString &); 125 void tip( const QRect &, const QString &, const QRect & ); 126 void tip( const QRect &, const QString&, const QString &, const QRect &); 127 128 void clear(); 129 130 public: parentWidget()131 QWidget *parentWidget() const { return p; } group()132 QToolTipGroup *group() const { return g; } 133 134 private: 135 QWidget *p; 136 QToolTipGroup *g; 137 static QFont *ttFont; 138 static QPalette *ttPalette; 139 140 friend class QTipManager; 141 }; 142 143 144 #endif // QT_NO_TOOLTIP 145 146 #endif // QTOOLTIP_H 147