Add new string - Start slideshow, Slideshow setting
[apps/osp/ImageViewer.git] / src / IvImageCropForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                IvImageCrop.cpp
19  * @brief               This is the implementation file for Image Crop.
20  */
21
22 #include <FApp.h>
23 #include <FMedia.h>
24 #include "IvImageCropForm.h"
25 #include "IvImageViewerPresentationModel.h"
26 #include "IvResourceManager.h"
27 #include "IvTypes.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Media;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 static const unsigned int CROP_BOX_RECTANGLE_COLOR = Color32<199, 110, 6>::Value;
40 static const int CROP_BOX_LINE_WIDTH = 5;
41
42 ImageCropForm::ImageCropForm(void)
43         : __imageHeight(0)
44         , __imageWidth(0)
45         , __isOrientationChanged(false)
46         , __pCanvas(null)
47         , __pCurrentBitmap(null)
48         , __pRectangleBitmap(null)
49 {
50         __pointLocation = OUTSIDE_CROPBOX;
51 }
52
53 ImageCropForm::~ImageCropForm(void)
54 {
55         if (__pCurrentBitmap != null)
56         {
57                 delete __pCurrentBitmap;
58         }
59         if (__pRectangleBitmap != null)
60         {
61                 delete __pRectangleBitmap;
62         }
63         if (__pCanvas != null)
64         {
65                 delete __pCanvas;
66                 __pCanvas = null;
67         }
68 }
69
70 bool
71 ImageCropForm::Initialize(void)
72 {
73         Form::Construct(IDL_FORM_IMAGE_CROP);
74         Form::SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
75         return true;
76 }
77
78 result
79 ImageCropForm::OnInitializing(void)
80 {
81         result r = E_SUCCESS;
82
83         AppResource* pAppResource = null;
84         Bitmap* pSaveButtonBitmap = null;
85         Bitmap* pCancelButtonBitmap  = null;
86         Bitmap* pCWRotationButtonBitmap  = null;
87         Bitmap* pCCWRotationButtonBitmap  = null;
88         Panel* pPanel = null;
89         Button* pSaveButton = null;
90         Button* pCancelButton = null;
91         pAppResource = UiApp::App::GetInstance()->GetAppResource();
92         if (pAppResource != null)
93         {
94                 pSaveButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_SAVE_ICON);
95                 pCancelButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CANCEL_ICON);
96                 pCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON);
97                 pCCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON);
98                 __pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
99         }
100
101         pPanel = static_cast<Panel*>(GetControl(L"IDC_FOOTER_PANEL"));
102         if (pPanel != null)
103         {
104                 pSaveButton = static_cast<Button*>(pPanel->GetControl(L"IDC_SAVE_BUTTON"));
105                 if (pSaveButton != null)
106                 {
107                         Point startPoint((pSaveButton->GetWidth() - pSaveButtonBitmap->GetWidth()) / 2,
108                                         (pSaveButton->GetHeight() - pSaveButtonBitmap->GetHeight()) / 2);
109                         pSaveButton->SetNormalBitmap(startPoint, *pSaveButtonBitmap);
110                         pSaveButton->AddActionEventListener(*this);
111                         pSaveButton->SetActionId(IDA_BUTTON_SAVE);
112                 }
113
114                 pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
115                 if (pCancelButton != null)
116                 {
117                         Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,
118                                         (pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2);
119                         pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
120                         pCancelButton->AddActionEventListener(*this);
121                         pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
122                 }
123                 Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
124                 if (pLabel != null)
125                 {
126                         SetControlAlwaysOnTop(*pPanel, true);
127                 }
128                 SetControlAlwaysAtBottom(*pLabel, true);
129         }
130         AddTouchEventListener(*this);
131         AddOrientationEventListener(*this);
132
133         delete pSaveButtonBitmap;
134         delete pCancelButtonBitmap;
135         delete pCWRotationButtonBitmap;
136         delete pCCWRotationButtonBitmap;
137         return r;
138 }
139
140 void
141 ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
142 {
143         AppLogDebug("ENTER");
144         String* pFilePath = null;
145         if (pArgs != null)
146         {
147                 pFilePath = static_cast<String*>(pArgs->GetAt(0));
148                 delete pArgs;
149         }
150         else
151         {
152                 return;
153         }
154         if (pFilePath != null)
155         {
156                 __sourceFilePath.Append(*pFilePath);
157                 result r = __imageBuffer.Construct(pFilePath->GetPointer());
158                 if (r == E_SUCCESS)
159                 {
160                         __imageWidth = __imageBuffer.GetWidth();
161                         __imageHeight = __imageBuffer.GetHeight();
162                         __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
163                 }
164                 Image img;
165                 __imageFormat = img.GetImageFormat(__sourceFilePath);
166         }
167         SetValue();
168         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
169 }
170
171 void
172 ImageCropForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
173 {
174         AppLogDebug("ENTER");
175         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
176 }
177
178 result
179 ImageCropForm::OnDraw(void)
180 {
181         result r = E_SUCCESS;
182         AppLogDebug("ENTER");
183         if (__pCanvas != null)
184         {
185                 r = __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
186                 r = __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap);
187                 r = __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height));
188                 r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Rectangle
189                 r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Rectangle
190                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Left Rectangle
191                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Right Rectangle
192                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Left Rectangle
193                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Right Rectangle
194                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Right Rectangle
195                 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Left Rectangle
196         }
197         AppLogDebug("EXIT");
198         return r;
199 }
200
201 void
202 ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
203 {
204         SceneManager* pSceneManager = SceneManager::GetInstance();
205         switch(actionId)
206         {
207         case IDA_BUTTON_CANCEL:
208                 pSceneManager->GoBackward(BackwardSceneTransition());
209                 break;
210         case IDA_BUTTON_SAVE:
211         {
212                 ImageBuffer* pCropBuffer = null;
213                 int count = 1;
214                 int index = 0;
215                 String destFilePath;
216                 String stringToInsert = L"_";
217                 String delimiter = L".";
218                 if (__sourceFilePath.IsEmpty() == false)
219                 {
220                         __sourceFilePath.Reverse();
221                         __sourceFilePath.IndexOf(delimiter, 0, index);
222                         __sourceFilePath.Reverse();
223                         __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
224                         destFilePath.Append(__sourceFilePath);
225                         destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
226                         while (File::IsFileExist(destFilePath) == true)
227                         {
228                                 count++;
229                                 destFilePath.Clear();
230                                 destFilePath.Append(__sourceFilePath);
231                                 destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
232                         }
233                         pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
234                                                 (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
235                         pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
236                         ContentManager::ScanFile(destFilePath);
237                         delete pCropBuffer;
238                 }
239                 pSceneManager->GoBackward(BackwardSceneTransition());
240                 AppLog("Exit");
241         }
242         break;
243         }
244 }
245
246 void
247 ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
248 {
249         AppLogDebug("ENTER");
250         __isOrientationChanged = true;
251         SetValue();
252         __pCanvas->Clear();
253         AppLogDebug("EXIT");
254 }
255
256 void
257 ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
258 {
259         AppLogDebug("ENTER");
260         __touchStart = currentPosition;
261         CheckCurrentPosition(currentPosition);
262         AppLogDebug("EXIT");
263 }
264
265 void
266 ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
267 {
268         AppLogDebug("ENTER");
269         int deltaX = currentPosition.x - __touchStart.x;
270         int deltaY = currentPosition.y - __touchStart.y;
271         switch(__pointLocation)
272         {
273         case INSIDE_TOP_RECTANGLE:
274         {
275                 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
276                 {
277                         __cropBox.y += deltaY;
278                         __cropBox.height -= deltaY;
279                 }
280         }
281         break;
282
283         case INSIDE_BOTTOM_RECTANGLE:
284         {
285                 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
286                         && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
287                 {
288                         __cropBox.height += deltaY;
289                 }
290         }
291         break;
292
293         case INSIDE_LEFT_RECTANGLE:
294         {
295                 if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
296                 {
297                         __cropBox.x += deltaX;
298                         __cropBox.width -= deltaX;
299                 }
300         }
301         break;
302
303         case INSIDE_RIGHT_RECTANGLE:
304         {
305                 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
306                         && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
307                 {
308                         __cropBox.width += deltaX;
309                 }
310         }
311         break;
312
313         case INSIDE_TOP_LEFT_RECTANGLE:
314         {
315                 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
316                                 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
317                 {
318                         __cropBox.y += deltaY;
319                         __cropBox.height -= deltaY;
320                         __cropBox.x += deltaX;
321                         __cropBox.width -= deltaX;
322                 }
323         }
324         break;
325
326         case INSIDE_TOP_RIGHT_RECTANGLE:
327         {
328                 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
329                                 && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
330                 {
331                         __cropBox.width += deltaX;
332                         __cropBox.y += deltaY;
333                         __cropBox.height -= deltaY;
334                 }
335         }
336         break;
337
338         case INSIDE_BOTTOM_LEFT_RECTANGLE:
339         {
340                 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
341                         && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
342                 {
343                         __cropBox.x += deltaX;
344                         __cropBox.width -= deltaX;
345                         __cropBox.height += deltaY;
346                 }
347         }
348         break;
349
350         case INSIDE_BOTTOM_RIGHT_RECTANGLE:
351         {
352                 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
353                         && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
354                 {
355                         __cropBox.width += deltaX;
356                         __cropBox.height += deltaY;
357                 }
358         }
359         break;
360
361         case INSIDE_CROPBOX:
362         {
363                 if ((__cropBox.x + deltaX) > __imageBox.x)
364                 {
365                         __cropBox.x += deltaX;
366                 }
367                 else
368                 {
369                         __cropBox.x = __imageBox.x;
370                 }
371                 if ((__cropBox.y + deltaY) > __imageBox.y)
372                 {
373                         __cropBox.y += deltaY;
374                 }
375                 else
376                 {
377                         __cropBox.y = __imageBox.y;
378                 }
379                 if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
380                 {
381                         __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
382                 }
383                 if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
384                 {
385                         __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
386                 }
387         }
388         break;
389
390         default:
391                 break;
392         }
393         RequestRedraw(false);
394         __touchStart = currentPosition;
395         AppLogDebug("EXIT");
396 }
397
398 void
399 ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
400 {
401         AppLogDebug("ENTER");
402         __pointLocation = OUTSIDE_CROPBOX;
403         AppLogDebug("EXIT");
404 }
405
406 void
407 ImageCropForm::CheckCurrentPosition(const Point currentPosition)
408 {
409         AppLogDebug("ENTER");
410         if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
411                 && currentPosition.y >  (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
412         {
413                 __pointLocation = INSIDE_TOP_RECTANGLE;
414         }
415         else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
416                 && currentPosition.y >  ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
417         {
418                 __pointLocation = INSIDE_LEFT_RECTANGLE;
419         }
420         else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
421                 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
422         {
423                 __pointLocation = INSIDE_RIGHT_RECTANGLE;
424         }
425         else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
426                 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
427         {
428                 __pointLocation = INSIDE_BOTTOM_RECTANGLE;
429         }
430         else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
431                          && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
432         {
433                 __pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
434         }
435         else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
436                         && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
437         {
438                 __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
439         }
440         else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
441                         && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
442         {
443                 __pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
444         }
445         else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
446                         && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
447         {
448                 __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
449         }
450         else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
451         {
452                 __pointLocation = INSIDE_CROPBOX;
453         }
454         else
455         {
456                 __pointLocation = OUTSIDE_CROPBOX;
457         }
458         AppLogDebug("EXIT");
459         return;
460 }
461
462 void
463 ImageCropForm::SetValue(void)
464 {
465         int prevHeight = __imageBox.height;
466         int prevWidth = __imageBox.width;
467         int prevImageboxX = __imageBox.x;
468         int prevImageBoxY = __imageBox.y;
469         int indicatorBarHeight = 0;
470
471         if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
472         {
473                 indicatorBarHeight = 21;
474         }
475         else
476         {
477                 indicatorBarHeight = 60;
478         }
479
480         if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
481         {
482                 if (__imageHeight > __imageWidth)
483                 {
484                         __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
485                         __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
486                         __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
487                         __imageBox.y = indicatorBarHeight;
488                 }
489                 else
490                 {
491                         __imageBox.width = GetClientAreaBounds().width;
492                         __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
493                         __imageBox.x = 0;
494                         __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
495                 }
496         }
497         else if (__imageWidth > GetClientAreaBounds().width)
498         {
499                 __imageBox.width = GetClientAreaBounds().width;
500                 __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
501                 __imageBox.x = 0;
502                 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
503
504         }
505         else if (__imageHeight > GetClientAreaBounds().height)
506         {
507                 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
508                 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
509                 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
510                 __imageBox.y = indicatorBarHeight;
511         }
512         else
513         {
514                 __imageBox.height = __imageHeight;
515                 __imageBox.width = __imageWidth;
516                 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
517                 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
518         }
519         if (__isOrientationChanged == false)
520         {
521                 if (__imageHeight >= __imageWidth)
522                 {
523                         __cropBox.height = __imageBox.height / 2;
524                         __cropBox.width = __imageBox.width / 2;
525                         __cropBox.y =  __imageBox.y + (__imageBox.height / 4);
526                         __cropBox.x = __imageBox.x + (__imageBox.width / 4);
527                 }
528                 else
529                 {
530                         __cropBox.height = (2 * __imageBox.height) / 3;
531                         __cropBox.width = (2 * __imageBox.width) / 3;
532                         __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
533                         __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
534                 }
535         }
536         else
537         {
538                 float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float)prevWidth;
539                 __cropBox.x = (temp + 0.5);
540                 temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float)prevHeight;
541                 __cropBox.y = (temp + 0.5);
542                 temp = (__cropBox.height * __imageBox.height) / (float)prevHeight;
543                 __cropBox.height = (temp + 0.5);
544                 temp = (__cropBox.width * __imageBox.width) / (float)prevWidth;
545                 __cropBox.width = (temp + 0.5);
546         }
547         __pCanvas = GetCanvasN();
548         __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);
549
550 }