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);
54     void FlipHorizontally();
55     void FlipVertically();
56     void RotateNTimes90Degrees(int iN);
57     HBITMAP GetBitmap();
58     int PtStackSize();
59     void DrawFramePoly(HDC hDCImage);
60     void SetSrcAndDestRectFromPoints(const POINT& ptFrom, const POINT& ptTo);
61     void SetSrcRectSizeToZero();
62     BOOL IsSrcRectSizeNonzero();
63     void ModifyDestRect(POINT& ptDelta, int iAction);
64     LONG GetDestRectWidth();
65     LONG GetDestRectHeight();
66     LONG GetDestRectLeft();
67     LONG GetDestRectTop();
68     void DrawTextToolText(HDC hDCImage, COLORREF crFg, COLORREF crBg, BOOL bBgTransparent = FALSE);
69 
70 private:
71     SelectionModel(const SelectionModel&);
72     SelectionModel& operator=(const SelectionModel&);
73 };
74