2015-05-08 16:02:36 +00:00
|
|
|
/*
|
2023-06-23 11:04:32 +00:00
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
|
|
|
* PURPOSE: Providing the canvas window class
|
2023-06-27 18:22:21 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
2015-05-08 16:02:36 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-09 12:36:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-03-16 22:45:14 +00:00
|
|
|
class CCanvasWindow : public CWindowImpl<CCanvasWindow>
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-12 12:12:37 +00:00
|
|
|
DECLARE_WND_CLASS_EX(_T("ReactOSPaintCanvas"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
|
|
|
|
COLOR_APPWORKSPACE)
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-03-16 22:45:14 +00:00
|
|
|
BEGIN_MSG_MAP(CCanvasWindow)
|
2015-07-07 10:42:49 +00:00
|
|
|
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
2023-03-19 01:42:10 +00:00
|
|
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
|
|
|
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
2015-07-07 10:42:49 +00:00
|
|
|
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
|
|
|
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
2023-03-19 01:42:10 +00:00
|
|
|
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
2017-06-19 13:02:09 +00:00
|
|
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
2023-04-08 13:25:27 +00:00
|
|
|
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
|
|
|
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
|
|
|
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
2023-03-19 01:42:10 +00:00
|
|
|
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
|
|
|
|
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
2023-04-08 13:25:27 +00:00
|
|
|
MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
|
2023-03-19 01:42:10 +00:00
|
|
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
2021-12-27 13:20:22 +00:00
|
|
|
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
|
2023-03-19 01:42:10 +00:00
|
|
|
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
|
|
|
|
MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
|
2023-05-31 04:21:01 +00:00
|
|
|
MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit)
|
2023-06-17 12:15:35 +00:00
|
|
|
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
2015-07-07 10:42:49 +00:00
|
|
|
END_MSG_MAP()
|
|
|
|
|
2023-03-19 01:42:10 +00:00
|
|
|
CCanvasWindow();
|
2023-06-15 23:05:23 +00:00
|
|
|
virtual ~CCanvasWindow();
|
2023-03-19 01:42:10 +00:00
|
|
|
|
2023-04-08 13:25:27 +00:00
|
|
|
BOOL m_drawing;
|
|
|
|
|
|
|
|
VOID cancelDrawing();
|
|
|
|
VOID finishDrawing();
|
2023-03-16 22:51:12 +00:00
|
|
|
VOID Update(HWND hwndFrom);
|
|
|
|
|
2023-04-08 13:25:27 +00:00
|
|
|
VOID ImageToCanvas(POINT& pt);
|
|
|
|
VOID ImageToCanvas(RECT& rc);
|
|
|
|
VOID CanvasToImage(POINT& pt, BOOL bZoomed = FALSE);
|
|
|
|
VOID CanvasToImage(RECT& rc, BOOL bZoomed = FALSE);
|
|
|
|
VOID GetImageRect(RECT& rc);
|
2023-06-13 07:31:18 +00:00
|
|
|
VOID MoveSelection(INT xDelta, INT yDelta);
|
2023-04-08 13:25:27 +00:00
|
|
|
|
2023-03-16 22:51:12 +00:00
|
|
|
protected:
|
2023-06-24 10:39:07 +00:00
|
|
|
HITTEST m_hitSelection;
|
|
|
|
HITTEST m_hitCanvasSizeBox;
|
2023-03-19 01:42:10 +00:00
|
|
|
POINT m_ptOrig; // The origin of drag start
|
2023-06-17 12:15:35 +00:00
|
|
|
HBITMAP m_ahbmCached[2]; // The cached buffer bitmaps
|
2023-06-24 10:39:07 +00:00
|
|
|
CRect m_rcResizing; // Resizing rectagle
|
2023-03-19 01:42:10 +00:00
|
|
|
|
2023-06-24 10:39:07 +00:00
|
|
|
HITTEST CanvasHitTest(POINT pt);
|
2023-03-19 01:42:10 +00:00
|
|
|
RECT GetBaseRect();
|
|
|
|
VOID DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint);
|
|
|
|
VOID OnHVScroll(WPARAM wParam, INT fnBar);
|
2023-04-08 13:25:27 +00:00
|
|
|
VOID drawZoomFrame(INT mouseX, INT mouseY);
|
|
|
|
|
2023-06-24 10:39:07 +00:00
|
|
|
HITTEST SelectionHitTest(POINT ptImage);
|
|
|
|
VOID StartSelectionDrag(HITTEST hit, POINT ptImage);
|
2023-06-13 05:57:59 +00:00
|
|
|
VOID SelectionDragging(POINT ptImage);
|
|
|
|
VOID EndSelectionDrag(POINT ptImage);
|
2023-03-19 01:42:10 +00:00
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-03-19 01:42:10 +00:00
|
|
|
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2017-06-19 13:02:09 +00:00
|
|
|
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-04-08 13:25:27 +00:00
|
|
|
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);
|
2023-03-19 01:42:10 +00:00
|
|
|
LRESULT OnMouseMove(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);
|
2023-04-08 13:25:27 +00:00
|
|
|
LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-03-19 01:42:10 +00:00
|
|
|
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2021-12-27 13:20:22 +00:00
|
|
|
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-03-19 01:42:10 +00:00
|
|
|
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-05-31 04:21:01 +00:00
|
|
|
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-06-17 12:15:35 +00:00
|
|
|
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2023-04-08 13:25:27 +00:00
|
|
|
|
|
|
|
LRESULT OnLRButtonDown(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnLRButtonDblClk(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
LRESULT OnLRButtonUp(BOOL bLeftButton, UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
2015-07-07 10:42:49 +00:00
|
|
|
};
|