mirror of
https://github.com/reactos/reactos.git
synced 2024-10-05 08:54:40 +00:00
[PAINT]
- angle rounding for lines and polygons when SHIFT key is pressed - equal width and height for (rounded) rectangles and ellipses when SHIFT key is pressed Based on a patch by Katayama Hirofumi, see #5285 svn path=/trunk/; revision=47062
This commit is contained in:
parent
8e5ba15296
commit
93baff6f05
|
@ -143,6 +143,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
HBITMAP tempBm;
|
||||
int i;
|
||||
TCHAR tooltips[16][30];
|
||||
HDC hDC;
|
||||
|
||||
TCHAR *c;
|
||||
TCHAR sfnFilename[1000];
|
||||
|
@ -152,7 +153,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
TCHAR ofnFiletitle[256];
|
||||
TCHAR ofnFilter[1000];
|
||||
TCHAR miniaturetitle[100];
|
||||
int custColors[16] = { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
|
||||
static int custColors[16] = { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
|
||||
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff
|
||||
};
|
||||
|
||||
|
@ -371,8 +372,10 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
|
||||
NULL, hThisInstance, NULL);
|
||||
|
||||
hDrawingDC = CreateCompatibleDC(GetDC(hImageArea));
|
||||
hSelDC = CreateCompatibleDC(GetDC(hImageArea));
|
||||
hDC = GetDC(hImageArea);
|
||||
hDrawingDC = CreateCompatibleDC(hDC);
|
||||
hSelDC = CreateCompatibleDC(hDC);
|
||||
ReleaseDC(hImageArea, hDC);
|
||||
SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, fgColor));
|
||||
SelectObject(hDrawingDC, CreateSolidBrush(bgColor));
|
||||
|
||||
|
|
|
@ -25,6 +25,34 @@ placeSelWin()
|
|||
//SendMessage(hSelection, WM_PAINT, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
regularize(short x0, short y0, short *x1, short *y1)
|
||||
{
|
||||
if (abs(*x1 - x0) >= abs(*y1 - y0))
|
||||
*y1 = y0 + (*y1 > y0 ? abs(*x1 - x0) : -abs(*x1 - x0));
|
||||
else
|
||||
*x1 = x0 + (*x1 > x0 ? abs(*y1 - y0) : -abs(*y1 - y0));
|
||||
}
|
||||
|
||||
void
|
||||
roundTo8Directions(short x0, short y0, short *x1, short *y1)
|
||||
{
|
||||
if (abs(*x1 - x0) >= abs(*y1 - y0))
|
||||
{
|
||||
if (abs(*y1 - y0) * 5 < abs(*x1 - x0) * 2)
|
||||
*y1 = y0;
|
||||
else
|
||||
*y1 = y0 + (*y1 > y0 ? abs(*x1 - x0) : -abs(*x1 - x0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (abs(*x1 - x0) * 5 < abs(*y1 - y0) * 2)
|
||||
*x1 = x0;
|
||||
else
|
||||
*x1 = x0 + (*x1 > x0 ? abs(*y1 - y0) : -abs(*y1 - y0));
|
||||
}
|
||||
}
|
||||
|
||||
POINT pointStack[256];
|
||||
short pointSP;
|
||||
POINT *ptStack = NULL;
|
||||
|
@ -147,6 +175,8 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 11:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
|
@ -169,21 +199,30 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 13:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
|
||||
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y);
|
||||
if (pointSP + 1 >= 2)
|
||||
Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE);
|
||||
break;
|
||||
case 15:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
}
|
||||
|
@ -276,6 +315,8 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 11:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
|
@ -285,12 +326,17 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 13:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
|
||||
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y);
|
||||
pointSP++;
|
||||
if (pointSP >= 2)
|
||||
{
|
||||
|
@ -310,10 +356,14 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 15:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
}
|
||||
|
@ -398,6 +448,8 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 11:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
|
@ -420,21 +472,30 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 13:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
|
||||
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y);
|
||||
if (pointSP + 1 >= 2)
|
||||
Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE);
|
||||
break;
|
||||
case 15:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
}
|
||||
|
@ -457,6 +518,8 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 11:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
|
@ -466,12 +529,17 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 13:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
|
||||
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y);
|
||||
pointSP++;
|
||||
if (pointSP >= 2)
|
||||
{
|
||||
|
@ -491,10 +559,14 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
|||
break;
|
||||
case 15:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue