Author: bfreisen
Date: Fri Jan 2 13:58:25 2015
New Revision: 65938
URL:
http://svn.reactos.org/svn/reactos?rev=65938&view=rev
Log:
[MSPAINT] partially apply patch by swyter (bugfixes only). See CORE-5644
Modified:
trunk/reactos/base/applications/mspaint/drawing.c
trunk/reactos/base/applications/mspaint/drawing.h
trunk/reactos/base/applications/mspaint/mouse.c
trunk/reactos/base/applications/mspaint/selection.c
trunk/reactos/base/applications/mspaint/winproc.c
Modified: trunk/reactos/base/applications/mspaint/drawing.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/drawing.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/drawing.c [iso-8859-1] Fri Jan 2 13:58:25
2015
@@ -67,11 +67,16 @@
}
void
-Poly(HDC hdc, POINT * lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness,
int style, BOOL closed)
-{
- LOGBRUSH logbrush;
- HBRUSH oldBrush;
- HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
+Poly(HDC hdc, POINT * lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness,
int style, BOOL closed, BOOL inverted)
+{
+ LOGBRUSH logbrush;
+ HBRUSH oldBrush;
+ HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
+ UINT oldRop = GetROP2(hdc);
+
+ if (inverted)
+ SetROP2(hdc, R2_NOTXORPEN);
+
logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
logbrush.lbColor = (style == 2) ? fg : bg;
logbrush.lbHatch = 0;
@@ -82,6 +87,8 @@
Polyline(hdc, lpPoints, nCount);
DeleteObject(SelectObject(hdc, oldBrush));
DeleteObject(SelectObject(hdc, oldPen));
+
+ SetROP2(hdc, oldRop);
}
void
@@ -223,6 +230,10 @@
HBRUSH oldBrush;
LOGBRUSH logbrush;
HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000));
+ UINT oldRop = GetROP2(hdc);
+
+ SetROP2(hdc, R2_NOTXORPEN);
+
logbrush.lbStyle = BS_HOLLOW;
logbrush.lbColor = 0;
logbrush.lbHatch = 0;
@@ -230,23 +241,26 @@
Rectangle(hdc, x1, y1, x2, y2);
DeleteObject(SelectObject(hdc, oldBrush));
DeleteObject(SelectObject(hdc, oldPen));
-}
-
-void
-SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
-{
- HBRUSH oldBrush;
- LOGBRUSH logbrush;
- HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000));
+
+ SetROP2(hdc, oldRop);
+}
+
+void
+SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, DWORD
system_selection_color)
+{
+ HBRUSH oldBrush;
+ LOGBRUSH logbrush;
+ HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, system_selection_color));
+
logbrush.lbStyle = BS_HOLLOW;
logbrush.lbColor = 0;
logbrush.lbHatch = 0;
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
- Rectangle(hdc, x1, y1, x2, y2);
- DeleteObject(SelectObject(hdc, oldBrush));
- DeleteObject(SelectObject(hdc, oldPen));
- oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00000000));
- oldBrush = SelectObject(hdc, CreateSolidBrush(0x00000000));
+ Rectangle(hdc, x1, y1, x2, y2); /* SEL BOX FRAME */
+ DeleteObject(SelectObject(hdc, oldBrush));
+ DeleteObject(SelectObject(hdc, oldPen));
+ oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, system_selection_color));
+ oldBrush = SelectObject(hdc, CreateSolidBrush(system_selection_color));
Rectangle(hdc, x1 - 1, y1 - 1, x1 + 2, y1 + 2);
Rectangle(hdc, x2 - 2, y1 - 1, x2 + 2, y1 + 2);
Rectangle(hdc, x1 - 1, y2 - 2, x1 + 2, y2 + 1);
Modified: trunk/reactos/base/applications/mspaint/drawing.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/drawing.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/drawing.h [iso-8859-1] Fri Jan 2 13:58:25
2015
@@ -14,7 +14,7 @@
void RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int
thickness, int style);
-void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness,
int style, BOOL closed);
+void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness,
int style, BOOL closed, BOOL inverted);
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int
thickness);
@@ -30,6 +30,6 @@
void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);
-void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);
+void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, DWORD
system_selection_color);
void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR
lpchText, HFONT font, LONG style);
Modified: trunk/reactos/base/applications/mspaint/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/mouse.c [iso-8859-1] Fri Jan 2 13:58:25 2015
@@ -118,7 +118,7 @@
pointStack[pointSP].x = x;
pointStack[pointSP].y = y;
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
if (pointSP == 0)
{
newReversible();
@@ -142,7 +142,7 @@
ptStack[ptSP].x = max(0, min(x, imgXRes));
ptStack[ptSP].y = max(0, min(y, imgYRes));
resetToU1();
- Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
+ Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE, TRUE); /* draw the freehand
selection inverted/xored */
break;
case TOOL_RECTSEL:
case TOOL_TEXT:
@@ -208,7 +208,7 @@
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
&pointStack[pointSP].x,
&pointStack[pointSP].y);
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
break;
case TOOL_ELLIPSE:
resetToU1();
@@ -267,13 +267,13 @@
ptStackCopy[i].x = ptStack[i].x - rectSel_src.left;
ptStackCopy[i].y = ptStack[i].y - rectSel_src.top;
}
- Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE);
+ Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE,
FALSE);
HeapFree(GetProcessHeap(), 0, ptStackCopy);
SelectObject(hSelDC, hSelBm =
CreateDIBWithProperties(RECT_WIDTH(rectSel_src), RECT_HEIGHT(rectSel_src)));
resetToU1();
MaskBlt(hSelDC, 0, 0, RECT_WIDTH(rectSel_src), RECT_HEIGHT(rectSel_src),
hDrawingDC, rectSel_src.left,
rectSel_src.top, hSelMask, 0, 0, MAKEROP4(SRCCOPY, WHITENESS));
- Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE);
+ Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE, FALSE);
newReversible();
MaskBlt(hDrawingDC, rectSel_src.left, rectSel_src.top,
RECT_WIDTH(rectSel_src), RECT_HEIGHT(rectSel_src), hSelDC, 0,
@@ -362,12 +362,12 @@
if ((pointStack[0].x - x) * (pointStack[0].x - x) +
(pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth *
lineWidth + 1)
{
- Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE);
+ Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE,
FALSE);
pointSP = 0;
}
else
{
- Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
}
}
if (pointSP == 255)
@@ -438,7 +438,7 @@
pointStack[pointSP].x = x;
pointStack[pointSP].y = y;
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
if (pointSP == 0)
{
newReversible();
@@ -503,7 +503,7 @@
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
&pointStack[pointSP].x,
&pointStack[pointSP].y);
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
break;
case TOOL_ELLIPSE:
resetToU1();
@@ -565,12 +565,12 @@
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);
+ Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE,
FALSE);
pointSP = 0;
}
else
{
- Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle,
FALSE);
+ Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
}
}
if (pointSP == 255)
Modified: trunk/reactos/base/applications/mspaint/selection.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/selection.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/selection.c [iso-8859-1] Fri Jan 2 13:58:25
2015
@@ -37,6 +37,7 @@
POINTS pos;
POINTS frac;
POINT delta;
+DWORD system_selection_color;
void
RegisterWclSelection()
@@ -95,8 +96,8 @@
if (IsWindowVisible(hSelection))
{
SendMessage(hSelection, WM_LBUTTONDOWN, 0, MAKELPARAM(0, 0));
- SendMessage(hSelection, WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
- SendMessage(hSelection, WM_LBUTTONUP, 0, MAKELPARAM(0, 0));
+ SendMessage(hSelection, WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
+ SendMessage(hSelection, WM_LBUTTONUP, 0, MAKELPARAM(0, 0));
}
}
@@ -143,12 +144,22 @@
HDC hDC = GetDC(hwnd);
DefWindowProc(hwnd, message, wParam, lParam);
SelectionFrame(hDC, 1, 1, RECT_WIDTH(rectSel_dest) * zoom / 1000 + 5,
- RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 5);
+ RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 5,
+ system_selection_color);
ReleaseDC(hwnd, hDC);
}
break;
}
+ case WM_CREATE:
+ case WM_SYSCOLORCHANGE:
+ {
+ /* update the system selection color */
+ system_selection_color = GetSysColor(COLOR_HIGHLIGHT);
+ SendMessage(hwnd, WM_PAINT, 0, MAKELPARAM(0, 0));
+ break;
+ }
case WM_LBUTTONDOWN:
+ {
pos.x = GET_X_LPARAM(lParam);
pos.y = GET_Y_LPARAM(lParam);
delta.x = 0;
@@ -159,6 +170,7 @@
moving = TRUE;
InvalidateRect(hScrlClient, NULL, TRUE);
break;
+ }
case WM_MOUSEMOVE:
if (moving)
{
Modified: trunk/reactos/base/applications/mspaint/winproc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/winproc.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/winproc.c [iso-8859-1] Fri Jan 2 13:58:25
2015
@@ -806,7 +806,7 @@
if (activeTool == TOOL_FREESEL)
{
newReversible();
- Poly(hDrawingDC, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
+ Poly(hDrawingDC, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE, TRUE);
}
break;
}