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 * Image Editor plugin control class. |
16 * Image Editor plugin control class. |
17 * |
17 * |
18 */ |
18 */ |
19 |
|
20 |
|
21 // INCLUDES |
19 // INCLUDES |
22 #include "imageeditordrawcontrol.h" |
20 #include "imageeditordrawcontrol.h" |
23 #include "draw.hrh" |
21 #include "draw.hrh" |
24 |
|
25 #include "ImageEditorUI.hrh" |
22 #include "ImageEditorUI.hrh" |
26 #include "ImageEditorPluginBase.hrh" |
23 #include "ImageEditorPluginBase.hrh" |
27 |
|
28 #include "PluginInfo.h" |
24 #include "PluginInfo.h" |
29 #include "JpTimer.h" |
25 #include "JpTimer.h" |
30 #include "ImageEditorUids.hrh" |
26 #include "ImageEditorUids.hrh" |
31 #include "ImageEditorUiDefs.h" |
27 #include "ImageEditorUiDefs.h" |
32 #include "SystemParameters.h" |
28 #include "SystemParameters.h" |
33 #include "drawpath.h" |
29 #include "drawpath.h" |
34 #include "selectionpopup.h" |
30 #include "selectionpopup.h" |
35 |
|
36 #include "iepb.h" |
31 #include "iepb.h" |
37 // debug log |
32 // debug log |
38 #include "imageeditordebugutils.h" |
33 #include "imageeditordebugutils.h" |
39 |
|
40 #include <fbs.h> |
34 #include <fbs.h> |
41 #include <badesca.h> |
35 #include <badesca.h> |
42 #include <gdi.h> |
36 #include <gdi.h> |
43 #include <eikenv.h> |
37 #include <eikenv.h> |
44 #include <bitdev.h> |
38 #include <bitdev.h> |
45 |
|
46 #include <aknview.h> |
39 #include <aknview.h> |
47 #include <aknutils.h> |
40 #include <aknutils.h> |
48 |
|
49 #include <ImageEditorUI.mbg> |
41 #include <ImageEditorUI.mbg> |
50 #include <AknInfoPopupNoteController.h> |
42 #include <AknInfoPopupNoteController.h> |
51 #include <draw.rsg> |
43 #include <draw.rsg> |
52 #include <bautils.h> |
44 #include <bautils.h> |
53 #include <ConeResLoader.h> |
45 #include <ConeResLoader.h> |
54 #include <gulalign.h> |
46 #include <gulalign.h> |
55 #include <csxhelp/sie.hlp.hrh> |
47 #include <csxhelp/sie.hlp.hrh> |
56 |
48 #include <Icons_doodle.mbg> |
|
49 #include "CImageLabel.h" |
|
50 #include <aknnotewrappers.h> |
57 // Log file |
51 // Log file |
58 _LIT(KDrawPluginLogFile,"drawplugin.log"); |
52 _LIT(KDrawPluginLogFile,"drawplugin.log"); |
59 |
53 |
60 // CONSTANTS |
54 // CONSTANTS |
61 const TInt KWait = 1; |
55 const TInt KWait = 1; |
62 const TInt KMainTextIndex = 0; |
56 const TInt KMainTextIndex = 0; |
63 |
57 //#define HORIZ TPoint(0,72),TPoint(502,360) |
|
58 //#define VERTICAL TPoint(0,92),TPoint(360,579) |
64 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
65 // NewL |
60 // NewL |
66 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
67 // |
62 // |
68 CImageEditorDrawControl* CImageEditorDrawControl::NewL( |
63 CImageEditorDrawControl* CImageEditorDrawControl::NewL(const TRect& aRect, |
69 const TRect& aRect, |
64 CCoeControl* aParent, RPointerArray<CDrawPath>& aPaths, TRgb& aRgb, |
70 CCoeControl* aParent ) |
65 TSize& aSize, TBool &aDisplayTool) |
71 { |
66 { |
72 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NewL()"); |
67 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NewL()"); |
73 |
68 |
74 CImageEditorDrawControl * self = new (ELeave) CImageEditorDrawControl; |
69 CImageEditorDrawControl * self = new (ELeave) CImageEditorDrawControl( |
75 CleanupStack::PushL (self); |
70 aPaths, aRgb, aSize, aDisplayTool); |
76 self->ConstructL (aRect, aParent); |
71 CleanupStack::PushL(self); |
77 CleanupStack::Pop (); // self |
72 self->ConstructL(aRect, aParent); |
78 return self; |
73 CleanupStack::Pop(); // self |
79 } |
74 return self; |
|
75 } |
80 |
76 |
81 // --------------------------------------------------------------------------- |
77 // --------------------------------------------------------------------------- |
82 // CImageEditorDrawControl |
78 // CImageEditorDrawControl |
83 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
84 // |
80 // |
85 CImageEditorDrawControl::CImageEditorDrawControl() : |
81 CImageEditorDrawControl::CImageEditorDrawControl( |
86 iTickCount(0), |
82 RPointerArray<CDrawPath>& aPaths, TRgb& aRgb, TSize& aSize, |
87 iNaviStepMultiplier(KDefaultSmallNavigationStepMultiplier), |
83 TBool& aDisplayTool) : |
88 iDisplayingOkOptionsMenu(EFalse), |
84 iTickCount(0), iX(0), iY(0), iNaviStepMultiplier( |
89 iReadyToRender(EFalse), |
85 KDefaultSmallNavigationStepMultiplier), iDisplayingOkOptionsMenu( |
90 iResLoader( *ControlEnv() ) |
86 EFalse), iReadyToRender(EFalse), iResLoader(*ControlEnv()), iPaths( |
91 {} |
87 aPaths), iRgb(aRgb), iSize(aSize), iDisplayTool(aDisplayTool) |
|
88 |
|
89 { |
|
90 } |
92 |
91 |
93 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |
94 // ~CImageEditorDrawControl() |
93 // ~CImageEditorDrawControl() |
95 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
96 // |
95 // |
97 CImageEditorDrawControl::~CImageEditorDrawControl() |
96 CImageEditorDrawControl::~CImageEditorDrawControl() |
98 { |
97 { |
99 LOG(KDrawPluginLogFile, |
98 LOG(KDrawPluginLogFile, |
100 "CImageEditorDrawControl::~CImageEditorDrawControl()"); |
99 "CImageEditorDrawControl::~CImageEditorDrawControl()"); |
101 delete iTimer; |
100 delete iCustomComponet; |
102 delete iIndicator; |
101 delete iTimer; |
103 delete iIndicatorMask; |
102 delete iIndicator; |
|
103 delete iIndicatorMask; |
104 delete iPopupController; |
104 delete iPopupController; |
105 delete iTooltipResize; |
105 delete iTooltipResize; |
106 iPaths.ResetAndDestroy(); |
106 delete iRollAo; |
107 delete iNaviPaneText; |
107 delete iNaviPaneText; |
|
108 delete iGc; |
|
109 delete iBitmapDev; |
|
110 delete iAnimationAO; |
|
111 |
|
112 iUndoPaths.ResetAndDestroy(); |
108 iResLoader.Close(); |
113 iResLoader.Close(); |
109 } |
114 |
|
115 for (int i = 0; i < iTotalComponent; i++) |
|
116 { |
|
117 CImageLabel* &temp = iLabels[i]; |
|
118 if (temp != NULL) |
|
119 { |
|
120 delete temp; |
|
121 temp = NULL; |
|
122 } |
|
123 } |
|
124 iLabels.ResetAndDestroy(); |
|
125 |
|
126 |
|
127 } |
110 |
128 |
111 // --------------------------------------------------------------------------- |
129 // --------------------------------------------------------------------------- |
112 // ConstructL |
130 // ConstructL |
113 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
114 // |
132 // |
115 void CImageEditorDrawControl::ConstructL( |
133 void CImageEditorDrawControl::ConstructL(const TRect& aRect, |
116 const TRect& /*aRect*/, CCoeControl* aParent ) |
134 CCoeControl* aParent) |
117 { |
135 { |
118 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::ConstructL()"); |
136 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::ConstructL()"); |
119 // Set parent window |
137 |
120 SetContainerWindowL(*aParent); |
138 CreateWindowL(); |
121 |
139 EnableDragEvents(); |
122 // Create resource utility |
140 //iRollDirection = EFalse; |
|
141 iStatuspaneHeight = aRect.iTl.iY; |
|
142 iUndo = EFalse; |
|
143 iRedo = EFalse; |
|
144 iCanRedo = EFalse; |
|
145 //iRollDirection = ETrue; |
|
146 // Create resource utility |
123 TFileName resFile; |
147 TFileName resFile; |
124 // resource file name |
148 // resource file name |
125 _LIT (KResourceFile, "draw.rsc"); |
149 _LIT(KResourceFile, "draw.rsc"); |
126 resFile.Append(KPgnResourcePath); |
150 resFile.Append(KPgnResourcePath); |
127 resFile.Append(KResourceFile); |
151 resFile.Append(KResourceFile); |
128 |
152 |
129 User::LeaveIfError( CompleteWithAppPath( resFile ) ); |
153 User::LeaveIfError(CompleteWithAppPath(resFile)); |
130 // Implementation of RConeResourceLoader uses BaflUtils::NearestLanguageFile |
154 // Implementation of RConeResourceLoader uses BaflUtils::NearestLanguageFile |
131 // to search for a localised resource in proper search order |
155 // to search for a localised resource in proper search order |
132 iResLoader.OpenL( resFile ); |
156 iResLoader.OpenL(resFile); |
133 |
157 |
134 // Create timer for fast key repeat |
158 // Create timer for fast key repeat |
135 iTimer = CJPTimer::NewL( this ); |
159 iTimer = CJPTimer::NewL(this); |
136 |
160 |
137 iPopupController = CAknInfoPopupNoteController::NewL(); |
161 iPopupController = CAknInfoPopupNoteController::NewL(); |
138 iTooltipResize = ControlEnv()->AllocReadResourceL(R_TOOLTIP_TEXT_RESIZE); |
162 iTooltipResize = ControlEnv()->AllocReadResourceL(R_TOOLTIP_TEXT_RESIZE); |
139 |
163 |
140 EnableDragEvents(); |
164 SetExtentToWholeScreen(); |
141 |
165 // TRect a(HORIZ); |
|
166 // iClientRectH = a; |
|
167 // TRect b(VERTICAL); |
|
168 // iClientRectV = b; |
|
169 iCustomComponetClick = EFalse; |
|
170 TRect rect = Rect(); |
|
171 //iDisplayTool=ETrue; |
|
172 if (rect.Width() < rect.Height()) |
|
173 { |
|
174 InitializeMainMenu(EMainMenuHorizontal); |
|
175 } |
|
176 else if (rect.Width() > rect.Height()) |
|
177 { |
|
178 InitializeMainMenu(EMainMenuVertical); |
|
179 } |
|
180 |
|
181 TRect Trect(TPoint(0, 0), TPoint(50, 50)); |
|
182 iCustomComponet = CCustomerComponet::NewL(Trect, this); |
|
183 iCustomComponet->SetExtent(TPoint(40, 100), TSize(50, 50)); |
|
184 iCustomComponet->SetHandlePointerObserver(this); |
|
185 iLastPointEventType = EFalse; |
142 // Activate control |
186 // Activate control |
143 ActivateL(); |
187 ActivateL(); |
144 } |
188 |
|
189 } |
|
190 |
|
191 void CImageEditorDrawControl::InitializeMainMenu( |
|
192 TMainMenuLayout aMainMenuLayout) |
|
193 { |
|
194 iMainMenuLayout = aMainMenuLayout; |
|
195 _LIT(KSvgPath, "\\resource\\apps\\icons_doodle.mif"); |
|
196 TFileName svgFile(KSvgPath); |
|
197 User::LeaveIfError(CompleteWithAppPath(svgFile)); |
|
198 iTotalComponent = 7; |
|
199 TRect clipRect; |
|
200 if (iMainMenuLayout == EMainMenuHorizontal) |
|
201 { |
|
202 iLoopMenuRect = TRect(TPoint(0, Rect().iBr.iY - 87), TSize(360, 87)); |
|
203 |
|
204 for (int i = 0; i < iTotalComponent; i++) |
|
205 { |
|
206 if (iDisplayTool) |
|
207 { |
|
208 TRect |
|
209 Rect1(TPoint(i * 72, iLoopMenuRect.iTl.iY), TSize(72, |
|
210 87)); |
|
211 clipRect = Rect1; |
|
212 } |
|
213 |
|
214 else |
|
215 { |
|
216 TRect Rect2(TPoint(i * 72 - iLoopMenuRect.Width() - 72 * 2, |
|
217 iLoopMenuRect.iTl.iY), TSize(72, 87)); |
|
218 clipRect = Rect2; |
|
219 } |
|
220 |
|
221 CImageLabel* label = CImageLabel::NewL(this, clipRect, |
|
222 CImageLabel::ELabelHorizontal); |
|
223 label->SetHandlePointerObserver(this); |
|
224 iLabels.Append(label); |
|
225 } |
|
226 } |
|
227 else if (iMainMenuLayout == EMainMenuVertical) |
|
228 { |
|
229 iLoopMenuRect = TRect(TPoint(Rect().iBr.iX - 87, 0), TSize(87, 360)); |
|
230 |
|
231 for (int i = 0; i < iTotalComponent; i++) |
|
232 { |
|
233 if (iDisplayTool) |
|
234 { |
|
235 TRect |
|
236 Rect1(TPoint(iLoopMenuRect.iTl.iX, i * 72), TSize(87, |
|
237 72)); |
|
238 clipRect = Rect1; |
|
239 } |
|
240 else |
|
241 { |
|
242 TRect Rect2(TPoint(iLoopMenuRect.iTl.iX, i * 72 |
|
243 - iLoopMenuRect.Height() - 72 * 2), TSize(87, 72)); |
|
244 clipRect = Rect2; |
|
245 } |
|
246 |
|
247 CImageLabel* label = CImageLabel::NewL(this, clipRect, |
|
248 CImageLabel::ELabelVertical); |
|
249 label->SetHandlePointerObserver(this); |
|
250 iLabels.Append(label); |
|
251 } |
|
252 } |
|
253 |
|
254 iLabels[0]->SetImage(svgFile, EMbmIcons_doodlePensize); |
|
255 iLabels[0]->SetTooltip(_L("Pensize")); |
|
256 |
|
257 iLabels[1]->SetImage(svgFile, EMbmIcons_doodlePalette); |
|
258 iLabels[1]->SetTooltip(_L("Palette")); |
|
259 |
|
260 iLabels[2]->SetImage(svgFile, EMbmIcons_doodleUndo); |
|
261 iLabels[2]->SetTooltip(_L("Undo")); |
|
262 |
|
263 iLabels[3]->SetImage(svgFile, EMbmIcons_doodleSave); |
|
264 iLabels[3]->SetTooltip(_L("Save")); |
|
265 |
|
266 iLabels[4]->SetImage(svgFile, EMbmIcons_doodleMenu); |
|
267 iLabels[4]->SetTooltip(_L("About")); |
|
268 |
|
269 iLabels[5]->SetImage(svgFile, EMbmIcons_doodlePalette); |
|
270 iLabels[5]->SetTooltip(_L("Redo")); |
|
271 |
|
272 iLabels[6]->SetImage(svgFile, EMbmIcons_doodlePensize); |
|
273 iLabels[6]->SetTooltip(_L("Null")); |
|
274 |
|
275 iAnimationAO = CAnimationAO::NewL(); |
|
276 iAnimationAO->SetObserver(this); |
|
277 iRollAo = CRollAO::NewL(); |
|
278 iRollAo->SetObserver(this); |
|
279 |
|
280 iButtonDownPoint = TPoint(0, 0); |
|
281 iDragStartPoint = TPoint(0, 0); |
|
282 iDragPrePoint = TPoint(0, 0); |
|
283 iDragUpPoint = TPoint(0, 0); |
|
284 |
|
285 iPointStartInLoopRect = EFalse; |
|
286 iDragIsStart = EFalse; |
|
287 iEnableAnimationEffect = EFalse; |
|
288 iDragOffset = 0; |
|
289 |
|
290 } |
145 |
291 |
146 // --------------------------------------------------------------------------- |
292 // --------------------------------------------------------------------------- |
147 // SetView |
293 // SetView |
148 // --------------------------------------------------------------------------- |
294 // --------------------------------------------------------------------------- |
149 // |
295 // |
150 void CImageEditorDrawControl::SetView(CAknView* aView) |
296 void CImageEditorDrawControl::SetView(CAknView* aView) |
151 { |
297 { |
152 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetView()"); |
298 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetView()"); |
153 ASSERT( aView ); |
299 ASSERT(aView); |
154 iEditorView = aView; |
300 iEditorView = aView; |
155 } |
301 } |
156 |
302 |
157 // --------------------------------------------------------------------------- |
303 // --------------------------------------------------------------------------- |
158 // SetSelectedUiItemL |
304 // SetSelectedUiItemL |
159 // --------------------------------------------------------------------------- |
305 // --------------------------------------------------------------------------- |
160 // |
306 // |
161 void CImageEditorDrawControl::SetSelectedUiItemL(CPluginInfo* aItem) |
307 void CImageEditorDrawControl::SetSelectedUiItemL(CPluginInfo* aItem) |
162 { |
308 { |
163 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetSelectedUiItemL()"); |
309 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetSelectedUiItemL()"); |
164 ASSERT( aItem ); |
310 ASSERT(aItem); |
165 iItem = aItem; |
311 iItem = aItem; |
166 delete iNaviPaneText; |
312 delete iNaviPaneText; |
167 iNaviPaneText = NULL; |
313 iNaviPaneText = NULL; |
168 iNaviPaneText = (iItem->Parameters()[KMainTextIndex]).AllocL(); |
314 iNaviPaneText = (iItem->Parameters()[KMainTextIndex]).AllocL(); |
169 iEditorView->HandleCommandL(EImageEditorCmdRender); |
315 iEditorView->HandleCommandL(EImageEditorCmdRender); |
170 } |
316 } |
171 |
317 |
172 // --------------------------------------------------------------------------- |
318 // --------------------------------------------------------------------------- |
173 // OfferKeyEventL |
319 // OfferKeyEventL |
174 // --------------------------------------------------------------------------- |
320 // --------------------------------------------------------------------------- |
175 // |
321 // |
176 TKeyResponse CImageEditorDrawControl::OfferKeyEventL( |
322 TKeyResponse CImageEditorDrawControl::OfferKeyEventL( |
177 const TKeyEvent& aKeyEvent, |
323 const TKeyEvent& aKeyEvent, TEventCode aType) |
178 TEventCode aType) |
324 { |
179 { |
325 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::OfferKeyEventL()"); |
180 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::OfferKeyEventL()"); |
326 |
181 |
327 TKeyResponse response = EKeyWasNotConsumed; |
182 TKeyResponse response = EKeyWasNotConsumed; |
328 |
183 |
329 // If busy, do not handle anything |
184 // If busy, do not handle anything |
330 if (Busy()) |
185 if ( Busy() ) |
331 { |
186 { |
332 response = EKeyWasConsumed; |
187 response = EKeyWasConsumed; |
333 } |
188 } |
334 |
189 |
335 // In main state handle the OK Options menu |
190 // In main state handle the OK Options menu |
336 else if (aKeyEvent.iCode == EKeyOK) |
191 else if ( aKeyEvent.iCode == EKeyOK ) |
337 { |
192 { |
338 iDisplayingOkOptionsMenu = ETrue; |
193 iDisplayingOkOptionsMenu = ETrue; |
339 iEditorView->HandleCommandL(EImageEditorTryDisplayMenuBar); |
194 iEditorView->HandleCommandL (EImageEditorTryDisplayMenuBar); |
340 response = EKeyWasConsumed; |
195 response = EKeyWasConsumed; |
341 } |
196 } |
342 |
197 |
343 // We handle only event keys |
198 // We handle only event keys |
344 else if (EEventKey == aType) |
199 else if (EEventKey == aType) |
345 { |
200 { |
|
201 |
346 |
202 switch (aKeyEvent.iCode) |
347 switch (aKeyEvent.iCode) |
203 { |
348 { |
204 |
349 |
205 case EKeyDownArrow: |
350 case EKeyDownArrow: |
206 case EKeyUpArrow: |
351 case EKeyUpArrow: |
207 case EKeyRightArrow: |
352 case EKeyRightArrow: |
208 case EKeyLeftArrow: |
353 case EKeyLeftArrow: |
209 { |
354 { |
210 SetPositionOnImage( ComputeIndicatorPosition() ); |
355 SetPositionOnImage(ComputeIndicatorPosition()); |
211 StoreParameters( EFalse, EFalse ); |
356 StoreParameters(EFalse, EFalse); |
212 response = EKeyWasConsumed; |
357 response = EKeyWasConsumed; |
213 break; |
358 break; |
214 } |
359 } |
215 |
360 |
216 case EKeyOK: |
361 case EKeyOK: |
217 { |
362 { |
218 break; |
363 break; |
219 } |
364 } |
220 |
365 |
221 case 0x30: // 0 |
366 case 0x30: // 0 |
222 case 0x32: // 2 |
367 case 0x32: // 2 |
223 case 0x34: // 4 |
368 case 0x34: // 4 |
224 case 0x35: // 5 |
369 case 0x35: // 5 |
225 case 0x36: // 6 |
370 case 0x36: // 6 |
226 case 0x38: // 8 |
371 case 0x38: // 8 |
227 case EStdKeyIncVolume: // zoom in key |
372 case EStdKeyIncVolume: // zoom in key |
228 case EStdKeyDecVolume: // zoom out key |
373 case EStdKeyDecVolume: // zoom out key |
229 { |
374 { |
230 StorePosAndScaleRelScreen(); |
375 StorePosAndScaleRelScreen(); |
231 break; |
376 break; |
232 } |
377 } |
233 |
378 |
234 default: |
379 default: |
235 { |
380 { |
236 break; |
381 break; |
237 } |
382 } |
238 } |
383 } |
239 } |
384 } |
240 |
385 |
241 // Key pressed down, mark pressed key |
386 // Key pressed down, mark pressed key |
242 else if (aType == EEventKeyDown) |
387 else if (aType == EEventKeyDown) |
243 { |
388 { |
244 switch (aKeyEvent.iScanCode) |
389 switch (aKeyEvent.iScanCode) |
245 { |
390 { |
246 case EStdKeyUpArrow: |
391 case EStdKeyUpArrow: |
247 { |
392 { |
248 iKeyCode = 1; |
393 iKeyCode = 1; |
249 response = EKeyWasConsumed; |
394 response = EKeyWasConsumed; |
250 break; |
395 break; |
251 } |
396 } |
252 case EStdKeyDownArrow: |
397 case EStdKeyDownArrow: |
253 { |
398 { |
254 iKeyCode = 2; |
399 iKeyCode = 2; |
255 response = EKeyWasConsumed; |
400 response = EKeyWasConsumed; |
256 break; |
401 break; |
257 } |
402 } |
258 case EStdKeyLeftArrow: |
403 case EStdKeyLeftArrow: |
259 { |
404 { |
260 iKeyCode = 3; |
405 iKeyCode = 3; |
261 response = EKeyWasConsumed; |
406 response = EKeyWasConsumed; |
262 break; |
407 break; |
263 } |
408 } |
264 case EStdKeyRightArrow: |
409 case EStdKeyRightArrow: |
265 { |
410 { |
266 iKeyCode = 4; |
411 iKeyCode = 4; |
267 response = EKeyWasConsumed; |
412 response = EKeyWasConsumed; |
268 break; |
413 break; |
269 } |
414 } |
270 } |
415 } |
271 |
416 |
272 if ( iKeyCode != 0 ) |
417 if (iKeyCode != 0) |
273 { |
418 { |
274 iNaviStepMultiplier = KDefaultSmallNavigationStepMultiplier; |
419 iNaviStepMultiplier = KDefaultSmallNavigationStepMultiplier; |
275 iTickCount = 0; |
420 iTickCount = 0; |
276 iTimer->Call( KWait ); |
421 iTimer->Call(KWait); |
277 } |
422 } |
278 } |
423 } |
279 |
424 |
280 // Key released, mark all keys to zero |
425 // Key released, mark all keys to zero |
281 else if (aType == EEventKeyUp) |
426 else if (aType == EEventKeyUp) |
282 { |
427 { |
283 switch (aKeyEvent.iScanCode) |
428 switch (aKeyEvent.iScanCode) |
284 { |
429 { |
285 case EStdKeyUpArrow: |
430 case EStdKeyUpArrow: |
286 case EStdKeyDownArrow: |
431 case EStdKeyDownArrow: |
287 case EStdKeyLeftArrow: |
432 case EStdKeyLeftArrow: |
288 case EStdKeyRightArrow: |
433 case EStdKeyRightArrow: |
289 { |
434 { |
290 iKeyCode = 0; |
435 iKeyCode = 0; |
291 response = EKeyWasConsumed; |
436 response = EKeyWasConsumed; |
292 ShowTooltip(); |
437 ShowTooltip(); |
293 break; |
438 break; |
294 } |
439 } |
295 } |
440 } |
296 } |
441 } |
297 |
442 |
298 return response; |
443 return response; |
299 } |
444 } |
300 |
445 |
301 // --------------------------------------------------------------------------- |
446 // --------------------------------------------------------------------------- |
302 // SizeChanged |
447 // SizeChanged |
303 // --------------------------------------------------------------------------- |
448 // --------------------------------------------------------------------------- |
304 // |
449 // |
305 void CImageEditorDrawControl::SizeChanged() |
450 void CImageEditorDrawControl::SizeChanged() |
306 { |
451 { |
307 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SizeChanged()"); |
452 if (iSizeChangeFlag) |
308 } |
453 { |
309 |
454 SetToolBarStatus(); |
|
455 } |
|
456 else |
|
457 { |
|
458 iSizeChangeFlag = ETrue; |
|
459 } |
|
460 if (iDragIsStart) |
|
461 { |
|
462 if (iMainMenuLayout == EMainMenuHorizontal) |
|
463 { |
|
464 for (TInt i = 0; i < iTotalComponent; i++) |
|
465 { |
|
466 if (iLabels[0]->Rect().iTl.iX <= 0) |
|
467 { |
|
468 TInt x = iLabels[i]->Rect().iTl.iX; |
|
469 iLabels[i]->SetPosition(TPoint(x + iDragOffset, |
|
470 iLoopMenuRect.iTl.iY)); |
|
471 iLabels[i]->ResetControl(); |
|
472 } |
|
473 } |
|
474 } |
|
475 else if (iMainMenuLayout == EMainMenuVertical) |
|
476 { |
|
477 for (TInt i = 0; i < iTotalComponent; i++) |
|
478 { |
|
479 if (iLabels[0]->Rect().iTl.iY <= 0) |
|
480 { |
|
481 TInt y = iLabels[i]->Rect().iTl.iY; |
|
482 iLabels[i]->SetPosition(TPoint(iLoopMenuRect.iTl.iX, y |
|
483 + iDragOffset)); |
|
484 iLabels[i]->ResetControl(); |
|
485 } |
|
486 } |
|
487 } |
|
488 DrawNow(); |
|
489 } |
|
490 } |
|
491 |
|
492 void CImageEditorDrawControl::SetToolBarStatus() |
|
493 { |
|
494 |
|
495 if (iMainMenuLayout == EMainMenuHorizontal) |
|
496 { |
|
497 TInt leftX = iLabels[0]->Rect().iTl.iX; |
|
498 TInt rightX = iLabels[iTotalComponent - 1]->Rect().iBr.iX; |
|
499 if (leftX == 0) |
|
500 iDisplayTool = ETrue; |
|
501 else if (rightX == 0) |
|
502 iDisplayTool = EFalse; |
|
503 } |
|
504 else if (iMainMenuLayout == EMainMenuVertical) |
|
505 { |
|
506 TInt topY = iLabels[0]->Rect().iTl.iY; |
|
507 TInt bottomY = iLabels[iTotalComponent - 1]->Rect().iBr.iY; |
|
508 if (topY == 0) |
|
509 iDisplayTool = ETrue; |
|
510 else if (bottomY == 0) |
|
511 iDisplayTool = EFalse; |
|
512 |
|
513 } |
|
514 |
|
515 } |
310 // --------------------------------------------------------------------------- |
516 // --------------------------------------------------------------------------- |
311 // GetParam |
517 // GetParam |
312 // --------------------------------------------------------------------------- |
518 // --------------------------------------------------------------------------- |
313 // |
519 // |
314 TDesC& CImageEditorDrawControl::GetParam() |
520 TDesC& CImageEditorDrawControl::GetParam() |
315 { |
521 { |
316 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetParam()"); |
522 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetParam()"); |
317 LOGDES(KDrawPluginLogFile, iParam); |
523 LOGDES(KDrawPluginLogFile, iParam); |
318 return iParam; |
524 return iParam; |
319 } |
525 } |
320 |
526 |
321 // --------------------------------------------------------------------------- |
527 // --------------------------------------------------------------------------- |
322 // SetSystemParameters |
528 // SetSystemParameters |
323 // --------------------------------------------------------------------------- |
529 // --------------------------------------------------------------------------- |
324 // |
530 // |
325 void CImageEditorDrawControl::SetSystemParameters(const CSystemParameters* aPars) |
531 void CImageEditorDrawControl::SetSystemParameters( |
326 { |
532 const CSystemParameters* aPars) |
327 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetSystemParameters()"); |
533 { |
328 ASSERT( aPars ); |
534 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SetSystemParameters()"); |
329 iSysPars = aPars; |
535 ASSERT(aPars); |
330 } |
536 iSysPars = aPars; |
|
537 } |
331 |
538 |
332 // --------------------------------------------------------------------------- |
539 // --------------------------------------------------------------------------- |
333 // HandlePluginCommandL |
540 // HandlePluginCommandL |
334 // --------------------------------------------------------------------------- |
541 // --------------------------------------------------------------------------- |
335 // |
542 // |
336 void CImageEditorDrawControl::HandlePluginCommandL(const TInt aCommand) |
543 void CImageEditorDrawControl::HandlePluginCommandL(const TInt aCommand) |
337 { |
544 { |
338 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::HandlePluginCommandL()"); |
545 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::HandlePluginCommandL()"); |
339 |
546 |
340 switch (aCommand) |
547 switch (aCommand) |
341 { |
548 { |
342 case EImageEditorFocusLost: |
549 case EImageEditorFocusLost: |
343 { |
550 { |
344 if (iTimer) |
551 if (iTimer) |
345 { |
552 { |
346 iTimer->Cancel(); |
553 iTimer->Cancel(); |
347 } |
554 } |
348 break; |
555 break; |
349 } |
556 } |
350 case EPgnSoftkeyIdOk: |
557 case EPgnSoftkeyIdOk: |
351 { |
558 { |
352 iPopupController->HideInfoPopupNote(); |
559 iPopupController->HideInfoPopupNote(); |
353 break; |
560 break; |
354 } |
561 } |
355 case EPgnSoftkeyIdCancel: |
562 case EPgnSoftkeyIdCancel: |
356 { |
563 { |
357 iPopupController->HideInfoPopupNote(); |
564 iPopupController->HideInfoPopupNote(); |
358 iEditorView->HandleCommandL (EImageEditorCancelPlugin); |
565 iEditorView->HandleCommandL(EImageEditorCancelPlugin); |
359 break; |
566 break; |
360 } |
567 } |
361 case EPgnSoftkeyIdDone: |
568 case EPgnSoftkeyIdDone: |
362 // FALLTROUHG |
569 // FALLTROUHG |
363 case EDrawPgnMenuCmdDone: |
570 case EDrawPgnMenuCmdDone: |
364 { |
571 { |
365 iPopupController->HideInfoPopupNote(); |
572 iPopupController->HideInfoPopupNote(); |
366 StoreParameters(EFalse, ETrue); |
573 StoreParameters(EFalse, ETrue); |
367 iEditorView->HandleCommandL( EImageEditorCmdRender );//results Draw call |
574 iEditorView->HandleCommandL(EImageEditorCmdRender);//results Draw call |
368 iEditorView->HandleCommandL(EImageEditorApplyPlugin); |
575 iEditorView->HandleCommandL(EImageEditorApplyPlugin); |
369 break; |
576 break; |
370 } |
577 } |
371 case EDrawPgnMenuCmdResize: |
578 case EDrawPgnMenuCmdResize: |
372 { |
579 { |
373 StoreParameters(ETrue, ETrue); |
580 StoreParameters(ETrue, ETrue); |
374 iEditorView->HandleCommandL( EImageEditorCmdRender );//results Draw call |
581 iEditorView->HandleCommandL(EImageEditorCmdRender);//results Draw call |
375 SelectSizeL(); |
582 SelectSizeL(); |
376 break; |
583 break; |
377 } |
584 } |
378 case EDrawPgnMenuCmdColor: |
585 case EDrawPgnMenuCmdColor: |
379 { |
586 { |
380 StoreParameters(ETrue, ETrue); |
587 StoreParameters(ETrue, ETrue); |
381 iEditorView->HandleCommandL( EImageEditorCmdRender );//results Draw call |
588 iEditorView->HandleCommandL(EImageEditorCmdRender);//results Draw call |
382 SDrawUtils::LaunchColorSelectionPopupL(iPreview, Rect(), iRgb); |
589 SDrawUtils::LaunchColorSelectionPopupL(iPreview, Rect(), iRgb); |
383 break; |
590 break; |
384 } |
591 } |
385 case EDrawPgnMenuCmdCancel: |
592 case EDrawPgnMenuCmdCancel: |
386 { |
593 { |
387 iReadyToRender = EFalse; |
594 iReadyToRender = EFalse; |
388 iEditorView->HandleCommandL(EImageEditorCancelPlugin); |
595 iEditorView->HandleCommandL(EImageEditorCancelPlugin); |
389 break; |
596 break; |
390 } |
597 } |
391 |
598 |
392 case EImageEditorGlobalZoomChanged: |
599 case EImageEditorGlobalZoomChanged: |
393 // FALLTROUGHT |
600 // FALLTROUGHT |
394 case EImageEditorGlobalPanChanged: |
601 case EImageEditorGlobalPanChanged: |
395 { |
602 { |
396 RestorePosAndScaleRelScreen(); |
603 RestorePosAndScaleRelScreen(); |
397 //StoreParameters(); |
604 StoreTempParams(); |
398 StoreTempParams(); |
605 iEditorView->HandleCommandL(EImageEditorCmdRender); |
399 iEditorView->HandleCommandL (EImageEditorCmdRender); |
606 break; |
400 |
607 } |
401 //DrawNow(); |
608 |
402 break; |
609 case EImageEditorPreScreenModeChange: |
403 } |
610 { |
404 |
|
405 case EImageEditorPreScreenModeChange: |
|
406 { |
|
407 StorePosAndScaleRelImage(); |
611 StorePosAndScaleRelImage(); |
408 break; |
612 break; |
409 } |
613 } |
410 |
614 |
411 case EImageEditorPostScreenModeChange: |
615 case EImageEditorPostScreenModeChange: |
412 { |
616 { |
413 RestorePosAndScaleRelImage(); |
617 RestorePosAndScaleRelImage(); |
414 ClipPosition(); |
618 ClipPosition(); |
415 //StoreParameters(); |
619 StoreTempParams(); |
416 StoreTempParams(); |
620 iEditorView->HandleCommandL(EImageEditorCmdRender); |
417 iEditorView->HandleCommandL (EImageEditorCmdRender); |
621 break; |
418 //DrawNow(); |
622 } |
419 break; |
623 default: |
420 } |
624 { |
421 |
625 break; |
422 default: |
626 } |
423 { |
627 } |
424 break; |
628 } |
425 } |
|
426 } |
|
427 } |
|
428 |
629 |
429 // --------------------------------------------------------------------------- |
630 // --------------------------------------------------------------------------- |
430 // GetSoftkeyIndexL |
631 // GetSoftkeyIndexL |
431 // --------------------------------------------------------------------------- |
632 // --------------------------------------------------------------------------- |
432 // |
633 // |
433 TInt CImageEditorDrawControl::GetSoftkeyIndexL() |
634 TInt CImageEditorDrawControl::GetSoftkeyIndexL() |
434 { |
635 { |
435 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetSoftkeyIndexL()"); |
636 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetSoftkeyIndexL()"); |
436 // : Check needed states |
637 // : Check needed states |
437 TInt state(2); |
638 TInt state(2); |
438 return state; |
639 return state; |
439 } |
640 } |
440 |
641 |
441 // --------------------------------------------------------------------------- |
642 // --------------------------------------------------------------------------- |
442 // GetContextMenuResourceId |
643 // GetContextMenuResourceId |
443 // --------------------------------------------------------------------------- |
644 // --------------------------------------------------------------------------- |
444 // |
645 // |
445 TInt CImageEditorDrawControl::GetContextMenuResourceId() |
646 TInt CImageEditorDrawControl::GetContextMenuResourceId() |
446 { |
647 { |
447 return R_TEXT_CONTEXT_MENUBAR; |
648 return R_TEXT_CONTEXT_MENUBAR; |
448 } |
649 } |
449 |
650 |
450 // --------------------------------------------------------------------------- |
651 // --------------------------------------------------------------------------- |
451 // GetDimmedMenuItems |
652 // GetDimmedMenuItems |
452 // --------------------------------------------------------------------------- |
653 // --------------------------------------------------------------------------- |
453 // |
654 // |
454 TBitField CImageEditorDrawControl::GetDimmedMenuItems() |
655 TBitField CImageEditorDrawControl::GetDimmedMenuItems() |
455 { |
656 { |
456 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetDimmedMenuItems()"); |
657 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetDimmedMenuItems()"); |
457 |
658 |
458 TBitField dimmedMenuItems; |
659 TBitField dimmedMenuItems; |
459 TInt count = iItem->MenuItems().Count(); |
660 TInt count = iItem->MenuItems().Count(); |
460 |
661 |
461 if ( iDisplayingOkOptionsMenu ) |
662 if (iDisplayingOkOptionsMenu) |
462 { |
663 { |
463 // Dim the command EImageEditorCancelPlugin |
664 // Dim the command EImageEditorCancelPlugin |
464 for ( TInt i = 0; i < count; i++) |
665 for (TInt i = 0; i < count; i++) |
465 { |
666 { |
466 // get the menu item id |
667 // get the menu item id |
467 TInt menuItem = iItem->MenuItems().At(i).iCommandId; |
668 TInt menuItem = iItem->MenuItems().At(i).iCommandId; |
468 if ( menuItem == EDrawPgnMenuCmdCancel ) |
669 if (menuItem == EDrawPgnMenuCmdCancel) |
469 { |
670 { |
470 dimmedMenuItems.SetBit( i ); |
671 dimmedMenuItems.SetBit(i); |
471 } |
672 } |
472 } |
673 } |
473 iDisplayingOkOptionsMenu = EFalse; |
674 iDisplayingOkOptionsMenu = EFalse; |
474 } |
675 } |
475 |
676 |
476 for ( TInt i = 0; i < count; i++) |
677 for (TInt i = 0; i < count; i++) |
477 { |
678 { |
478 // get the menu item id |
679 // get the menu item id |
479 TInt menuItem = iItem->MenuItems().At(i).iCommandId; |
680 TInt menuItem = iItem->MenuItems().At(i).iCommandId; |
480 if ( menuItem == EDrawPgnMenuCmdMax ) |
681 if (menuItem == EDrawPgnMenuCmdMax) |
481 { |
682 { |
482 dimmedMenuItems.SetBit( i ); |
683 dimmedMenuItems.SetBit(i); |
483 } |
684 } |
484 } |
685 } |
485 return dimmedMenuItems; |
686 return dimmedMenuItems; |
486 } |
687 } |
487 |
688 |
488 // --------------------------------------------------------------------------- |
689 // --------------------------------------------------------------------------- |
489 // GetNaviPaneTextL |
690 // GetNaviPaneTextL |
490 // --------------------------------------------------------------------------- |
691 // --------------------------------------------------------------------------- |
491 // |
692 // |
492 TPtrC CImageEditorDrawControl::GetNaviPaneTextL( |
693 TPtrC CImageEditorDrawControl::GetNaviPaneTextL( |
493 TBool& aLeftNaviPaneScrollButtonVisibile, |
694 TBool& aLeftNaviPaneScrollButtonVisibile, |
494 TBool& aRightNaviPaneScrollButtonVisible ) |
695 TBool& aRightNaviPaneScrollButtonVisible) |
495 { |
696 { |
496 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetNaviPaneTextL()"); |
697 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetNaviPaneTextL()"); |
497 |
698 |
498 aLeftNaviPaneScrollButtonVisibile = EFalse; |
699 aLeftNaviPaneScrollButtonVisibile = EFalse; |
499 aRightNaviPaneScrollButtonVisible = EFalse; |
700 aRightNaviPaneScrollButtonVisible = EFalse; |
500 return *iNaviPaneText; |
701 return *iNaviPaneText; |
501 } |
702 } |
502 |
703 |
503 // --------------------------------------------------------------------------- |
704 // --------------------------------------------------------------------------- |
504 // Draw |
705 // Draw |
505 // --------------------------------------------------------------------------- |
706 // --------------------------------------------------------------------------- |
506 // |
707 // |
507 void CImageEditorDrawControl::Draw(const TRect& aRect) const |
708 void CImageEditorDrawControl::Draw(const TRect& aRect) const |
508 { |
709 { |
509 CWindowGc & gc = SystemGc(); |
710 CWindowGc & gc = SystemGc(); |
510 if( IsReadyToRender() ) |
711 gc.SetBrushColor(KRgbBlack); |
511 { |
712 gc.Clear(aRect); |
512 CPreviewControlBase::DrawPreviewImage(aRect); |
713 |
513 } |
714 TRect ImageRect(iSysPars->VisibleImageRectPrev()); |
514 |
715 CPreviewControlBase::DrawPreviewImage(aRect); |
515 if( iPaths.Count() ) |
716 gc.SetClippingRect(TRect(TPoint(ImageRect.iTl.iX, ImageRect.iTl.iY |
516 { |
717 + iStatuspaneHeight), ImageRect.Size())); |
517 ASSERT( iSysPars ); |
718 |
518 for( TInt i(0); i<iPaths.Count(); ++i) |
719 if (iPaths.Count() > 0) |
519 { |
720 { |
520 CDrawPath* path = iPaths[i]; |
721 // ASSERT( iSysPars ); |
521 CArrayFix<TPoint>* pathPoints = path->ItemArray(); |
722 TInt count = iPaths.Count(); |
522 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
723 for (TInt i(0); i < iPaths.Count(); ++i) |
523 gc.SetPenColor( path->Color() ); |
724 { |
524 gc.SetPenSize( ScaledLineSize( path->Size() ) ); |
725 CDrawPath* path = iPaths[i]; |
525 gc.DrawPolyLine( pathPoints ); |
726 CArrayFix<TPoint>* pathPoints = path->ItemArray(); |
526 } |
727 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
527 } |
728 gc.SetPenColor(path->Color()); |
528 |
729 gc.SetPenSize(ScaledLineSize(path->Size())); |
529 /* |
730 gc.DrawPolyLine(pathPoints); |
530 * : Too slow cause we need to redraw preview image everytime |
731 } |
531 * if( iIndicator && iIndicator->Handle() && |
732 } |
532 iIndicatorMask && iIndicatorMask->Handle() ) |
733 } |
533 { |
|
534 gc.BitBltMasked ( |
|
535 ComputeIndicatorPosition(), |
|
536 iIndicator, |
|
537 TRect (iIndicator->SizeInPixels()), |
|
538 iIndicatorMask, |
|
539 EFalse |
|
540 ); |
|
541 }*/ |
|
542 } |
|
543 |
734 |
544 // --------------------------------------------------------------------------- |
735 // --------------------------------------------------------------------------- |
545 // NaviDown |
736 // NaviDown |
546 // --------------------------------------------------------------------------- |
737 // --------------------------------------------------------------------------- |
547 // |
738 // |
548 void CImageEditorDrawControl::NaviDown() |
739 void CImageEditorDrawControl::NaviDown() |
549 { |
740 { |
550 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviDown()"); |
741 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviDown()"); |
551 } |
742 } |
552 |
743 |
553 // --------------------------------------------------------------------------- |
744 // --------------------------------------------------------------------------- |
554 // NaviUp |
745 // NaviUp |
555 // --------------------------------------------------------------------------- |
746 // --------------------------------------------------------------------------- |
556 // |
747 // |
557 void CImageEditorDrawControl::NaviUp() |
748 void CImageEditorDrawControl::NaviUp() |
558 { |
749 { |
559 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviUp()"); |
750 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviUp()"); |
560 } |
751 } |
561 |
752 |
562 // --------------------------------------------------------------------------- |
753 // --------------------------------------------------------------------------- |
563 // NaviRight |
754 // NaviRight |
564 // --------------------------------------------------------------------------- |
755 // --------------------------------------------------------------------------- |
565 // |
756 // |
566 void CImageEditorDrawControl::NaviRight() |
757 void CImageEditorDrawControl::NaviRight() |
567 { |
758 { |
568 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviRight()"); |
759 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviRight()"); |
569 } |
760 } |
570 |
761 |
571 // --------------------------------------------------------------------------- |
762 // --------------------------------------------------------------------------- |
572 // NaviLeft |
763 // NaviLeft |
573 // --------------------------------------------------------------------------- |
764 // --------------------------------------------------------------------------- |
574 // |
765 // |
575 void CImageEditorDrawControl::NaviLeft() |
766 void CImageEditorDrawControl::NaviLeft() |
576 { |
767 { |
577 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviLeft()"); |
768 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::NaviLeft()"); |
578 } |
769 } |
579 |
770 |
580 // --------------------------------------------------------------------------- |
771 // --------------------------------------------------------------------------- |
581 // SelectSizeL |
772 // SelectSizeL |
582 // --------------------------------------------------------------------------- |
773 // --------------------------------------------------------------------------- |
583 // |
774 // |
584 void CImageEditorDrawControl::SelectSizeL() |
775 void CImageEditorDrawControl::SelectSizeL() |
585 { |
776 { |
586 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SelectSizeL()"); |
777 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::SelectSizeL()"); |
587 // Symmetric line width / height |
778 // Symmetric line width / height |
588 TInt size(iSize.iWidth); |
779 TInt size(iSize.iWidth); |
589 CSelectionDialog::RunDlgLD( iPreview, Rect(), size ); |
780 CSelectionDialog::RunDlgLD(iPreview, Rect(), size, iRgb, |
590 iSize = TSize(size,size); |
781 iSysPars->VisibleImageRectPrev()); |
591 } |
782 iSize = TSize(size, size); |
|
783 } |
592 |
784 |
593 // --------------------------------------------------------------------------- |
785 // --------------------------------------------------------------------------- |
594 // StoreTempParams |
786 // StoreTempParams |
595 // --------------------------------------------------------------------------- |
787 // --------------------------------------------------------------------------- |
596 // |
788 // |
597 void CImageEditorDrawControl::StoreTempParams() |
789 void CImageEditorDrawControl::StoreTempParams() |
598 { |
790 { |
599 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::StoreTempParams()"); |
791 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::StoreTempParams(" |
600 } |
792 "" |
|
793 ")"); |
|
794 } |
601 |
795 |
602 // --------------------------------------------------------------------------- |
796 // --------------------------------------------------------------------------- |
603 // RestoreTempParams |
797 // RestoreTempParams |
604 // --------------------------------------------------------------------------- |
798 // --------------------------------------------------------------------------- |
605 // |
799 // |
606 void CImageEditorDrawControl::RestoreTempParams() |
800 void CImageEditorDrawControl::RestoreTempParams() |
607 { |
801 { |
608 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::RestoreTempParams()"); |
802 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::RestoreTempParams()"); |
609 } |
803 } |
610 |
804 |
611 // --------------------------------------------------------------------------- |
805 // --------------------------------------------------------------------------- |
612 // GetHelpContext |
806 // GetHelpContext |
613 // --------------------------------------------------------------------------- |
807 // --------------------------------------------------------------------------- |
614 // |
808 // |
615 void CImageEditorDrawControl::GetHelpContext(TCoeHelpContext& aContext) const |
809 void CImageEditorDrawControl::GetHelpContext(TCoeHelpContext& aContext) const |
616 { |
810 { |
617 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetHelpContext()"); |
811 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::GetHelpContext()"); |
618 |
812 |
619 aContext.iMajor = TUid::Uid(UID_IMAGE_EDITOR); |
813 aContext.iMajor = TUid::Uid(UID_IMAGE_EDITOR); |
620 aContext.iContext = KSIE_HLP_EDIT_TEXT; |
814 aContext.iContext = KSIE_HLP_EDIT_TEXT; |
621 } |
815 } |
622 |
816 |
623 // --------------------------------------------------------------------------- |
817 // --------------------------------------------------------------------------- |
624 // PrepareL |
818 // PrepareL |
625 // --------------------------------------------------------------------------- |
819 // --------------------------------------------------------------------------- |
626 // |
820 // |
627 void CImageEditorDrawControl::PrepareL() |
821 void CImageEditorDrawControl::PrepareL() |
628 { |
822 { |
629 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::PrepareL()"); |
823 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::PrepareL()"); |
630 |
824 |
631 // Get current view port |
825 // Get current view port |
632 TRect rect = iSysPars->VisibleImageRectPrev(); |
826 TRect rect = iSysPars->VisibleImageRectPrev(); |
633 |
827 |
634 // Set default position |
828 iReadyToRender = ETrue; |
635 iX = (rect.iTl.iX + rect.iBr.iX) / 2; |
829 |
636 iY = (rect.iTl.iY + rect.iBr.iY) / 2; |
830 iEditorView->HandleCommandL(EImageEditorCmdRender); |
637 |
831 } |
638 // Set default color to white |
|
639 iRgb = KRgbWhite; |
|
640 |
|
641 // Set default size |
|
642 TInt defaultSize(8); |
|
643 iSize = TSize(defaultSize, defaultSize); |
|
644 iReadyToRender = ETrue; |
|
645 |
|
646 iEditorView->HandleCommandL( EImageEditorCmdRender ); |
|
647 } |
|
648 |
832 |
649 // --------------------------------------------------------------------------- |
833 // --------------------------------------------------------------------------- |
650 // LoadIndicatorL |
834 // LoadIndicatorL |
651 // --------------------------------------------------------------------------- |
835 // --------------------------------------------------------------------------- |
652 // |
836 // |
653 void CImageEditorDrawControl::LoadIndicatorL( |
837 void CImageEditorDrawControl::LoadIndicatorL(TInt aBitmapInd, TInt aMaskInd) |
654 TInt aBitmapInd, TInt aMaskInd ) |
838 { |
655 { |
839 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::LoadIndicatorL()"); |
656 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::LoadIndicatorL()"); |
840 |
657 |
841 // Delete old indicator |
658 // Delete old indicator |
842 delete iIndicator; |
659 delete iIndicator; |
843 iIndicator = 0; |
660 iIndicator = 0; |
844 delete iIndicatorMask; |
661 delete iIndicatorMask; |
845 iIndicatorMask = 0; |
662 iIndicatorMask = 0; |
846 |
663 |
847 // Load new indicator |
664 // Load new indicator |
848 SDrawUtils::GetIndicatorBitmapL(iIndicator, iIndicatorMask, aBitmapInd, |
665 SDrawUtils::GetIndicatorBitmapL ( |
849 aMaskInd); |
666 iIndicator, |
850 } |
667 iIndicatorMask, |
|
668 aBitmapInd, |
|
669 aMaskInd |
|
670 ); |
|
671 } |
|
672 |
851 |
673 // --------------------------------------------------------------------------- |
852 // --------------------------------------------------------------------------- |
674 // ComputeIndicatorPosition |
853 // ComputeIndicatorPosition |
675 // --------------------------------------------------------------------------- |
854 // --------------------------------------------------------------------------- |
676 // |
855 // |
677 TPoint CImageEditorDrawControl::ComputeIndicatorPosition() const |
856 TPoint CImageEditorDrawControl::ComputeIndicatorPosition() const |
678 { |
857 { |
679 TRect vprect = iSysPars->VisibleImageRect(); |
858 TRect vprect = iSysPars->VisibleImageRect(); |
680 TRect vpprect = iSysPars->VisibleImageRectPrev(); |
859 TRect vpprect = iSysPars->VisibleImageRectPrev(); |
681 |
860 |
682 TInt x( 0 ); |
861 TInt x(0); |
683 TInt y( 0 ); |
862 TInt y(0); |
684 // check if there is no indicator |
863 // check if there is no indicator |
685 if ( !iIndicator ) |
864 if (!iIndicator) |
686 { |
865 { |
687 return TPoint ( x, y ); |
866 return TPoint(x, y); |
688 } |
867 } |
689 |
868 |
690 y = ((iY - vprect.iTl.iY) * vpprect.Height()) / vprect.Height(); |
869 y = ((iY - vprect.iTl.iY) * vpprect.Height()) / vprect.Height(); |
691 y += vpprect.iTl.iY; |
870 y += vpprect.iTl.iY; |
692 //y -= iIndicator->SizeInPixels().iHeight; /// 4; |
871 |
693 |
872 x = ((iX - vprect.iTl.iX) * vpprect.Width()) / vprect.Width(); |
694 x = ((iX - vprect.iTl.iX) * vpprect.Width()) / vprect.Width(); |
|
695 x += vpprect.iTl.iX; |
873 x += vpprect.iTl.iX; |
696 //x -= iIndicator->SizeInPixels().iWidth / 2; |
874 |
697 |
875 return TPoint(x, y); |
698 return TPoint (x,y); |
|
699 } |
876 } |
700 |
877 |
701 // --------------------------------------------------------------------------- |
878 // --------------------------------------------------------------------------- |
702 // IsReadyToRender |
879 // IsReadyToRender |
703 // --------------------------------------------------------------------------- |
880 // --------------------------------------------------------------------------- |
704 // |
881 // |
705 TBool CImageEditorDrawControl::IsReadyToRender() const |
882 TBool CImageEditorDrawControl::IsReadyToRender() const |
706 { |
883 { |
707 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::IsReadyToRender()"); |
884 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::IsReadyToRender()"); |
708 return iReadyToRender; |
885 return iReadyToRender; |
709 } |
886 } |
710 |
887 |
711 // --------------------------------------------------------------------------- |
888 // --------------------------------------------------------------------------- |
712 // StoreParameters |
889 // StoreParameters |
713 // --------------------------------------------------------------------------- |
890 // --------------------------------------------------------------------------- |
714 // |
891 // |
715 void CImageEditorDrawControl::StoreParameters(TBool aLastItem, TBool aDone) |
892 void CImageEditorDrawControl::StoreParameters(TBool aLastItem, TBool aDone) |
716 { |
893 { |
717 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::StoreParameters()"); |
894 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::StoreParameters()"); |
718 RDebug::Print(_L("CImageEditorDrawControl::StoreParameters color[%d]"), |
895 RDebug::Print(_L("CImageEditorDrawControl::StoreParameters color[%d]"), |
719 iRgb.Internal()); |
896 iRgb.Internal()); |
720 |
897 |
721 iParam.Copy(_L("x ")); |
898 iParam.Copy(_L("x ")); |
722 iParam.AppendNum (iX); |
899 iParam.AppendNum(iX); |
723 iParam.Append(_L(" y ")); |
900 iParam.Append(_L(" y ")); |
724 iParam.AppendNum (iY); |
901 iParam.AppendNum(iY); |
725 |
902 if (aLastItem) |
726 if( aLastItem ) |
903 { |
727 { |
904 iParam.Append(_L(" size ")); |
728 iParam.Append(_L(" size ")); |
905 iParam.AppendNum(iSize.iHeight); |
729 iParam.AppendNum (iSize.iHeight); |
906 iParam.Append(_L(" color ")); |
730 iParam.Append(_L(" color ")); |
907 iParam.AppendNum(iRgb.Value()); |
731 iParam.AppendNum ( iRgb.Value() ); |
|
732 iParam.Append(_L(" lastItem ")); |
908 iParam.Append(_L(" lastItem ")); |
733 } |
909 } |
734 if( aDone ) |
910 |
735 { |
911 if (aDone) |
736 iParam.Append(_L("done")); |
912 { |
737 } |
913 iParam.Zero(); |
738 } |
914 iParam.Append(_L("done")); |
|
915 } |
|
916 if (iUndo) |
|
917 { |
|
918 iParam.Zero(); |
|
919 iParam.Append(_L("Undo")); |
|
920 } |
|
921 if (iRedo) |
|
922 { |
|
923 iParam.Zero(); |
|
924 iParam.Append(_L("redone")); |
|
925 } |
|
926 } |
739 |
927 |
740 // --------------------------------------------------------------------------- |
928 // --------------------------------------------------------------------------- |
741 // TimerCallBack |
929 // TimerCallBack |
742 // --------------------------------------------------------------------------- |
930 // --------------------------------------------------------------------------- |
743 // |
931 // |
744 void CImageEditorDrawControl::TimerCallBack() |
932 void CImageEditorDrawControl::TimerCallBack() |
745 { |
933 { |
746 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::TimerCallBack()"); |
934 LOG(KDrawPluginLogFile, "CImageEditorDrawControl::TimerCallBack()"); |
747 |
935 |
748 if (iTickCount > KDefaultFastKeyTimerMultiplyThresholdInTicks) |
936 if (iTickCount > KDefaultFastKeyTimerMultiplyThresholdInTicks) |
749 { |
937 { |
750 iNaviStepMultiplier = KDefaultBigNavigationStepMultiplier; |
938 iNaviStepMultiplier = KDefaultBigNavigationStepMultiplier; |
751 } |
939 } |
752 else |
940 else |
753 { |
941 { |
754 iTickCount++; |
942 iTickCount++; |
755 } |
943 } |
756 |
944 |
757 if (iKeyCode) |
945 if (iKeyCode) |
758 { |
946 { |
759 |
947 |
760 switch (iKeyCode) |
948 switch (iKeyCode) |
761 { |
949 { |
762 case 1: |
950 case 1: |
763 { |
951 { |
764 NaviUp(); |
952 NaviUp(); |
765 break; |
953 break; |
766 } |
954 } |
767 case 2: |
955 case 2: |
768 { |
956 { |
769 NaviDown(); |
957 NaviDown(); |
770 break; |
958 break; |
771 } |
959 } |
772 case 3: |
960 case 3: |
773 { |
961 { |
774 NaviLeft(); |
962 NaviLeft(); |
775 break; |
963 break; |
776 } |
964 } |
777 case 4: |
965 case 4: |
778 { |
966 { |
779 NaviRight(); |
967 NaviRight(); |
780 break; |
968 break; |
781 } |
969 } |
782 default: |
970 default: |
783 break; |
971 break; |
784 } |
972 } |
785 //StoreParameters(); |
973 //StoreParameters(); |
786 TRAP_IGNORE( iEditorView->HandleCommandL(EImageEditorCmdRender) ); |
974 TRAP_IGNORE(iEditorView->HandleCommandL(EImageEditorCmdRender)); |
787 iTimer->Call (KWait); |
975 iTimer->Call(KWait); |
788 } |
976 } |
789 } |
977 } |
790 |
978 |
791 // --------------------------------------------------------------------------- |
979 // --------------------------------------------------------------------------- |
792 // StorePosAndScaleRelScreen |
980 // StorePosAndScaleRelScreen |
793 // --------------------------------------------------------------------------- |
981 // --------------------------------------------------------------------------- |
794 // |
982 // |
795 void CImageEditorDrawControl::StorePosAndScaleRelScreen() |
983 void CImageEditorDrawControl::StorePosAndScaleRelScreen() |
796 { |
984 { |
797 LOG(KDrawPluginLogFile, |
985 LOG(KDrawPluginLogFile, |
798 "CImageEditorClipartControl::StorePosAndScaleRelScreen()"); |
986 "CImageEditorClipartControl::StorePosAndScaleRelScreen()"); |
799 iParam.Copy(_L("nop")); |
987 iParam.Copy(_L("nop")); |
800 } |
988 } |
801 |
989 |
802 // --------------------------------------------------------------------------- |
990 // --------------------------------------------------------------------------- |
803 // ?description_if_needed |
991 // ?description_if_needed |
804 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
805 // |
993 // |
806 void CImageEditorDrawControl::RestorePosAndScaleRelScreen() |
994 void CImageEditorDrawControl::RestorePosAndScaleRelScreen() |
807 { |
995 { |
808 LOG(KDrawPluginLogFile, |
996 LOG(KDrawPluginLogFile, |
809 "CImageEditorClipartControl::RestorePosAndScaleRelScreen()"); |
997 "CImageEditorClipartControl::RestorePosAndScaleRelScreen()"); |
810 } |
998 } |
811 |
|
812 |
999 |
813 // --------------------------------------------------------------------------- |
1000 // --------------------------------------------------------------------------- |
814 // StorePosAndScaleRelImage |
1001 // StorePosAndScaleRelImage |
815 // --------------------------------------------------------------------------- |
1002 // --------------------------------------------------------------------------- |
816 // |
1003 // |
817 void CImageEditorDrawControl::StorePosAndScaleRelImage() |
1004 void CImageEditorDrawControl::StorePosAndScaleRelImage() |
818 { |
1005 { |
819 TReal relscale = iSysPars->RelScale(); |
1006 TReal relscale = iSysPars->RelScale(); |
820 LOGFMT(KDrawPluginLogFile, |
1007 LOGFMT(KDrawPluginLogFile, |
821 "CImageEditorClipartControl::StorePosAndScaleRelImage():%g", |
1008 "CImageEditorClipartControl::StorePosAndScaleRelImage():%g", |
822 relscale); |
1009 relscale); |
823 } |
1010 } |
824 |
1011 |
825 // --------------------------------------------------------------------------- |
1012 // --------------------------------------------------------------------------- |
826 // RestorePosAndScaleRelImage |
1013 // RestorePosAndScaleRelImage |
827 // --------------------------------------------------------------------------- |
1014 // --------------------------------------------------------------------------- |
828 // |
1015 // |
829 void CImageEditorDrawControl::RestorePosAndScaleRelImage() |
1016 void CImageEditorDrawControl::RestorePosAndScaleRelImage() |
830 { |
1017 { |
831 TReal relscale = iSysPars->RelScale(); |
1018 TReal relscale = iSysPars->RelScale(); |
832 LOGFMT(KDrawPluginLogFile, |
1019 LOGFMT(KDrawPluginLogFile, |
833 "CImageEditorClipartControl::RestorePosAndScaleRelImage():%g", |
1020 "CImageEditorClipartControl::RestorePosAndScaleRelImage():%g", |
834 relscale); |
1021 relscale); |
835 } |
1022 } |
836 |
1023 |
837 // --------------------------------------------------------------------------- |
1024 // --------------------------------------------------------------------------- |
838 // ClipPosition |
1025 // ClipPosition |
839 // --------------------------------------------------------------------------- |
1026 // --------------------------------------------------------------------------- |
840 // |
1027 // |
841 void CImageEditorDrawControl::ClipPosition() |
1028 void CImageEditorDrawControl::ClipPosition() |
842 { |
1029 { |
843 if ( iX < iSysPars->VisibleImageRect().iTl.iX ) |
1030 if (iX < iSysPars->VisibleImageRect().iTl.iX) |
844 { |
1031 { |
845 iX = iSysPars->VisibleImageRect().iTl.iX; |
1032 iX = iSysPars->VisibleImageRect().iTl.iX; |
846 } |
1033 } |
847 else if ( iX > iSysPars->VisibleImageRect().iBr.iX ) |
1034 else if (iX > iSysPars->VisibleImageRect().iBr.iX) |
848 { |
1035 { |
849 iX = iSysPars->VisibleImageRect().iBr.iX; |
1036 iX = iSysPars->VisibleImageRect().iBr.iX; |
850 } |
1037 } |
851 |
1038 |
852 if ( iY < iSysPars->VisibleImageRect().iTl.iY ) |
1039 if (iY < iSysPars->VisibleImageRect().iTl.iY) |
853 { |
1040 { |
854 iY = iSysPars->VisibleImageRect().iTl.iY; |
1041 iY = iSysPars->VisibleImageRect().iTl.iY; |
855 } |
1042 } |
856 else if ( iY > iSysPars->VisibleImageRect().iBr.iY ) |
1043 else if (iY > iSysPars->VisibleImageRect().iBr.iY) |
857 { |
1044 { |
858 iY = iSysPars->VisibleImageRect().iBr.iY; |
1045 iY = iSysPars->VisibleImageRect().iBr.iY; |
859 } |
1046 } |
860 } |
1047 } |
861 |
1048 |
862 // --------------------------------------------------------------------------- |
1049 // --------------------------------------------------------------------------- |
863 // HandlePointerEventL |
1050 // HandlePointerEventL |
864 // --------------------------------------------------------------------------- |
1051 // --------------------------------------------------------------------------- |
865 // |
1052 // |
866 void CImageEditorDrawControl::HandlePointerEventL( |
1053 void CImageEditorDrawControl::HandlePointerEventL( |
867 const TPointerEvent &aPointerEvent) |
1054 const TPointerEvent &aPointerEvent) |
868 { |
1055 { |
869 RDebug::Print(_L("CImageEditorDrawControl::HandlePointerEventL pen[%d]"), |
1056 SetToolBarStatus(); |
870 AknLayoutUtils::PenEnabled()); |
1057 RDebug::Print(_L("CImageEditorDrawControl::HandlePointerEventL pen[%d]"), |
871 if( AknLayoutUtils::PenEnabled() && !Busy()) |
1058 AknLayoutUtils::PenEnabled()); |
872 { |
1059 if (iRollflag) |
873 RDebug::Print(_L("CImageEditorDrawControl::iType [%d]"), |
1060 return; |
874 aPointerEvent.iType); |
1061 if (AknLayoutUtils::PenEnabled() && !Busy()) |
875 TBool lastItem( EFalse ); |
1062 { |
876 switch( aPointerEvent.iType ) |
1063 RDebug::Print(_L("CImageEditorDrawControl::iType [%d]"), |
|
1064 aPointerEvent.iType); |
|
1065 TBool lastItem(EFalse); |
|
1066 TPoint point = aPointerEvent.iPosition; |
|
1067 |
|
1068 switch (aPointerEvent.iType) |
877 { |
1069 { |
878 case TPointerEvent::EButton1Down: |
1070 case TPointerEvent::EButton1Down: |
879 { |
1071 { |
880 iReadyToRender = EFalse; |
1072 |
881 |
1073 iButtonDownPoint = point; |
882 CDrawPath* lastPath = CDrawPath::NewL(); |
1074 iLastPointEventType = EFalse; |
883 CleanupStack::PushL( lastPath ); |
1075 CCoeControl::HandlePointerEventL(aPointerEvent); |
884 lastPath->SetColor( iRgb ); |
1076 |
885 lastPath->SetSize( iSize ); |
1077 if (iLoopMenuRect.Contains(point) && !iCustomComponetClick |
886 SetPositionOnImage( aPointerEvent.iPosition ); |
1078 && iDisplayTool) |
887 lastPath->AddItemL( aPointerEvent.iPosition ); |
1079 |
888 iPaths.AppendL( lastPath ); |
1080 { |
889 CleanupStack::Pop( lastPath ); |
1081 iPointStartInLoopRect = ETrue; |
890 break; |
1082 if (iDragIsStart) |
891 } |
1083 { |
|
1084 iAnimationAO->Cancel(); |
|
1085 iDragIsStart = EFalse; |
|
1086 } |
|
1087 |
|
1088 } |
|
1089 else if ((!iLoopMenuRect.Contains(point) |
|
1090 && !iCustomComponetClick && iDisplayTool) |
|
1091 || (!iDisplayTool && !iCustomComponetClick)) |
|
1092 { |
|
1093 iPointStartInLoopRect = EFalse; |
|
1094 //System dispose |
|
1095 iReadyToRender = EFalse; |
|
1096 CDrawPath* lastPath = CDrawPath::NewL(); |
|
1097 CleanupStack::PushL(lastPath); |
|
1098 lastPath->SetColor(iRgb); |
|
1099 lastPath->SetSize(iSize); |
|
1100 SetPositionOnImage(aPointerEvent.iPosition); |
|
1101 lastPath->AddItemL(aPointerEvent.iPosition); |
|
1102 iPaths.AppendL(lastPath); |
|
1103 CleanupStack::Pop(lastPath); |
|
1104 iCanRedo = EFalse; |
|
1105 iUndoPaths.ResetAndDestroy(); |
|
1106 } |
|
1107 } |
|
1108 break; |
|
1109 case TPointerEvent::EButton1Up: |
|
1110 { |
|
1111 // System dispose |
|
1112 iReadyToRender = ETrue; |
|
1113 iCustomComponetClick = EFalse; |
|
1114 lastItem = ETrue; |
|
1115 HandleMainMenuButtonUp(point); |
|
1116 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
1117 DrawNow(); |
|
1118 |
|
1119 } |
|
1120 break; |
892 case TPointerEvent::EDrag: |
1121 case TPointerEvent::EDrag: |
893 { |
1122 { |
894 if( iPaths.Count() ) |
1123 CCoeControl::HandlePointerEventL(aPointerEvent); |
895 { |
1124 //System dispose |
896 CDrawPath* path = iPaths[iPaths.Count()-1]; |
1125 iLastPointEventType = ETrue; |
897 // store current position for next round |
1126 |
898 iPointerPosition = aPointerEvent.iPosition; |
1127 if ((iDisplayTool && iPaths.Count() && !iCustomComponetClick |
899 SetPositionOnImage( aPointerEvent.iPosition ); |
1128 && !iPointStartInLoopRect) || (!iDisplayTool |
900 path->AddItemL( aPointerEvent.iPosition ); |
1129 && iPaths.Count() && !iCustomComponetClick)) |
901 } |
1130 { |
902 break; |
1131 iCanRedo = EFalse; |
903 } |
1132 iUndoPaths.ResetAndDestroy(); |
904 case TPointerEvent::EButton1Up: |
1133 CDrawPath* path = iPaths[iPaths.Count() - 1]; |
905 { |
1134 // store current position for next round |
906 iReadyToRender = ETrue; |
1135 iPointerPosition = aPointerEvent.iPosition; |
907 ShowTooltip(); |
1136 SetPositionOnImage(aPointerEvent.iPosition); |
908 lastItem = ETrue; |
1137 path->AddItemL(aPointerEvent.iPosition); |
|
1138 } |
|
1139 //Self dispose |
|
1140 if (iCustomComponetClick) |
|
1141 { |
|
1142 TPoint con(aPointerEvent.iPosition.iX - 25, |
|
1143 aPointerEvent.iPosition.iY - 25); |
|
1144 iCustomComponet->SetExtent(con, TSize(50, 50)); |
|
1145 DrawNow(); |
|
1146 } |
|
1147 |
|
1148 if (iDisplayTool && iPointStartInLoopRect) |
|
1149 |
|
1150 { |
|
1151 HandleMainMenuButtonDrag(point); |
|
1152 } |
|
1153 } |
909 break; |
1154 break; |
910 } |
|
911 |
|
912 default: |
1155 default: |
913 { |
1156 |
914 break; |
1157 break; |
915 } |
1158 |
916 } |
1159 } |
|
1160 |
|
1161 //System dispose |
|
1162 if ((!iPointStartInLoopRect && iDisplayTool) || !iDisplayTool) |
|
1163 { |
|
1164 if (!(iCustomComponet->Rect().Contains(aPointerEvent.iPosition))) |
|
1165 { |
|
1166 StoreParameters(lastItem, EFalse); |
|
1167 iEditorView->HandleCommandL(EImageEditorCmdRender);//results Draw call |
|
1168 } |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 } |
|
1173 |
|
1174 // --------------------------------------------------------------------------- |
|
1175 // HandleMainMenuButtonUp |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // |
|
1178 void CImageEditorDrawControl::HandleMainMenuButtonUp(TPoint aPoint) |
|
1179 { |
|
1180 if (iMainMenuLayout == EMainMenuHorizontal) |
|
1181 { |
|
1182 if (iDragIsStart) |
|
1183 { |
|
1184 //Drag event is end (Except activating animation effect). |
|
1185 iDragIsStart = EFalse; |
|
1186 |
|
1187 if (Abs(iDragPrePoint.iX - aPoint.iX) > 1) |
|
1188 { |
|
1189 //Animation effect is activated |
|
1190 iDragIsStart = ETrue; |
|
1191 iStartSpeed = aPoint.iX - iDragPrePoint.iX; |
|
1192 iAnimationAO->StartL(0); |
|
1193 } |
|
1194 } |
|
1195 } |
|
1196 else if (iMainMenuLayout == EMainMenuVertical) |
|
1197 { |
|
1198 if (iDragIsStart) |
|
1199 { |
|
1200 //Drag event is end (Except activating animation effect). |
|
1201 iDragIsStart = EFalse; |
|
1202 |
|
1203 if (Abs(iDragPrePoint.iY - aPoint.iY) > 1) |
|
1204 { |
|
1205 //Animation effect is activated |
|
1206 iDragIsStart = ETrue; |
|
1207 iStartSpeed = aPoint.iY - iDragPrePoint.iY; |
|
1208 iAnimationAO->StartL(0); |
|
1209 } |
|
1210 } |
|
1211 } |
|
1212 } |
|
1213 |
|
1214 // --------------------------------------------------------------------------- |
|
1215 // HandleMainMenuButtonDrag |
|
1216 // --------------------------------------------------------------------------- |
|
1217 // |
|
1218 void CImageEditorDrawControl::HandleMainMenuButtonDrag(TPoint aPoint) |
|
1219 { |
|
1220 if (iMainMenuLayout == EMainMenuHorizontal) |
|
1221 { |
|
1222 if (iPointStartInLoopRect && !iDragIsStart && Abs(aPoint.iX |
|
1223 - iButtonDownPoint.iX) >= DRAG_LENGTH) |
|
1224 { |
|
1225 iDragIsStart = ETrue; |
|
1226 iDragStartPoint = aPoint; |
|
1227 |
|
1228 for (TInt i = 0; i < iTotalComponent; i++) |
|
1229 { |
|
1230 if (iLabels[i]->Rect().Contains(iButtonDownPoint)) |
|
1231 { |
|
1232 iLabels[i]->LabelIsMoving(); |
|
1233 } |
|
1234 } |
|
1235 } |
|
1236 |
|
1237 if (iDragIsStart) |
|
1238 { |
|
1239 iDragPrePoint = iDragUpPoint; |
|
1240 iDragUpPoint = aPoint; |
|
1241 iDragOffset = aPoint.iX - iDragStartPoint.iX; |
|
1242 iDragStartPoint = aPoint; |
917 |
1243 |
918 StoreParameters( lastItem, EFalse ); |
1244 CalculateEffectiveOffset(); |
919 iEditorView->HandleCommandL( EImageEditorCmdRender );//results Draw call |
1245 SizeChanged(); |
920 CCoeControl::HandlePointerEventL( aPointerEvent ); |
1246 } |
921 } |
1247 } |
922 } |
1248 else if (iMainMenuLayout == EMainMenuVertical) |
|
1249 { |
|
1250 if (iPointStartInLoopRect && !iDragIsStart && Abs(aPoint.iY |
|
1251 - iButtonDownPoint.iY) >= DRAG_LENGTH) |
|
1252 { |
|
1253 iDragIsStart = ETrue; |
|
1254 iDragStartPoint = aPoint; |
|
1255 |
|
1256 for (TInt i = 0; i < iTotalComponent; i++) |
|
1257 { |
|
1258 if (iLabels[i]->Rect().Contains(iButtonDownPoint)) |
|
1259 { |
|
1260 iLabels[i]->LabelIsMoving(); |
|
1261 } |
|
1262 } |
|
1263 } |
|
1264 |
|
1265 if (iDragIsStart) |
|
1266 { |
|
1267 iDragPrePoint = iDragUpPoint; |
|
1268 iDragUpPoint = aPoint; |
|
1269 iDragOffset = aPoint.iY - iDragStartPoint.iY; |
|
1270 iDragStartPoint = aPoint; |
|
1271 |
|
1272 CalculateEffectiveOffset(); |
|
1273 SizeChanged(); |
|
1274 } |
|
1275 } |
|
1276 } |
|
1277 |
|
1278 // --------------------------------------------------------------------------- |
|
1279 // UndoDrawPath |
|
1280 // --------------------------------------------------------------------------- |
|
1281 // |
|
1282 void CImageEditorDrawControl::UndoDrawPath() |
|
1283 { |
|
1284 if (iPaths.Count()) |
|
1285 { |
|
1286 iUndoPaths.Append(iPaths[iPaths.Count() - 1]); |
|
1287 iPaths.Remove(iPaths.Count() - 1); |
|
1288 iCanRedo = ETrue; |
|
1289 } |
|
1290 } |
|
1291 |
|
1292 // --------------------------------------------------------------------------- |
|
1293 // RedoDrawPath |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // |
|
1296 void CImageEditorDrawControl::RedoDrawPath() |
|
1297 { |
|
1298 if (iUndoPaths.Count()) |
|
1299 { |
|
1300 iPaths.Append(iUndoPaths[iUndoPaths.Count() - 1]); |
|
1301 iUndoPaths.Remove(iUndoPaths.Count() - 1); |
|
1302 } |
|
1303 } |
|
1304 |
|
1305 // --------------------------------------------------------------------------- |
|
1306 // HandlePointerNotify |
|
1307 // --------------------------------------------------------------------------- |
|
1308 // |
|
1309 void CImageEditorDrawControl::HandlePointerNotify(CCoeControl* aComponent) |
|
1310 { |
|
1311 //pen size |
|
1312 if (iLabels[0] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1313 { |
|
1314 MakeVisibleLable(EFalse); |
|
1315 SelectSizeL(); |
|
1316 MakeVisibleLable(ETrue); |
|
1317 } |
|
1318 //pen color |
|
1319 else if (iLabels[1] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1320 { |
|
1321 MakeVisibleLable(EFalse); |
|
1322 SDrawUtils::LaunchColorSelectionPopupL(iPreview, Rect(), iRgb); |
|
1323 MakeVisibleLable(ETrue); |
|
1324 } |
|
1325 //undo |
|
1326 else if (iLabels[2] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1327 { |
|
1328 UndoDrawPath(); |
|
1329 iUndo = ETrue; |
|
1330 StoreParameters(EFalse, EFalse); |
|
1331 iEditorView->HandleCommandL(EImageEditorCmdRender); |
|
1332 iUndo = EFalse; |
|
1333 } |
|
1334 //save and quit |
|
1335 else if (iLabels[3] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1336 { |
|
1337 iPopupController->HideInfoPopupNote(); |
|
1338 StoreParameters(EFalse, ETrue); |
|
1339 iEditorView->HandleCommandL(EImageEditorApplyPlugin); |
|
1340 } |
|
1341 else if (iLabels[4] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1342 { |
|
1343 |
|
1344 } |
|
1345 else if (iLabels[5] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1346 { |
|
1347 iRedo = ETrue; |
|
1348 RedoDrawPath(); |
|
1349 StoreParameters(EFalse, EFalse); |
|
1350 iEditorView->HandleCommandL(EImageEditorCmdRender); |
|
1351 iRedo = EFalse; |
|
1352 } |
|
1353 else if (iLabels[6] == dynamic_cast<CImageLabel*> (aComponent)) |
|
1354 { |
|
1355 |
|
1356 } |
|
1357 else if (iCustomComponet == dynamic_cast<CCustomerComponet*> (aComponent)) |
|
1358 { |
|
1359 if (iCustomComponet->GetButtonType()) |
|
1360 { |
|
1361 iCustomComponetClick = ETrue; |
|
1362 } |
|
1363 |
|
1364 if ((!iCustomComponet->GetButtonType()) && (!iLastPointEventType)) |
|
1365 { |
|
1366 StartTheAnimation(); |
|
1367 |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 } |
923 |
1372 |
924 // --------------------------------------------------------------------------- |
1373 // --------------------------------------------------------------------------- |
925 // SetPositionOnImage |
1374 // SetPositionOnImage |
926 // --------------------------------------------------------------------------- |
1375 // --------------------------------------------------------------------------- |
927 // |
1376 // |
928 void CImageEditorDrawControl::SetPositionOnImage( TPoint aPointedPosition ) |
1377 void CImageEditorDrawControl::SetPositionOnImage(TPoint aPointedPosition) |
929 { |
1378 { |
930 ASSERT( iSysPars ); |
1379 ASSERT(iSysPars); |
931 // Get system parameters |
1380 // Get system parameters |
932 TRect visibleImageRect( iSysPars->VisibleImageRect() ); |
1381 TRect visibleImageRect(iSysPars->VisibleImageRect()); |
933 TRect visibleImageRectPrev( iSysPars->VisibleImageRectPrev() ); |
1382 TRect visibleImageRectPrev(iSysPars->VisibleImageRectPrev()); |
934 |
1383 |
935 TInt xPosFactorDivider( visibleImageRectPrev.Width() ); |
1384 TInt xPosFactorDivider(visibleImageRectPrev.Width()); |
936 TInt yPosFactorDivider( visibleImageRectPrev.Height() ); |
1385 TInt yPosFactorDivider(visibleImageRectPrev.Height()); |
937 |
1386 |
938 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::vir w:%d h:%d", |
1387 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::vir w:%d h:%d", |
939 visibleImageRect.Width(), visibleImageRect.Height()); |
1388 visibleImageRect.Width(), visibleImageRect.Height()); |
940 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::virp w:%d h:%d", |
1389 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::virp w:%d h:%d", |
941 visibleImageRectPrev.Width(), visibleImageRectPrev.Height()); |
1390 visibleImageRectPrev.Width(), visibleImageRectPrev.Height()); |
942 |
1391 |
943 // Dividing by zero will cause panic -> check |
1392 // Dividing by zero will cause panic -> check |
944 if ( xPosFactorDivider == 0 || yPosFactorDivider == 0 ) |
1393 if (xPosFactorDivider == 0 || yPosFactorDivider == 0) |
945 { |
1394 { |
946 // Set default position |
1395 // Set default position |
947 iX = (visibleImageRect.iTl.iX + visibleImageRect.iBr.iX) / 2; |
1396 iX = (visibleImageRect.iTl.iX + visibleImageRect.iBr.iX) / 2; |
948 iY = (visibleImageRect.iTl.iY + visibleImageRect.iBr.iY) / 2; |
1397 iY = (visibleImageRect.iTl.iY + visibleImageRect.iBr.iY) / 2; |
949 } |
1398 } |
950 else |
1399 else |
951 { |
1400 { |
952 // Calculate relative position on the screen |
1401 // Calculate relative position on the screen |
953 TReal xPositionFactor |
1402 TReal xPositionFactor(TReal(aPointedPosition.iX |
954 ( TReal( aPointedPosition.iX - visibleImageRectPrev.iTl.iX ) / |
1403 - visibleImageRectPrev.iTl.iX) / xPosFactorDivider); |
955 xPosFactorDivider ); |
1404 // |
956 |
1405 // TReal yPositionFactor(TReal(aPointedPosition.iY - iStatuspaneHeight |
957 TReal yPositionFactor |
1406 // - visibleImageRectPrev.iTl.iY) / yPosFactorDivider); |
958 ( TReal( aPointedPosition.iY - visibleImageRectPrev.iTl.iY ) / |
1407 TReal yPositionFactor(TReal(aPointedPosition.iY |
959 yPosFactorDivider ); |
1408 - visibleImageRectPrev.iTl.iY) / yPosFactorDivider); |
960 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::pfx:%g pfy:%g", |
1409 LOGFMT2(KDrawPluginLogFile, "CImageEditorDrawControl::pfx:%g pfy:%g", |
961 xPositionFactor, yPositionFactor); |
1410 xPositionFactor, yPositionFactor); |
962 // Calculate position on visible image |
1411 // Calculate position on visible image |
963 |
1412 |
964 iX = visibleImageRect.iTl.iX + |
1413 iX = visibleImageRect.iTl.iX + visibleImageRect.Width() |
965 visibleImageRect.Width() * xPositionFactor + 0.5; |
1414 * xPositionFactor + 0.5; |
966 |
1415 |
967 iY = visibleImageRect.iTl.iY + |
1416 iY = visibleImageRect.iTl.iY + visibleImageRect.Height() |
968 visibleImageRect.Height() * yPositionFactor + 0.5; |
1417 * yPositionFactor + 0.5; |
969 } |
1418 } |
970 |
1419 |
971 LOGFMT4(KDrawPluginLogFile, "CImageEditorDrawControl::Draw x:%d iX:%d y:%d iY:%d", |
1420 LOGFMT4(KDrawPluginLogFile, |
972 aPointedPosition.iX, iX, aPointedPosition.iY, iY); |
1421 "CImageEditorDrawControl::Draw x:%d iX:%d y:%d iY:%d", |
|
1422 aPointedPosition.iX, iX, aPointedPosition.iY, iY); |
973 // Check that not out of bounds |
1423 // Check that not out of bounds |
974 //ClipPosition(); |
1424 //ClipPosition(); |
975 } |
1425 } |
976 |
1426 |
977 // --------------------------------------------------------------------------- |
1427 // --------------------------------------------------------------------------- |
978 // GetPositionOnView |
1428 // GetPositionOnView |
979 // --------------------------------------------------------------------------- |
1429 // --------------------------------------------------------------------------- |
980 // |
1430 // |
981 TPoint CImageEditorDrawControl::GetPositionOnView() |
1431 TPoint CImageEditorDrawControl::GetPositionOnView() |
982 { |
1432 { |
983 ASSERT( iSysPars ); |
1433 ASSERT(iSysPars); |
984 // Get system parameters |
1434 // Get system parameters |
985 TRect visibleImageRect( iSysPars->VisibleImageRect() ); |
1435 TRect visibleImageRect(iSysPars->VisibleImageRect()); |
986 TRect visibleImageRectPrev( iSysPars->VisibleImageRectPrev() ); |
1436 TRect visibleImageRectPrev(iSysPars->VisibleImageRectPrev()); |
987 |
1437 |
988 TInt xPosFactorDivider( visibleImageRectPrev.Width() ); |
1438 TInt xPosFactorDivider(visibleImageRectPrev.Width()); |
989 TInt yPosFactorDivider( visibleImageRectPrev.Height() ); |
1439 TInt yPosFactorDivider(visibleImageRectPrev.Height()); |
990 |
1440 |
991 // Calculate relative position on the screen |
1441 // Calculate relative position on the screen |
992 TReal xPositionFactor( TReal( iX + visibleImageRectPrev.iTl.iX ) / |
1442 TReal xPositionFactor(TReal(iX + visibleImageRectPrev.iTl.iX) |
993 xPosFactorDivider ); |
1443 / xPosFactorDivider); |
994 |
1444 |
995 TReal yPositionFactor( TReal( iY + visibleImageRectPrev.iTl.iY ) / |
1445 TReal yPositionFactor(TReal(iY + visibleImageRectPrev.iTl.iY) |
996 yPosFactorDivider ); |
1446 / yPosFactorDivider); |
997 |
1447 |
998 LOGFMT2(KDrawPluginLogFile, |
1448 LOGFMT2(KDrawPluginLogFile, |
999 "CImageEditorDrawControl::GetPositionOnView xf:%g yf:%g", |
1449 "CImageEditorDrawControl::GetPositionOnView xf:%g yf:%g", |
1000 xPositionFactor , yPositionFactor ); |
1450 xPositionFactor, yPositionFactor); |
1001 |
1451 |
1002 LOGFMT2(KDrawPluginLogFile, |
1452 LOGFMT2(KDrawPluginLogFile, |
1003 "CImageEditorDrawControl::GetPositionOnView xf:%d yf:%d", |
1453 "CImageEditorDrawControl::GetPositionOnView xf:%d yf:%d", |
1004 xPosFactorDivider , yPosFactorDivider ); |
1454 xPosFactorDivider, yPosFactorDivider); |
1005 |
1455 |
1006 LOGFMT2(KDrawPluginLogFile, |
1456 LOGFMT2(KDrawPluginLogFile, |
1007 "CImageEditorDrawControl::GetPositionOnView w:%d h:%d", |
1457 "CImageEditorDrawControl::GetPositionOnView w:%d h:%d", iX, iY); |
1008 iX , iY ); |
1458 |
1009 |
1459 TInt xPosition(iX + visibleImageRectPrev.iTl.iX); |
1010 TInt xPosition(iX + visibleImageRectPrev.iTl.iX); |
1460 TInt yPosition(iY + visibleImageRectPrev.iTl.iY); |
1011 TInt yPosition(iY + visibleImageRectPrev.iTl.iY); |
1461 |
1012 |
1462 LOGFMT3(KDrawPluginLogFile, |
1013 LOGFMT3(KDrawPluginLogFile, |
1463 "CImageEditorDrawControl::GetPositionOnView w:%d h:%d S:%g", |
1014 "CImageEditorDrawControl::GetPositionOnView w:%d h:%d S:%g", |
1464 xPosition, yPosition, iSysPars->RelScale()); |
1015 xPosition, yPosition, iSysPars->RelScale()); |
1465 |
1016 |
1466 return TPoint(xPosition, yPosition); |
1017 return TPoint(xPosition, yPosition); |
1467 } |
1018 } |
|
1019 |
1468 |
1020 // --------------------------------------------------------------------------- |
1469 // --------------------------------------------------------------------------- |
1021 // ShowTooltip |
1470 // ShowTooltip |
1022 // --------------------------------------------------------------------------- |
1471 // --------------------------------------------------------------------------- |
1023 // |
1472 // |
1024 void CImageEditorDrawControl::ShowTooltip() |
1473 void CImageEditorDrawControl::ShowTooltip() |
1025 { |
1474 { |
1026 iPopupController->HideInfoPopupNote(); |
1475 iPopupController->HideInfoPopupNote(); |
1027 |
1476 |
1028 TPoint iconPosition = ComputeIndicatorPosition(); |
1477 TPoint iconPosition = ComputeIndicatorPosition(); |
1029 TRect iconRect( iconPosition.iX, iconPosition.iY, |
1478 TRect iconRect(iconPosition.iX, iconPosition.iY, iconPosition.iX, |
1030 iconPosition.iX, iconPosition.iY ); |
1479 iconPosition.iY); |
1031 |
1480 |
1032 |
1481 /*SDrawUtils::ShowToolTip( iPopupController, |
1033 /*SDrawUtils::ShowToolTip( iPopupController, |
1482 this, |
1034 this, |
1483 iconPosition, |
1035 iconPosition, |
1484 EHRightVTop, |
1036 EHRightVTop, |
1485 *iTooltipResize ); |
1037 *iTooltipResize ); |
1486 */ |
1038 */ |
1487 |
1039 |
1488 } |
1040 } |
|
1041 |
1489 |
1042 // --------------------------------------------------------------------------- |
1490 // --------------------------------------------------------------------------- |
1043 // ScaledLineSize |
1491 // ScaledLineSize |
1044 // --------------------------------------------------------------------------- |
1492 // --------------------------------------------------------------------------- |
1045 // |
1493 // |
1046 TSize CImageEditorDrawControl::ScaledLineSize( TSize aOriginalSize ) const |
1494 TSize CImageEditorDrawControl::ScaledLineSize(TSize aOriginalSize) const |
1047 { |
1495 { |
1048 TInt sizew(aOriginalSize.iWidth * iSysPars->RelScale() + 0.5); |
1496 TInt sizew(aOriginalSize.iWidth * iSysPars->RelScale() + 0.5); |
1049 TInt sizeh(aOriginalSize.iHeight * iSysPars->RelScale() + 0.5); |
1497 TInt sizeh(aOriginalSize.iHeight * iSysPars->RelScale() + 0.5); |
1050 if( sizew < 1 ) |
1498 if (sizew < 1) |
1051 { |
1499 { |
1052 sizew++; |
1500 sizew++; |
1053 } |
1501 } |
1054 if( sizeh < 1 ) |
1502 if (sizeh < 1) |
1055 { |
1503 { |
1056 sizeh++; |
1504 sizeh++; |
1057 } |
1505 } |
1058 |
1506 |
1059 LOGFMT3(KDrawPluginLogFile, |
1507 LOGFMT3(KDrawPluginLogFile, |
1060 "CImageEditorDrawControl::ScaledLineSize w:%d h:%d S:%g", |
1508 "CImageEditorDrawControl::ScaledLineSize w:%d h:%d S:%g", sizew, |
1061 sizew, sizeh, iSysPars->RelScale()); |
1509 sizeh, iSysPars->RelScale()); |
1062 return TSize(sizew , sizeh); |
1510 return TSize(sizew, sizeh); |
1063 } |
1511 } |
1064 |
1512 |
|
1513 // --------------------------------------------------------------------------- |
|
1514 // CountComponentControls |
|
1515 // --------------------------------------------------------------------------- |
|
1516 // |
|
1517 TInt CImageEditorDrawControl::CountComponentControls() const |
|
1518 { |
|
1519 return iTotalComponent + 1; |
|
1520 } |
|
1521 |
|
1522 // --------------------------------------------------------------------------- |
|
1523 // ComponentControl |
|
1524 // --------------------------------------------------------------------------- |
|
1525 // |
|
1526 CCoeControl* CImageEditorDrawControl::ComponentControl(TInt aIndex) const |
|
1527 { |
|
1528 switch (aIndex) |
|
1529 { |
|
1530 case 7: |
|
1531 return iCustomComponet; |
|
1532 case 0: |
|
1533 return iLabels[0]; |
|
1534 case 1: |
|
1535 return iLabels[1]; |
|
1536 case 2: |
|
1537 return iLabels[2]; |
|
1538 case 3: |
|
1539 return iLabels[3]; |
|
1540 case 4: |
|
1541 return iLabels[4]; |
|
1542 case 5: |
|
1543 return iLabels[5]; |
|
1544 case 6: |
|
1545 return iLabels[6]; |
|
1546 default: |
|
1547 return NULL; |
|
1548 } |
|
1549 return NULL; |
|
1550 } |
|
1551 |
|
1552 // --------------------------------------------------------------------------- |
|
1553 // Notify |
|
1554 // --------------------------------------------------------------------------- |
|
1555 // |
|
1556 void CImageEditorDrawControl::Notify() |
|
1557 { |
|
1558 if (iStartSpeed > 0) |
|
1559 { |
|
1560 iStartSpeed -= 2; |
|
1561 if (iStartSpeed <= 0) |
|
1562 { |
|
1563 iStartSpeed = 0; |
|
1564 iDragIsStart = EFalse; |
|
1565 iAnimationAO->Cancel(); |
|
1566 } |
|
1567 } |
|
1568 else if (iStartSpeed < 0) |
|
1569 { |
|
1570 iStartSpeed += 2; |
|
1571 if (iStartSpeed >= 0) |
|
1572 { |
|
1573 iStartSpeed = 0; |
|
1574 iDragIsStart = EFalse; |
|
1575 iAnimationAO->Cancel(); |
|
1576 } |
|
1577 } |
|
1578 else |
|
1579 { |
|
1580 iDragIsStart = EFalse; |
|
1581 iAnimationAO->Cancel(); |
|
1582 } |
|
1583 |
|
1584 iDragOffset += iStartSpeed; |
|
1585 CalculateEffectiveOffset(); |
|
1586 SizeChanged(); |
|
1587 } |
|
1588 |
|
1589 // --------------------------------------------------------------------------- |
|
1590 // Roll |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // |
|
1593 void CImageEditorDrawControl::Roll() |
|
1594 { |
|
1595 SetToolBarStatus(); |
|
1596 //TInt leftX = iLabels[0]->Rect().iTl.iX; |
|
1597 //TInt rightX = iLabels[iTotalComponent - 1]->Rect().iBr.iX; |
|
1598 TInt offset = 0; |
|
1599 iRollflag = ETrue; |
|
1600 if (iDisplayTool) |
|
1601 iRollDirection = EFalse; |
|
1602 else |
|
1603 iRollDirection = ETrue; |
|
1604 |
|
1605 |
|
1606 if (iRollDirection) |
|
1607 { |
|
1608 offset = 4; |
|
1609 } |
|
1610 else |
|
1611 { |
|
1612 offset = -4; |
|
1613 } |
|
1614 |
|
1615 if (iMainMenuLayout == EMainMenuHorizontal) |
|
1616 { |
|
1617 for (TInt i = 0; i < iLabels.Count(); i++) |
|
1618 { |
|
1619 TInt x = iLabels[i]->Rect().iTl.iX; |
|
1620 iLabels[i]->SetPosition(TPoint(x + offset, iLoopMenuRect.iTl.iY)); |
|
1621 iLabels[i]->ResetControl(); |
|
1622 } |
|
1623 if (iLabels[0]->Rect().iTl.iX == 0 |
|
1624 || iLabels[iLabels.Count() - 1]->Rect().iBr.iX == 0) |
|
1625 iRollflag = EFalse; |
|
1626 } |
|
1627 else if (iMainMenuLayout == EMainMenuVertical) |
|
1628 { |
|
1629 for (TInt i = 0; i < iLabels.Count(); i++) |
|
1630 { |
|
1631 TInt y = iLabels[i]->Rect().iTl.iY; |
|
1632 iLabels[i]->SetPosition(TPoint(iLoopMenuRect.iTl.iX, y + offset)); |
|
1633 iLabels[i]->ResetControl(); |
|
1634 } |
|
1635 if (iLabels[0]->Rect().iTl.iY == 0 |
|
1636 || iLabels[iLabels.Count() - 1]->Rect().iBr.iY == 0) |
|
1637 iRollflag = EFalse; |
|
1638 } |
|
1639 |
|
1640 DrawNow(); |
|
1641 |
|
1642 if (!iRollflag) |
|
1643 { |
|
1644 //iRollDirection = !iRollDirection; |
|
1645 iRollAo->Cancel(); |
|
1646 } |
|
1647 } |
|
1648 |
|
1649 // --------------------------------------------------------------------------- |
|
1650 // CalculateEffectiveOffset |
|
1651 // --------------------------------------------------------------------------- |
|
1652 // |
|
1653 void CImageEditorDrawControl::CalculateEffectiveOffset() |
|
1654 { |
|
1655 if (iMainMenuLayout == EMainMenuHorizontal) |
|
1656 { |
|
1657 TInt leftX = iLabels[0]->Rect().iTl.iX; |
|
1658 TInt rightX = iLabels[iTotalComponent - 1]->Rect().iBr.iX; |
|
1659 TInt offset = iDragOffset; |
|
1660 if (leftX + offset > 0) |
|
1661 { |
|
1662 iDragOffset = Abs(leftX); |
|
1663 } |
|
1664 |
|
1665 if (rightX + offset < 360) |
|
1666 { |
|
1667 iDragOffset = -(rightX - 360); |
|
1668 } |
|
1669 } |
|
1670 else if (iMainMenuLayout == EMainMenuVertical) |
|
1671 { |
|
1672 TInt topY = iLabels[0]->Rect().iTl.iY; |
|
1673 TInt bottomY = iLabels[iTotalComponent - 1]->Rect().iBr.iY; |
|
1674 TInt offset = iDragOffset; |
|
1675 if (topY + offset > 0) |
|
1676 { |
|
1677 iDragOffset = Abs(topY); |
|
1678 } |
|
1679 |
|
1680 if (bottomY + offset < 360) |
|
1681 { |
|
1682 iDragOffset = -(bottomY - 360); |
|
1683 } |
|
1684 } |
|
1685 } |
|
1686 |
|
1687 // --------------------------------------------------------------------------- |
|
1688 // MakeVisibleLable |
|
1689 // --------------------------------------------------------------------------- |
|
1690 // |
|
1691 void CImageEditorDrawControl::MakeVisibleLable(TBool aFlag) |
|
1692 { |
|
1693 if (aFlag) |
|
1694 { |
|
1695 for (int i = 0; i < iTotalComponent; i++) |
|
1696 { |
|
1697 iLabels[i]->MakeVisible(ETrue); |
|
1698 } |
|
1699 } |
|
1700 else |
|
1701 { |
|
1702 for (int i = 0; i < iTotalComponent; i++) |
|
1703 { |
|
1704 iLabels[i]->MakeVisible(EFalse); |
|
1705 } |
|
1706 } |
|
1707 } |
|
1708 |
|
1709 // --------------------------------------------------------------------------- |
|
1710 // StartTheAnimation |
|
1711 // --------------------------------------------------------------------------- |
|
1712 // |
|
1713 void CImageEditorDrawControl::StartTheAnimation() |
|
1714 { |
|
1715 iRollAo->StartL(0); |
|
1716 } |
|
1717 |
1065 // End of File |
1718 // End of File |