2 * PROJECT: PAINT for ReactOS
5 * PURPOSE: Things which should not be in the mouse event handler itself
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
11 #include "globalvar.h"
16 /* FUNCTIONS ********************************************************/
20 MoveWindow(hSelection
, rectSel_dest
[0]*zoom
/1000, rectSel_dest
[1]*zoom
/1000, rectSel_dest
[2]*zoom
/1000+6, rectSel_dest
[3]*zoom
/1000+6, TRUE
);
21 BringWindowToTop(hSelection
);
22 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
23 //SendMessage(hSelection, WM_PAINT, 0, 0);
26 POINT pointStack
[256];
29 void startPaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
45 ShowWindow(hSelection
, SW_HIDE
);
49 Erase(hdc
, x
, y
, x
, y
, bg
, rubberRadius
);
57 SetPixel(hdc
, x
, y
, fg
);
61 Brush(hdc
, x
, y
, x
, y
, fg
, brushStyle
);
65 Airbrush(hdc
, x
, y
, fg
, airBrushWidth
);
68 pointStack
[pointSP
].x
= x
;
69 pointStack
[pointSP
].y
= y
;
77 pointStack
[pointSP
].x
= x
;
78 pointStack
[pointSP
].y
= y
;
79 if (pointSP
+1>=2) Poly(hdc
, pointStack
, pointSP
+1, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
89 void whilePaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
98 tempX
= max(0, min(x
, imgXRes
));
99 tempY
= max(0, min(y
, imgYRes
));
100 rectSel_dest
[0] = rectSel_src
[0] = min(startX
, tempX
);
101 rectSel_dest
[1] = rectSel_src
[1] = min(startY
, tempY
);
102 rectSel_dest
[2] = rectSel_src
[2] = max(startX
, tempX
)-min(startX
, tempX
);
103 rectSel_dest
[3] = rectSel_src
[3] = max(startY
, tempY
)-min(startY
, tempY
);
104 RectSel(hdc
, startX
, startY
, tempX
, tempY
);
108 Erase(hdc
, lastX
, lastY
, x
, y
, bg
, rubberRadius
);
111 Line(hdc
, lastX
, lastY
, x
, y
, fg
, 1);
114 Brush(hdc
, lastX
, lastY
, x
, y
, fg
, brushStyle
);
117 Airbrush(hdc
, x
, y
, fg
, airBrushWidth
);
121 Line(hdc
, startX
, startY
, x
, y
, fg
, lineWidth
);
125 pointStack
[pointSP
].x
= x
;
126 pointStack
[pointSP
].y
= y
;
129 case 1: Line(hdc
, pointStack
[0].x
, pointStack
[0].y
, pointStack
[1].x
, pointStack
[1].y
, fg
, lineWidth
); break;
130 case 2: Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[2], pointStack
[1], fg
, lineWidth
); break;
131 case 3: Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[3], pointStack
[1], fg
, lineWidth
); break;
136 Rect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
140 pointStack
[pointSP
].x
= x
;
141 pointStack
[pointSP
].y
= y
;
142 if (pointSP
+1>=2) Poly(hdc
, pointStack
, pointSP
+1, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
146 Ellp(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
150 RRect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
158 void endPaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
164 if ((rectSel_src
[2]!=0)&&(rectSel_src
[3]!=0))
166 DeleteObject(SelectObject(hSelDC
, hSelBm
= (HBITMAP
)CreateDIBWithProperties(rectSel_src
[2], rectSel_src
[3])));
167 BitBlt(hSelDC
, 0, 0, rectSel_src
[2], rectSel_src
[3], hDrawingDC
, rectSel_src
[0], rectSel_src
[1], SRCCOPY
);
169 ShowWindow(hSelection
, SW_SHOW
);
173 Erase(hdc
, lastX
, lastY
, x
, y
, bg
, rubberRadius
);
176 Line(hdc
, lastX
, lastY
, x
, y
, fg
, 1);
177 SetPixel(hdc
, x
, y
, fg
);
181 Line(hdc
, startX
, startY
, x
, y
, fg
, lineWidth
);
185 if (pointSP
==4) pointSP
= 0;
189 Rect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
193 pointStack
[pointSP
].x
= x
;
194 pointStack
[pointSP
].y
= y
;
198 if ( (pointStack
[0].x
-x
)*(pointStack
[0].x
-x
) + (pointStack
[0].y
-y
)*(pointStack
[0].y
-y
) <= lineWidth
*lineWidth
+1)
200 Poly(hdc
, pointStack
, pointSP
, fg
, bg
, lineWidth
, shapeStyle
, TRUE
);
205 Poly(hdc
, pointStack
, pointSP
, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
208 if (pointSP
==255) pointSP
--;
212 Ellp(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
216 RRect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
221 void startPaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
237 Replace(hdc
, x
, y
, x
, y
, fg
, bg
, rubberRadius
);
245 SetPixel(hdc
, x
, y
, bg
);
249 Brush(hdc
, x
, y
, x
, y
, bg
, brushStyle
);
253 Airbrush(hdc
, x
, y
, bg
, airBrushWidth
);
256 pointStack
[pointSP
].x
= x
;
257 pointStack
[pointSP
].y
= y
;
265 pointStack
[pointSP
].x
= x
;
266 pointStack
[pointSP
].y
= y
;
267 if (pointSP
+1>=2) Poly(hdc
, pointStack
, pointSP
+1, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
277 void whilePaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
282 Replace(hdc
, lastX
, lastY
, x
, y
, fg
, bg
, rubberRadius
);
285 Line(hdc
, lastX
, lastY
, x
, y
, bg
, 1);
288 Brush(hdc
, lastX
, lastY
, x
, y
, bg
, brushStyle
);
291 Airbrush(hdc
, x
, y
, bg
, airBrushWidth
);
295 Line(hdc
, startX
, startY
, x
, y
, bg
, lineWidth
);
299 pointStack
[pointSP
].x
= x
;
300 pointStack
[pointSP
].y
= y
;
303 case 1: Line(hdc
, pointStack
[0].x
, pointStack
[0].y
, pointStack
[1].x
, pointStack
[1].y
, bg
, lineWidth
); break;
304 case 2: Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[2], pointStack
[1], bg
, lineWidth
); break;
305 case 3: Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[3], pointStack
[1], bg
, lineWidth
); break;
310 Rect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
314 pointStack
[pointSP
].x
= x
;
315 pointStack
[pointSP
].y
= y
;
316 if (pointSP
+1>=2) Poly(hdc
, pointStack
, pointSP
+1, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
320 Ellp(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
324 RRect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
332 void endPaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
337 Replace(hdc
, lastX
, lastY
, x
, y
, fg
, bg
, rubberRadius
);
340 Line(hdc
, lastX
, lastY
, x
, y
, bg
, 1);
341 SetPixel(hdc
, x
, y
, bg
);
345 Line(hdc
, startX
, startY
, x
, y
, bg
, lineWidth
);
349 if (pointSP
==4) pointSP
= 0;
353 Rect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
357 pointStack
[pointSP
].x
= x
;
358 pointStack
[pointSP
].y
= y
;
362 if ( (pointStack
[0].x
-x
)*(pointStack
[0].x
-x
) + (pointStack
[0].y
-y
)*(pointStack
[0].y
-y
) <= lineWidth
*lineWidth
+1)
364 Poly(hdc
, pointStack
, pointSP
, bg
, fg
, lineWidth
, shapeStyle
, TRUE
);
369 Poly(hdc
, pointStack
, pointSP
, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
372 if (pointSP
==255) pointSP
--;
376 Ellp(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
380 RRect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);