1 /*
2  * PROJECT:     PAINT for ReactOS
3  * LICENSE:     LGPL
4  * FILE:        base/applications/mspaint/selectionmodel.h
5  * PURPOSE:     Keep track of selection parameters, notify listeners
6  * PROGRAMMERS: Benedikt Freisen
7  *              Katayama Hirofumi MZ
8  */
9 
10 #pragma once
11 
12 /* DEFINES **********************************************************/
13 
14 #define ACTION_MOVE                 0
15 #define ACTION_RESIZE_TOP_LEFT      1
16 #define ACTION_RESIZE_TOP           2
17 #define ACTION_RESIZE_TOP_RIGHT     3
18 #define ACTION_RESIZE_LEFT          4
19 #define ACTION_RESIZE_RIGHT         5
20 #define ACTION_RESIZE_BOTTOM_LEFT   6
21 #define ACTION_RESIZE_BOTTOM        7
22 #define ACTION_RESIZE_BOTTOM_RIGHT  8
23 
24 /* CLASSES **********************************************************/
25 
26 class SelectionModel
27 {
28 private:
29     HDC m_hDC;
30     RECT m_rcSrc;
31     RECT m_rcDest;
32     HBITMAP m_hBm;
33     HBITMAP m_hMask;
34     POINT *m_ptStack;
35     int m_iPtSP;
36 
37 //     void NotifySelectionChanging();
38 //     void NotifySelectionChanged();
39     void NotifyRefreshNeeded();
40 
41 public:
42     SelectionModel();
43     ~SelectionModel();
44     void ResetPtStack();
45     void PushToPtStack(LONG x, LONG y);
46     void CalculateBoundingBoxAndContents(HDC hDCImage);
47     void CalculateContents(HDC hDCImage);
48     void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg);
49     void DrawBackgroundRect(HDC hDCImage, COLORREF crBg);
50     void DrawSelection(HDC hDCImage, COLORREF crBg = 0, BOOL bBgTransparent = FALSE);
51     void DrawSelectionStretched(HDC hDCImage);
52     void ScaleContentsToFit();
53     void InsertFromHBITMAP(HBITMAP hBm, INT x = 0, INT y = 0);
54     void FlipHorizontally();
55     void FlipVertically();
56     void RotateNTimes90Degrees(int iN);
57     void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0);
58     HBITMAP GetBitmap() const;
59     int PtStackSize() const;
60     void DrawFramePoly(HDC hDCImage);
61     void SetSrcAndDestRectFromPoints(const POINT& ptFrom, const POINT& ptTo);
62     void SetSrcRectSizeToZero();
63     BOOL IsSrcRectSizeNonzero() const;
64     void ModifyDestRect(POINT& ptDelta, int iAction);
65     LONG GetDestRectWidth() const;
66     LONG GetDestRectHeight() const;
67     LONG GetDestRectLeft() const;
68     LONG GetDestRectTop() const;
69     void GetRect(LPRECT prc) const;
70 
71 private:
72     SelectionModel(const SelectionModel&);
73     SelectionModel& operator=(const SelectionModel&);
74 };
75