26
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: CMIDCanvasGraphicsItem - Implements the native part Canvas Graphics Item class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMIDCANVASGRAPHICSITEM_H
|
|
20 |
#define CMIDCANVASGRAPHICSITEM_H
|
|
21 |
|
|
22 |
// EXTERNAL INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
|
|
25 |
// INTERNAL INCLUDES
|
|
26 |
#include <MMIDCanvasGraphicsItem.h>
|
|
27 |
#include <MMIDCustomComponent.h>
|
|
28 |
#include <MMIDScalable.h>
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class CMIDCanvasGraphicsItemPainter;
|
|
32 |
class CCoeControl;
|
|
33 |
class MMIDCustomComponentContainer;
|
|
34 |
class CMIDUtils;
|
|
35 |
|
|
36 |
// CLASS DESCRIPTION
|
|
37 |
/**
|
|
38 |
* Defines the Canvas Graphics Item native side component.
|
|
39 |
*/
|
|
40 |
NONSHARABLE_CLASS(CMIDCanvasGraphicsItem) :
|
|
41 |
public CBase,
|
|
42 |
public MMIDCanvasGraphicsItem,
|
|
43 |
public MMIDCustomComponent,
|
|
44 |
public MMIDScalable
|
|
45 |
{
|
|
46 |
public: // Type definitions
|
|
47 |
|
|
48 |
class TCtorParams
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
// The CanvasGraphicsItemPainter native side peer handle. Not owned.
|
|
52 |
CMIDCanvasGraphicsItemPainter* iPainterHandle;
|
|
53 |
// The shared CMIDUtils instance. Not owned.
|
|
54 |
CMIDUtils* iUtils;
|
|
55 |
|
|
56 |
TCtorParams::TCtorParams() :
|
|
57 |
iPainterHandle(NULL),
|
|
58 |
iUtils(NULL) {}
|
|
59 |
};
|
|
60 |
|
|
61 |
public: // Constructors and destructor
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Two-phased constructor. Creates an instance from this class
|
|
65 |
* The caller takes the ownership of the returned instance
|
|
66 |
*
|
|
67 |
* @param aParams The construction parameters of this class.
|
|
68 |
* @return New instance from this class
|
|
69 |
*/
|
|
70 |
static CMIDCanvasGraphicsItem* NewL(const TCtorParams& aParams);
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Destructor.
|
|
74 |
*/
|
|
75 |
virtual ~CMIDCanvasGraphicsItem();
|
|
76 |
|
|
77 |
public: // From MMIDCustomComponent
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Returns the count of controls in this custom component.
|
|
81 |
*
|
|
82 |
* Note that the count must not change during the lifetime
|
|
83 |
* of the object. The count of all components is updated
|
|
84 |
* when it is added to the custom component container.
|
|
85 |
*
|
|
86 |
* This is done in order to improve the performance when counting
|
|
87 |
* countrols.
|
|
88 |
*
|
|
89 |
* @return The count of controls in this custom component.
|
|
90 |
* @since S60 5.0
|
|
91 |
*/
|
|
92 |
TInt CustomComponentControlCount() const;
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Returns an UI control of this custom component.
|
|
96 |
*
|
|
97 |
* The index specifies which component is requested. The method
|
|
98 |
* works similar to CCoeControl::ComponentControl() method. The
|
|
99 |
* ownership of the control is NOT transferred to the caller.
|
|
100 |
*
|
|
101 |
* @param aIndex The index of the control to be retrieved.
|
|
102 |
* @return The UI control of this custom component.
|
|
103 |
* @since S60 5.0
|
|
104 |
*/
|
|
105 |
CCoeControl* CustomComponentControl(TInt aIndex);
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Indicates that the container is about to be disposed.
|
|
109 |
*
|
|
110 |
* The custom component does not have to remove itself
|
|
111 |
* from the container since the container removes all components
|
|
112 |
* when disposing.
|
|
113 |
*
|
|
114 |
* @since S60 5.0
|
|
115 |
*/
|
|
116 |
void CustomComponentContainerDisposing();
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Indicates if traversal is needed and does the traverse.
|
|
120 |
*
|
|
121 |
* Not used on CanvasGraphicsItem.
|
|
122 |
*
|
|
123 |
* @param aEvent Key Event.
|
|
124 |
* @since S60 5.0
|
|
125 |
*/
|
|
126 |
void TraverseL(const TKeyEvent& /* aEvent */) {}
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Processes the received pointer event.
|
|
130 |
*
|
|
131 |
* @param aPointerEvent The pointer event. iPosition will be reset to the
|
|
132 |
* parent window position. iParentPosition will be invalid for the
|
|
133 |
* container.
|
|
134 |
* @since S60 5.0
|
|
135 |
*/
|
|
136 |
void ProcessPointerEventL(const TPointerEvent& /*aPointerEvent*/) {}
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Gets the current touch-enabled state
|
|
140 |
*
|
|
141 |
* @return false, this component is not touch-enabled
|
|
142 |
* @since S60 5.0
|
|
143 |
*/
|
|
144 |
TBool IsTouchEnabled()
|
|
145 |
{
|
|
146 |
return EFalse;
|
|
147 |
}
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Handles fullscreen state of parent Canvas.
|
|
151 |
*
|
|
152 |
* @since S60 5.0
|
|
153 |
*/
|
|
154 |
void HandleFullscreenModeChange();
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Handles system resource change messages.
|
|
158 |
*
|
|
159 |
* @param aType A message UID value.
|
|
160 |
*
|
|
161 |
* @since S60 5.0
|
|
162 |
*/
|
|
163 |
void HandleResourceChange(TInt aType);
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Handles switching from foreground to background and vice versa.
|
|
167 |
*
|
|
168 |
* @param aForeground Flag if it switches to foreground or to backgound.
|
|
169 |
*
|
|
170 |
* @since S60 5.0
|
|
171 |
*/
|
|
172 |
void HandleForeground(TBool aForeground);
|
|
173 |
|
|
174 |
public: // From MMIDScalable
|
|
175 |
|
|
176 |
TBool IsScalingOn() const;
|
|
177 |
|
|
178 |
public: // From MMIDCanvasGraphicsItem
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Sets the parent of this canvas graphics item component. The parent must
|
|
182 |
* implement the custom component container interface in order to
|
|
183 |
* provide necessary services for registering custom UI components.
|
|
184 |
*
|
|
185 |
* The ownership of the parent is not transffered to this object.
|
|
186 |
*
|
|
187 |
* @param aComponentContainer The parent MIDP custom component
|
|
188 |
* container.
|
|
189 |
* @since S60 5.0
|
|
190 |
*/
|
|
191 |
void SetParentL(MMIDCustomComponentContainer* aComponentContainer);
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Sets the direct container of this canvas graphics item component.
|
|
195 |
*
|
|
196 |
* Note that the canvas graphics item does not necessary need to have direct
|
|
197 |
* container. If the parent component is responsible for somekind of
|
|
198 |
* custom drawing using direct screena access, this method can be used
|
|
199 |
* to register the direct container.
|
|
200 |
*
|
|
201 |
* The canvas graphics item adds itself to the direct container so that it
|
|
202 |
* is not able to draw on top of the canvas graphics item when direct content
|
|
203 |
* is added to the screen.
|
|
204 |
*
|
|
205 |
* @param aDirectContainer The direct container of this compoennt if
|
|
206 |
* any. <code>NULL</code> removes the current container.
|
|
207 |
* @since S60 5.0
|
|
208 |
*/
|
|
209 |
void SetDirectContainerL(MDirectContainer* aDirectContainer);
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Sets the elevation of this canvas graphics item component.
|
|
213 |
*
|
|
214 |
* If the specified elevation exeeds to amount of items in the
|
|
215 |
* custom component container, the item becomes the topmost item
|
|
216 |
* in the custom component stack.
|
|
217 |
*
|
|
218 |
* Note that the elevation requsted may not be the actual elevation
|
|
219 |
* of the item (if, for example, the elevation is higher than the
|
|
220 |
* amount of all items, the elevation is set to the top).
|
|
221 |
*
|
|
222 |
* @param aElevation The new elevation (Z-position) of this item.
|
|
223 |
* @since S60 5.0
|
|
224 |
*/
|
|
225 |
void SetElevationL(TInt aElevation);
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Returns the elevation of this canvas graphics item component.
|
|
229 |
*
|
|
230 |
* @return The elevation of this canvas graphics item component.
|
|
231 |
* @since S60 5.0
|
|
232 |
*/
|
|
233 |
TInt Elevation();
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Sets this canvas graphics item component visible if it is hidden.
|
|
237 |
*
|
|
238 |
* Depending on the current status of the canvas graphics item, this operation
|
|
239 |
* is no-op if there is nothing to be done. (i.e. the canvas graphics item is set
|
|
240 |
* hidden when it is already hidden).
|
|
241 |
*
|
|
242 |
* @param aVisible Indicates the visibility status of the canvas graphics item.
|
|
243 |
* @since S60 5.0
|
|
244 |
*/
|
|
245 |
void SetVisibleL(TBool aVisible);
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Sets the size of this canvas graphics item component.
|
|
249 |
*
|
|
250 |
* @param aWidth The width of the item.
|
|
251 |
* @param aHeight The height of the item.
|
|
252 |
* @since S60 5.0
|
|
253 |
*/
|
|
254 |
void SetSizeL(const TInt aWidth, const TInt aHeight);
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Sets the position of this canvas graphics item component.
|
|
258 |
*
|
|
259 |
* Note: Calling this function results in a call to
|
|
260 |
* CMIDCanvasGraphicsItemEdwin::PositionChanged().
|
|
261 |
*
|
|
262 |
* @param aX The x coordinate of the anchor point.
|
|
263 |
* @param aY The y coordinate of the anchor point.
|
|
264 |
* @since S60 5.0
|
|
265 |
*/
|
|
266 |
void SetPosition(const TInt aX, const TInt aY);
|
|
267 |
|
|
268 |
public: // From MMIDComponent
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Invoked by the framework to clean up any resources used by the
|
|
272 |
* implementation.
|
|
273 |
*
|
|
274 |
* Typically, the implementation will do "delete this" but is clearly
|
|
275 |
* not restricted to
|
|
276 |
*
|
|
277 |
* @since S60 5.0
|
|
278 |
*/
|
|
279 |
void Dispose();
|
|
280 |
public: // Own methods
|
|
281 |
|
|
282 |
/**
|
|
283 |
* Removes this component from component container
|
|
284 |
* when its painter being disposed first (during finalization)
|
|
285 |
*/
|
|
286 |
void CMIDCanvasGraphicsItem::DeregisterCanvasGraphicsItem();
|
|
287 |
|
|
288 |
|
|
289 |
private: // own methods
|
|
290 |
/**
|
|
291 |
* This method is called when some change which can affect scaling
|
|
292 |
* of CanvasGraphicsItem.
|
|
293 |
*
|
|
294 |
* @param aChange Indicator what change was occurred.
|
|
295 |
* @since S60 5.0
|
|
296 |
*/
|
|
297 |
void HandleChangeForScaling(TChange aChange);
|
|
298 |
|
|
299 |
private: // Construtors
|
|
300 |
|
|
301 |
/**
|
|
302 |
* C++ constructor.
|
|
303 |
*/
|
|
304 |
CMIDCanvasGraphicsItem();
|
|
305 |
|
|
306 |
/**
|
|
307 |
* Second phase constructor
|
|
308 |
*
|
|
309 |
* @param aParams The construction parameters of this class.
|
|
310 |
*/
|
|
311 |
void ConstructL(const TCtorParams& aParams);
|
|
312 |
|
|
313 |
private: // Data
|
|
314 |
|
|
315 |
// canvas graphics item control. Not owned.
|
|
316 |
CMIDCanvasGraphicsItemPainter* iItemPainter;
|
|
317 |
|
|
318 |
// Container for this object. Not owned.
|
|
319 |
MMIDCustomComponentContainer* iComponentContainer;
|
|
320 |
|
|
321 |
// The shared CMIDUtils instance. Not owned.
|
|
322 |
CMIDUtils* iUtils;
|
|
323 |
|
|
324 |
// A non-scaled size of item. Needed by scaling.
|
|
325 |
TSize iNonScaledSize;
|
|
326 |
|
|
327 |
// A non-scaled position of item. Needed by scaling.
|
|
328 |
TPoint iNonScaledPosition;
|
|
329 |
|
|
330 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
331 |
// Indicates state of partial VKB
|
|
332 |
TBool iPartialVKBOpen;
|
|
333 |
#endif
|
|
334 |
};
|
|
335 |
|
|
336 |
#endif // CMIDCANVASGRAPHICSITEM_H
|
|
337 |
|
|
338 |
// End of file
|