OSDN Git Service

5222a113d1ab98853ec71ce31d4e6b0c6929b39e
[qt-creator-jp/qt-creator-jp.git] / src / plugins / texteditor / tooltip / tips.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef TIPS_H
35 #define TIPS_H
36
37 #include <QtCore/QSharedPointer>
38 #include <QtGui/QLabel>
39 #include <QtGui/QPixmap>
40
41 QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
42
43 namespace TextEditor {
44 class TipContent;
45 }
46
47 #ifndef Q_MOC_RUN
48 namespace TextEditor {
49 namespace Internal {
50 #endif
51
52 // Please do not change the name of this class. Detailed comments in tooltip.h.
53 class QTipLabel : public QLabel
54 {
55     Q_OBJECT
56 protected:
57     QTipLabel(QWidget *parent);
58
59 public:
60     virtual ~QTipLabel();
61
62     void setContent(const TextEditor::TipContent &content);
63     const TextEditor::TipContent &content() const;
64
65     virtual void configure(const QPoint &pos, QWidget *w) = 0;
66     virtual bool canHandleContentReplacement(const TextEditor::TipContent &content) const = 0;
67
68     bool isInteractive() const;
69
70 private:
71     TextEditor::TipContent *m_tipContent;
72 };
73
74 class ColorTip : public QTipLabel
75 {
76     Q_OBJECT
77 public:
78     ColorTip(QWidget *parent);
79     virtual ~ColorTip();
80
81     virtual void configure(const QPoint &pos, QWidget *w);
82     virtual bool canHandleContentReplacement(const TipContent &content) const;
83
84 private:
85     virtual void paintEvent(QPaintEvent *event);
86
87     QPixmap m_tilePixMap;
88 };
89
90 class TextTip : public QTipLabel
91 {
92     Q_OBJECT
93 public:
94     TextTip(QWidget *parent);
95     virtual ~TextTip();
96
97     virtual void configure(const QPoint &pos, QWidget *w);
98     virtual bool canHandleContentReplacement(const TipContent &content) const;
99
100 private:
101     virtual void paintEvent(QPaintEvent *event);
102     virtual void resizeEvent(QResizeEvent *event);
103 };
104
105 class WidgetTip : public QTipLabel
106 {
107     Q_OBJECT
108 public:
109     explicit WidgetTip(QWidget *parent = 0);
110
111     virtual void configure(const QPoint &pos, QWidget *w);
112     virtual bool canHandleContentReplacement(const TipContent &content) const;
113
114 public slots:
115     void pinToolTipWidget();
116
117 private:
118     QWidget *takeWidget(Qt::WindowFlags wf = 0);
119
120     QVBoxLayout *m_layout;
121 };
122
123 #ifndef Q_MOC_RUN
124 } // namespace Internal
125 } // namespace TextEditor
126 #endif
127
128 #endif // TIPS_H