1 /* |
1 /* |
2 * Copyright (c) 2010 Ixonos Plc. |
2 * Copyright (c) 2010 Ixonos Plc. |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the "Eclipse Public License v1.0" |
5 * under the terms of the "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - Initial contribution |
10 * Nokia Corporation - Initial contribution |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * Ixonos Plc |
13 * Ixonos Plc |
14 * |
14 * |
15 * Description: |
15 * Description: |
16 * Draw plugin control class header. |
16 * Draw plugin control class header. |
17 * |
17 * |
18 */ |
18 */ |
19 |
19 |
20 #ifndef IMAGEEDITORDRAWCONTROL_H |
20 #ifndef IMAGEEDITORDRAWCONTROL_H |
21 #define IMAGEEDITORDRAWCONTROL_H |
21 #define IMAGEEDITORDRAWCONTROL_H |
22 |
22 |
23 // INCLUDES |
23 // INCLUDES |
24 #include "PreviewControlBase.h" |
24 #include "PreviewControlBase.h" |
25 #include "MTimerCallBack.h" |
25 #include "MTimerCallBack.h" |
26 |
26 |
27 #include <coecntrl.h> |
27 #include <coecntrl.h> |
28 #include <ConeResLoader.h> |
28 #include <ConeResLoader.h> |
|
29 #include "AnimationAO.h" |
|
30 #include "CImageLabel.h" |
|
31 #include "CustomerComponet.h" |
|
32 #include "RollAO.h" |
29 |
33 |
30 // FORWARD DECLARATIONS |
34 // FORWARD DECLARATIONS |
31 class CAknView; |
35 class CAknView; |
32 class CFbsBitmap; |
36 class CFbsBitmap; |
33 class CPluginInfo; |
37 class CPluginInfo; |
34 class CSystemParameters; |
38 class CSystemParameters; |
35 class CJPTimer; |
39 class CJPTimer; |
36 class CAknInfoPopupNoteController; |
40 class CAknInfoPopupNoteController; |
37 class CDrawPath; |
41 class CDrawPath; |
|
42 class CImageLabel; |
|
43 class CAnimationAO; |
38 |
44 |
39 /* CLASS: CImageEditorDrawControl |
45 /* CLASS: CImageEditorDrawControl |
40 * |
46 * |
41 * CImageEditorDrawControl is a control for text insertion plug-in. |
47 * CImageEditorDrawControl is a control for text insertion plug-in. |
42 * |
48 * |
43 */ |
49 */ |
44 class CImageEditorDrawControl : public CPreviewControlBase, |
50 class CImageEditorDrawControl : public CPreviewControlBase, |
45 public MTimerCallBack |
51 public MTimerCallBack, |
46 { |
52 public MAnimationObserver, |
|
53 public MHandlePointerObserver, |
|
54 public MRollObserver |
|
55 { |
|
56 static const int DRAG_LENGTH = 5; |
|
57 enum TMainMenuLayout |
|
58 { |
|
59 EMainMenuHorizontal, EMainMenuVertical |
|
60 }; |
47 public: |
61 public: |
48 |
62 |
49 /** @name Methods:*/ |
63 /** @name Methods:*/ |
50 //@{ |
64 //@{ |
51 |
65 |
52 /** NewL factory method |
66 /** NewL factory method |
53 * |
67 * |
54 * @param aRect - control rectangle |
68 * @param aRect - control rectangle |
55 * @param aParent - pointer to window owning control |
69 * @param aParent - pointer to window owning control |
56 * @return pointer to created CImageEditorDrawControl object |
70 * @return pointer to created CImageEditorDrawControl object |
57 */ |
71 */ |
58 static CImageEditorDrawControl* NewL( |
72 static CImageEditorDrawControl* NewL(const TRect& aRect, |
59 const TRect& aRect, |
73 CCoeControl* aParent, RPointerArray<CDrawPath>& aPaths,TRgb& aRgb, TSize& aSize,TBool &aDisplayTool); |
60 CCoeControl* aParent |
|
61 ); |
|
62 |
74 |
63 /** Destructor */ |
75 /** Destructor */ |
64 ~CImageEditorDrawControl(); |
76 ~CImageEditorDrawControl(); |
65 |
77 |
66 protected: // From CImageEditorControlBase |
78 protected: |
|
79 // From CImageEditorControlBase |
67 /** Second phase constructor |
80 /** Second phase constructor |
68 * |
81 * |
69 * @see CImageEditorControlBase |
82 * @see CImageEditorControlBase |
70 */ |
83 */ |
71 void ConstructL( |
84 void ConstructL(const TRect& aRect, CCoeControl* aParent); |
72 const TRect& aRect, |
|
73 CCoeControl* aParent |
|
74 ); |
|
75 |
85 |
76 /* Setter for view reference |
86 /* Setter for view reference |
77 * |
87 * |
78 * @see CImageEditorControlBase |
88 * @see CImageEditorControlBase |
79 */ |
89 */ |
80 void SetView(CAknView* aView); |
90 void SetView(CAknView* aView); |
81 |
91 |
82 /* SetSelectedUiItemL |
92 /* SetSelectedUiItemL |
83 * |
93 * |
84 * @see CImageEditorControlBase |
94 * @see CImageEditorControlBase |
85 */ |
95 */ |
86 void SetSelectedUiItemL(CPluginInfo* aItem); |
96 void SetSelectedUiItemL(CPluginInfo* aItem); |
87 |
97 |
88 /** PrepareL |
98 /** PrepareL |
89 * |
99 * |
90 * @see CImageEditorControlBase |
100 * @see CImageEditorControlBase |
91 */ |
101 */ |
92 void PrepareL(); |
102 void PrepareL(); |
93 |
103 |
94 /* OfferKeyEventL |
104 /* OfferKeyEventL |
95 * |
105 * |
96 * @see CImageEditorControlBase |
106 * @see CImageEditorControlBase |
97 */ |
107 */ |
98 TKeyResponse OfferKeyEventL( |
108 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
99 const TKeyEvent& aKeyEvent, |
109 |
100 TEventCode aType |
110 /* HandlePointerEventL |
101 ); |
111 * |
|
112 * @see CImageEditorControlBase |
|
113 */ |
|
114 void HandlePointerEventL(const TPointerEvent &aPointerEvent); |
|
115 |
|
116 /* HandlePluginCommandL |
|
117 * |
|
118 * @see CImageEditorControlBase |
|
119 */ |
|
120 void HandlePluginCommandL(const TInt aCommand); |
|
121 |
|
122 /* GetSoftkeyIndexL |
|
123 * |
|
124 * @see CImageEditorControlBase |
|
125 */ |
|
126 TInt GetSoftkeyIndexL(); |
|
127 |
|
128 /* GetContextMenuResourceId |
|
129 * |
|
130 * @see CImageEditorControlBase |
|
131 */ |
|
132 TInt GetContextMenuResourceId(); |
|
133 |
|
134 /* GetDimmedMenuItems |
|
135 * |
|
136 * @see CImageEditorControlBase |
|
137 */ |
|
138 TBitField GetDimmedMenuItems(); |
|
139 |
|
140 /* GetNaviPaneTextL |
|
141 * |
|
142 * @see CImageEditorControlBase |
|
143 */ |
|
144 TPtrC GetNaviPaneTextL(TBool& aLeftNaviPaneScrollButtonVisibile, |
|
145 TBool& aRightNaviPaneScrollButtonVisible); |
|
146 |
|
147 public: |
|
148 /* GetParam |
|
149 * |
|
150 * Gets pointer to the parameter struct. |
|
151 * @return - pointer to MIA parameter struct |
|
152 */ |
|
153 TDesC& GetParam(); |
|
154 |
|
155 /* SetSysteParameters |
|
156 * |
|
157 * Sets reference to system parameters to plug-in. |
|
158 * @param aSysPars - System parameters instance |
|
159 */ |
|
160 void SetSystemParameters(const CSystemParameters* aSysPars); |
|
161 |
|
162 /* IsReadyToRender |
|
163 * |
|
164 * @return - ETrue when control is ready render |
|
165 */ |
|
166 TBool IsReadyToRender() const; |
|
167 |
|
168 protected: |
|
169 |
|
170 /* GetHelpContext |
|
171 * |
|
172 * @see CCoeControl |
|
173 */ |
|
174 virtual void GetHelpContext(TCoeHelpContext& aContext) const; |
|
175 |
|
176 /* TimerCallBack |
|
177 * |
|
178 * @see MTimerCallBack |
|
179 */ |
|
180 void TimerCallBack(); |
|
181 |
|
182 /*MakeVisibleLable |
|
183 * |
|
184 * make the controller visible |
|
185 * @param aFlag - ETrue,make the tool bar visible,otherwise. |
|
186 */ |
|
187 void MakeVisibleLable(TBool aFlag); |
102 |
188 |
103 /* HandlePointerEventL |
189 /**StartTheAnimation |
104 * |
190 * |
105 * @see CImageEditorControlBase |
191 * start the auto-moving active object for tool bar. |
106 */ |
192 */ |
107 void HandlePointerEventL( const TPointerEvent &aPointerEvent ); |
193 void StartTheAnimation(); |
108 |
|
109 /* HandlePluginCommandL |
|
110 * |
|
111 * @see CImageEditorControlBase |
|
112 */ |
|
113 void HandlePluginCommandL(const TInt aCommand); |
|
114 |
|
115 /* GetSoftkeyIndexL |
|
116 * |
|
117 * @see CImageEditorControlBase |
|
118 */ |
|
119 TInt GetSoftkeyIndexL(); |
|
120 |
|
121 /* GetContextMenuResourceId |
|
122 * |
|
123 * @see CImageEditorControlBase |
|
124 */ |
|
125 TInt GetContextMenuResourceId(); |
|
126 |
|
127 /* GetDimmedMenuItems |
|
128 * |
|
129 * @see CImageEditorControlBase |
|
130 */ |
|
131 TBitField GetDimmedMenuItems(); |
|
132 |
|
133 /* GetNaviPaneTextL |
|
134 * |
|
135 * @see CImageEditorControlBase |
|
136 */ |
|
137 TPtrC GetNaviPaneTextL( |
|
138 TBool& aLeftNaviPaneScrollButtonVisibile, |
|
139 TBool& aRightNaviPaneScrollButtonVisible); |
|
140 public: |
|
141 /* GetParam |
|
142 * |
|
143 * Gets pointer to the parameter struct. |
|
144 * @return - pointer to MIA parameter struct |
|
145 */ |
|
146 TDesC& GetParam(); |
|
147 |
|
148 /* SetSysteParameters |
|
149 * |
|
150 * Sets reference to system parameters to plug-in. |
|
151 * @param aSysPars - System parameters instance |
|
152 */ |
|
153 void SetSystemParameters(const CSystemParameters* aSysPars); |
|
154 |
|
155 /* IsReadyToRender |
|
156 * |
|
157 * @return - ETrue when control is ready render |
|
158 */ |
|
159 TBool IsReadyToRender() const; |
|
160 |
194 |
161 protected: |
195 protected: |
162 |
196 |
163 /* GetHelpContext |
197 /** @name Methods:*/ |
164 * |
198 //@{ |
165 * @see CCoeControl |
199 /* SizeChanged |
166 */ |
200 * |
167 virtual void GetHelpContext(TCoeHelpContext& aContext) const; |
201 * @see CImageEditorControlBase |
168 |
202 */ |
169 /* TimerCallBack |
203 void SizeChanged(); |
170 * |
204 |
171 * @see MTimerCallBack |
205 //@} |
172 */ |
206 |
173 void TimerCallBack(); |
207 /** @name Members:*/ |
174 |
208 //@{ |
175 //@} |
209 |
176 |
210 //@} |
|
211 |
|
212 private: |
|
213 /** Default constructor */ |
|
214 CImageEditorDrawControl(RPointerArray<CDrawPath>& aPaths,TRgb& aRgb, TSize& aSize,TBool &aDisplayTool); |
|
215 |
|
216 /** Draw |
|
217 * |
|
218 * @see CImageEditorControlBase |
|
219 * |
|
220 */ |
|
221 virtual void Draw(const TRect & aRect) const; |
177 |
222 |
178 protected: |
223 protected: |
179 |
224 /**CountComponentControls |
180 /** @name Methods:*/ |
225 * |
181 //@{ |
226 * @see CImageEditorControlBase |
182 /* SizeChanged |
227 */ |
183 * |
228 TInt CountComponentControls() const; |
184 * @see CImageEditorControlBase |
229 |
185 */ |
230 /**ComponentControl |
186 void SizeChanged(); |
231 * |
187 |
232 * |
188 //@} |
233 * @see CImageEditorControlBase |
189 |
234 */ |
190 /** @name Members:*/ |
235 CCoeControl* ComponentControl(TInt aIndex) const; |
191 //@{ |
236 |
192 |
237 private: |
193 //@} |
238 // Implementation |
194 |
239 void NaviDown(); |
195 private: |
240 void NaviUp(); |
196 |
241 void NaviRight(); |
197 CImageEditorDrawControl (); |
242 void NaviLeft(); |
198 |
243 void SelectSizeL(); |
199 /** Draw |
244 void StoreTempParams(); |
200 * |
245 void RestoreTempParams(); |
201 * @see CImageEditorControlBase |
246 void RenderTextImageL(); |
202 * |
247 void LoadIndicatorL(TInt aBitmapInd, TInt aMaskInd); |
203 */ |
248 TPoint ComputeIndicatorPosition() const; |
204 virtual void Draw (const TRect & aRect) const; |
|
205 |
|
206 private: // Implementation |
|
207 void NaviDown(); |
|
208 void NaviUp(); |
|
209 void NaviRight(); |
|
210 void NaviLeft(); |
|
211 void SelectSizeL(); |
|
212 void StoreTempParams(); |
|
213 void RestoreTempParams(); |
|
214 void RenderTextImageL(); |
|
215 void LoadIndicatorL ( TInt aBitmapInd, TInt aMaskInd ); |
|
216 TPoint ComputeIndicatorPosition() const; |
|
217 void StoreParameters(TBool aLastItem, TBool aDone); |
249 void StoreParameters(TBool aLastItem, TBool aDone); |
218 void StorePosAndScaleRelScreen(); |
250 void StorePosAndScaleRelScreen(); |
219 void RestorePosAndScaleRelScreen(); |
251 void RestorePosAndScaleRelScreen(); |
220 void StorePosAndScaleRelImage(); |
252 void StorePosAndScaleRelImage(); |
221 void RestorePosAndScaleRelImage(); |
253 void RestorePosAndScaleRelImage(); |
222 void ClipPosition(); |
254 void ClipPosition(); |
223 void SetPositionOnImage( TPoint aPointedPosition ); |
255 void SetPositionOnImage(TPoint aPointedPosition); |
224 TPoint GetPositionOnView(); |
256 TPoint GetPositionOnView(); |
225 void ShowTooltip(); |
257 void ShowTooltip(); |
226 TSize ScaledLineSize( TSize aOriginalSize ) const; |
258 TSize ScaledLineSize(TSize aOriginalSize) const; |
227 |
259 |
228 //@} |
260 public: |
229 |
261 /**Notify |
230 /** @name Members:*/ |
262 * |
231 //@{ |
263 * handle the event by Active object |
232 |
264 */ |
233 /// Ref: to Editor view |
265 virtual void Notify(); |
234 CAknView* iEditorView; |
266 |
235 |
267 /**HandlePointerNotify |
236 /// Source image size |
268 * |
237 const CSystemParameters* iSysPars; |
269 * handle the press icon event |
238 |
270 * @param aComponent - the icon control of tool bar |
239 /// Ref: to Plug-in info |
271 */ |
240 CPluginInfo* iItem; |
272 virtual void HandlePointerNotify(CCoeControl* aComponent); |
241 |
273 |
242 /// Own: Navigation pane text |
274 /**Roll |
243 HBufC* iNaviPaneText; |
275 * |
244 |
276 * the fuction for AO to move the tool bar |
245 /// X position |
277 */ |
246 TInt iX; |
278 virtual void Roll(); |
247 /// Y position |
279 |
248 TInt iY; |
280 private: |
249 /// Color |
281 /**InitializeMainMenu |
250 TRgb iRgb; |
282 * |
251 |
283 * initialize the tool bar |
252 /// Timer for fast key events |
284 * @param aMainMenuLayout - horizon or veritical layout of the tool bar |
|
285 */ |
|
286 void InitializeMainMenu(TMainMenuLayout aMainMenuLayout); |
|
287 |
|
288 /**CalculateEffectiveOffset |
|
289 * |
|
290 * calculate vaild offset for tool bar |
|
291 */ |
|
292 void CalculateEffectiveOffset(); |
|
293 |
|
294 /**HandleMainMenuButtonUp |
|
295 * |
|
296 * handle the up event on tool bar |
|
297 * @param aPoint - the position on screen |
|
298 */ |
|
299 void HandleMainMenuButtonUp(TPoint aPoint); |
|
300 |
|
301 /**HandleMainMenuButtonDrag |
|
302 * |
|
303 * handle the drag event on tool bar |
|
304 * @param aPoint - the position on screen |
|
305 */ |
|
306 void HandleMainMenuButtonDrag(TPoint aPoint); |
|
307 |
|
308 private: |
|
309 /**UndoDrawPath |
|
310 * |
|
311 * undo the drawed lines on screen |
|
312 */ |
|
313 void UndoDrawPath(); |
|
314 |
|
315 /**RedoDrawPath |
|
316 * |
|
317 * redo the undo lines on screen |
|
318 */ |
|
319 void RedoDrawPath(); |
|
320 |
|
321 private: |
|
322 |
|
323 //@} |
|
324 |
|
325 /** @name Members:*/ |
|
326 //@{ |
|
327 |
|
328 /// Ref: to Editor view |
|
329 CAknView* iEditorView; |
|
330 |
|
331 /// Source image size |
|
332 const CSystemParameters* iSysPars; |
|
333 |
|
334 /// Ref: to Plug-in info |
|
335 CPluginInfo* iItem; |
|
336 |
|
337 /// Own: Navigation pane text |
|
338 HBufC* iNaviPaneText; |
|
339 |
|
340 /// X position |
|
341 TInt iX; |
|
342 /// Y position |
|
343 TInt iY; |
|
344 |
|
345 /// Timer for fast key events |
253 CJPTimer* iTimer; |
346 CJPTimer* iTimer; |
254 TUint32 iKeyCode; |
347 TUint32 iKeyCode; |
255 |
348 |
256 /// Pressed key event code |
349 /// Pressed key event code |
257 TInt iPressedKeyScanCode; |
350 TInt iPressedKeyScanCode; |
258 |
351 |
259 /// Number of ticks since timer start |
352 /// Number of ticks since timer start |
260 TInt iTickCount; |
353 TInt iTickCount; |
261 |
354 |
262 /// Multiplier to control the navigation movement speed |
355 /// Multiplier to control the navigation movement speed |
263 TInt iNaviStepMultiplier; |
356 TInt iNaviStepMultiplier; |
264 |
357 |
265 /// Showing Ok options menu, where some items are dimmed |
358 /// Showing Ok options menu, where some items are dimmed |
266 TBool iDisplayingOkOptionsMenu; |
359 TBool iDisplayingOkOptionsMenu; |
267 |
360 |
268 /// Own: State indicator glyph |
361 /// Own: State indicator glyph |
269 CFbsBitmap* iIndicator; |
362 CFbsBitmap* iIndicator; |
270 CFbsBitmap* iIndicatorMask; |
363 CFbsBitmap* iIndicatorMask; |
271 |
364 |
272 /// Ready to render |
365 /// Ready to render |
273 TBool iReadyToRender; |
366 TBool iReadyToRender; |
274 |
367 |
275 /// Parameter |
368 /// Parameter |
276 TBuf<256> iParam; |
369 TBuf<256> iParam; |
277 |
370 |
278 // Popup controller |
371 // Popup controller |
279 CAknInfoPopupNoteController* iPopupController; |
372 CAknInfoPopupNoteController* iPopupController; |
280 // Tooltip texts |
373 // Tooltip texts |
281 HBufC* iTooltipResize; |
374 HBufC* iTooltipResize; |
282 |
375 |
283 // Previous pen position. Make touch rotating and resizing possible |
376 // Previous pen position. Make touch rotating and resizing possible |
284 TPoint iPointerPosition; |
377 TPoint iPointerPosition; |
285 // Multiplier to control the rotating speed by touch |
378 // Multiplier to control the rotating speed by touch |
286 TInt iTouchAngleMultiplier; |
379 TInt iTouchAngleMultiplier; |
287 |
380 |
288 /// Resource reader |
381 /// Resource reader |
289 RConeResourceLoader iResLoader; |
382 RConeResourceLoader iResLoader; |
290 /// Line size |
383 /// Line size |
291 TSize iSize; |
384 TSize& iSize; |
|
385 /// Color |
|
386 TRgb& iRgb; |
292 /// Own: drawn paths |
387 /// Own: drawn paths |
293 RPointerArray<CDrawPath> iPaths; |
388 RPointerArray<CDrawPath> &iPaths; |
294 |
389 //bitmap device |
295 //@} |
390 CFbsBitmapDevice* iBitmapDev; |
296 |
391 CGraphicsContext* iGc; |
297 }; |
392 //@} |
298 |
393 |
|
394 private: |
|
395 |
|
396 void SetToolBarStatus(); |
|
397 RPointerArray<CImageLabel> iLabels; |
|
398 |
|
399 TRect iLoopMenuRect; |
|
400 TPoint iButtonDownPoint; |
|
401 TPoint iDragStartPoint; |
|
402 TPoint iDragPrePoint; |
|
403 TPoint iDragUpPoint; |
|
404 |
|
405 TInt iTotalComponent; |
|
406 TInt iDragOffset; |
|
407 TInt iStartSpeed; |
|
408 |
|
409 CAnimationAO* iAnimationAO; |
|
410 CRollAO* iRollAo; |
|
411 |
|
412 TBool iPointStartInLoopRect; |
|
413 TBool iDragIsStart; |
|
414 TBool iEnableAnimationEffect; |
|
415 TMainMenuLayout iMainMenuLayout; |
|
416 ///implement undo and redo functions. |
|
417 |
|
418 private: |
|
419 |
|
420 RPointerArray<CDrawPath> iUndoPaths; |
|
421 TBool iUndo; |
|
422 TBool iRedo; |
|
423 TBool iCanRedo; |
|
424 //ETrue: roll in |
|
425 //EFalse:roll out |
|
426 TBool iRollDirection; |
|
427 private: |
|
428 |
|
429 CCustomerComponet *iCustomComponet; |
|
430 TBool iCustomComponetClick; |
|
431 TBool iLastPointEventType; |
|
432 TBool iRollflag; |
|
433 TBool &iDisplayTool; |
|
434 TBool iSizeChangeFlag; |
|
435 }; |
299 |
436 |
300 #endif |
437 #endif |