reactos/base/applications/mspaint/sizebox.c
Amine Khaldi 527f2f9057 [SHELL/EXPERIMENTS]
* Create a branch for some evul shell experiments.

svn path=/branches/shell-experiments/; revision=61927
2014-02-02 19:37:27 +00:00

102 lines
4.1 KiB
C

/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL
* FILE: sizebox.c
* PURPOSE: Window procedure of the size boxes
* PROGRAMMERS: Benedikt Freisen
*/
/* INCLUDES *********************************************************/
#include "precomp.h"
/* FUNCTIONS ********************************************************/
BOOL resizing = FALSE;
short xOrig;
short yOrig;
LRESULT CALLBACK
SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_SETCURSOR:
if ((hwnd == hSizeboxLeftTop) || (hwnd == hSizeboxRightBottom))
SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
if ((hwnd == hSizeboxLeftBottom) || (hwnd == hSizeboxRightTop))
SetCursor(LoadCursor(NULL, IDC_SIZENESW));
if ((hwnd == hSizeboxLeftCenter) || (hwnd == hSizeboxRightCenter))
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
if ((hwnd == hSizeboxCenterTop) || (hwnd == hSizeboxCenterBottom))
SetCursor(LoadCursor(NULL, IDC_SIZENS));
break;
case WM_LBUTTONDOWN:
resizing = TRUE;
xOrig = GET_X_LPARAM(lParam);
yOrig = GET_Y_LPARAM(lParam);
SetCapture(hwnd);
break;
case WM_MOUSEMOVE:
if (resizing)
{
TCHAR sizeStr[100];
short xRel;
short yRel;
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
if (hwnd == hSizeboxLeftTop)
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel);
if (hwnd == hSizeboxCenterTop)
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes - yRel);
if (hwnd == hSizeboxRightTop)
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes - yRel);
if (hwnd == hSizeboxLeftCenter)
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes);
if (hwnd == hSizeboxRightCenter)
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes);
if (hwnd == hSizeboxLeftBottom)
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes + yRel);
if (hwnd == hSizeboxCenterBottom)
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes + yRel);
if (hwnd == hSizeboxRightBottom)
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes + yRel);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
}
break;
case WM_LBUTTONUP:
if (resizing)
{
short xRel;
short yRel;
ReleaseCapture();
resizing = FALSE;
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
if (hwnd == hSizeboxLeftTop)
cropReversible(imgXRes - xRel, imgYRes - yRel, xRel, yRel);
if (hwnd == hSizeboxCenterTop)
cropReversible(imgXRes, imgYRes - yRel, 0, yRel);
if (hwnd == hSizeboxRightTop)
cropReversible(imgXRes + xRel, imgYRes - yRel, 0, yRel);
if (hwnd == hSizeboxLeftCenter)
cropReversible(imgXRes - xRel, imgYRes, xRel, 0);
if (hwnd == hSizeboxRightCenter)
cropReversible(imgXRes + xRel, imgYRes, 0, 0);
if (hwnd == hSizeboxLeftBottom)
cropReversible(imgXRes - xRel, imgYRes + yRel, xRel, 0);
if (hwnd == hSizeboxCenterBottom)
cropReversible(imgXRes, imgYRes + yRel, 0, 0);
if (hwnd == hSizeboxRightBottom)
cropReversible(imgXRes + xRel, imgYRes + yRel, 0, 0);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
}
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}