|
1 /* |
|
2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__EIKIMAGE_H__) |
|
20 #define __EIKIMAGE_H__ |
|
21 |
|
22 #if !defined(__EIKALIGN_H__) |
|
23 #include <eikalign.h> |
|
24 #endif |
|
25 |
|
26 class CFbsBitmap; |
|
27 class CBitmapContext; |
|
28 |
|
29 /** |
|
30 * The package class @c CEikImage enables bitmaps to be packaged into an |
|
31 * image. Two bitmaps can be packaged, one for the image itself and, |
|
32 * optionally, another for the image’s mask. |
|
33 */ |
|
34 class CEikImage : public CEikAlignedControl |
|
35 { |
|
36 |
|
37 public: |
|
38 |
|
39 /** |
|
40 * C++ default constructor. |
|
41 */ |
|
42 IMPORT_C CEikImage(); |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 */ |
|
47 IMPORT_C ~CEikImage(); |
|
48 |
|
49 public: // framework |
|
50 |
|
51 /** |
|
52 * Gets the minimum size required to draw the image. |
|
53 * |
|
54 * @return The minimum size required to draw the image. |
|
55 */ |
|
56 IMPORT_C TSize MinimumSize(); |
|
57 |
|
58 /** |
|
59 * Constructs an image from resource using the specified resource reader. |
|
60 * |
|
61 * @param aReader The resource reader. |
|
62 */ |
|
63 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); |
|
64 |
|
65 public: // new functions |
|
66 |
|
67 /** |
|
68 * Creates a bitmap and a mask for an icon. If @c aMaskId is not negative |
|
69 * then function allocates bitmap and mask objects and sets member variables |
|
70 * to point at them. These bitmaps are not ready for drawing until they are |
|
71 * initialized with @c SetSize() method. Usually, UI controls do this. Note |
|
72 * also that a single @c SetSize() call initializes both the bitmap and the |
|
73 * mask. |
|
74 * |
|
75 * If @c aMaskId is not needed and not given then this function creates the |
|
76 * bitmap for an icon. Returned object is saved to the member variable. The |
|
77 * bitmap is not ready for drawing until it is initialized with @c |
|
78 * SetSize() method. Usually, UI controls do this. |
|
79 * |
|
80 * @param aFilename File name. Can be either MBM or MIF file. |
|
81 * Extension is changed based on the given bitmap ID. |
|
82 * @param aMainId Bitmap id. |
|
83 * @param aMaskId Mask id, by default -1. |
|
84 */ |
|
85 IMPORT_C void CreatePictureFromFileL(const TDesC& aFilename, |
|
86 TInt aMainId, |
|
87 TInt aMaskId=-1); |
|
88 |
|
89 /** |
|
90 * Sets picture parameters. |
|
91 * |
|
92 * @param aBitmap A bitmap. |
|
93 * @param aMaskBitmap A bitmap mask. |
|
94 */ |
|
95 IMPORT_C void SetPicture(const CFbsBitmap* aBitmap, |
|
96 const CFbsBitmap* aMaskBitmap=NULL); |
|
97 |
|
98 /** |
|
99 * Sets emphasis. |
|
100 * |
|
101 * @param aEmphasis Full emphasis if @c ETrue and if not then @c EFalse. |
|
102 */ |
|
103 IMPORT_C void SetEmphasis(TBool aEmphasis); |
|
104 |
|
105 /** |
|
106 * Sets the owner of the picture. |
|
107 * |
|
108 * @param aOwnership @c Etrue if owner is external and @c EFalse if not. |
|
109 */ |
|
110 IMPORT_C void SetPictureOwnedExternally(TBool aOwnership); |
|
111 |
|
112 /** |
|
113 * Gets a pointer of @c CFbsBitmap object. |
|
114 * |
|
115 * @return Pointer to handle to the bitmap or NULL. |
|
116 */ |
|
117 IMPORT_C const CFbsBitmap* Bitmap() const; |
|
118 |
|
119 /** |
|
120 * Gets pointer of @c CFbsBitmap object. |
|
121 * |
|
122 * @return Pointer to handle to the bitmap's mask or NULL. |
|
123 */ |
|
124 IMPORT_C const CFbsBitmap* Mask() const; |
|
125 |
|
126 /** |
|
127 * Sets new bitmap. |
|
128 * |
|
129 * @param aBitmap Pointer to @c CFbsBitmap object containing the bitmap. |
|
130 */ |
|
131 IMPORT_C void SetBitmap(const CFbsBitmap* aBitmap); |
|
132 |
|
133 /** |
|
134 * Sets new bitmap mask. |
|
135 * |
|
136 * @param aMaskBitmap Pointer to @c CFbsBitmap object containing the bitmap |
|
137 * mask. |
|
138 */ |
|
139 IMPORT_C void SetMask(const CFbsBitmap* aMaskBitmap); |
|
140 |
|
141 /** |
|
142 * Sets new bitmap and bitmap's mask. |
|
143 * |
|
144 * @param aNewBitmap A bitmap. |
|
145 * @param aNewMask A bitmap mask. |
|
146 */ |
|
147 IMPORT_C void SetNewBitmaps(const CFbsBitmap* aNewBitmap, |
|
148 const CFbsBitmap* aNewMask); |
|
149 |
|
150 /** |
|
151 * Checks whether picture is owned externally. |
|
152 * |
|
153 * @return @c ETrue if picture owned externally and @c EFalse if |
|
154 * not. |
|
155 */ |
|
156 IMPORT_C TBool IsPictureOwnedExternally(); |
|
157 |
|
158 /** |
|
159 * Sets the brush style. |
|
160 * |
|
161 * @param aBrushStyle A brush style. |
|
162 */ |
|
163 IMPORT_C void SetBrushStyle(CGraphicsContext::TBrushStyle aBrushStyle); |
|
164 |
|
165 public: // from CCoeControl |
|
166 |
|
167 /** |
|
168 * From @c CCoeControl. |
|
169 * |
|
170 * Handles pointer events. |
|
171 * |
|
172 * This function gets called whenever a pointer event occurs in the |
|
173 * control, i.e. when the pointer is within the control's extent, or when |
|
174 * the control has grabbed the pointer. The control should implement this |
|
175 * function to handle pointer events. |
|
176 * |
|
177 * Note: events of type @c EButton1Down are processed before |
|
178 * @c HandlePointerEventL() is called in order to transfer keyboard focus |
|
179 * to the control in which the @c EButton1Down event occurred. |
|
180 * |
|
181 * If overriding @c HandlePointerEventL(), the implementation must include |
|
182 * a base call to @c CCoeControl's @c HandlePointerEventL(). |
|
183 * |
|
184 * @param aPointerEvent The pointer event. |
|
185 */ |
|
186 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
187 |
|
188 protected: // from CCoeControl |
|
189 |
|
190 /** |
|
191 * From @c CCoeControl |
|
192 * |
|
193 * Writes the internal state of the control and its components to a stream. |
|
194 * Does nothing in release mode. Designed to be overidden and base called |
|
195 * by subclasses. |
|
196 * |
|
197 * @since App-Framework_6.1 |
|
198 * @param[in,out] aWriteStream The pointer writestream. |
|
199 */ |
|
200 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
201 |
|
202 private: // from CCoeControl |
|
203 |
|
204 IMPORT_C void Draw(const TRect& aRect) const; |
|
205 IMPORT_C void Reserved_2(); |
|
206 |
|
207 private: |
|
208 |
|
209 /** |
|
210 * From CAknControl |
|
211 */ |
|
212 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
213 |
|
214 private: |
|
215 |
|
216 const CFbsBitmap* iBitmap; |
|
217 const CFbsBitmap* iMaskBitmap; |
|
218 TInt iImFlags; |
|
219 TInt iSpare; |
|
220 CGraphicsContext::TBrushStyle iBrushStyle; |
|
221 }; |
|
222 |
|
223 #endif // __EIKIMAGE_H__ |