1 | /*
|
---|
2 | * fancylabel.h - the FancyLabel widget
|
---|
3 | * Copyright (C) 2003 Michail Pishchagin
|
---|
4 | *
|
---|
5 | * This library is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU Lesser General Public
|
---|
7 | * License as published by the Free Software Foundation; either
|
---|
8 | * version 2.1 of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This library is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
13 | * Lesser General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU Lesser General Public
|
---|
16 | * License along with this library; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | *
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef FANCYLABEL_H
|
---|
22 | #define FANCYLABEL_H
|
---|
23 |
|
---|
24 | #include <qwidget.h>
|
---|
25 | #include <qlabel.h>
|
---|
26 |
|
---|
27 | class QPixmap;
|
---|
28 | class QColor;
|
---|
29 | class Icon;
|
---|
30 |
|
---|
31 | class FancyLabel : public QWidget
|
---|
32 | {
|
---|
33 | Q_OBJECT
|
---|
34 | Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
|
---|
35 | Q_PROPERTY( QString text READ text WRITE setText )
|
---|
36 | Q_PROPERTY( QString help READ help WRITE setHelp )
|
---|
37 | Q_PROPERTY( QColor colorFrom READ colorFrom WRITE setColorFrom )
|
---|
38 | Q_PROPERTY( QColor colorTo READ colorTo WRITE setColorTo )
|
---|
39 | Q_PROPERTY( QColor colorFont READ colorFont WRITE setColorFont )
|
---|
40 | Q_PROPERTY( QString iconName READ iconName WRITE setIcon )
|
---|
41 |
|
---|
42 | Q_ENUMS( Shape Shadow )
|
---|
43 | Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
|
---|
44 | Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
|
---|
45 | Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
|
---|
46 | Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
|
---|
47 |
|
---|
48 | public:
|
---|
49 | FancyLabel (QWidget *parent = 0, const char *name = 0);
|
---|
50 | ~FancyLabel ();
|
---|
51 |
|
---|
52 | const QString &text () const;
|
---|
53 | const QString &help () const;
|
---|
54 | const QPixmap *pixmap () const;
|
---|
55 | const QColor &colorFrom () const;
|
---|
56 | const QColor &colorTo () const;
|
---|
57 | const QColor &colorFont () const;
|
---|
58 | const Icon *icon () const;
|
---|
59 | const QString &iconName () const;
|
---|
60 | void setText (const QString &);
|
---|
61 | void setHelp (const QString &);
|
---|
62 | void setPixmap (const QPixmap &);
|
---|
63 | void setColorFrom (const QColor &);
|
---|
64 | void setColorTo (const QColor &);
|
---|
65 | void setColorFont (const QColor &);
|
---|
66 | void setIcon (const Icon *);
|
---|
67 | void setIcon (const QString &);
|
---|
68 | void setIcon (const QPixmap &);
|
---|
69 |
|
---|
70 | enum Shape { NoFrame = 0, // no frame
|
---|
71 | Box = 0x0001, // rectangular box
|
---|
72 | Panel = 0x0002, // rectangular panel
|
---|
73 | WinPanel = 0x0003, // rectangular panel (Windows)
|
---|
74 | StyledPanel = 0x0006, // rectangular panel depending on the GUI style
|
---|
75 | PopupPanel = 0x0007, // rectangular panel depending on the GUI style
|
---|
76 | MenuBarPanel = 0x0008,
|
---|
77 | ToolBarPanel = 0x0009,
|
---|
78 | LineEditPanel = 0x000a,
|
---|
79 | TabWidgetPanel = 0x000b,
|
---|
80 | GroupBoxPanel = 0x000c,
|
---|
81 | MShape = 0x000f // mask for the shape
|
---|
82 | };
|
---|
83 | enum Shadow { Plain = 0x0010, // plain line
|
---|
84 | Raised = 0x0020, // raised shadow effect
|
---|
85 | Sunken = 0x0030, // sunken shadow effect
|
---|
86 | MShadow = 0x00f0 }; // mask for the shadow
|
---|
87 |
|
---|
88 | Shape frameShape () const;
|
---|
89 | void setFrameShape (Shape);
|
---|
90 |
|
---|
91 | Shadow frameShadow () const;
|
---|
92 | void setFrameShadow (Shadow);
|
---|
93 |
|
---|
94 | int lineWidth () const;
|
---|
95 | void setLineWidth (int);
|
---|
96 |
|
---|
97 | int midLineWidth () const;
|
---|
98 | void setMidLineWidth (int);
|
---|
99 |
|
---|
100 | void setScaledContents(int width, int height);
|
---|
101 | static void setSmallFontSize(int);
|
---|
102 |
|
---|
103 | private:
|
---|
104 | class Private;
|
---|
105 | Private *d;
|
---|
106 | };
|
---|
107 |
|
---|
108 | class IconLabel : public QLabel
|
---|
109 | {
|
---|
110 | Q_OBJECT
|
---|
111 | Q_PROPERTY( QString iconName READ iconName WRITE setIcon )
|
---|
112 |
|
---|
113 | public:
|
---|
114 | IconLabel(QWidget *parent = 0, const char *name = 0);
|
---|
115 | ~IconLabel();
|
---|
116 |
|
---|
117 | const Icon *icon () const;
|
---|
118 | const QString &iconName () const;
|
---|
119 | void setIcon (const Icon *, bool copyIcon = true);
|
---|
120 | void setIcon (const QString &);
|
---|
121 | void setIcon (const QPixmap &);
|
---|
122 |
|
---|
123 | void setScaledContents(int width, int height);
|
---|
124 |
|
---|
125 | class Private;
|
---|
126 | private:
|
---|
127 | void drawContents (QPainter *paint);
|
---|
128 |
|
---|
129 | Private *d;
|
---|
130 | };
|
---|
131 |
|
---|
132 | #endif
|
---|