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 | void setFixedHeight (int);
|
---|
81 |
|
---|
82 | public slots:
|
---|
83 | virtual void setText( const QString &);
|
---|
84 | virtual void setPixmap( const QPixmap & );
|
---|
85 | virtual void setPicture( const QPicture & );
|
---|
86 | virtual void setMovie( const QMovie & );
|
---|
87 | virtual void setNum( int );
|
---|
88 | virtual void setNum( double );
|
---|
89 | void clear();
|
---|
90 |
|
---|
91 | protected slots:
|
---|
92 | void putToClipBoard();
|
---|
93 |
|
---|
94 | protected:
|
---|
95 | void drawContents ( QPainter * );
|
---|
96 | void fontChange ( const QFont & );
|
---|
97 | void mouseMoveEvent (QMouseEvent *);
|
---|
98 | void mousePressEvent (QMouseEvent *);
|
---|
99 | void resizeEvent ( QResizeEvent* );
|
---|
100 | void focusInEvent ( QFocusEvent* );
|
---|
101 | void keyPressEvent ( QKeyEvent* );
|
---|
102 | void contextMenuEvent (QContextMenuEvent*);
|
---|
103 |
|
---|
104 | signals:
|
---|
105 | void textChanged();
|
---|
106 | void clickedOnLink (const QString&);
|
---|
107 |
|
---|
108 | private slots:
|
---|
109 | void acceleratorSlot();
|
---|
110 | void buddyDied();
|
---|
111 | void movieUpdated(const QRect&);
|
---|
112 | void movieResized(const QSize&);
|
---|
113 |
|
---|
114 | private:
|
---|
115 | void init();
|
---|
116 | void clearContents();
|
---|
117 | void updateLabel (QSize oldSizeHint);
|
---|
118 | QString compressText (int paneWidth = -1) const;
|
---|
119 | QSize sizeForWidth (int w) const;
|
---|
120 |
|
---|
121 | QString ltext;
|
---|
122 | QPixmap *lpixmap;
|
---|
123 | QPicture *lpicture;
|
---|
124 | QMovie *lmovie;
|
---|
125 | QPopupMenu *popupMenu;
|
---|
126 | QWidget *lbuddy;
|
---|
127 | ushort align;
|
---|
128 | short extraMargin;
|
---|
129 | uint autoresize:1;
|
---|
130 | uint scaledcontents :1;
|
---|
131 | uint baseheight;
|
---|
132 | TextFormat textformat;
|
---|
133 | QAccel *accel;
|
---|
134 | QLabelPrivate *d;
|
---|
135 | QSimpleRichText *doc;
|
---|
136 |
|
---|
137 | friend class QTipLabel;
|
---|
138 |
|
---|
139 | QIRichLabel( const QIRichLabel & );
|
---|
140 | QIRichLabel &operator=( const QIRichLabel & );
|
---|
141 | };
|
---|
142 |
|
---|
143 | #endif // __QIRichLabel_h__
|
---|