mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 05:01:31 +00:00
[MSPAINT] Simplify canvas mouse message handling (#5803)
- Unify some mouse message handlers of CCanvasWindow. - Add CCanvasWindow::m_nMouseDownMsg member. CORE-19094
This commit is contained in:
parent
8f1eb03ad2
commit
f49919ce5d
2 changed files with 26 additions and 53 deletions
|
@ -310,10 +310,13 @@ LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
|
|
||||||
|
m_nMouseDownMsg = nMsg;
|
||||||
|
BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN);
|
||||||
|
|
||||||
HITTEST hitSelection = SelectionHitTest(pt);
|
HITTEST hitSelection = SelectionHitTest(pt);
|
||||||
if (hitSelection != HIT_NONE)
|
if (hitSelection != HIT_NONE)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +336,7 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
canvasWindow.ClientToScreen(&pt);
|
ClientToScreen(&pt);
|
||||||
mainWindow.TrackPopupMenu(pt, 0);
|
mainWindow.TrackPopupMenu(pt, 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -347,13 +350,13 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam
|
||||||
case TOOL_BEZIER:
|
case TOOL_BEZIER:
|
||||||
case TOOL_SHAPE:
|
case TOOL_SHAPE:
|
||||||
toolsModel.OnCancelDraw();
|
toolsModel.OnCancelDraw();
|
||||||
canvasWindow.Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOOL_FREESEL:
|
case TOOL_FREESEL:
|
||||||
case TOOL_RECTSEL:
|
case TOOL_RECTSEL:
|
||||||
toolsModel.OnFinishDraw();
|
toolsModel.OnFinishDraw();
|
||||||
canvasWindow.Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -386,40 +389,21 @@ LRESULT CCanvasWindow::OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CCanvasWindow::OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
|
||||||
return OnLRButtonDown(TRUE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
|
||||||
return OnLRButtonDown(FALSE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
{
|
||||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
CanvasToImage(pt);
|
CanvasToImage(pt);
|
||||||
|
|
||||||
m_drawing = FALSE;
|
m_drawing = FALSE;
|
||||||
ReleaseCapture();
|
::ReleaseCapture();
|
||||||
|
m_nMouseDownMsg = 0;
|
||||||
|
|
||||||
toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, TRUE);
|
toolsModel.OnButtonDown(nMsg == WM_LBUTTONDBLCLK, pt.x, pt.y, TRUE);
|
||||||
toolsModel.resetTool();
|
toolsModel.resetTool();
|
||||||
Invalidate(FALSE);
|
Invalidate(FALSE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
|
||||||
return OnLRButtonDblClk(TRUE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
|
||||||
return OnLRButtonDblClk(FALSE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
|
@ -612,13 +596,16 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
CanvasToImage(pt);
|
CanvasToImage(pt);
|
||||||
|
|
||||||
::ReleaseCapture();
|
::ReleaseCapture();
|
||||||
|
|
||||||
|
BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN);
|
||||||
|
m_nMouseDownMsg = 0;
|
||||||
|
|
||||||
if (m_drawing)
|
if (m_drawing)
|
||||||
{
|
{
|
||||||
m_drawing = FALSE;
|
m_drawing = FALSE;
|
||||||
|
@ -680,16 +667,6 @@ LRESULT CCanvasWindow::OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
|
||||||
return OnLRButtonUp(TRUE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
||||||
{
|
|
||||||
return OnLRButtonUp(FALSE, nMsg, wParam, lParam, bHandled);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
if (CWaitCursor::IsWaiting())
|
if (CWaitCursor::IsWaiting())
|
||||||
|
@ -760,6 +737,7 @@ LRESULT CCanvasWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
||||||
{
|
{
|
||||||
// Cancel dragging
|
// Cancel dragging
|
||||||
::ReleaseCapture();
|
::ReleaseCapture();
|
||||||
|
m_nMouseDownMsg = 0;
|
||||||
m_hitCanvasSizeBox = HIT_NONE;
|
m_hitCanvasSizeBox = HIT_NONE;
|
||||||
::SetRectEmpty(&m_rcResizing);
|
::SetRectEmpty(&m_rcResizing);
|
||||||
Invalidate(TRUE);
|
Invalidate(TRUE);
|
||||||
|
|
|
@ -20,13 +20,13 @@ public:
|
||||||
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
||||||
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
||||||
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnButtonDblClk)
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnButtonDblClk)
|
||||||
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
|
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
|
||||||
MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
|
MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp)
|
||||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||||
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
|
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
|
||||||
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
|
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
|
||||||
|
@ -76,14 +76,8 @@ protected:
|
||||||
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
||||||
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
@ -91,7 +85,8 @@ protected:
|
||||||
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
|
||||||
LRESULT OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
UINT m_nMouseDownMsg = 0;
|
||||||
LRESULT OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue