mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 10:43:52 +00:00
[MSPAINT]
- Enable drag cancellation -- patch by Katayama Hirofumi MZ CORE-13395 #resolve svn path=/trunk/; revision=75418
This commit is contained in:
parent
564e7818da
commit
b36097ee50
7 changed files with 157 additions and 16 deletions
|
@ -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 @@ LRESULT CImgAreaWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
{
|
||||
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 @@ LRESULT CImgAreaWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
}
|
||||
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 @@ LRESULT CImgAreaWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
{
|
||||
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 @@ LRESULT CImgAreaWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
}
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
||||
}
|
||||
ReleaseCapture();
|
||||
drawing = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ public:
|
|||
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 @@ private:
|
|||
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();
|
||||
};
|
||||
|
|
|
@ -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 @@ LRESULT CSelectionWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
|||
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)
|
||||
|
|
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
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];
|
||||
|
|
|
@ -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 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
|
||||
}
|
||||
ReleaseCapture();
|
||||
resizing = FALSE;
|
||||
ReleaseCapture();
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSizeboxWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
LRESULT CSizeboxWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
resizing = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSizeboxWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == VK_ESCAPE)
|
||||
{
|
||||
if (GetCapture() == m_hWnd)
|
||||
{
|
||||
ReleaseCapture();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -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 @@ public:
|
|||
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);
|
||||
};
|
||||
|
|
|
@ -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 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
{
|
||||
if (wParam == VK_ESCAPE)
|
||||
{
|
||||
if (!imageArea.drawing)
|
||||
HWND hwndCapture = GetCapture();
|
||||
if (hwndCapture)
|
||||
{
|
||||
/* Deselect */
|
||||
if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_FREESEL))
|
||||
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)
|
||||
{
|
||||
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);
|
||||
SendMessage(hwndCapture, nMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (toolsModel.GetActiveTool())
|
||||
{
|
||||
case TOOL_SHAPE: case TOOL_BEZIER:
|
||||
imageArea.SendMessage(nMsg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* FIXME: also cancel current drawing underway */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue