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