|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <gdi.h> |
|
17 #include <gulicon.h> |
|
18 #include <fbs.h> |
|
19 #include "GULSTD.H" |
|
20 |
|
21 CGulIcon::CGulIcon() |
|
22 : iBitmapsOwnedExternally(EFalse) |
|
23 { |
|
24 } |
|
25 |
|
26 EXPORT_C CGulIcon::~CGulIcon() |
|
27 /** Destructor. */ |
|
28 { |
|
29 if(!iBitmapsOwnedExternally) |
|
30 { |
|
31 if(iMask!=iBitmap) |
|
32 delete iMask; |
|
33 |
|
34 delete iBitmap; |
|
35 } |
|
36 } |
|
37 |
|
38 EXPORT_C CGulIcon* CGulIcon::NewLC() |
|
39 /** Creates a new icon and leaves it on the cleanup stack. |
|
40 |
|
41 @return The new icon. */ |
|
42 { |
|
43 CGulIcon* self=new(ELeave) CGulIcon; |
|
44 CleanupStack::PushL(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 EXPORT_C CGulIcon* CGulIcon::NewL(CFbsBitmap* aBitmap,CFbsBitmap* aMask) |
|
50 /** Creates a new icon using the bitmap and mask. |
|
51 |
|
52 It takes ownership of the bitmap and mask and returns a pointer to the new object. |
|
53 |
|
54 @param aBitmap The icon bitmap. |
|
55 @param aMask The icon mask. |
|
56 @return The new icon. */ |
|
57 { |
|
58 __ASSERT_DEBUG(aBitmap,Panic(EEgulPanicNullPointer)); |
|
59 |
|
60 CGulIcon* self=NewLC(); |
|
61 self->SetBitmap(aBitmap); |
|
62 self->SetMask(aMask); |
|
63 CleanupStack::Pop(); // self |
|
64 return self; |
|
65 } |
|
66 |
|
67 EXPORT_C CGulIcon* CGulIcon::NewL() |
|
68 /** Creates a new icon. |
|
69 |
|
70 @return The new icon. */ |
|
71 { |
|
72 CGulIcon* self=NewLC(); |
|
73 CleanupStack::Pop(); // self |
|
74 return self; |
|
75 } |
|
76 |
|
77 EXPORT_C void CGulIcon::SetBitmap(CFbsBitmap* aBitmap) |
|
78 /** Sets the icon image's bitmap. |
|
79 |
|
80 Transfers ownership to this object unless bitmaps are set to be owned externally. |
|
81 |
|
82 @param aBitmap Pointer to the icon image's bitmap. */ |
|
83 { |
|
84 __ASSERT_DEBUG(aBitmap,Panic(EEgulPanicNullPointer)); |
|
85 |
|
86 if(!iBitmapsOwnedExternally && iBitmap!=iMask) |
|
87 delete iBitmap; |
|
88 |
|
89 iBitmap=aBitmap; |
|
90 } |
|
91 |
|
92 EXPORT_C CFbsBitmap* CGulIcon::Bitmap() const |
|
93 /** Gets the icon image's bitmap. |
|
94 |
|
95 Does not normally imply transfer of ownership. Ownership can be transferred if bitmaps |
|
96 are set to be owned externally. |
|
97 |
|
98 @return Pointer to the icon image's bitmap. */ |
|
99 { |
|
100 return iBitmap; |
|
101 } |
|
102 |
|
103 EXPORT_C void CGulIcon::SetMask(CFbsBitmap* aMask) |
|
104 /** Sets the icon image's mask. |
|
105 |
|
106 Ownership is transferred to this object unless the bitmaps are owned externally. |
|
107 |
|
108 The mask can be set to be identical to the bitmap if the bitmap is self-masking. |
|
109 |
|
110 @param aMask Pointer to the icon image's mask. */ |
|
111 { |
|
112 if(!iBitmapsOwnedExternally && iBitmap!=iMask) |
|
113 delete iMask; |
|
114 |
|
115 iMask=aMask; |
|
116 } |
|
117 |
|
118 EXPORT_C CFbsBitmap* CGulIcon::Mask() const |
|
119 /** Gets the icon image's mask. |
|
120 |
|
121 Transfers ownership to the caller if bitmaps are owned externally. |
|
122 |
|
123 @return Pointer to the icon image's mask. */ |
|
124 { |
|
125 return iMask; |
|
126 } |
|
127 |
|
128 EXPORT_C void CGulIcon::SetBitmapsOwnedExternally(TBool aOwnedExternally) |
|
129 /** Sets the bitmap and mask to be owned externally. |
|
130 |
|
131 @param aOwnedExternally ETrue if bitmaps are set as externally owned. EFalse |
|
132 if bitmaps are set as not being externally owned. */ |
|
133 { |
|
134 iBitmapsOwnedExternally=aOwnedExternally; |
|
135 } |
|
136 |
|
137 EXPORT_C TBool CGulIcon::BitmapsOwnedExternally() const |
|
138 /** Gets the icon bitmap ownership. |
|
139 |
|
140 @return ETrue if bitmaps are externally owned. EFalse if bitmaps are |
|
141 owned by this object. */ |
|
142 { |
|
143 return iBitmapsOwnedExternally; |
|
144 } |
|
145 |