1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * innotek Qt extensions: QIRichLabel class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
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 | void setFixedHeight (int);
|
---|
81 |
|
---|
82 | void setMaxHeightMode (bool);
|
---|
83 |
|
---|
84 | public slots:
|
---|
85 | virtual void setText( const QString &);
|
---|
86 | virtual void setPixmap( const QPixmap & );
|
---|
87 | virtual void setPicture( const QPicture & );
|
---|
88 | virtual void setMovie( const QMovie & );
|
---|
89 | virtual void setNum( int );
|
---|
90 | virtual void setNum( double );
|
---|
91 | void clear();
|
---|
92 |
|
---|
93 | protected slots:
|
---|
94 | void putToClipBoard();
|
---|
95 |
|
---|
96 | protected:
|
---|
97 | void drawContents ( QPainter * );
|
---|
98 | void fontChange ( const QFont & );
|
---|
99 | void mouseMoveEvent (QMouseEvent *);
|
---|
100 | void mousePressEvent (QMouseEvent *);
|
---|
101 | void resizeEvent ( QResizeEvent* );
|
---|
102 | void focusInEvent ( QFocusEvent* );
|
---|
103 | void keyPressEvent ( QKeyEvent* );
|
---|
104 | void contextMenuEvent (QContextMenuEvent*);
|
---|
105 |
|
---|
106 | signals:
|
---|
107 | void clickedOnLink (const QString&);
|
---|
108 |
|
---|
109 | private slots:
|
---|
110 | void acceleratorSlot();
|
---|
111 | void buddyDied();
|
---|
112 | void movieUpdated(const QRect&);
|
---|
113 | void movieResized(const QSize&);
|
---|
114 |
|
---|
115 | private:
|
---|
116 | void init();
|
---|
117 | void clearContents();
|
---|
118 | void updateLabel (QSize oldSizeHint);
|
---|
119 | QString compressText (int paneWidth = -1) const;
|
---|
120 | QSize sizeForWidth (int w) const;
|
---|
121 |
|
---|
122 | QString ltext;
|
---|
123 | QString mTipText;
|
---|
124 | bool mIsMainTip;
|
---|
125 | QPixmap *lpixmap;
|
---|
126 | QPicture *lpicture;
|
---|
127 | QMovie *lmovie;
|
---|
128 | QPopupMenu *popupMenu;
|
---|
129 | QString popupBuffer;
|
---|
130 | QWidget *lbuddy;
|
---|
131 | ushort align;
|
---|
132 | short extraMargin;
|
---|
133 | uint autoresize:1;
|
---|
134 | uint scaledcontents :1;
|
---|
135 | uint baseheight;
|
---|
136 | TextFormat textformat;
|
---|
137 | QAccel *accel;
|
---|
138 | QLabelPrivate *d;
|
---|
139 | QSimpleRichText *doc;
|
---|
140 | bool mMaxHeightMode;
|
---|
141 |
|
---|
142 | friend class QTipLabel;
|
---|
143 |
|
---|
144 | QIRichLabel( const QIRichLabel & );
|
---|
145 | QIRichLabel &operator=( const QIRichLabel & );
|
---|
146 | };
|
---|
147 |
|
---|
148 | #endif // __QIRichLabel_h__
|
---|