-
Notifications
You must be signed in to change notification settings - Fork 1
/
selectionmodel.h
79 lines (63 loc) · 2.36 KB
/
selectionmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
* PURPOSE: Keep track of selection parameters, notify listeners
* COPYRIGHT: Copyright 2015 Benedikt Freisen <[email protected]>
* Copyright 2019-2023 Katayama Hirofumi MZ <[email protected]>
*/
#pragma once
class SelectionModel
{
private:
HBITMAP m_hbmColor;
HBITMAP m_hbmMask;
public:
COLORREF m_rgbBack;
BOOL m_bShow;
BOOL m_bContentChanged;
CRect m_rc; // in image pixel coordinates
POINT m_ptHit; // in image pixel coordinates
CRect m_rcOld; // in image pixel coordinates
SelectionModel();
~SelectionModel();
void SetRectFromPoints(const POINT& ptFrom, const POINT& ptTo);
void setMask(const CRect& rc, HBITMAP hbmMask);
BOOL TakeOff();
void Landing();
BOOL IsLanded() const;
void HideSelection();
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
void drawFrameOnCanvas(HDC hCanvasDC);
void moveSelection(INT xDelta, INT yDelta);
HBITMAP GetSelectionContents();
void DrawBackground(HDC hDCImage, COLORREF crBg);
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg);
void DrawBackgroundRect(HDC hDCImage, COLORREF crBg);
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc, HBITMAP hbm);
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent)
{
return DrawSelection(hDCImage, crBg, bBgTransparent, m_rc);
}
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc)
{
return DrawSelection(hDCImage, crBg, bBgTransparent, rc, m_hbmColor);
}
void InsertFromHBITMAP(HBITMAP hbmColor, INT x = 0, INT y = 0, HBITMAP hbmMask = NULL);
// operation
void FlipHorizontally();
void FlipVertically();
void RotateNTimes90Degrees(int iN);
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY);
void InvertSelection();
void Dragging(HITTEST hit, POINT pt);
void ClearMaskImage();
void ClearColorImage();
void NotifyContentChanged();
void StretchSelection(BOOL bShrink);
private:
SelectionModel(const SelectionModel&);
SelectionModel& operator=(const SelectionModel&);
void ShiftPtStack(INT dx, INT dy);
void SwapWidthAndHeight();
};