xref: /reactos/base/applications/mspaint/canvas.h (revision b8598e09)
17361592eSKatayama Hirofumi MZ /*
27361592eSKatayama Hirofumi MZ  * PROJECT:    PAINT for ReactOS
38f1f1c7aSStanislav Motylkov  * LICENSE:    LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
47361592eSKatayama Hirofumi MZ  * PURPOSE:    Providing the canvas window class
5f5200e6cSStanislav Motylkov  * COPYRIGHT:  Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
67361592eSKatayama Hirofumi MZ  */
77361592eSKatayama Hirofumi MZ 
87361592eSKatayama Hirofumi MZ #pragma once
97361592eSKatayama Hirofumi MZ 
107361592eSKatayama Hirofumi MZ class CCanvasWindow : public CWindowImpl<CCanvasWindow>
117361592eSKatayama Hirofumi MZ {
127361592eSKatayama Hirofumi MZ public:
13640d67d1SKatayama Hirofumi MZ     DECLARE_WND_CLASS_EX(L"ReactOSPaintCanvas", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
1483762575SKatayama Hirofumi MZ                          COLOR_APPWORKSPACE)
157361592eSKatayama Hirofumi MZ 
167361592eSKatayama Hirofumi MZ     BEGIN_MSG_MAP(CCanvasWindow)
177361592eSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_SIZE, OnSize)
186b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_PAINT, OnPaint)
196b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
207361592eSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
217361592eSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
226b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
23f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
24f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
2597e53c69SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_MBUTTONDOWN, OnButtonDown)
26f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnButtonDblClk)
27f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnButtonDblClk)
286b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
29f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
30f49919ceSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp)
3197e53c69SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_MBUTTONUP, OnButtonUp)
326b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
337361592eSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
346b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
356b6a0457SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
36aeffa57eSKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit)
37e8c7e300SKatayama Hirofumi MZ         MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
387361592eSKatayama Hirofumi MZ     END_MSG_MAP()
397361592eSKatayama Hirofumi MZ 
406b6a0457SKatayama Hirofumi MZ     CCanvasWindow();
412f856f6fSKatayama Hirofumi MZ     virtual ~CCanvasWindow();
426b6a0457SKatayama Hirofumi MZ 
43efe7368cSKatayama Hirofumi MZ     BOOL m_drawing;
44efe7368cSKatayama Hirofumi MZ 
45*b8598e09SKatayama Hirofumi MZ     VOID OnEndDraw(BOOL bCancel);
468f1eb03aSKatayama Hirofumi MZ     VOID updateScrollRange();
478f1eb03aSKatayama Hirofumi MZ     VOID updateScrollPos(INT x = 0, INT y = 0);
48eacf003cSKatayama Hirofumi MZ 
49efe7368cSKatayama Hirofumi MZ     VOID ImageToCanvas(POINT& pt);
50efe7368cSKatayama Hirofumi MZ     VOID ImageToCanvas(RECT& rc);
5158c26d3fSKatayama Hirofumi MZ     VOID CanvasToImage(POINT& pt);
5258c26d3fSKatayama Hirofumi MZ     VOID CanvasToImage(RECT& rc);
53efe7368cSKatayama Hirofumi MZ     VOID GetImageRect(RECT& rc);
548f1eb03aSKatayama Hirofumi MZ     VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget);
558f1eb03aSKatayama Hirofumi MZ     VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0);
56efe7368cSKatayama Hirofumi MZ 
57eacf003cSKatayama Hirofumi MZ protected:
58cb98e91bSKatayama Hirofumi MZ     HITTEST m_hitCanvasSizeBox;
596b6a0457SKatayama Hirofumi MZ     POINT m_ptOrig; // The origin of drag start
60e8c7e300SKatayama Hirofumi MZ     HBITMAP m_ahbmCached[2]; // The cached buffer bitmaps
61cb98e91bSKatayama Hirofumi MZ     CRect m_rcResizing; // Resizing rectagle
626b6a0457SKatayama Hirofumi MZ 
63cb98e91bSKatayama Hirofumi MZ     HITTEST CanvasHitTest(POINT pt);
646b6a0457SKatayama Hirofumi MZ     RECT GetBaseRect();
656b6a0457SKatayama Hirofumi MZ     VOID DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint);
666b6a0457SKatayama Hirofumi MZ     VOID OnHVScroll(WPARAM wParam, INT fnBar);
67efe7368cSKatayama Hirofumi MZ 
687361592eSKatayama Hirofumi MZ     LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
697361592eSKatayama Hirofumi MZ     LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
707361592eSKatayama Hirofumi MZ     LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
716b6a0457SKatayama Hirofumi MZ     LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
726b6a0457SKatayama Hirofumi MZ     LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
736b6a0457SKatayama Hirofumi MZ     LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
746b6a0457SKatayama Hirofumi MZ     LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
756b6a0457SKatayama Hirofumi MZ     LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
767361592eSKatayama Hirofumi MZ     LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
776b6a0457SKatayama Hirofumi MZ     LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
786b6a0457SKatayama Hirofumi MZ     LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
79aeffa57eSKatayama Hirofumi MZ     LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
80e8c7e300SKatayama Hirofumi MZ     LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
81efe7368cSKatayama Hirofumi MZ 
82f49919ceSKatayama Hirofumi MZ     UINT m_nMouseDownMsg = 0;
83f49919ceSKatayama Hirofumi MZ     LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
84f49919ceSKatayama Hirofumi MZ     LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
85f49919ceSKatayama Hirofumi MZ     LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
867361592eSKatayama Hirofumi MZ };
87