87cee6c027a41f5d866e9084b4ddbba021513789
2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/paint/mouse.c
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 ********************************************************/
21 MoveWindow(hSelection
, rectSel_dest
[0] * zoom
/ 1000, rectSel_dest
[1] * zoom
/ 1000,
22 rectSel_dest
[2] * zoom
/ 1000 + 6, rectSel_dest
[3] * zoom
/ 1000 + 6, TRUE
);
23 BringWindowToTop(hSelection
);
24 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
25 //SendMessage(hSelection, WM_PAINT, 0, 0);
28 POINT pointStack
[256];
32 startPaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
49 ShowWindow(hSelection
, SW_HIDE
);
53 Erase(hdc
, x
, y
, x
, y
, bg
, rubberRadius
);
61 SetPixel(hdc
, x
, y
, fg
);
65 Brush(hdc
, x
, y
, x
, y
, fg
, brushStyle
);
69 Airbrush(hdc
, x
, y
, fg
, airBrushWidth
);
72 pointStack
[pointSP
].x
= x
;
73 pointStack
[pointSP
].y
= y
;
81 pointStack
[pointSP
].x
= x
;
82 pointStack
[pointSP
].y
= y
;
84 Poly(hdc
, pointStack
, pointSP
+ 1, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
95 whilePaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
104 tempX
= max(0, min(x
, imgXRes
));
105 tempY
= max(0, min(y
, imgYRes
));
106 rectSel_dest
[0] = rectSel_src
[0] = min(startX
, tempX
);
107 rectSel_dest
[1] = rectSel_src
[1] = min(startY
, tempY
);
108 rectSel_dest
[2] = rectSel_src
[2] = max(startX
, tempX
) - min(startX
, tempX
);
109 rectSel_dest
[3] = rectSel_src
[3] = max(startY
, tempY
) - min(startY
, tempY
);
110 RectSel(hdc
, startX
, startY
, tempX
, tempY
);
114 Erase(hdc
, lastX
, lastY
, x
, y
, bg
, rubberRadius
);
117 Line(hdc
, lastX
, lastY
, x
, y
, fg
, 1);
120 Brush(hdc
, lastX
, lastY
, x
, y
, fg
, brushStyle
);
123 Airbrush(hdc
, x
, y
, fg
, airBrushWidth
);
127 Line(hdc
, startX
, startY
, x
, y
, fg
, lineWidth
);
131 pointStack
[pointSP
].x
= x
;
132 pointStack
[pointSP
].y
= y
;
136 Line(hdc
, pointStack
[0].x
, pointStack
[0].y
, pointStack
[1].x
, pointStack
[1].y
, fg
,
140 Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[2], pointStack
[1], fg
, lineWidth
);
143 Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[3], pointStack
[1], fg
, lineWidth
);
149 Rect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
153 pointStack
[pointSP
].x
= x
;
154 pointStack
[pointSP
].y
= y
;
155 if (pointSP
+ 1 >= 2)
156 Poly(hdc
, pointStack
, pointSP
+ 1, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
160 Ellp(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
164 RRect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
173 endPaintingL(HDC hdc
, short x
, short y
, int fg
, int bg
)
179 if ((rectSel_src
[2] != 0) && (rectSel_src
[3] != 0))
181 DeleteObject(SelectObject
183 (HBITMAP
) CreateDIBWithProperties(rectSel_src
[2], rectSel_src
[3])));
184 BitBlt(hSelDC
, 0, 0, rectSel_src
[2], rectSel_src
[3], hDrawingDC
, rectSel_src
[0],
185 rectSel_src
[1], SRCCOPY
);
187 ShowWindow(hSelection
, SW_SHOW
);
191 Erase(hdc
, lastX
, lastY
, x
, y
, bg
, rubberRadius
);
194 Line(hdc
, lastX
, lastY
, x
, y
, fg
, 1);
195 SetPixel(hdc
, x
, y
, fg
);
199 Line(hdc
, startX
, startY
, x
, y
, fg
, lineWidth
);
208 Rect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
212 pointStack
[pointSP
].x
= x
;
213 pointStack
[pointSP
].y
= y
;
217 if ((pointStack
[0].x
- x
) * (pointStack
[0].x
- x
) +
218 (pointStack
[0].y
- y
) * (pointStack
[0].y
- y
) <= lineWidth
* lineWidth
+ 1)
220 Poly(hdc
, pointStack
, pointSP
, fg
, bg
, lineWidth
, shapeStyle
, TRUE
);
225 Poly(hdc
, pointStack
, pointSP
, fg
, bg
, lineWidth
, shapeStyle
, FALSE
);
233 Ellp(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
237 RRect(hdc
, startX
, startY
, x
, y
, fg
, bg
, lineWidth
, shapeStyle
);
243 startPaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
260 Replace(hdc
, x
, y
, x
, y
, fg
, bg
, rubberRadius
);
268 SetPixel(hdc
, x
, y
, bg
);
272 Brush(hdc
, x
, y
, x
, y
, bg
, brushStyle
);
276 Airbrush(hdc
, x
, y
, bg
, airBrushWidth
);
279 pointStack
[pointSP
].x
= x
;
280 pointStack
[pointSP
].y
= y
;
288 pointStack
[pointSP
].x
= x
;
289 pointStack
[pointSP
].y
= y
;
290 if (pointSP
+ 1 >= 2)
291 Poly(hdc
, pointStack
, pointSP
+ 1, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
302 whilePaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
307 Replace(hdc
, lastX
, lastY
, x
, y
, fg
, bg
, rubberRadius
);
310 Line(hdc
, lastX
, lastY
, x
, y
, bg
, 1);
313 Brush(hdc
, lastX
, lastY
, x
, y
, bg
, brushStyle
);
316 Airbrush(hdc
, x
, y
, bg
, airBrushWidth
);
320 Line(hdc
, startX
, startY
, x
, y
, bg
, lineWidth
);
324 pointStack
[pointSP
].x
= x
;
325 pointStack
[pointSP
].y
= y
;
329 Line(hdc
, pointStack
[0].x
, pointStack
[0].y
, pointStack
[1].x
, pointStack
[1].y
, bg
,
333 Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[2], pointStack
[1], bg
, lineWidth
);
336 Bezier(hdc
, pointStack
[0], pointStack
[2], pointStack
[3], pointStack
[1], bg
, lineWidth
);
342 Rect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
346 pointStack
[pointSP
].x
= x
;
347 pointStack
[pointSP
].y
= y
;
348 if (pointSP
+ 1 >= 2)
349 Poly(hdc
, pointStack
, pointSP
+ 1, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
353 Ellp(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
357 RRect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
366 endPaintingR(HDC hdc
, short x
, short y
, int fg
, int bg
)
371 Replace(hdc
, lastX
, lastY
, x
, y
, fg
, bg
, rubberRadius
);
374 Line(hdc
, lastX
, lastY
, x
, y
, bg
, 1);
375 SetPixel(hdc
, x
, y
, bg
);
379 Line(hdc
, startX
, startY
, x
, y
, bg
, lineWidth
);
388 Rect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
392 pointStack
[pointSP
].x
= x
;
393 pointStack
[pointSP
].y
= y
;
397 if ((pointStack
[0].x
- x
) * (pointStack
[0].x
- x
) +
398 (pointStack
[0].y
- y
) * (pointStack
[0].y
- y
) <= lineWidth
* lineWidth
+ 1)
400 Poly(hdc
, pointStack
, pointSP
, bg
, fg
, lineWidth
, shapeStyle
, TRUE
);
405 Poly(hdc
, pointStack
, pointSP
, bg
, fg
, lineWidth
, shapeStyle
, FALSE
);
413 Ellp(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);
417 RRect(hdc
, startX
, startY
, x
, y
, bg
, fg
, lineWidth
, shapeStyle
);