1 /*
2  * TextFloat.h - class textFloat, a floating text-label
3  *
4  * Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5  *
6  * This file is part of LMMS - https://lmms.io
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program (see COPYING); if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301 USA.
22  *
23  */
24 
25 
26 #ifndef TEXT_FLOAT_H
27 #define TEXT_FLOAT_H
28 
29 #include <QWidget>
30 #include <QPixmap>
31 
32 #include "export.h"
33 
34 
35 class EXPORT TextFloat : public QWidget
36 {
37 	Q_OBJECT
38 public:
39 	TextFloat();
~TextFloat()40 	virtual ~TextFloat()
41 	{
42 	}
43 
44 	void setTitle( const QString & _title );
45 	void setText( const QString & _text );
46 	void setPixmap( const QPixmap & _pixmap );
47 
48 	void setVisibilityTimeOut( int _msecs );
49 
50 
51 	static TextFloat * displayMessage( const QString & _msg,
52 						int _timeout = 2000,
53 						QWidget * _parent = NULL,
54 						int _add_y_margin = 0 );
55 	static TextFloat * displayMessage( const QString & _title,
56 						const QString & _msg,
57 						const QPixmap & _pixmap =
58 								QPixmap(),
59 						int _timeout = 2000,
60 						QWidget * _parent = NULL );
61 
moveGlobal(QWidget * _w,const QPoint & _offset)62 	void moveGlobal( QWidget * _w, const QPoint & _offset )
63 	{
64 		move( _w->mapToGlobal( QPoint( 0, 0 ) )+_offset );
65 	}
66 
67 
68 protected:
69 	virtual void paintEvent( QPaintEvent * _me );
70 	virtual void mousePressEvent( QMouseEvent * _me );
71 
72 
73 private:
74 	void updateSize();
75 
76 	QString m_title;
77 	QString m_text;
78 	QPixmap m_pixmap;
79 
80 };
81 
82 #endif
83