mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 17:56:00 +00:00
- During resizing the future size is shown in the status bar
- Rubber works as color replacer when used with right mouse button (mouse handling code reorganized) - Bug occuring when painting to neg. coordinates finally fixed - Polygon-tool added - Bezier-tool added svn path=/trunk/; revision=41851
This commit is contained in:
parent
6488e69c4a
commit
2b1fbadac0
8 changed files with 356 additions and 104 deletions
|
@ -20,13 +20,13 @@ void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickn
|
||||||
DeleteObject(SelectObject(hdc, oldPen));
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled)
|
void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style)
|
||||||
{
|
{
|
||||||
HBRUSH oldBrush;
|
HBRUSH oldBrush;
|
||||||
LOGBRUSH logbrush;
|
LOGBRUSH logbrush;
|
||||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
||||||
if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW;
|
if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID;
|
||||||
logbrush.lbColor = bg;
|
if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg;
|
||||||
logbrush.lbHatch = 0;
|
logbrush.lbHatch = 0;
|
||||||
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
||||||
Rectangle(hdc, x1, y1, x2, y2);
|
Rectangle(hdc, x1, y1, x2, y2);
|
||||||
|
@ -34,13 +34,13 @@ void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int t
|
||||||
DeleteObject(SelectObject(hdc, oldPen));
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled)
|
void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style)
|
||||||
{
|
{
|
||||||
HBRUSH oldBrush;
|
HBRUSH oldBrush;
|
||||||
LOGBRUSH logbrush;
|
LOGBRUSH logbrush;
|
||||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
||||||
if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW;
|
if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID;
|
||||||
logbrush.lbColor = bg;
|
if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg;
|
||||||
logbrush.lbHatch = 0;
|
logbrush.lbHatch = 0;
|
||||||
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
||||||
Ellipse(hdc, x1, y1, x2, y2);
|
Ellipse(hdc, x1, y1, x2, y2);
|
||||||
|
@ -48,13 +48,13 @@ void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int t
|
||||||
DeleteObject(SelectObject(hdc, oldPen));
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled)
|
void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style)
|
||||||
{
|
{
|
||||||
LOGBRUSH logbrush;
|
LOGBRUSH logbrush;
|
||||||
HBRUSH oldBrush;
|
HBRUSH oldBrush;
|
||||||
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
||||||
if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW;
|
if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID;
|
||||||
logbrush.lbColor = bg;
|
if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg;
|
||||||
logbrush.lbHatch = 0;
|
logbrush.lbHatch = 0;
|
||||||
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
||||||
RoundRect(hdc, x1, y1, x2, y2, 16, 16);
|
RoundRect(hdc, x1, y1, x2, y2, 16, 16);
|
||||||
|
@ -62,6 +62,35 @@ void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int
|
||||||
DeleteObject(SelectObject(hdc, oldPen));
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed)
|
||||||
|
{
|
||||||
|
LOGBRUSH logbrush;
|
||||||
|
HBRUSH oldBrush;
|
||||||
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
||||||
|
if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID;
|
||||||
|
if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg;
|
||||||
|
logbrush.lbHatch = 0;
|
||||||
|
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
||||||
|
if (closed)
|
||||||
|
Polygon(hdc, lpPoints, nCount);
|
||||||
|
else
|
||||||
|
Polyline(hdc, lpPoints, nCount);
|
||||||
|
DeleteObject(SelectObject(hdc, oldBrush));
|
||||||
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness)
|
||||||
|
{
|
||||||
|
POINT fourPoints[4];
|
||||||
|
fourPoints[0] = p1;
|
||||||
|
fourPoints[1] = p2;
|
||||||
|
fourPoints[2] = p3;
|
||||||
|
fourPoints[3] = p4;
|
||||||
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
|
||||||
|
PolyBezier(hdc, fourPoints, 4);
|
||||||
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
|
}
|
||||||
|
|
||||||
void Fill(HDC hdc, int x, int y, int color)
|
void Fill(HDC hdc, int x, int y, int color)
|
||||||
{
|
{
|
||||||
HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color));
|
HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color));
|
||||||
|
@ -81,6 +110,15 @@ void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radiu
|
||||||
DeleteObject(SelectObject(hdc, oldPen));
|
DeleteObject(SelectObject(hdc, oldPen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius)
|
||||||
|
{
|
||||||
|
short a, x, y;
|
||||||
|
for (a=0; a<=100; a++)
|
||||||
|
for (y=(y1*(100-a)+y2*a)/100-radius+1; y<(y1*(100-a)+y2*a)/100+radius+1; y++)
|
||||||
|
for (x=(x1*(100-a)+x2*a)/100-radius+1; x<(x1*(100-a)+x2*a)/100+radius+1; x++)
|
||||||
|
if (GetPixel(hdc, x, y)==fg) SetPixel(hdc, x, y, bg);
|
||||||
|
}
|
||||||
|
|
||||||
void Airbrush(HDC hdc, short x, short y, int color, int r)
|
void Airbrush(HDC hdc, short x, short y, int color, int r)
|
||||||
{
|
{
|
||||||
short a;
|
short a;
|
||||||
|
|
|
@ -8,16 +8,22 @@
|
||||||
|
|
||||||
void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness);
|
void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness);
|
||||||
|
|
||||||
void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled);
|
void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style);
|
||||||
|
|
||||||
void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled);
|
void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style);
|
||||||
|
|
||||||
void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled);
|
void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style);
|
||||||
|
|
||||||
|
void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed);
|
||||||
|
|
||||||
|
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness);
|
||||||
|
|
||||||
void Fill(HDC hdc, int x, int y, int color);
|
void Fill(HDC hdc, int x, int y, int color);
|
||||||
|
|
||||||
void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius);
|
void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius);
|
||||||
|
|
||||||
|
void Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius);
|
||||||
|
|
||||||
void Airbrush(HDC hdc, short x, short y, int color, int r);
|
void Airbrush(HDC hdc, short x, short y, int color, int r);
|
||||||
|
|
||||||
void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style);
|
void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style);
|
||||||
|
|
|
@ -85,3 +85,8 @@ extern HWND hSizeboxRightCenter;
|
||||||
extern HWND hSizeboxLeftBottom;
|
extern HWND hSizeboxLeftBottom;
|
||||||
extern HWND hSizeboxCenterBottom;
|
extern HWND hSizeboxCenterBottom;
|
||||||
extern HWND hSizeboxRightBottom;
|
extern HWND hSizeboxRightBottom;
|
||||||
|
|
||||||
|
/* VARIABLES declared in mouse.c *************************************/
|
||||||
|
|
||||||
|
extern POINT pointStack[256];
|
||||||
|
extern short pointSP;
|
||||||
|
|
|
@ -23,37 +23,70 @@ void placeSelWin()
|
||||||
//SendMessage(hSelection, WM_PAINT, 0, 0);
|
//SendMessage(hSelection, WM_PAINT, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startPainting(HDC hdc, short x, short y, int fg, int bg)
|
POINT pointStack[256];
|
||||||
|
short pointSP;
|
||||||
|
|
||||||
|
void startPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||||
{
|
{
|
||||||
startX = x;
|
startX = x;
|
||||||
startY = y;
|
startY = y;
|
||||||
lastX = x;
|
lastX = x;
|
||||||
lastY = y;
|
lastY = y;
|
||||||
if ((activeTool!=5)&&(activeTool!=6)) newReversible();
|
|
||||||
switch (activeTool)
|
switch (activeTool)
|
||||||
{
|
{
|
||||||
|
case 1:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
newReversible();
|
||||||
case 2:
|
case 2:
|
||||||
|
newReversible();
|
||||||
ShowWindow(hSelection, SW_HIDE);
|
ShowWindow(hSelection, SW_HIDE);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
newReversible();
|
||||||
Erase(hdc, x, y, x, y, bg, rubberRadius);
|
Erase(hdc, x, y, x, y, bg, rubberRadius);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
newReversible();
|
||||||
Fill(hdc, x, y, fg);
|
Fill(hdc, x, y, fg);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
newReversible();
|
||||||
SetPixel(hdc, x, y, fg);
|
SetPixel(hdc, x, y, fg);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
newReversible();
|
||||||
Brush(hdc, x, y, x, y, fg, brushStyle);
|
Brush(hdc, x, y, x, y, fg, brushStyle);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
|
newReversible();
|
||||||
Airbrush(hdc, x, y, fg, airBrushWidth);
|
Airbrush(hdc, x, y, fg, airBrushWidth);
|
||||||
break;
|
break;
|
||||||
|
case 12:
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
if (pointSP==0)
|
||||||
|
{
|
||||||
|
newReversible();
|
||||||
|
pointSP++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, fg, bg, lineWidth, shapeStyle, FALSE);
|
||||||
|
if (pointSP==0)
|
||||||
|
{
|
||||||
|
newReversible();
|
||||||
|
pointSP++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void whilePainting(HDC hdc, short x, short y, int fg, int bg)
|
void whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||||
{
|
{
|
||||||
switch (activeTool)
|
switch (activeTool)
|
||||||
{
|
{
|
||||||
|
@ -87,50 +120,34 @@ void whilePainting(HDC hdc, short x, short y, int fg, int bg)
|
||||||
resetToU1();
|
resetToU1();
|
||||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||||
break;
|
break;
|
||||||
|
case 12:
|
||||||
|
resetToU1();
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
switch (pointSP)
|
||||||
|
{
|
||||||
|
case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg, lineWidth); break;
|
||||||
|
case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth); break;
|
||||||
|
case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth); break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
{
|
break;
|
||||||
case 0:
|
case 14:
|
||||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
resetToU1();
|
||||||
break;
|
pointStack[pointSP].x = x;
|
||||||
case 1:
|
pointStack[pointSP].y = y;
|
||||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, fg, bg, lineWidth, shapeStyle, FALSE);
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Rect(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
RRect(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +155,7 @@ void whilePainting(HDC hdc, short x, short y, int fg, int bg)
|
||||||
lastY = y;
|
lastY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endPainting(HDC hdc, short x, short y, int fg, int bg)
|
void endPaintingL(HDC hdc, short x, short y, int fg, int bg)
|
||||||
{
|
{
|
||||||
switch (activeTool)
|
switch (activeTool)
|
||||||
{
|
{
|
||||||
|
@ -163,50 +180,204 @@ void endPainting(HDC hdc, short x, short y, int fg, int bg)
|
||||||
resetToU1();
|
resetToU1();
|
||||||
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
Line(hdc, startX, startY, x, y, fg, lineWidth);
|
||||||
break;
|
break;
|
||||||
|
case 12:
|
||||||
|
pointSP++;
|
||||||
|
if (pointSP==4) pointSP = 0;
|
||||||
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
resetToU1();
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
pointSP++;
|
||||||
|
if (pointSP>=2)
|
||||||
{
|
{
|
||||||
case 0:
|
if ( (pointStack[0].x-x)*(pointStack[0].x-x) + (pointStack[0].y-y)*(pointStack[0].y-y) <= lineWidth*lineWidth+1)
|
||||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
{
|
||||||
break;
|
Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE);
|
||||||
case 1:
|
pointSP = 0;
|
||||||
Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
}
|
||||||
break;
|
else
|
||||||
case 2:
|
{
|
||||||
Rect(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE);
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
if (pointSP==255) pointSP--;
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Ellp(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
resetToU1();
|
resetToU1();
|
||||||
switch (shapeStyle)
|
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||||
|
{
|
||||||
|
startX = x;
|
||||||
|
startY = y;
|
||||||
|
lastX = x;
|
||||||
|
lastY = y;
|
||||||
|
switch (activeTool)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
newReversible();
|
||||||
|
case 3:
|
||||||
|
newReversible();
|
||||||
|
Replace(hdc, x, y, x, y, fg, bg, rubberRadius);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
newReversible();
|
||||||
|
Fill(hdc, x, y, bg);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
newReversible();
|
||||||
|
SetPixel(hdc, x, y, bg);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
newReversible();
|
||||||
|
Brush(hdc, x, y, x, y, bg, brushStyle);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
newReversible();
|
||||||
|
Airbrush(hdc, x, y, bg, airBrushWidth);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
if (pointSP==0)
|
||||||
{
|
{
|
||||||
case 0:
|
newReversible();
|
||||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, FALSE);
|
pointSP++;
|
||||||
break;
|
}
|
||||||
case 1:
|
break;
|
||||||
RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, TRUE);
|
case 14:
|
||||||
break;
|
pointStack[pointSP].x = x;
|
||||||
case 2:
|
pointStack[pointSP].y = y;
|
||||||
RRect(hdc, startX, startY, x, y, fg, fg, lineWidth, TRUE);
|
if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, bg, fg, lineWidth, shapeStyle, FALSE);
|
||||||
break;
|
if (pointSP==0)
|
||||||
|
{
|
||||||
|
newReversible();
|
||||||
|
pointSP++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||||
|
{
|
||||||
|
switch (activeTool)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
Line(hdc, lastX, lastY, x, y, bg, 1);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
Brush(hdc, lastX, lastY, x, y, bg, brushStyle);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
Airbrush(hdc, x, y, bg, airBrushWidth);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
resetToU1();
|
||||||
|
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
resetToU1();
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
switch (pointSP)
|
||||||
|
{
|
||||||
|
case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg, lineWidth); break;
|
||||||
|
case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], bg, lineWidth); break;
|
||||||
|
case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], bg, lineWidth); break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
resetToU1();
|
||||||
|
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
resetToU1();
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, bg, fg, lineWidth, shapeStyle, FALSE);
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
resetToU1();
|
||||||
|
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
resetToU1();
|
||||||
|
RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastX = x;
|
||||||
|
lastY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void endPaintingR(HDC hdc, short x, short y, int fg, int bg)
|
||||||
|
{
|
||||||
|
switch (activeTool)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
Line(hdc, lastX, lastY, x, y, bg, 1);
|
||||||
|
SetPixel(hdc, x, y, bg);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
resetToU1();
|
||||||
|
Line(hdc, startX, startY, x, y, bg, lineWidth);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
pointSP++;
|
||||||
|
if (pointSP==4) pointSP = 0;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
resetToU1();
|
||||||
|
Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
resetToU1();
|
||||||
|
pointStack[pointSP].x = x;
|
||||||
|
pointStack[pointSP].y = y;
|
||||||
|
pointSP++;
|
||||||
|
if (pointSP>=2)
|
||||||
|
{
|
||||||
|
if ( (pointStack[0].x-x)*(pointStack[0].x-x) + (pointStack[0].y-y)*(pointStack[0].y-y) <= lineWidth*lineWidth+1)
|
||||||
|
{
|
||||||
|
Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE);
|
||||||
|
pointSP = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pointSP==255) pointSP--;
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
resetToU1();
|
||||||
|
Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
resetToU1();
|
||||||
|
RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,8 +8,14 @@
|
||||||
|
|
||||||
void placeSelWin();
|
void placeSelWin();
|
||||||
|
|
||||||
void startPainting(HDC hdc, short x, short y, int fg, int bg);
|
void startPaintingL(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
||||||
void whilePainting(HDC hdc, short x, short y, int fg, int bg);
|
void whilePaintingL(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
||||||
void endPainting(HDC hdc, short x, short y, int fg, int bg);
|
void endPaintingL(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
||||||
|
void startPaintingR(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
||||||
|
void whilePaintingR(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
||||||
|
void endPaintingR(HDC hdc, short x, short y, int fg, int bg);
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
/* INCLUDES *********************************************************/
|
/* INCLUDES *********************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <tchar.h>
|
||||||
#include "globalvar.h"
|
#include "globalvar.h"
|
||||||
#include "drawing.h"
|
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "mouse.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ********************************************************/
|
/* FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
@ -43,7 +43,31 @@ LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
SetCapture(hwnd);
|
SetCapture(hwnd);
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
// TODO: print things in the status bar
|
if (resizing)
|
||||||
|
{
|
||||||
|
TCHAR sizeStr[100];
|
||||||
|
short xRel;
|
||||||
|
short yRel;
|
||||||
|
xRel = ((short)LOWORD(lParam)-xOrig)*1000/zoom;
|
||||||
|
yRel = ((short)HIWORD(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;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
if (resizing)
|
if (resizing)
|
||||||
|
@ -70,6 +94,7 @@ LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
cropReversible(imgXRes, imgYRes+yRel, 0, 0);
|
cropReversible(imgXRes, imgYRes+yRel, 0, 0);
|
||||||
if (hwnd==hSizeboxRightBottom)
|
if (hwnd==hSizeboxRightBottom)
|
||||||
cropReversible(imgXRes+xRel, imgYRes+yRel, 0, 0);
|
cropReversible(imgXRes+xRel, imgYRes+yRel, 0, 0);
|
||||||
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)_T(""));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -148,14 +148,14 @@ LRESULT CALLBACK SettingsWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shapeStyle==0)
|
if (shapeStyle==0)
|
||||||
Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, FALSE);
|
Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 0);
|
||||||
else
|
else
|
||||||
Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, FALSE);
|
Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 0);
|
||||||
if (shapeStyle==1)
|
if (shapeStyle==1)
|
||||||
Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, TRUE);
|
Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 1);
|
||||||
else
|
else
|
||||||
Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, TRUE);
|
Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 1);
|
||||||
Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE), 1, TRUE);
|
Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE), 1, 1);
|
||||||
for (i=0; i<5; i++)
|
for (i=0; i<5; i++)
|
||||||
{
|
{
|
||||||
if (lineWidth==i+1)
|
if (lineWidth==i+1)
|
||||||
|
|
|
@ -29,6 +29,7 @@ void selectTool(int tool)
|
||||||
{
|
{
|
||||||
ShowWindow(hSelection, SW_HIDE);
|
ShowWindow(hSelection, SW_HIDE);
|
||||||
activeTool = tool;
|
activeTool = tool;
|
||||||
|
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
|
||||||
SendMessage(hToolSettings, WM_PAINT, 0, 0);
|
SendMessage(hToolSettings, WM_PAINT, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +355,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
SetCapture(hImageArea);
|
SetCapture(hImageArea);
|
||||||
drawing = TRUE;
|
drawing = TRUE;
|
||||||
startPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
startPaintingL(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
SendMessage(hwnd, WM_LBUTTONUP, wParam, lParam);
|
SendMessage(hwnd, WM_LBUTTONUP, wParam, lParam);
|
||||||
|
@ -371,7 +372,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
SetCapture(hImageArea);
|
SetCapture(hImageArea);
|
||||||
drawing = TRUE;
|
drawing = TRUE;
|
||||||
startPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
|
startPaintingR(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
SendMessage(hwnd, WM_RBUTTONUP, wParam, lParam);
|
SendMessage(hwnd, WM_RBUTTONUP, wParam, lParam);
|
||||||
|
@ -386,7 +387,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
drawing = FALSE;
|
drawing = FALSE;
|
||||||
endPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
endPaintingL(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||||
if (activeTool==5)
|
if (activeTool==5)
|
||||||
{
|
{
|
||||||
|
@ -402,7 +403,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
drawing = FALSE;
|
drawing = FALSE;
|
||||||
endPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
|
endPaintingR(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||||
if (activeTool==5)
|
if (activeTool==5)
|
||||||
{
|
{
|
||||||
|
@ -426,7 +427,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
if ((wParam&MK_LBUTTON)!=0)
|
if ((wParam&MK_LBUTTON)!=0)
|
||||||
{
|
{
|
||||||
whilePainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
whilePaintingL(hDrawingDC, (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||||
if ((activeTool>=10)||(activeTool==2))
|
if ((activeTool>=10)||(activeTool==2))
|
||||||
{
|
{
|
||||||
|
@ -437,7 +438,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
if ((wParam&MK_RBUTTON)!=0)
|
if ((wParam&MK_RBUTTON)!=0)
|
||||||
{
|
{
|
||||||
whilePainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
|
whilePaintingR(hDrawingDC, (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom, fgColor, bgColor);
|
||||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||||
if (activeTool>=10)
|
if (activeTool>=10)
|
||||||
{
|
{
|
||||||
|
@ -564,9 +565,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
case IDM_EDITSELECTALL:
|
case IDM_EDITSELECTALL:
|
||||||
if (activeTool==2)
|
if (activeTool==2)
|
||||||
{
|
{
|
||||||
startPainting(hDrawingDC, 0, 0, fgColor, bgColor);
|
startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
||||||
whilePainting(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
whilePaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
||||||
endPainting(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
endPaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDM_EDITCOPYTO:
|
case IDM_EDITCOPYTO:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue