|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Text plugin control class header. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef IMAGEEDITORTEXTCONTROL_H |
|
23 #define IMAGEEDITORTEXTCONTROL_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <coecntrl.h> |
|
27 |
|
28 #include "PreviewControlBase.h" |
|
29 #include "MTimerCallBack.h" |
|
30 #include <ConeResLoader.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CAknView; |
|
34 class CFbsBitmap; |
|
35 class CPluginInfo; |
|
36 class CSystemParameters; |
|
37 class CJPTimer; |
|
38 class CAknInfoPopupNoteController; |
|
39 |
|
40 #ifdef RD_TACTILE_FEEDBACK |
|
41 class MTouchFeedback; |
|
42 #endif /* RD_TACTILE_FEEDBACK */ |
|
43 |
|
44 /* CLASS: CImageEditorTextControl |
|
45 * |
|
46 * CImageEditorTextControl is a control for text insertion plug-in. |
|
47 * |
|
48 */ |
|
49 class CImageEditorTextControl : public CPreviewControlBase, |
|
50 public MTimerCallBack |
|
51 |
|
52 { |
|
53 |
|
54 public: |
|
55 |
|
56 /** @name Methods:*/ |
|
57 //@{ |
|
58 |
|
59 /** NewL factory method, pops cleanupstack |
|
60 * |
|
61 * @param aRect - control rectangle |
|
62 * @param aParent - pointer to window owning control |
|
63 * @return pointer to created CImageEditorTextControl object |
|
64 */ |
|
65 static CImageEditorTextControl * NewL ( |
|
66 const TRect & aRect, |
|
67 CCoeControl * aParent |
|
68 ); |
|
69 |
|
70 /** Destructor |
|
71 * |
|
72 * @param - |
|
73 * @return - |
|
74 */ |
|
75 virtual ~CImageEditorTextControl (); |
|
76 |
|
77 /** Second phase constructor |
|
78 * |
|
79 * @see CImageEditorControlBase |
|
80 * |
|
81 */ |
|
82 virtual void ConstructL ( |
|
83 const TRect & aRect, |
|
84 CCoeControl * aParent |
|
85 ); |
|
86 |
|
87 /* Setter for view reference |
|
88 * |
|
89 * @see CImageEditorControlBase |
|
90 * |
|
91 */ |
|
92 virtual void SetView (CAknView * aView); |
|
93 |
|
94 /* SetSelectedUiItemL |
|
95 * |
|
96 * @see CImageEditorControlBase |
|
97 * |
|
98 */ |
|
99 virtual void SetSelectedUiItemL (CPluginInfo * aItem); |
|
100 |
|
101 /** PrepareL |
|
102 * |
|
103 * @see CImageEditorControlBase |
|
104 * |
|
105 */ |
|
106 virtual void PrepareL (); |
|
107 |
|
108 /* OfferKeyEventL |
|
109 * |
|
110 * @see CImageEditorControlBase |
|
111 * |
|
112 */ |
|
113 virtual TKeyResponse OfferKeyEventL ( |
|
114 const TKeyEvent & aKeyEvent, |
|
115 TEventCode aType |
|
116 ); |
|
117 |
|
118 /* HandlePointerEventL |
|
119 * |
|
120 * @see CImageEditorControlBase |
|
121 * |
|
122 */ |
|
123 virtual void HandlePointerEventL( const TPointerEvent &aPointerEvent ); |
|
124 |
|
125 /* HandlePluginCommandL |
|
126 * |
|
127 * @see CImageEditorControlBase |
|
128 * |
|
129 */ |
|
130 virtual void HandlePluginCommandL (const TInt aCommand); |
|
131 |
|
132 /* GetSoftkeyIndexL |
|
133 * |
|
134 * @see CImageEditorControlBase |
|
135 */ |
|
136 virtual TInt GetSoftkeyIndexL(); |
|
137 |
|
138 /* GetContextMenuResourceId |
|
139 * |
|
140 * @see CImageEditorControlBase |
|
141 */ |
|
142 virtual TInt GetContextMenuResourceId(); |
|
143 |
|
144 /* GetDimmedMenuItems |
|
145 * |
|
146 * @see CImageEditorControlBase |
|
147 */ |
|
148 virtual TBitField GetDimmedMenuItems(); |
|
149 |
|
150 /* GetNaviPaneTextL |
|
151 * |
|
152 * @see CImageEditorControlBase |
|
153 */ |
|
154 virtual TPtrC GetNaviPaneTextL ( |
|
155 TBool& aLeftNaviPaneScrollButtonVisibile, |
|
156 TBool& aRightNaviPaneScrollButtonVisible); |
|
157 |
|
158 /* GetParam |
|
159 * |
|
160 * Gets pointer to the parameter struct. |
|
161 * |
|
162 * @param - |
|
163 * @return - pointer to MIA parameter struct |
|
164 */ |
|
165 TDesC & GetParam (); |
|
166 |
|
167 /* SetSysteParameters |
|
168 * |
|
169 * Sets reference to system parameters to plug-in. |
|
170 * |
|
171 * @param aSysPars - System parameters instance |
|
172 * @return - |
|
173 */ |
|
174 void SetSystemParameters (const CSystemParameters * aSysPars); |
|
175 |
|
176 /* SetTextL |
|
177 * |
|
178 * Sets user inputted text to text plug-in. |
|
179 * |
|
180 * @param aText - text data |
|
181 * @return - |
|
182 */ |
|
183 void SetTextL (const TDesC & aText); |
|
184 |
|
185 /* GetHelpContext |
|
186 * |
|
187 * @see CCoeControl |
|
188 * |
|
189 */ |
|
190 virtual void GetHelpContext(TCoeHelpContext& aContext) const; |
|
191 |
|
192 /* IsReadyToRender |
|
193 * |
|
194 * @param - |
|
195 * @return - |
|
196 */ |
|
197 TBool IsReadyToRender () const; |
|
198 |
|
199 /* TimerCallBack |
|
200 * |
|
201 * @see MTimerCallBack |
|
202 * |
|
203 */ |
|
204 virtual void TimerCallBack(); |
|
205 |
|
206 //@} |
|
207 |
|
208 |
|
209 protected: |
|
210 |
|
211 /** @name Methods:*/ |
|
212 //@{ |
|
213 /* SizeChanged |
|
214 * |
|
215 * @see CImageEditorControlBase |
|
216 * |
|
217 */ |
|
218 virtual void SizeChanged(); |
|
219 |
|
220 //@} |
|
221 |
|
222 /** @name Members:*/ |
|
223 //@{ |
|
224 |
|
225 //@} |
|
226 |
|
227 private: |
|
228 |
|
229 /** @name Methods:*/ |
|
230 //@{ |
|
231 |
|
232 /** Default constructor |
|
233 * |
|
234 * @param - |
|
235 * @return - |
|
236 */ |
|
237 CImageEditorTextControl (); |
|
238 |
|
239 /** Draw |
|
240 * |
|
241 * @see CImageEditorControlBase |
|
242 * |
|
243 */ |
|
244 virtual void Draw (const TRect & aRect) const; |
|
245 |
|
246 /** NaviDown |
|
247 * |
|
248 * Handles navi key down event. |
|
249 * |
|
250 * @param - |
|
251 * @return - |
|
252 */ |
|
253 void NaviDown(); |
|
254 |
|
255 /** NaviUp |
|
256 * |
|
257 * Handles nave key up event. |
|
258 * |
|
259 * @param - |
|
260 * @return - |
|
261 */ |
|
262 void NaviUp(); |
|
263 |
|
264 /** NaviRight |
|
265 * |
|
266 * Handles nave key right event. |
|
267 * |
|
268 * @param - |
|
269 * @return - |
|
270 */ |
|
271 void NaviRight(); |
|
272 |
|
273 /** NaviLeft |
|
274 * |
|
275 * Handles nave key left event. |
|
276 * |
|
277 * @param - |
|
278 * @return - |
|
279 */ |
|
280 void NaviLeft(); |
|
281 |
|
282 /** ToMoveStateL |
|
283 * |
|
284 * Handles transition to Move state. |
|
285 * |
|
286 * @param - |
|
287 * @return - |
|
288 */ |
|
289 void ToMoveStateL(); |
|
290 |
|
291 /** ToResizeStateL |
|
292 * |
|
293 * Handles transition to Resize state. |
|
294 * |
|
295 * @param - |
|
296 * @return - |
|
297 */ |
|
298 void ToResizeStateL(); |
|
299 |
|
300 /** ToRotateStateL |
|
301 * |
|
302 * Handles transition to Rotate state. |
|
303 * |
|
304 * @param - |
|
305 * @return - |
|
306 */ |
|
307 void ToRotateStateL(); |
|
308 |
|
309 /** ToMainStateL |
|
310 * |
|
311 * Handles transition to Main state. |
|
312 * |
|
313 * @param - |
|
314 * @return - |
|
315 */ |
|
316 void ToMainStateL(); |
|
317 |
|
318 /** StoreTempParams |
|
319 * |
|
320 * Store all parameters to temp variables. |
|
321 * |
|
322 * @param - |
|
323 * @return - |
|
324 */ |
|
325 void StoreTempParams(); |
|
326 |
|
327 /** RestoreTempParams |
|
328 * |
|
329 * Restore parameters from temp variables. |
|
330 * |
|
331 * @param - |
|
332 * @return - |
|
333 */ |
|
334 void RestoreTempParams(); |
|
335 |
|
336 /** RenderTextImageL |
|
337 * |
|
338 * Renders the text into a EGray2 binary bitmap and copies the contents |
|
339 * of the bitmap to a binary buffer. |
|
340 * |
|
341 * @param - |
|
342 * @return - |
|
343 */ |
|
344 void RenderTextImageL(); |
|
345 |
|
346 /** LoadIndicatorL |
|
347 * |
|
348 * Loads indicator. |
|
349 * |
|
350 * @param aBitmapInd - indicator bitmap MBM index |
|
351 * @param aMaskInd - indicator mask MBM index |
|
352 * @return - |
|
353 */ |
|
354 void LoadIndicatorL ( |
|
355 TInt aBitmapInd, |
|
356 TInt aMaskInd |
|
357 ); |
|
358 |
|
359 /** ComputeIndicatorPosition |
|
360 * |
|
361 * Computes indicator position. |
|
362 * |
|
363 * @param - |
|
364 * @return - |
|
365 */ |
|
366 TPoint ComputeIndicatorPosition() const; |
|
367 |
|
368 /** StoreParameters |
|
369 * |
|
370 * Stores parameters to command line. |
|
371 * |
|
372 * @param - |
|
373 * @return - |
|
374 */ |
|
375 void StoreParameters(); |
|
376 |
|
377 /** StorePosAndScaleRelScreen |
|
378 * |
|
379 * Stores text position and scale relative to |
|
380 * screen. |
|
381 * |
|
382 * @param - |
|
383 * @return - |
|
384 */ |
|
385 void StorePosAndScaleRelScreen(); |
|
386 |
|
387 /** RestorePosAndScaleRelScreen |
|
388 * |
|
389 * Restores text position and scale relative to |
|
390 * screen. |
|
391 * |
|
392 * @param - |
|
393 * @return - |
|
394 */ |
|
395 void RestorePosAndScaleRelScreen(); |
|
396 |
|
397 /** StorePosAndScaleRelImage |
|
398 * |
|
399 * Stores position and scale relative to image. |
|
400 * |
|
401 * @param - |
|
402 * @return - |
|
403 */ |
|
404 void StorePosAndScaleRelImage(); |
|
405 |
|
406 /** StoreParameters |
|
407 * |
|
408 * Restores position and scale relative to image. |
|
409 * |
|
410 * @param - |
|
411 * @return - |
|
412 */ |
|
413 void RestorePosAndScaleRelImage(); |
|
414 |
|
415 /** ClipPosition |
|
416 * |
|
417 * Clips clipart position after screen mode change. |
|
418 * |
|
419 * @param - |
|
420 * @return - |
|
421 */ |
|
422 void ClipPosition(); |
|
423 |
|
424 /** SetTextPosition |
|
425 * |
|
426 * Sets current Text to a new position |
|
427 * |
|
428 * @param - aPointedPosition Middle point position on the screen where |
|
429 * text should should be moved |
|
430 * @return - |
|
431 */ |
|
432 void SetTextPosition( TPoint aPointedPosition ); |
|
433 |
|
434 /** ShowTooltip |
|
435 * |
|
436 * Show tooltip text on the screen. Tooltip text is set based |
|
437 * on the current state. |
|
438 * |
|
439 * @param - |
|
440 * @return - |
|
441 */ |
|
442 void ShowTooltip(); |
|
443 |
|
444 /** CalculateRotation |
|
445 * |
|
446 * Function is used to calculate rotation when text is rotated |
|
447 * with touch. Needed rotation is calculated based on dragging start |
|
448 * and end points. This function also changes rotation variables after |
|
449 * calculation. |
|
450 * |
|
451 * @param - aStartPoint - A position where dragging started |
|
452 * @param - aEndPoint - A position where dragging ended |
|
453 * @return - ETrue if rotate value is changed in the function |
|
454 */ |
|
455 TBool CalculateRotation( TPoint aStartPoint, TPoint aEndPoint ); |
|
456 |
|
457 /** CalculateResize |
|
458 * |
|
459 * Function is used to calculate new scale value when text is resized |
|
460 * with touch. The value is calculated based on dragging start |
|
461 * and end points. This function also changes scale member variable |
|
462 * after calculation. |
|
463 * |
|
464 * @param - aStartPoint - A position where dragging started |
|
465 * @param - aEndPoint - A position where dragging ended |
|
466 * @return - TBool - ETrue if scale value is changed in the function |
|
467 */ |
|
468 TBool CalculateResize( TPoint aStartPoint, TPoint aEndPoint ); |
|
469 |
|
470 //@} |
|
471 |
|
472 /** @name Typedefs:*/ |
|
473 //@{ |
|
474 enum TInsertTextState |
|
475 { |
|
476 // Invalid |
|
477 EInsertTextStateMin = 0, |
|
478 // Plugin main view first time |
|
479 EInsertTextStateFirst, |
|
480 // Plugin main view |
|
481 EInsertTextStateMain, |
|
482 // Move |
|
483 EInsertTextStateMove, |
|
484 // Rotate |
|
485 EInsertTextStateRotate, |
|
486 // Resize |
|
487 EInsertTextStateResize, |
|
488 // Invalid |
|
489 ECropStateMax |
|
490 } iState; |
|
491 //@} |
|
492 |
|
493 |
|
494 /** @name Members:*/ |
|
495 //@{ |
|
496 // Parent control |
|
497 CCoeControl* iParent; |
|
498 |
|
499 /// Editor view |
|
500 CAknView * iEditorView; |
|
501 |
|
502 /// Source image size |
|
503 const CSystemParameters * iSysPars; |
|
504 |
|
505 /// Plug-in info |
|
506 CPluginInfo * iItem; |
|
507 |
|
508 /// Navigation pane text |
|
509 TBuf<64> iNaviPaneText; |
|
510 |
|
511 /// User inputted text |
|
512 TBuf<256> iText; |
|
513 |
|
514 /// Text x position |
|
515 TInt iX; |
|
516 /// Text y position |
|
517 TInt iY; |
|
518 /// Text scale |
|
519 TInt iScale; |
|
520 /// Text scale minimum |
|
521 TInt iScaleMin; |
|
522 /// Text scale maximum |
|
523 TInt iScaleMax; |
|
524 /// Text angle |
|
525 TInt iAngle; |
|
526 /// Text color |
|
527 TRgb iRgb; |
|
528 |
|
529 /// Temp parameters |
|
530 TInt iTempX; |
|
531 TInt iTempY; |
|
532 TInt iTempScale; |
|
533 TInt iTempAngle; |
|
534 |
|
535 TReal iScaleOld; |
|
536 TReal iPosXOld; |
|
537 TReal iPosYOld; |
|
538 |
|
539 /// Timer for fast key events |
|
540 CJPTimer * iTimer; |
|
541 TUint32 iKeyCode; |
|
542 |
|
543 /// Pressed key event code |
|
544 TInt iPressedKeyScanCode; |
|
545 |
|
546 /// Number of ticks since timer start |
|
547 TInt iTickCount; |
|
548 |
|
549 /// Multiplier to control the navigation movement speed |
|
550 TInt iNaviStepMultiplier; |
|
551 |
|
552 /// Showing Ok options menu, where some items are dimmed |
|
553 TBool iDisplayingOkOptionsMenu; |
|
554 |
|
555 /// State indicator glyph |
|
556 CFbsBitmap * iIndicator; |
|
557 CFbsBitmap * iIndicatorMask; |
|
558 |
|
559 /// Ready to render |
|
560 TBool iReadyToRender; |
|
561 |
|
562 /// Parameter |
|
563 TBuf<256> iParam; |
|
564 |
|
565 // Popup controller |
|
566 CAknInfoPopupNoteController* iPopupController; |
|
567 // Tooltip texts |
|
568 HBufC * iTooltipResize; |
|
569 HBufC * iTooltipMove; |
|
570 HBufC * iTooltipRotate; |
|
571 |
|
572 // Previous pen position. Make touch rotating and resizing possible |
|
573 TPoint iPointerPosition; |
|
574 |
|
575 /// Resource reader |
|
576 RConeResourceLoader iResLoader; |
|
577 |
|
578 // Feedback for screen touch: |
|
579 #ifdef RD_TACTILE_FEEDBACK |
|
580 MTouchFeedback* iTouchFeedBack; |
|
581 #endif /* RD_TACTILE_FEEDBACK */ |
|
582 //@} |
|
583 |
|
584 }; |
|
585 |
|
586 |
|
587 #endif |