#include <FSystem.h>
#include <FSocial.h>
#include "IvImageCropForm.h"
+#include "IvImageViewerApp.h"
#include "IvImageViewerPresentationModel.h"
#include "IvResourceManager.h"
#include "IvTypes.h"
static const int CROP_BOX_LINE_WIDTH = 5;
ImageCropForm::ImageCropForm(void)
- : __imageHeight(0)
+ : __cropMode(APPCONTROL_DATA_AUTO)
+ , __imageHeight(0)
, __imageWidth(0)
, __isOrientationChanged(false)
, __pCanvas(null)
, __pRectangleBitmap(null)
, __pointLocation(OUTSIDE_CROPBOX)
, __pPresentationModel(null)
+ , __statusValue(-1)
+ , __formHeight(0)
+ , __formWidth(0)
{
}
result
ImageCropForm::OnInitializing(void)
{
- result r = E_SUCCESS;
-
AppResource* pAppResource = null;
Bitmap* pSaveButtonBitmap = null;
Bitmap* pCancelButtonBitmap = null;
- Bitmap* pCWRotationButtonBitmap = null;
- Bitmap* pCCWRotationButtonBitmap = null;
Panel* pPanel = null;
Button* pSaveButton = null;
Button* pCancelButton = null;
{
pSaveButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_SAVE_ICON);
pCancelButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CANCEL_ICON);
- pCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON);
- pCCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON);
__pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
}
AddOrientationEventListener(*this);
__pPresentationModel->AddFileUpdateListener(this);
- delete pCWRotationButtonBitmap;
- delete pCCWRotationButtonBitmap;
- return r;
+ return E_SUCCESS;
}
void
AppLogDebug("ENTER pArgs(%x)", pArgs);
if (pArgs != null)
{
- IEnumerator* pEnum = pArgs->GetEnumeratorN();
- if (pEnum->MoveNext() != E_SUCCESS)
- {
- delete pEnum;
- delete pArgs;
- AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
+ __sourceFilePath = *(static_cast<String*>(pArgs->GetAt(0)));
+ __cropMode = *(static_cast<String*>(pArgs->GetAt(1)));
+ }
+ else
+ {
+ __sourceFilePath = __pPresentationModel->GetFilePathAt(0);
- return;
- }
- __sourceFilePath = *(static_cast<String*>(pEnum->GetCurrent()));
- if (__sourceFilePath.IsEmpty() == false)
- {
- result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
- if (r == E_SUCCESS)
- {
- __imageWidth = __imageBuffer.GetWidth();
- __imageHeight = __imageBuffer.GetHeight();
- __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
- }
- Image img;
- __imageFormat = img.GetImageFormat(__sourceFilePath);
- }
- if (pEnum->MoveNext() != E_SUCCESS)
- {
- delete pEnum;
- delete pArgs;
- AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
+ ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
+ const IMap* pIMap = pImageViewerApp->GetAppControlArguments();
- return;
- }
- __cropMode = *(static_cast<String*>(pEnum->GetCurrent()));
- if (__cropMode.IsEmpty() == false)
+ if (pIMap != null)
{
- __cropMode.ToLowerCase();
- if (__cropMode == "auto")
- {
- delete pEnum;
- delete pArgs;
- SetValue();
- return;
- }
- else if (__cropMode == "fit-to-screen")
- {
- if (pEnum->MoveNext() != E_SUCCESS)
- {
- delete pEnum;
- delete pArgs;
- AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
-
- return;
- }
- Integer *pStatus = static_cast<Integer*>(pEnum->GetCurrent());
- if (pStatus != null)
- {
- __statusValue = pStatus->ToInt();
- }
- if (__statusValue == SET_AT_TYPE_CALLER_IMAGE)
- {
- if (pEnum->MoveNext() != E_SUCCESS)
- {
- delete pEnum;
- delete pArgs;
- AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
-
- return;
- }
-
- LongLong* pContentId = static_cast<LongLong*>(pEnum->GetCurrent());
- if (pContentId != null)
- {
- __contentId = pContentId->ToLongLong();
- }
- }
+ const String* pCropMode = static_cast<const String*>(pIMap->GetValue(String(APPCONTROL_KEY_IMAGE_CROP_MODE)));
- delete pEnum;
- delete pArgs;
- SetValue();
+ if (pCropMode != null)
+ {
+ __cropMode = *pCropMode;
}
}
}
-// if (pArgs != null)
-// {
-// __sourceFilePath = *(static_cast<String*>(pArgs->GetAt(0)));
-// __cropMode = *(static_cast<String*>(pArgs->GetAt(1)));
-// delete pArgs;
-// }
-// else
-// {
-// __sourceFilePath = __pPresentationModel->GetFilePathAt(0);
-// }
-/* if (__sourceFilePath.IsEmpty() == false && __cropMode.IsEmpty() == false)
- {
- __cropMode.ToLowerCase();
+
+ if (__sourceFilePath.IsEmpty() == false)
+ {
result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
if (r == E_SUCCESS)
{
}
Image img;
__imageFormat = img.GetImageFormat(__sourceFilePath);
- }*/
- SetValue();
+ }
+
+ if (__cropMode == APPCONTROL_DATA_AUTO)
+ {
+ SetValue();
+ return;
+ }
+ else if (__cropMode == APPCONTROL_DATA_FIT_TO_SCREEN)
+ {
+ Integer *pStatus = static_cast<Integer*>(pArgs->GetAt(2));
+ if (pStatus != null)
+ {
+ __statusValue = pStatus->ToInt();
+ }
+ if (__statusValue == SET_AT_TYPE_CALLER_IMAGE)
+ {
+ LongLong* pContentId = static_cast<LongLong*>(pArgs->GetAt(3));
+ if (pContentId != null)
+ {
+ __contentId = pContentId->ToLongLong();
+ }
+ }
+ SetValue();
+ }
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
r = __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
r = __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap);
r = __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height));
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- }
- AppLogDebug("EXIT");
+ r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); //Left Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); //Right Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Left Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Right Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Right Rectangle
+ r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Left Rectangle
+ }
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return r;
}
switch(actionId)
{
case IDA_BUTTON_CANCEL:
- pSceneManager->GoBackward(BackwardSceneTransition());
- break;
+ {
+ ImageViewerApp* pApp = dynamic_cast<ImageViewerApp*>(UiApp::GetInstance());
+
+ if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_IMAGE_CROP)
+ {
+ if (pApp != null)
+ {
+ pApp->SendAppControlResult(APP_CTRL_RESULT_CANCELED, null);
+ pApp->Terminate();
+ }
+ }
+ else
+ {
+ pSceneManager->GoBackward(BackwardSceneTransition());
+ }
+ }
+ break;
+
case IDA_BUTTON_SAVE:
{
- if (__cropMode == "auto")
+ if (__cropMode == APPCONTROL_DATA_AUTO)
{
ImageBuffer* pCropBuffer = null;
int count = 1;
int index = 0;
String destFilePath;
- String stringToInsert = L"_";
- String delimiter = L".";
+ ImageViewerApp* pApp = dynamic_cast<ImageViewerApp*>(UiApp::GetInstance());
+
if (__sourceFilePath.IsEmpty() == false)
{
- __sourceFilePath.Reverse();
- __sourceFilePath.IndexOf(delimiter, 0, index);
- __sourceFilePath.Reverse();
- __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
- destFilePath.Append(__sourceFilePath);
- destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
- while (File::IsFileExist(destFilePath) == true)
+ if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_IMAGE_CROP)
+ {
+ destFilePath.Append(App::GetInstance()->GetAppDataPath());
+ destFilePath.Append(__pPresentationModel->GetFileName(__sourceFilePath));
+ destFilePath.Reverse();
+ destFilePath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
+ destFilePath.Reverse();
+ destFilePath.Insert(FILE_NAME_SEPARATOR, destFilePath.GetLength() - index - 1);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+
+ while (File::IsFileExist(destFilePath) == true)
+ {
+ count++;
+ destFilePath.Clear();
+ destFilePath.Append(App::GetInstance()->GetAppDataPath());
+ destFilePath.Append(__pPresentationModel->GetFileName(__sourceFilePath));
+ destFilePath.Insert(FILE_NAME_SEPARATOR, destFilePath.GetLength() - index - 1);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ }
+
+ }
+ else
{
- count++;
- destFilePath.Clear();
+ __sourceFilePath.Reverse();
+ __sourceFilePath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
+ __sourceFilePath.Reverse();
+ __sourceFilePath.Insert(FILE_NAME_SEPARATOR, __sourceFilePath.GetLength() - index - 1);
destFilePath.Append(__sourceFilePath);
destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ while (File::IsFileExist(destFilePath) == true)
+ {
+ count++;
+ destFilePath.Clear();
+ destFilePath.Append(__sourceFilePath);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ }
+
}
+
pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
(__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
}
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
pList->Add(new (std::nothrow) String(destFilePath));
- pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+
+ if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_IMAGE_CROP)
+ {
+ HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+ pMap->Construct();
+ pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTED), pList);
+
+ if (pApp != null)
+ {
+ pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
+ pApp->Terminate();
+ }
+ }
+ else
+ {
+ pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+ }
}
- else if(__cropMode == "fit-to-screen")
+ else if (__cropMode == APPCONTROL_DATA_FIT_TO_SCREEN)
{
ImageBuffer* pCropBuffer = null;
result r = E_SUCCESS;
pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
(__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
+
if (__statusValue == SET_AT_TYPE_HOME_SCREEN_WALLPAPER)
{
- String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
+ String destPath = App::GetInstance()->GetAppDataPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
if (r == E_SUCCESS)
{
r = SettingInfo::SetValue(SETTING_VALUE_HOME_SCREEN_WALLPAPER, destPath);
}
- else if (r == E_OVERFLOW)
- {
- MessageBox messageBox;
- messageBox.Construct(L"", L"File size is too big", MSGBOX_STYLE_NONE, 3000);
- int modalResult = 0;
- messageBox.ShowAndWait(modalResult);
- }
}
else if (__statusValue == SET_AT_TYPE_LOCK_SCREEN_WALLPAPER)
{
- String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
+ String destPath = App::GetInstance()->GetAppDataPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
if (r == E_SUCCESS)
{
r = SettingInfo::SetValue(SETTING_VALUE_LOCK_SCREEN_WALLPAPER, destPath);
}
- else if (r == E_OVERFLOW)
- {
- MessageBox messageBox;
- messageBox.Construct(L"", L"File size is too big", MSGBOX_STYLE_NONE, 3000);
- int modalResult = 0;
- messageBox.ShowAndWait(modalResult);
- }
}
else if (__statusValue == SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER)
{
- String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
- String destPathHome = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
+ String destPath = App::GetInstance()->GetAppDataPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
+ String destPathHome = App::GetInstance()->GetAppDataPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
r = pCropBuffer->EncodeToFile(destPathHome, __imageFormat, true, 100);
if (r == E_SUCCESS)
int count = 1;
int index = 0;
String destFilePath;
- String stringToInsert = L"_";
- String delimiter = L".";
+
if (__sourceFilePath.IsEmpty() == false)
{
__sourceFilePath.Reverse();
- __sourceFilePath.IndexOf(delimiter, 0, index);
+ __sourceFilePath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
__sourceFilePath.Reverse();
- __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
+ __sourceFilePath.Insert(FILE_NAME_SEPARATOR, __sourceFilePath.GetLength() - index - 1);
destFilePath.Append(__sourceFilePath);
destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
while (File::IsFileExist(destFilePath) == true)
delete pContact;
delete pAddressbook;
delete pCropBuffer;
+
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
pList->Add(new (std::nothrow) String(destFilePath));
pSceneManager->GoBackward(BackwardSceneTransition(), pList);
- AppLog("Exit");
+
+ AppLogDebug("EXIT(%s)1", GetErrorMessage(GetLastResult()));
return;
}
delete pCropBuffer;
}
break;
}
- AppLog("Exit");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
__isOrientationChanged = true;
SetValue();
__pCanvas->Clear();
- AppLogDebug("EXIT");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
AppLogDebug("ENTER");
__touchStart = currentPosition;
CheckCurrentPosition(currentPosition);
- AppLogDebug("EXIT");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
AppLogDebug("ENTER");
int deltaX = currentPosition.x - __touchStart.x;
int deltaY = currentPosition.y - __touchStart.y;
- if (__cropMode.Equals("auto", false))
+ if (__cropMode.Equals(APPCONTROL_DATA_AUTO, false))
{
switch(__pointLocation)
{
case INSIDE_TOP_RECTANGLE:
{
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3)))
{
__cropBox.y += deltaY;
__cropBox.height -= deltaY;
case INSIDE_BOTTOM_RECTANGLE:
{
if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
- && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3))
{
__cropBox.height += deltaY;
}
case INSIDE_LEFT_RECTANGLE:
{
- if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
{
__cropBox.x += deltaX;
__cropBox.width -= deltaX;
case INSIDE_RIGHT_RECTANGLE:
{
if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
- && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3))
{
__cropBox.width += deltaX;
}
case INSIDE_TOP_LEFT_RECTANGLE:
{
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
- && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3))
+ && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
{
__cropBox.y += deltaY;
__cropBox.height -= deltaY;
case INSIDE_TOP_RIGHT_RECTANGLE:
{
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
- && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3))
+ && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3))
{
__cropBox.width += deltaX;
__cropBox.y += deltaY;
case INSIDE_BOTTOM_LEFT_RECTANGLE:
{
- if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
- && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3)
+ && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
{
__cropBox.x += deltaX;
__cropBox.width -= deltaX;
case INSIDE_BOTTOM_RIGHT_RECTANGLE:
{
- if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
- && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3)
+ && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3))
{
__cropBox.width += deltaX;
__cropBox.height += deltaY;
break;
}
}
- else if (__cropMode != "auto")
+ else if (__cropMode != APPCONTROL_DATA_AUTO)
{
if (__pointLocation == INSIDE_LEFT_RECTANGLE || __pointLocation == INSIDE_BOTTOM_LEFT_RECTANGLE
|| __pointLocation == INSIDE_TOP_LEFT_RECTANGLE)
int temp = __cropBox.height;
int height = (__formHeight * (__cropBox.width - (2 * deltaX))) /__formWidth;
temp = height - temp;
- if ((__cropBox.width - (2 * deltaX) > (CROP_RECTANGLE_HEIGHT * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
+ if ((__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
{
if (__cropBox.x + deltaX >= __imageBox.x && __cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
&& __cropBox.y - (temp / 2) >= __imageBox.y && __cropBox.y + __cropBox.height + (temp / 2) < __imageBox.y + __imageBox.height
- && (__cropBox.width - (2 * deltaX) > (CROP_RECTANGLE_HEIGHT * 3)))
+ && (__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)))
{
__cropBox.x += deltaX;
__cropBox.width = __cropBox.width - (2 * deltaX);
int temp = __cropBox.height;
int height = (__formHeight * (__cropBox.width - (2 * deltaX))) / __formWidth;
temp = height - temp;
- if ((__cropBox.width - (2 * deltaX) > (CROP_RECTANGLE_HEIGHT * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
+ if ((__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
{
- if (deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ if (deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
{
if (__cropBox.x + deltaX > __imageBox.x && __cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
&& __cropBox.y - (temp / 2) > __imageBox.y && __cropBox.y + __cropBox.height + (temp / 2) < __imageBox.y + __imageBox.height)
int temp = __cropBox.width;
int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
temp = width - temp;
- if (__cropBox.height - (2 * deltaY) > (__formHeight * (CROP_RECTANGLE_HEIGHT * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
+ if (__cropBox.height - (2 * deltaY) > (__formHeight * (H_CROP_RECTANGLE * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
{
if (__cropBox.x - (temp /2 ) > __imageBox.x && __cropBox.x + __cropBox.width + temp < __imageBox.x + __imageBox.width
&& __cropBox.y + (deltaY) > __imageBox.y && __cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height)
int temp = __cropBox.width;
int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
temp = width - temp;
- if (__cropBox.height - (2 * deltaY) > (__formHeight * (CROP_RECTANGLE_HEIGHT * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
+ if (__cropBox.height - (2 * deltaY) > (__formHeight * (H_CROP_RECTANGLE * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
{
if (__cropBox.x - (temp / 2) >= __imageBox.x && __cropBox.x + __cropBox.width + temp < __imageBox.x + __imageBox.width
&& __cropBox.y + deltaY > __imageBox.y && __cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height)
}
RequestRedraw(false);
__touchStart = currentPosition;
- AppLogDebug("EXIT");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
{
AppLogDebug("ENTER");
__pointLocation = OUTSIDE_CROPBOX;
- AppLogDebug("EXIT");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
void
ImageCropForm::CheckCurrentPosition(const Point currentPosition)
{
AppLogDebug("ENTER");
- if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
+ if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_TOP_RECTANGLE;
}
- else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_LEFT_RECTANGLE;
}
- else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > (__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_RIGHT_RECTANGLE;
}
- else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_BOTTOM_RECTANGLE;
}
- else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y +(H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
}
- else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y +(H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
}
- else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > (__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
}
- else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
- && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
+ else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2)) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2))
+ && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2)))
{
__pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
}
{
__pointLocation = OUTSIDE_CROPBOX;
}
- AppLogDebug("EXIT");
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return;
}
__formHeight = Form::GetBounds().height;
__formWidth = Form::GetBounds().width;
}
- else if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
{
__formHeight = Form::GetBounds().width;
__formWidth = Form::GetBounds().height;
}
- float clientAreaRatio = (GetClientAreaBoundsF().height - FOOTER_PANEL_HEIGHT) / GetClientAreaBoundsF().width;
- if (__imageWidth >= GetClientAreaBounds().width || __imageHeight > (GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT))
+ float clientAreaRatio = (GetClientAreaBoundsF().height - H_FOOTER_PANEL) / GetClientAreaBoundsF().width;
+ if (__imageWidth >= GetClientAreaBounds().width || __imageHeight > (GetClientAreaBounds().height - H_FOOTER_PANEL))
{
float imageRatio = __imageHeight / (float) __imageWidth;
if (imageRatio < clientAreaRatio)
__imageBox.width = GetClientAreaBounds().width;
__imageBox.height = (__imageHeight * __imageBox.width) / __imageWidth;
__imageBox.x = GetClientAreaBounds().x;
- __imageBox.y = GetClientAreaBounds().y + ((GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT) - __imageBox.height) / 2;
+ __imageBox.y = GetClientAreaBounds().y + ((GetClientAreaBounds().height - H_FOOTER_PANEL) - __imageBox.height) / 2;
}
else
{
- __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
+ __imageBox.height = GetClientAreaBounds().height - H_FOOTER_PANEL;
__imageBox.width = (__imageWidth * __imageBox.height) / __imageHeight;
__imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
__imageBox.y = GetClientAreaBounds().y;