source: trunk/include/qlabel.h@ 59

Last change on this file since 59 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 4.9 KB
Line 
1/**********************************************************************
2** $Id: qlabel.h 2 2005-11-16 15:49:26Z dmik $
3**
4** Definition of QLabel widget class
5**
6** Created : 941215
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the widgets module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QLABEL_H
39#define QLABEL_H
40
41#ifndef QT_H
42#include "qframe.h"
43#endif // QT_H
44
45#ifndef QT_NO_LABEL
46
47class QSimpleRichText;
48class QLabelPrivate;
49
50class Q_EXPORT QLabel : public QFrame
51{
52 Q_OBJECT
53 Q_PROPERTY( QString text READ text WRITE setText )
54 Q_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat )
55 Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
56 Q_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents )
57 Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
58 Q_PROPERTY( int indent READ indent WRITE setIndent )
59 Q_OVERRIDE( BackgroundMode backgroundMode DESIGNABLE true)
60
61public:
62 QLabel( QWidget *parent, const char* name=0, WFlags f=0 );
63 QLabel( const QString &text, QWidget *parent, const char* name=0,
64 WFlags f=0 );
65 QLabel( QWidget *buddy, const QString &,
66 QWidget *parent, const char* name=0, WFlags f=0 );
67 ~QLabel();
68
69 QString text() const { return ltext; }
70 QPixmap *pixmap() const { return lpixmap; }
71#ifndef QT_NO_PICTURE
72 QPicture *picture() const { return lpicture; }
73#endif
74#ifndef QT_NO_MOVIE
75 QMovie *movie() const;
76#endif
77
78 TextFormat textFormat() const;
79 void setTextFormat( TextFormat );
80
81 int alignment() const { return align; }
82 virtual void setAlignment( int );
83 int indent() const { return extraMargin; }
84 void setIndent( int );
85
86 bool autoResize() const { return autoresize; }
87 virtual void setAutoResize( bool );
88#ifndef QT_NO_IMAGE_SMOOTHSCALE
89 bool hasScaledContents() const;
90 void setScaledContents( bool );
91#endif
92 QSize sizeHint() const;
93 QSize minimumSizeHint() const;
94#ifndef QT_NO_ACCEL
95 virtual void setBuddy( QWidget * );
96 QWidget *buddy() const;
97#endif
98 int heightForWidth(int) const;
99
100 void setFont( const QFont &f );
101
102public slots:
103 virtual void setText( const QString &);
104 virtual void setPixmap( const QPixmap & );
105#ifndef QT_NO_PICTURE
106 virtual void setPicture( const QPicture & );
107#endif
108#ifndef QT_NO_MOVIE
109 virtual void setMovie( const QMovie & );
110#endif
111 virtual void setNum( int );
112 virtual void setNum( double );
113 void clear();
114
115protected:
116 void drawContents( QPainter * );
117 void fontChange( const QFont & );
118 void resizeEvent( QResizeEvent* );
119
120private slots:
121#ifndef QT_NO_ACCEL
122 void acceleratorSlot();
123 void buddyDied();
124#endif
125#ifndef QT_NO_MOVIE
126 void movieUpdated(const QRect&);
127 void movieResized(const QSize&);
128#endif
129
130private:
131 void init();
132 void clearContents();
133 void updateLabel( QSize oldSizeHint );
134 QSize sizeForWidth( int w ) const;
135 QString ltext;
136 QPixmap *lpixmap;
137#ifndef QT_NO_PICTURE
138 QPicture *lpicture;
139#endif
140#ifndef QT_NO_MOVIE
141 QMovie * lmovie;
142#endif
143#ifndef QT_NO_ACCEL
144 QWidget * lbuddy;
145#endif
146 ushort align;
147 short extraMargin;
148 uint autoresize:1;
149 uint scaledcontents :1;
150 TextFormat textformat;
151#ifndef QT_NO_RICHTEXT
152 QSimpleRichText* doc;
153#endif
154#ifndef QT_NO_ACCEL
155 QAccel * accel;
156#endif
157 QLabelPrivate* d;
158
159 friend class QTipLabel;
160
161private: // Disabled copy constructor and operator=
162#if defined(Q_DISABLE_COPY)
163 QLabel( const QLabel & );
164 QLabel &operator=( const QLabel & );
165#endif
166};
167
168
169#endif // QT_NO_LABEL
170
171#endif // QLABEL_H
Note: See TracBrowser for help on using the repository browser.