* Sync up to trunk head (r60691).
[reactos.git] / base / applications / mspaint / mouse.c
index 84909fb..70d2dba 100644 (file)
@@ -18,8 +18,7 @@ placeSelWin()
     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);
     BringWindowToTop(hSelection);
-    SendMessage(hImageArea, WM_PAINT, 0, 0);
-    //SendMessage(hSelection, WM_PAINT, 0, 0);
+    InvalidateRect(hImageArea, NULL, FALSE);
 }
 
 void
@@ -58,10 +57,10 @@ int ptSP = 0;
 void
 startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
 {
-    startX = x;
-    startY = y;
-    lastX = x;
-    lastY = y;
+    start.x = x;
+    start.y = y;
+    last.x = x;
+    last.y = y;
     switch (activeTool)
     {
         case TOOL_FREESEL:
@@ -146,26 +145,25 @@ whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
             break;
         case TOOL_RECTSEL:
         {
-            int tempX;
-            int tempY;
+            POINT temp;
             resetToU1();
-            tempX = max(0, min(x, imgXRes));
-            tempY = max(0, min(y, imgYRes));
-            rectSel_dest[0] = rectSel_src[0] = min(startX, tempX);
-            rectSel_dest[1] = rectSel_src[1] = min(startY, tempY);
-            rectSel_dest[2] = rectSel_src[2] = max(startX, tempX) - min(startX, tempX);
-            rectSel_dest[3] = rectSel_src[3] = max(startY, tempY) - min(startY, tempY);
-            RectSel(hdc, startX, startY, tempX, tempY);
+            temp.x = max(0, min(x, imgXRes));
+            temp.y = max(0, min(y, imgYRes));
+            rectSel_dest[0] = rectSel_src[0] = min(start.x, temp.x);
+            rectSel_dest[1] = rectSel_src[1] = min(start.y, temp.y);
+            rectSel_dest[2] = rectSel_src[2] = max(start.x, temp.x) - min(start.x, temp.x);
+            rectSel_dest[3] = rectSel_src[3] = max(start.y, temp.y) - min(start.y, temp.y);
+            RectSel(hdc, start.x, start.y, temp.x, temp.y);
             break;
         }
         case TOOL_RUBBER:
-            Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
+            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
             break;
         case TOOL_PEN:
-            Line(hdc, lastX, lastY, x, y, fg, 1);
+            Line(hdc, last.x, last.y, x, y, fg, 1);
             break;
         case TOOL_BRUSH:
-            Brush(hdc, lastX, lastY, x, y, fg, brushStyle);
+            Brush(hdc, last.x, last.y, x, y, fg, brushStyle);
             break;
         case TOOL_AIRBRUSH:
             Airbrush(hdc, x, y, fg, airBrushWidth);
@@ -173,8 +171,8 @@ whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_LINE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                roundTo8Directions(startX, startY, &x, &y);
-            Line(hdc, startX, startY, x, y, fg, lineWidth);
+                roundTo8Directions(start.x, start.y, &x, &y);
+            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
             break;
         case TOOL_BEZIER:
             resetToU1();
@@ -197,8 +195,8 @@ whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_RECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
         case TOOL_SHAPE:
             resetToU1();
@@ -213,19 +211,19 @@ whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_ELLIPSE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
         case TOOL_RRECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
     }
 
-    lastX = x;
-    lastY = y;
+    last.x = x;
+    last.y = y;
 }
 
 void
@@ -318,17 +316,17 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
             }
             break;
         case TOOL_RUBBER:
-            Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
+            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
             break;
         case TOOL_PEN:
-            Line(hdc, lastX, lastY, x, y, fg, 1);
+            Line(hdc, last.x, last.y, x, y, fg, 1);
             SetPixel(hdc, x, y, fg);
             break;
         case TOOL_LINE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                roundTo8Directions(startX, startY, &x, &y);
-            Line(hdc, startX, startY, x, y, fg, lineWidth);
+                roundTo8Directions(start.x, start.y, &x, &y);
+            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
             break;
         case TOOL_BEZIER:
             pointSP++;
@@ -338,8 +336,8 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_RECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
         case TOOL_SHAPE:
             resetToU1();
@@ -368,14 +366,14 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_ELLIPSE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
         case TOOL_RRECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
             break;
     }
 }
@@ -383,10 +381,10 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
 void
 startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
 {
-    startX = x;
-    startY = y;
-    lastX = x;
-    lastY = y;
+    start.x = x;
+    start.y = y;
+    last.x = x;
+    last.y = y;
     switch (activeTool)
     {
         case TOOL_FREESEL:
@@ -446,13 +444,13 @@ whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
     switch (activeTool)
     {
         case TOOL_RUBBER:
-            Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
+            Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
             break;
         case TOOL_PEN:
-            Line(hdc, lastX, lastY, x, y, bg, 1);
+            Line(hdc, last.x, last.y, x, y, bg, 1);
             break;
         case TOOL_BRUSH:
-            Brush(hdc, lastX, lastY, x, y, bg, brushStyle);
+            Brush(hdc, last.x, last.y, x, y, bg, brushStyle);
             break;
         case TOOL_AIRBRUSH:
             Airbrush(hdc, x, y, bg, airBrushWidth);
@@ -460,8 +458,8 @@ whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_LINE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                roundTo8Directions(startX, startY, &x, &y);
-            Line(hdc, startX, startY, x, y, bg, lineWidth);
+                roundTo8Directions(start.x, start.y, &x, &y);
+            Line(hdc, start.x, start.y, x, y, bg, lineWidth);
             break;
         case TOOL_BEZIER:
             resetToU1();
@@ -484,8 +482,8 @@ whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_RECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
         case TOOL_SHAPE:
             resetToU1();
@@ -500,19 +498,19 @@ whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_ELLIPSE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
         case TOOL_RRECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
     }
 
-    lastX = x;
-    lastY = y;
+    last.x = x;
+    last.y = y;
 }
 
 void
@@ -521,17 +519,17 @@ endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
     switch (activeTool)
     {
         case TOOL_RUBBER:
-            Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
+            Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
             break;
         case TOOL_PEN:
-            Line(hdc, lastX, lastY, x, y, bg, 1);
+            Line(hdc, last.x, last.y, x, y, bg, 1);
             SetPixel(hdc, x, y, bg);
             break;
         case TOOL_LINE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                roundTo8Directions(startX, startY, &x, &y);
-            Line(hdc, startX, startY, x, y, bg, lineWidth);
+                roundTo8Directions(start.x, start.y, &x, &y);
+            Line(hdc, start.x, start.y, x, y, bg, lineWidth);
             break;
         case TOOL_BEZIER:
             pointSP++;
@@ -541,8 +539,8 @@ endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_RECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
         case TOOL_SHAPE:
             resetToU1();
@@ -571,14 +569,14 @@ endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
         case TOOL_ELLIPSE:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
         case TOOL_RRECT:
             resetToU1();
             if (GetAsyncKeyState(VK_SHIFT) < 0)
-                regularize(startX, startY, &x, &y);
-            RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+                regularize(start.x, start.y, &x, &y);
+            RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
             break;
     }
 }