|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBICON_H |
|
27 #define HBICON_H |
|
28 |
|
29 #include <hbglobal.h> |
|
30 |
|
31 #include <QIcon> //krazy:exclude=qclasses |
|
32 #include <QMetaType> |
|
33 #include <QString> |
|
34 #include <QExplicitlySharedDataPointer> |
|
35 |
|
36 class HbIconPrivate; |
|
37 class HbIconAnimator; |
|
38 |
|
39 class HB_CORE_EXPORT HbIcon |
|
40 { |
|
41 public: |
|
42 HbIcon(); |
|
43 HbIcon(const QString &iconName); |
|
44 HbIcon(const QIcon &icon); |
|
45 |
|
46 HbIcon(const HbIcon &other); |
|
47 HbIcon &operator=(const HbIcon &other); |
|
48 |
|
49 bool operator==(const HbIcon &other) const; |
|
50 bool operator!=(const HbIcon &other) const; |
|
51 |
|
52 ~HbIcon(); |
|
53 |
|
54 bool isNull() const; |
|
55 bool isBadged() const; |
|
56 void clear(); |
|
57 |
|
58 QPixmap pixmap(); |
|
59 |
|
60 void setColor(const QColor &color); |
|
61 QColor color() const; |
|
62 |
|
63 QString iconName() const; |
|
64 void setIconName(const QString &iconName); |
|
65 |
|
66 QString iconName(QIcon::Mode mode, QIcon::State state) const; |
|
67 void setIconName(const QString &iconName, QIcon::Mode mode, QIcon::State state); |
|
68 |
|
69 QSizeF defaultSize() const; |
|
70 QSizeF size() const; |
|
71 void setSize(const QSizeF &size); |
|
72 |
|
73 void setHeight(qreal height); |
|
74 void setWidth(qreal width); |
|
75 |
|
76 qreal width() const; |
|
77 qreal height() const; |
|
78 |
|
79 enum MirroringMode { |
|
80 Default = 0, |
|
81 Forced = 1, |
|
82 Prevented = 2, |
|
83 LayoutDirection = 3 |
|
84 }; |
|
85 |
|
86 MirroringMode mirroringMode() const; |
|
87 void setMirroringMode(MirroringMode mode); |
|
88 |
|
89 enum Flag { |
|
90 DoNotCache = 0x01, |
|
91 ResolutionCorrected = 0x02, |
|
92 NoAutoStartAnimation = 0x04, |
|
93 Colorized = 0x08 |
|
94 }; |
|
95 |
|
96 Q_DECLARE_FLAGS(Flags, Flag) |
|
97 |
|
98 Flags flags() const; |
|
99 void setFlags(Flags flags); |
|
100 |
|
101 void paint(QPainter *painter, |
|
102 const QRectF &rect, |
|
103 Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio, |
|
104 Qt::Alignment alignment = Qt::AlignCenter, |
|
105 QIcon::Mode mode = QIcon::Normal, |
|
106 QIcon::State state = QIcon::Off) const; |
|
107 |
|
108 operator QVariant() const; |
|
109 |
|
110 QIcon &qicon() const; |
|
111 |
|
112 bool addBadge(Qt::Alignment alignment, |
|
113 const HbIcon& badge, |
|
114 int z=0); |
|
115 bool removeBadge(const HbIcon& badge); |
|
116 void removeAllBadges(); |
|
117 |
|
118 private: |
|
119 QExplicitlySharedDataPointer<HbIconPrivate> d; |
|
120 |
|
121 friend HB_CORE_EXPORT QDataStream &operator<<(QDataStream &, const HbIcon &); |
|
122 friend HB_CORE_EXPORT QDataStream &operator>>(QDataStream &, HbIcon &); |
|
123 friend class HbIconAnimator; |
|
124 friend class HbIconPrivate; |
|
125 }; |
|
126 |
|
127 HB_CORE_EXPORT QDataStream &operator<<(QDataStream &stream, const HbIcon &icon); |
|
128 HB_CORE_EXPORT QDataStream &operator>>(QDataStream &stream, HbIcon &icon); |
|
129 |
|
130 Q_DECLARE_METATYPE(HbIcon) |
|
131 Q_DECLARE_OPERATORS_FOR_FLAGS(HbIcon::Flags) |
|
132 |
|
133 #endif // HBICON_H |