Author: bfreisen
Date: Thu Jul 27 09:29:42 2017
New Revision: 75418
URL:
http://svn.reactos.org/svn/reactos?rev=75418&view=rev
Log:
[MSPAINT]
- Enable drag cancellation -- patch by Katayama Hirofumi MZ
CORE-13395 #resolve
Modified:
trunk/reactos/base/applications/mspaint/imgarea.cpp
trunk/reactos/base/applications/mspaint/imgarea.h
trunk/reactos/base/applications/mspaint/selection.cpp
trunk/reactos/base/applications/mspaint/selection.h
trunk/reactos/base/applications/mspaint/sizebox.cpp
trunk/reactos/base/applications/mspaint/sizebox.h
trunk/reactos/base/applications/mspaint/winproc.cpp
Modified: trunk/reactos/base/applications/mspaint/imgarea.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/imgarea.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/imgarea.cpp [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -5,6 +5,7 @@
* PURPOSE: Window procedure of the main window and all children apart from
* hPalWin, hToolSettings and hSelection
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
/* INCLUDES *********************************************************/
@@ -191,8 +192,6 @@
{
if (drawing)
{
- ReleaseCapture();
- drawing = FALSE;
endPaintingL(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
@@ -205,6 +204,71 @@
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
}
+ drawing = FALSE;
+ ReleaseCapture();
+ return 0;
+}
+
+void CImgAreaWindow::cancelDrawing()
+{
+ POINT pt;
+ switch (toolsModel.GetActiveTool())
+ {
+ case TOOL_FREESEL: case TOOL_RECTSEL:
+ case TOOL_TEXT: case TOOL_ZOOM: case TOOL_SHAPE:
+ imageModel.ResetToPrevious();
+ selectionModel.ResetPtStack();
+ pointSP = 0;
+ Invalidate(FALSE);
+ break;
+ default:
+ GetCursorPos(&pt);
+ ScreenToClient(&pt);
+ // FIXME: dirty hack
+ if (GetKeyState(VK_LBUTTON) < 0)
+ {
+ endPaintingL(imageModel.GetDC(), pt.x * 1000 / toolsModel.GetZoom(), pt.y
* 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ paletteModel.GetBgColor());
+ }
+ else if (GetKeyState(VK_RBUTTON) < 0)
+ {
+ endPaintingR(imageModel.GetDC(), pt.x * 1000 / toolsModel.GetZoom(), pt.y
* 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ paletteModel.GetBgColor());
+ }
+ imageModel.Undo();
+ pointSP = 0;
+ selectionModel.ResetPtStack();
+ }
+}
+
+LRESULT CImgAreaWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
+{
+ if (drawing)
+ {
+ cancelDrawing();
+ drawing = FALSE;
+ }
+ return 0;
+}
+
+LRESULT CImgAreaWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ if (wParam == VK_ESCAPE)
+ {
+ if (GetCapture() == m_hWnd)
+ {
+ ReleaseCapture();
+ }
+ else
+ {
+ switch (toolsModel.GetActiveTool())
+ {
+ case TOOL_SHAPE: case TOOL_BEZIER:
+ cancelDrawing();
+ break;
+ }
+ }
+ }
return 0;
}
@@ -212,8 +276,6 @@
{
if (drawing)
{
- ReleaseCapture();
- drawing = FALSE;
endPaintingR(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
@@ -226,6 +288,8 @@
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
}
+ ReleaseCapture();
+ drawing = FALSE;
return 0;
}
Modified: trunk/reactos/base/applications/mspaint/imgarea.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/imgarea.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/imgarea.h [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -5,6 +5,7 @@
* PURPOSE: Window procedure of the main window and all children apart from
* hPalWin, hToolSettings and hSelection
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
class CImgAreaWindow : public CWindowImpl<CMainWindow>
@@ -24,6 +25,8 @@
MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
MESSAGE_HANDLER(WM_IMAGEMODELDIMENSIONSCHANGED, OnImageModelDimensionsChanged)
MESSAGE_HANDLER(WM_IMAGEMODELIMAGECHANGED, OnImageModelImageChanged)
+ MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
+ MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
BOOL drawing;
@@ -40,6 +43,9 @@
LRESULT OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
LRESULT OnImageModelImageChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void drawZoomFrame(int mouseX, int mouseY);
+ void cancelDrawing();
};
Modified: trunk/reactos/base/applications/mspaint/selection.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/selection.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/selection.cpp [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -4,6 +4,7 @@
* FILE: base/applications/mspaint/selection.cpp
* PURPOSE: Window procedure of the selection window
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
/* INCLUDES *********************************************************/
@@ -230,6 +231,39 @@
return 0;
}
+LRESULT CSelectionWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
+{
+ if (m_bMoving)
+ {
+ m_bMoving = FALSE;
+ if (m_iAction == ACTION_MOVE)
+ {
+ // FIXME: dirty hack
+ placeSelWin();
+ imageModel.Undo();
+ imageModel.Undo();
+ }
+ else
+ {
+ m_iAction = ACTION_MOVE;
+ }
+ ShowWindow(SW_HIDE);
+ }
+ return 0;
+}
+
+LRESULT CSelectionWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ if (wParam == VK_ESCAPE)
+ {
+ if (GetCapture() == m_hWnd)
+ {
+ ReleaseCapture();
+ }
+ }
+ return 0;
+}
+
LRESULT CSelectionWindow::OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
{
if (toolsModel.GetActiveTool() == TOOL_TEXT)
Modified: trunk/reactos/base/applications/mspaint/selection.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/selection.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/selection.h [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -4,6 +4,7 @@
* FILE: base/applications/mspaint/selection.h
* PURPOSE: Window procedure of the selection window
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
class CSelectionWindow : public CWindowImpl<CSelectionWindow>
@@ -23,6 +24,8 @@
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
MESSAGE_HANDLER(WM_SELECTIONMODELREFRESHNEEDED, OnSelectionModelRefreshNeeded)
+ MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
+ MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -36,6 +39,8 @@
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
LRESULT OnSelectionModelRefreshNeeded(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
+ LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
private:
static const LPCTSTR m_lpszCursorLUT[9];
Modified: trunk/reactos/base/applications/mspaint/sizebox.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/sizebox.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/sizebox.cpp [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -4,6 +4,7 @@
* FILE: base/applications/mspaint/sizebox.cpp
* PURPOSE: Window procedure of the size boxes
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
/* INCLUDES *********************************************************/
@@ -98,13 +99,25 @@
imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
}
+ resizing = FALSE;
ReleaseCapture();
+ return 0;
+}
+
+LRESULT CSizeboxWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
+{
resizing = FALSE;
return 0;
}
-LRESULT CSizeboxWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+LRESULT CSizeboxWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- resizing = FALSE;
+ if (wParam == VK_ESCAPE)
+ {
+ if (GetCapture() == m_hWnd)
+ {
+ ReleaseCapture();
+ }
+ }
return 0;
}
Modified: trunk/reactos/base/applications/mspaint/sizebox.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/sizebox.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/sizebox.h [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -4,6 +4,7 @@
* FILE: base/applications/mspaint/sizebox.h
* PURPOSE: Window procedure of the size boxes
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
class CSizeboxWindow : public CWindowImpl<CSizeboxWindow>
@@ -16,12 +17,14 @@
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
- MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
+ MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
+ MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
Modified: trunk/reactos/base/applications/mspaint/winproc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/winproc.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/winproc.cpp [iso-8859-1] Thu Jul 27 09:29:42
2017
@@ -5,6 +5,7 @@
* PURPOSE: Window procedure of the main window and all children apart from
* hPalWin, hToolSettings and hSelection
* PROGRAMMERS: Benedikt Freisen
+ * Katayama Hirofumi MZ
*/
/* INCLUDES *********************************************************/
@@ -333,18 +334,33 @@
{
if (wParam == VK_ESCAPE)
{
- if (!imageArea.drawing)
- {
- /* Deselect */
- if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) ||
(toolsModel.GetActiveTool() == TOOL_FREESEL))
- {
- startPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- whilePaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- endPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- selectionWindow.ShowWindow(SW_HIDE);
- }
- }
- /* FIXME: also cancel current drawing underway */
+ HWND hwndCapture = GetCapture();
+ if (hwndCapture)
+ {
+ if (selectionWindow.m_hWnd == hwndCapture ||
+ imageArea.m_hWnd == hwndCapture ||
+ fullscreenWindow.m_hWnd == hwndCapture ||
+ sizeboxLeftTop.m_hWnd == hwndCapture ||
+ sizeboxCenterTop.m_hWnd == hwndCapture ||
+ sizeboxRightTop.m_hWnd == hwndCapture ||
+ sizeboxLeftCenter.m_hWnd == hwndCapture ||
+ sizeboxRightCenter.m_hWnd == hwndCapture ||
+ sizeboxLeftBottom.m_hWnd == hwndCapture ||
+ sizeboxCenterBottom.m_hWnd == hwndCapture ||
+ sizeboxRightBottom.m_hWnd == hwndCapture)
+ {
+ SendMessage(hwndCapture, nMsg, wParam, lParam);
+ }
+ }
+ else
+ {
+ switch (toolsModel.GetActiveTool())
+ {
+ case TOOL_SHAPE: case TOOL_BEZIER:
+ imageArea.SendMessage(nMsg, wParam, lParam);
+ break;
+ }
+ }
}
return 0;
}