1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * InnoTek Qt extensions: QIRichLabel class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * This class is based on the original QLabel implementation.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef __QIRichLabel_h__
|
---|
28 | #define __QIRichLabel_h__
|
---|
29 |
|
---|
30 | #include "qframe.h"
|
---|
31 |
|
---|
32 | class QSimpleRichText;
|
---|
33 | class QLabelPrivate;
|
---|
34 | class QAction;
|
---|
35 | class QPopupMenu;
|
---|
36 |
|
---|
37 | class QIRichLabel : public QFrame
|
---|
38 | {
|
---|
39 | Q_OBJECT
|
---|
40 | Q_PROPERTY( QString text READ text WRITE setText )
|
---|
41 | Q_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat )
|
---|
42 | Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
|
---|
43 | Q_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents )
|
---|
44 | Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
|
---|
45 | Q_PROPERTY( int indent READ indent WRITE setIndent )
|
---|
46 | Q_OVERRIDE( BackgroundMode backgroundMode DESIGNABLE true )
|
---|
47 |
|
---|
48 | public:
|
---|
49 | QIRichLabel (QWidget *parent, const char* name=0, WFlags f=0);
|
---|
50 | QIRichLabel (const QString &text, QWidget *parent, const char* name=0,
|
---|
51 | WFlags f=0);
|
---|
52 | QIRichLabel (QWidget *buddy, const QString &,
|
---|
53 | QWidget *parent, const char* name=0, WFlags f=0 );
|
---|
54 | ~QIRichLabel();
|
---|
55 |
|
---|
56 | QString text() const { return ltext; }
|
---|
57 | QPixmap *pixmap() const { return lpixmap; }
|
---|
58 | QPicture *picture() const { return lpicture; }
|
---|
59 | QMovie *movie() const;
|
---|
60 |
|
---|
61 | TextFormat textFormat() const;
|
---|
62 | void setTextFormat( TextFormat );
|
---|
63 |
|
---|
64 | int alignment() const { return align; }
|
---|
65 | virtual void setAlignment( int );
|
---|
66 | int indent() const { return extraMargin; }
|
---|
67 | void setIndent( int );
|
---|
68 |
|
---|
69 | bool autoResize() const { return autoresize; }
|
---|
70 | virtual void setAutoResize( bool );
|
---|
71 | bool hasScaledContents() const;
|
---|
72 | void setScaledContents( bool );
|
---|
73 | QSize sizeHint() const;
|
---|
74 | QSize minimumSizeHint() const;
|
---|
75 | virtual void setBuddy( QWidget * );
|
---|
76 | QWidget *buddy() const;
|
---|
77 | int heightForWidth(int) const;
|
---|
78 |
|
---|
79 | void setFont( const QFont &f );
|
---|
80 |
|
---|
81 | public slots:
|
---|
82 | virtual void setText( const QString &);
|
---|
83 | virtual void setPixmap( const QPixmap & );
|
---|
84 | virtual void setPicture( const QPicture & );
|
---|
85 | virtual void setMovie( const QMovie & );
|
---|
86 | virtual void setNum( int );
|
---|
87 | virtual void setNum( double );
|
---|
88 | void clear();
|
---|
89 |
|
---|
90 | protected:
|
---|
91 | void drawContents ( QPainter * );
|
---|
92 | void fontChange ( const QFont & );
|
---|
93 | void resizeEvent ( QResizeEvent* );
|
---|
94 | void focusInEvent ( QFocusEvent* );
|
---|
95 | void keyPressEvent ( QKeyEvent* );
|
---|
96 | void contextMenuEvent (QContextMenuEvent*);
|
---|
97 |
|
---|
98 | protected slots:
|
---|
99 | void putToClipBoard();
|
---|
100 |
|
---|
101 | private slots:
|
---|
102 | void acceleratorSlot();
|
---|
103 | void buddyDied();
|
---|
104 | void movieUpdated(const QRect&);
|
---|
105 | void movieResized(const QSize&);
|
---|
106 |
|
---|
107 | private:
|
---|
108 | void init();
|
---|
109 | void clearContents();
|
---|
110 | void updateLabel (QSize oldSizeHint);
|
---|
111 | QString compressText (int paneWidth = -1) const;
|
---|
112 | QSize sizeForWidth (int w) const;
|
---|
113 |
|
---|
114 | QString ltext;
|
---|
115 | QPixmap *lpixmap;
|
---|
116 | QPicture *lpicture;
|
---|
117 | QMovie *lmovie;
|
---|
118 | QAction *copyAction;
|
---|
119 | QPopupMenu *popupMenu;
|
---|
120 | QWidget *lbuddy;
|
---|
121 | ushort align;
|
---|
122 | short extraMargin;
|
---|
123 | uint autoresize:1;
|
---|
124 | uint scaledcontents :1;
|
---|
125 | TextFormat textformat;
|
---|
126 | QAccel *accel;
|
---|
127 | QLabelPrivate *d;
|
---|
128 | QSimpleRichText *doc;
|
---|
129 |
|
---|
130 | friend class QTipLabel;
|
---|
131 |
|
---|
132 | QIRichLabel( const QIRichLabel & );
|
---|
133 | QIRichLabel &operator=( const QIRichLabel & );
|
---|
134 | };
|
---|
135 |
|
---|
136 | #endif // __QIRichLabel_h__
|
---|