mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
[PAINT]
- Improvements by Black_Fox, see bug #5418 - Readability improvement, patch by Katayama Hirofumi, see bug #5420 svn path=/trunk/; revision=47372
This commit is contained in:
@@ -98,6 +98,24 @@
|
||||
#define ID_ELLIPSE 614
|
||||
#define ID_RRECT 615
|
||||
|
||||
//the following 16 numbers need to be in order, increasing by 1
|
||||
#define TOOL_FREESEL 1
|
||||
#define TOOL_RECTSEL 2
|
||||
#define TOOL_RUBBER 3
|
||||
#define TOOL_FILL 4
|
||||
#define TOOL_COLOR 5
|
||||
#define TOOL_ZOOM 6
|
||||
#define TOOL_PEN 7
|
||||
#define TOOL_BRUSH 8
|
||||
#define TOOL_AIRBRUSH 9
|
||||
#define TOOL_TEXT 10
|
||||
#define TOOL_LINE 11
|
||||
#define TOOL_BEZIER 12
|
||||
#define TOOL_RECT 13
|
||||
#define TOOL_SHAPE 14
|
||||
#define TOOL_ELLIPSE 15
|
||||
#define TOOL_RRECT 16
|
||||
|
||||
#define ID_ACCELERATORS 800
|
||||
|
||||
#define IDD_MIRRORROTATE 700
|
||||
|
||||
@@ -50,7 +50,7 @@ short lastY;
|
||||
int lineWidth = 1;
|
||||
int shapeStyle = 0;
|
||||
int brushStyle = 0;
|
||||
int activeTool = 7;
|
||||
int activeTool = TOOL_PEN;
|
||||
int airBrushWidth = 5;
|
||||
int rubberRadius = 4;
|
||||
int transpBg = 0;
|
||||
|
||||
@@ -67,7 +67,7 @@ startPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
lastY = y;
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case TOOL_FREESEL:
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
if (ptStack != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, ptStack);
|
||||
@@ -76,39 +76,39 @@ startPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
ptStack[0].x = x;
|
||||
ptStack[0].y = y;
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
case 13:
|
||||
case 15:
|
||||
case 16:
|
||||
case TOOL_TEXT:
|
||||
case TOOL_LINE:
|
||||
case TOOL_RECT:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
newReversible();
|
||||
break;
|
||||
case 2:
|
||||
case TOOL_RECTSEL:
|
||||
newReversible();
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
rectSel_src[2] = rectSel_src[3] = 0;
|
||||
break;
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
newReversible();
|
||||
Erase(hdc, x, y, x, y, bg, rubberRadius);
|
||||
break;
|
||||
case 4:
|
||||
case TOOL_FILL:
|
||||
newReversible();
|
||||
Fill(hdc, x, y, fg);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
newReversible();
|
||||
SetPixel(hdc, x, y, fg);
|
||||
break;
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
newReversible();
|
||||
Brush(hdc, x, y, x, y, fg, brushStyle);
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
newReversible();
|
||||
Airbrush(hdc, x, y, fg, airBrushWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if (pointSP == 0)
|
||||
@@ -117,7 +117,7 @@ startPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
pointSP++;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if (pointSP + 1 >= 2)
|
||||
@@ -136,7 +136,7 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case TOOL_FREESEL:
|
||||
if (ptSP == 0)
|
||||
newReversible();
|
||||
ptSP++;
|
||||
@@ -147,7 +147,7 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
resetToU1();
|
||||
Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
|
||||
break;
|
||||
case 2:
|
||||
case TOOL_RECTSEL:
|
||||
{
|
||||
short tempX;
|
||||
short tempY;
|
||||
@@ -161,25 +161,25 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
RectSel(hdc, startX, startY, tempX, tempY);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
Line(hdc, lastX, lastY, x, y, fg, 1);
|
||||
break;
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
Brush(hdc, lastX, lastY, x, y, fg, brushStyle);
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
Airbrush(hdc, x, y, fg, airBrushWidth);
|
||||
break;
|
||||
case 11:
|
||||
case TOOL_LINE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -197,13 +197,13 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
case TOOL_RECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -213,13 +213,13 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
if (pointSP + 1 >= 2)
|
||||
Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE);
|
||||
break;
|
||||
case 15:
|
||||
case TOOL_ELLIPSE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
case TOOL_RRECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
@@ -236,7 +236,7 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case TOOL_FREESEL:
|
||||
{
|
||||
POINT *ptStackCopy;
|
||||
int i;
|
||||
@@ -286,7 +286,7 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
ptStack = NULL;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case TOOL_RECTSEL:
|
||||
resetToU1();
|
||||
if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0))
|
||||
{
|
||||
@@ -306,31 +306,31 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
ShowWindow(hSelection, SW_SHOW);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
Line(hdc, lastX, lastY, x, y, fg, 1);
|
||||
SetPixel(hdc, x, y, fg);
|
||||
break;
|
||||
case 11:
|
||||
case TOOL_LINE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
pointSP++;
|
||||
if (pointSP == 4)
|
||||
pointSP = 0;
|
||||
break;
|
||||
case 13:
|
||||
case TOOL_RECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -354,13 +354,13 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||
if (pointSP == 255)
|
||||
pointSP--;
|
||||
break;
|
||||
case 15:
|
||||
case TOOL_ELLIPSE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
case TOOL_RRECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
@@ -378,35 +378,35 @@ startPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
lastY = y;
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case 10:
|
||||
case 11:
|
||||
case 13:
|
||||
case 15:
|
||||
case 16:
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_TEXT:
|
||||
case TOOL_LINE:
|
||||
case TOOL_RECT:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
newReversible();
|
||||
break;
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
newReversible();
|
||||
Replace(hdc, x, y, x, y, fg, bg, rubberRadius);
|
||||
break;
|
||||
case 4:
|
||||
case TOOL_FILL:
|
||||
newReversible();
|
||||
Fill(hdc, x, y, bg);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
newReversible();
|
||||
SetPixel(hdc, x, y, bg);
|
||||
break;
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
newReversible();
|
||||
Brush(hdc, x, y, x, y, bg, brushStyle);
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
newReversible();
|
||||
Airbrush(hdc, x, y, bg, airBrushWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if (pointSP == 0)
|
||||
@@ -415,7 +415,7 @@ startPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
pointSP++;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
if (pointSP + 1 >= 2)
|
||||
@@ -434,25 +434,25 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
Line(hdc, lastX, lastY, x, y, bg, 1);
|
||||
break;
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
Brush(hdc, lastX, lastY, x, y, bg, brushStyle);
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
Airbrush(hdc, x, y, bg, airBrushWidth);
|
||||
break;
|
||||
case 11:
|
||||
case TOOL_LINE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -470,13 +470,13 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
case TOOL_RECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -486,13 +486,13 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
if (pointSP + 1 >= 2)
|
||||
Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE);
|
||||
break;
|
||||
case 15:
|
||||
case TOOL_ELLIPSE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
case TOOL_RRECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
@@ -509,31 +509,31 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
Line(hdc, lastX, lastY, x, y, bg, 1);
|
||||
SetPixel(hdc, x, y, bg);
|
||||
break;
|
||||
case 11:
|
||||
case TOOL_LINE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
roundTo8Directions(startX, startY, &x, &y);
|
||||
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||
break;
|
||||
case 12:
|
||||
case TOOL_BEZIER:
|
||||
pointSP++;
|
||||
if (pointSP == 4)
|
||||
pointSP = 0;
|
||||
break;
|
||||
case 13:
|
||||
case TOOL_RECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 14:
|
||||
case TOOL_SHAPE:
|
||||
resetToU1();
|
||||
pointStack[pointSP].x = x;
|
||||
pointStack[pointSP].y = y;
|
||||
@@ -557,13 +557,13 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||
if (pointSP == 255)
|
||||
pointSP--;
|
||||
break;
|
||||
case 15:
|
||||
case TOOL_ELLIPSE:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||
break;
|
||||
case 16:
|
||||
case TOOL_RRECT:
|
||||
resetToU1();
|
||||
if (GetAsyncKeyState(VK_SHIFT) < 0)
|
||||
regularize(startX, startY, &x, &y);
|
||||
|
||||
@@ -34,13 +34,13 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
||||
DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == 6) ? BF_RECT : BF_RECT | BF_MIDDLE);
|
||||
DrawEdge(hdc, &rect2, (activeTool >= 13) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
|
||||
DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE);
|
||||
DrawEdge(hdc, &rect2, (activeTool >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 10:
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
{
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
@@ -50,7 +50,7 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
@@ -69,7 +69,7 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
@@ -82,7 +82,7 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
{
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
@@ -112,8 +112,8 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
case 12:
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
@@ -132,10 +132,10 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
@@ -178,23 +178,23 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 10:
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 64))
|
||||
{
|
||||
transpBg = (HIWORD(lParam) - 2) / 31;
|
||||
SendMessage(hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case TOOL_RUBBER:
|
||||
if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 62))
|
||||
{
|
||||
rubberRadius = (HIWORD(lParam) - 2) / 15 + 2;
|
||||
SendMessage(hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
case TOOL_BRUSH:
|
||||
if ((LOWORD(lParam) > 1) && (LOWORD(lParam) < 40) && (HIWORD(lParam) > 1)
|
||||
&& (HIWORD(lParam) < 62))
|
||||
{
|
||||
@@ -202,7 +202,7 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
SendMessage(hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
if (HIWORD(lParam) < 62)
|
||||
{
|
||||
if (HIWORD(lParam) < 30)
|
||||
@@ -222,18 +222,18 @@ SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
SendMessage(hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
case 12:
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
if (HIWORD(lParam) <= 62)
|
||||
{
|
||||
lineWidth = (HIWORD(lParam) - 2) / 12 + 1;
|
||||
SendMessage(hwnd, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
if (HIWORD(lParam) <= 60)
|
||||
{
|
||||
shapeStyle = (HIWORD(lParam) - 2) / 20;
|
||||
|
||||
@@ -460,19 +460,19 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (activeTool)
|
||||
{
|
||||
case 4:
|
||||
case TOOL_FILL:
|
||||
SetCursor(hCurFill);
|
||||
break;
|
||||
case 5:
|
||||
case TOOL_COLOR:
|
||||
SetCursor(hCurColor);
|
||||
break;
|
||||
case 6:
|
||||
case TOOL_ZOOM:
|
||||
SetCursor(hCurZoom);
|
||||
break;
|
||||
case 7:
|
||||
case TOOL_PEN:
|
||||
SetCursor(hCurPen);
|
||||
break;
|
||||
case 9:
|
||||
case TOOL_AIRBRUSH:
|
||||
SetCursor(hCurAirbrush);
|
||||
break;
|
||||
default:
|
||||
@@ -486,7 +486,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_LBUTTONDOWN:
|
||||
if (hwnd == hImageArea)
|
||||
{
|
||||
if ((!drawing) || (activeTool == 5))
|
||||
if ((!drawing) || (activeTool == TOOL_COLOR))
|
||||
{
|
||||
SetCapture(hImageArea);
|
||||
drawing = TRUE;
|
||||
@@ -499,7 +499,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
undo();
|
||||
}
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if ((activeTool == 6) && (zoom < 8000))
|
||||
if ((activeTool == TOOL_ZOOM) && (zoom < 8000))
|
||||
zoomTo(zoom * 2, (short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
}
|
||||
break;
|
||||
@@ -507,7 +507,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_RBUTTONDOWN:
|
||||
if (hwnd == hImageArea)
|
||||
{
|
||||
if ((!drawing) || (activeTool == 5))
|
||||
if ((!drawing) || (activeTool == TOOL_COLOR))
|
||||
{
|
||||
SetCapture(hImageArea);
|
||||
drawing = TRUE;
|
||||
@@ -520,7 +520,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
undo();
|
||||
}
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if ((activeTool == 6) && (zoom > 125))
|
||||
if ((activeTool == TOOL_ZOOM) && (zoom > 125))
|
||||
zoomTo(zoom / 2, (short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
}
|
||||
break;
|
||||
@@ -533,7 +533,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
endPaintingL(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, fgColor,
|
||||
bgColor);
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if (activeTool == 5)
|
||||
if (activeTool == TOOL_COLOR)
|
||||
{
|
||||
int tempColor =
|
||||
GetPixel(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom);
|
||||
@@ -553,7 +553,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
endPaintingR(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, fgColor,
|
||||
bgColor);
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if (activeTool == 5)
|
||||
if (activeTool == TOOL_COLOR)
|
||||
{
|
||||
int tempColor =
|
||||
GetPixel(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom);
|
||||
@@ -568,16 +568,13 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_MOUSEMOVE:
|
||||
if (hwnd == hImageArea)
|
||||
{
|
||||
if ((!drawing) || (activeTool <= 9))
|
||||
short xNow = (short)LOWORD(lParam) * 1000 / zoom;
|
||||
short yNow = (short)HIWORD(lParam) * 1000 / zoom;
|
||||
if ((!drawing) || (activeTool <= TOOL_AIRBRUSH))
|
||||
{
|
||||
TRACKMOUSEEVENT tme;
|
||||
|
||||
TCHAR coordStr[100];
|
||||
_stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam) * 1000 / zoom,
|
||||
(short)HIWORD(lParam) * 1000 / zoom);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr);
|
||||
|
||||
if (activeTool == 6)
|
||||
if (activeTool == TOOL_ZOOM)
|
||||
{
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
@@ -588,32 +585,73 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
tme.hwndTrack = hImageArea;
|
||||
tme.dwHoverTime = 0;
|
||||
TrackMouseEvent(&tme);
|
||||
|
||||
if (!drawing)
|
||||
{
|
||||
TCHAR coordStr[100];
|
||||
_stprintf(coordStr, _T("%d, %d"), xNow, yNow);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr);
|
||||
}
|
||||
}
|
||||
if (drawing)
|
||||
{
|
||||
/* values displayed in statusbar */
|
||||
short xRel = xNow - startX;
|
||||
short yRel = yNow - startY;
|
||||
/* freesel, rectsel and text tools always show numbers limited to fit into image area */
|
||||
if ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_TEXT))
|
||||
{
|
||||
if (xRel < 0)
|
||||
xRel = (xNow < 0) ? -startX : xRel;
|
||||
else if (xNow > imgXRes)
|
||||
xRel = imgXRes-startX;
|
||||
if (yRel < 0)
|
||||
yRel = (yNow < 0) ? -startY : yRel;
|
||||
else if (yNow > imgYRes)
|
||||
yRel = imgYRes-startY;
|
||||
}
|
||||
/* rectsel and shape tools always show non-negative numbers when drawing */
|
||||
if ((activeTool == TOOL_RECTSEL) || (activeTool == TOOL_SHAPE))
|
||||
{
|
||||
if (xRel < 0)
|
||||
xRel = -xRel;
|
||||
if (yRel < 0)
|
||||
yRel = -yRel;
|
||||
}
|
||||
/* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
|
||||
switch(activeTool)
|
||||
{
|
||||
case TOOL_RUBBER:
|
||||
case TOOL_PEN:
|
||||
case TOOL_BRUSH:
|
||||
case TOOL_AIRBRUSH:
|
||||
case TOOL_SHAPE:
|
||||
{
|
||||
TCHAR coordStr[100];
|
||||
_stprintf(coordStr, _T("%d, %d"), xNow, yNow);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((wParam & MK_LBUTTON) != 0)
|
||||
{
|
||||
whilePaintingL(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom,
|
||||
(short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor);
|
||||
whilePaintingL(hDrawingDC, xNow, yNow, fgColor, bgColor);
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if ((activeTool >= 10) || (activeTool == 2))
|
||||
if ((activeTool >= TOOL_TEXT) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_FREESEL))
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
_stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX,
|
||||
(short)HIWORD(lParam) * 1000 / zoom - startY);
|
||||
_stprintf(sizeStr, _T("%d x %d"), xRel, yRel);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
}
|
||||
}
|
||||
if ((wParam & MK_RBUTTON) != 0)
|
||||
{
|
||||
whilePaintingR(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom,
|
||||
(short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor);
|
||||
whilePaintingR(hDrawingDC, xNow, yNow, fgColor, bgColor);
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if (activeTool >= 10)
|
||||
if (activeTool >= TOOL_TEXT)
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
_stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX,
|
||||
(short)HIWORD(lParam) * 1000 / zoom - startY);
|
||||
_stprintf(sizeStr, _T("%d x %d"), xRel, yRel);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
}
|
||||
}
|
||||
@@ -623,7 +661,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_MOUSELEAVE:
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) _T(""));
|
||||
if (activeTool == 6)
|
||||
if (activeTool == TOOL_ZOOM)
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
break;
|
||||
|
||||
@@ -747,7 +785,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
/* remove selection window and already painted content using undo(),
|
||||
paint Rect for rectangular selections and nothing for freeform selections */
|
||||
undo();
|
||||
if (activeTool == 2)
|
||||
if (activeTool == TOOL_RECTSEL)
|
||||
{
|
||||
newReversible();
|
||||
Rect(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2] + rectSel_dest[0],
|
||||
@@ -756,7 +794,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
}
|
||||
case IDM_EDITSELECTALL:
|
||||
if (activeTool == 2)
|
||||
if (activeTool == TOOL_RECTSEL)
|
||||
{
|
||||
startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
||||
whilePaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
||||
|
||||
Reference in New Issue
Block a user