ReactOS
0.4.16-dev-329-g9223134
toolsmodel.h
Go to the documentation of this file.
1
/*
2
* PROJECT: PAINT for ReactOS
3
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4
* PURPOSE: Keep track of tool parameters, notify listeners
5
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6
*/
7
8
#pragma once
9
10
enum
TOOLTYPE
11
{
12
TOOL_FREESEL
= 1,
13
TOOL_RECTSEL
= 2,
14
TOOL_RUBBER
= 3,
15
TOOL_FILL
= 4,
16
TOOL_COLOR
= 5,
17
TOOL_ZOOM
= 6,
18
TOOL_PEN
= 7,
19
TOOL_BRUSH
= 8,
20
TOOL_AIRBRUSH
= 9,
21
TOOL_TEXT
= 10,
22
TOOL_LINE
= 11,
23
TOOL_BEZIER
= 12,
24
TOOL_RECT
= 13,
25
TOOL_SHAPE
= 14,
26
TOOL_ELLIPSE
= 15,
27
TOOL_RRECT
= 16,
28
TOOL_MAX
=
TOOL_RRECT
,
29
};
30
31
enum
BrushStyle
32
{
33
BrushStyleRound
,
34
BrushStyleSquare
,
35
BrushStyleForeSlash
,
36
BrushStyleBackSlash
,
37
};
38
39
/* CLASSES **********************************************************/
40
41
struct
ToolBase
42
{
43
HDC
m_hdc
;
44
COLORREF
m_fg
,
m_bg
;
45
46
ToolBase
() :
m_hdc
(
NULL
) { }
47
virtual
~ToolBase
() { }
48
49
virtual
void
OnButtonDown
(
BOOL
bLeftButton,
LONG
x
,
LONG
y
,
BOOL
bDoubleClick) { }
50
virtual
BOOL
OnMouseMove
(
BOOL
bLeftButton,
LONG
&
x
,
LONG
&
y
) {
return
TRUE
; }
51
virtual
BOOL
OnButtonUp
(
BOOL
bLeftButton,
LONG
&
x
,
LONG
&
y
) {
return
TRUE
; }
52
53
virtual
void
OnDrawOverlayOnImage
(
HDC
hdc
) { }
54
virtual
void
OnDrawOverlayOnCanvas
(
HDC
hdc
) { }
55
56
virtual
void
OnSpecialTweak
(
BOOL
bMinus) { }
57
58
virtual
void
OnEndDraw
(
BOOL
bCancel);
59
60
void
beginEvent
();
61
void
endEvent
();
62
void
reset
();
63
64
static
ToolBase
*
createToolObject
(
TOOLTYPE
type
);
65
};
66
67
class
ToolsModel
68
{
69
private
:
70
int
m_lineWidth
;
71
INT
m_penWidth
;
72
INT
m_brushWidth
;
73
int
m_shapeStyle
;
74
BrushStyle
m_brushStyle
;
75
TOOLTYPE
m_activeTool
;
76
TOOLTYPE
m_oldActiveTool
;
77
INT
m_airBrushRadius
;
78
int
m_rubberRadius
;
79
BOOL
m_transpBg
;
80
int
m_zoom
;
81
ToolBase
*
m_pToolObject
;
82
83
ToolBase
*
GetOrCreateTool
(
TOOLTYPE
nTool);
84
85
public
:
86
ToolsModel
();
87
~ToolsModel
();
88
89
BOOL
IsSelection
()
const
;
90
91
int
GetLineWidth
()
const
;
92
void
SetLineWidth
(
int
nLineWidth);
93
void
MakeLineThickerOrThinner
(
BOOL
bThinner);
94
95
INT
GetPenWidth
()
const
;
96
void
SetPenWidth
(
INT
nPenWidth);
97
void
MakePenThickerOrThinner
(
BOOL
bThinner);
98
99
int
GetShapeStyle
()
const
;
100
void
SetShapeStyle
(
int
nShapeStyle);
101
102
INT
GetBrushWidth
()
const
;
103
void
SetBrushWidth
(
INT
nBrushWidth);
104
void
MakeBrushThickerOrThinner
(
BOOL
bThinner);
105
106
BrushStyle
GetBrushStyle
()
const
;
107
void
SetBrushStyle
(
BrushStyle
nBrushStyle);
108
109
TOOLTYPE
GetActiveTool
()
const
;
110
TOOLTYPE
GetOldActiveTool
()
const
;
111
void
SetActiveTool
(
TOOLTYPE
nActiveTool);
112
113
INT
GetAirBrushRadius
()
const
;
114
void
SetAirBrushRadius
(
INT
nAirBrushRadius);
115
void
MakeAirBrushThickerOrThinner
(
BOOL
bThinner);
116
117
int
GetRubberRadius
()
const
;
118
void
SetRubberRadius
(
int
nRubberRadius);
119
void
MakeRubberThickerOrThinner
(
BOOL
bThinner);
120
121
SIZE
GetToolSize
()
const
;
122
123
BOOL
IsBackgroundTransparent
()
const
;
124
void
SetBackgroundTransparent
(
BOOL
bTransparent);
125
126
int
GetZoom
()
const
;
127
void
SetZoom
(
int
nZoom);
128
129
void
OnButtonDown
(
BOOL
bLeftButton,
LONG
x
,
LONG
y
,
BOOL
bDoubleClick);
130
void
OnMouseMove
(
BOOL
bLeftButton,
LONG
x
,
LONG
y
);
131
void
OnButtonUp
(
BOOL
bLeftButton,
LONG
x
,
LONG
y
);
132
void
OnEndDraw
(
BOOL
bCancel);
133
void
OnDrawOverlayOnImage
(
HDC
hdc
);
134
void
OnDrawOverlayOnCanvas
(
HDC
hdc
);
135
136
void
resetTool
();
137
void
selectAll
();
138
139
void
NotifyToolChanged
();
140
void
NotifyToolSettingsChanged
();
141
void
NotifyZoomChanged
();
142
143
void
SpecialTweak
(
BOOL
bMinus);
144
145
void
DrawWithMouseTool
(
POINT
pt
,
WPARAM
wParam
);
146
};
147
148
extern
ToolsModel
toolsModel
;
149
150
static
inline
int
Zoomed
(
int
xy)
151
{
152
return
xy *
toolsModel
.
GetZoom
() / 1000;
153
}
154
155
static
inline
int
UnZoomed
(
int
xy)
156
{
157
return
xy * 1000 /
toolsModel
.
GetZoom
();
158
}
159
160
static
inline
void
Zoomed
(
POINT
&
pt
)
161
{
162
pt
= {
Zoomed
(
pt
.x),
Zoomed
(
pt
.y) };
163
}
164
165
static
inline
void
Zoomed
(
RECT
& rc)
166
{
167
rc = {
Zoomed
(rc.
left
),
Zoomed
(rc.
top
),
Zoomed
(rc.
right
),
Zoomed
(rc.
bottom
) };
168
}
169
170
static
inline
void
UnZoomed
(
POINT
&
pt
)
171
{
172
pt
= {
UnZoomed
(
pt
.x),
UnZoomed
(
pt
.y) };
173
}
174
175
static
inline
void
UnZoomed
(
RECT
& rc)
176
{
177
rc = {
UnZoomed
(rc.
left
),
UnZoomed
(rc.
top
),
UnZoomed
(rc.
right
),
UnZoomed
(rc.
bottom
) };
178
}
ToolsModel
Definition:
toolsmodel.h:68
ToolsModel::MakeAirBrushThickerOrThinner
void MakeAirBrushThickerOrThinner(BOOL bThinner)
Definition:
toolsmodel.cpp:100
ToolsModel::OnDrawOverlayOnCanvas
void OnDrawOverlayOnCanvas(HDC hdc)
Definition:
mouse.cpp:1191
ToolsModel::OnDrawOverlayOnImage
void OnDrawOverlayOnImage(HDC hdc)
Definition:
mouse.cpp:1186
ToolsModel::OnEndDraw
void OnEndDraw(BOOL bCancel)
Definition:
mouse.cpp:1178
ToolsModel::SetBrushStyle
void SetBrushStyle(BrushStyle nBrushStyle)
Definition:
toolsmodel.cpp:128
ToolsModel::MakeBrushThickerOrThinner
void MakeBrushThickerOrThinner(BOOL bThinner)
Definition:
toolsmodel.cpp:94
ToolsModel::GetZoom
int GetZoom() const
Definition:
toolsmodel.cpp:261
ToolsModel::m_oldActiveTool
TOOLTYPE m_oldActiveTool
Definition:
toolsmodel.h:76
ToolsModel::GetLineWidth
int GetLineWidth() const
Definition:
toolsmodel.cpp:46
ToolsModel::m_airBrushRadius
INT m_airBrushRadius
Definition:
toolsmodel.h:77
ToolsModel::m_brushWidth
INT m_brushWidth
Definition:
toolsmodel.h:72
ToolsModel::IsSelection
BOOL IsSelection() const
Definition:
toolsmodel.cpp:41
ToolsModel::GetShapeStyle
int GetShapeStyle() const
Definition:
toolsmodel.cpp:112
ToolsModel::m_rubberRadius
int m_rubberRadius
Definition:
toolsmodel.h:78
ToolsModel::m_lineWidth
int m_lineWidth
Definition:
toolsmodel.h:70
ToolsModel::SetAirBrushRadius
void SetAirBrushRadius(INT nAirBrushRadius)
Definition:
toolsmodel.cpp:188
ToolsModel::resetTool
void resetTool()
Definition:
toolsmodel.cpp:302
ToolsModel::m_transpBg
BOOL m_transpBg
Definition:
toolsmodel.h:79
ToolsModel::m_shapeStyle
int m_shapeStyle
Definition:
toolsmodel.h:73
ToolsModel::GetOldActiveTool
TOOLTYPE GetOldActiveTool() const
Definition:
toolsmodel.cpp:139
ToolsModel::SetShapeStyle
void SetShapeStyle(int nShapeStyle)
Definition:
toolsmodel.cpp:117
ToolsModel::SetActiveTool
void SetActiveTool(TOOLTYPE nActiveTool)
Definition:
toolsmodel.cpp:144
ToolsModel::DrawWithMouseTool
void DrawWithMouseTool(POINT pt, WPARAM wParam)
Definition:
mouse.cpp:1201
ToolsModel::SetRubberRadius
void SetRubberRadius(int nRubberRadius)
Definition:
toolsmodel.cpp:199
ToolsModel::NotifyToolChanged
void NotifyToolChanged()
Definition:
toolsmodel.cpp:272
ToolsModel::OnMouseMove
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition:
mouse.cpp:1160
ToolsModel::m_brushStyle
BrushStyle m_brushStyle
Definition:
toolsmodel.h:74
ToolsModel::GetPenWidth
INT GetPenWidth() const
Definition:
toolsmodel.cpp:58
ToolsModel::m_zoom
int m_zoom
Definition:
toolsmodel.h:80
ToolsModel::GetBrushStyle
BrushStyle GetBrushStyle() const
Definition:
toolsmodel.cpp:123
ToolsModel::OnButtonDown
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition:
mouse.cpp:1152
ToolsModel::MakeRubberThickerOrThinner
void MakeRubberThickerOrThinner(BOOL bThinner)
Definition:
toolsmodel.cpp:106
ToolsModel::IsBackgroundTransparent
BOOL IsBackgroundTransparent() const
Definition:
toolsmodel.cpp:249
ToolsModel::SetZoom
void SetZoom(int nZoom)
Definition:
toolsmodel.cpp:266
ToolsModel::SetBackgroundTransparent
void SetBackgroundTransparent(BOOL bTransparent)
Definition:
toolsmodel.cpp:254
ToolsModel::m_activeTool
TOOLTYPE m_activeTool
Definition:
toolsmodel.h:75
ToolsModel::GetRubberRadius
int GetRubberRadius() const
Definition:
toolsmodel.cpp:194
ToolsModel::m_pToolObject
ToolBase * m_pToolObject
Definition:
toolsmodel.h:81
ToolsModel::NotifyToolSettingsChanged
void NotifyToolSettingsChanged()
Definition:
toolsmodel.cpp:284
ToolsModel::GetOrCreateTool
ToolBase * GetOrCreateTool(TOOLTYPE nTool)
Definition:
toolsmodel.cpp:34
ToolsModel::ToolsModel
ToolsModel()
Definition:
toolsmodel.cpp:14
ToolsModel::MakeLineThickerOrThinner
void MakeLineThickerOrThinner(BOOL bThinner)
Definition:
toolsmodel.cpp:82
ToolsModel::GetActiveTool
TOOLTYPE GetActiveTool() const
Definition:
toolsmodel.cpp:134
ToolsModel::MakePenThickerOrThinner
void MakePenThickerOrThinner(BOOL bThinner)
Definition:
toolsmodel.cpp:88
ToolsModel::~ToolsModel
~ToolsModel()
Definition:
toolsmodel.cpp:28
ToolsModel::SpecialTweak
void SpecialTweak(BOOL bMinus)
Definition:
mouse.cpp:1196
ToolsModel::selectAll
void selectAll()
Definition:
toolsmodel.cpp:307
ToolsModel::NotifyZoomChanged
void NotifyZoomChanged()
Definition:
toolsmodel.cpp:292
ToolsModel::SetPenWidth
void SetPenWidth(INT nPenWidth)
Definition:
toolsmodel.cpp:63
ToolsModel::SetBrushWidth
void SetBrushWidth(INT nBrushWidth)
Definition:
toolsmodel.cpp:75
ToolsModel::GetAirBrushRadius
INT GetAirBrushRadius() const
Definition:
toolsmodel.cpp:183
ToolsModel::OnButtonUp
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition:
mouse.cpp:1169
ToolsModel::SetLineWidth
void SetLineWidth(int nLineWidth)
Definition:
toolsmodel.cpp:51
ToolsModel::GetBrushWidth
INT GetBrushWidth() const
Definition:
toolsmodel.cpp:70
ToolsModel::GetToolSize
SIZE GetToolSize() const
Definition:
toolsmodel.cpp:205
ToolsModel::m_penWidth
INT m_penWidth
Definition:
toolsmodel.h:71
wParam
WPARAM wParam
Definition:
combotst.c:138
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
pt
#define pt(x, y)
Definition:
drawing.c:79
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
x
GLint GLint GLint GLint GLint x
Definition:
gl.h:1548
type
GLuint GLuint GLsizei GLenum type
Definition:
gl.h:1545
y
GLint GLint GLint GLint GLint GLint y
Definition:
gl.h:1548
hdc
HDC hdc
Definition:
main.c:9
HDC
static HDC
Definition:
imagelist.c:88
LONG
long LONG
Definition:
pedump.c:60
ToolBase
Definition:
toolsmodel.h:42
ToolBase::endEvent
void endEvent()
Definition:
mouse.cpp:138
ToolBase::OnMouseMove
virtual BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y)
Definition:
toolsmodel.h:50
ToolBase::OnButtonDown
virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition:
toolsmodel.h:49
ToolBase::m_hdc
HDC m_hdc
Definition:
toolsmodel.h:43
ToolBase::OnEndDraw
virtual void OnEndDraw(BOOL bCancel)
Definition:
mouse.cpp:125
ToolBase::OnSpecialTweak
virtual void OnSpecialTweak(BOOL bMinus)
Definition:
toolsmodel.h:56
ToolBase::reset
void reset()
Definition:
mouse.cpp:106
ToolBase::createToolObject
static ToolBase * createToolObject(TOOLTYPE type)
Definition:
mouse.cpp:1127
ToolBase::m_fg
COLORREF m_fg
Definition:
toolsmodel.h:44
ToolBase::OnDrawOverlayOnImage
virtual void OnDrawOverlayOnImage(HDC hdc)
Definition:
toolsmodel.h:53
ToolBase::beginEvent
void beginEvent()
Definition:
mouse.cpp:131
ToolBase::ToolBase
ToolBase()
Definition:
toolsmodel.h:46
ToolBase::OnDrawOverlayOnCanvas
virtual void OnDrawOverlayOnCanvas(HDC hdc)
Definition:
toolsmodel.h:54
ToolBase::OnButtonUp
virtual BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y)
Definition:
toolsmodel.h:51
ToolBase::~ToolBase
virtual ~ToolBase()
Definition:
toolsmodel.h:47
ToolBase::m_bg
COLORREF m_bg
Definition:
toolsmodel.h:44
_SIZE
Definition:
kdterminal.h:26
tagPOINT
Definition:
polytest.cpp:47
tagRECT
Definition:
windef.h:305
tagRECT::right
LONG right
Definition:
windef.h:308
tagRECT::bottom
LONG bottom
Definition:
windef.h:309
tagRECT::top
LONG top
Definition:
windef.h:307
tagRECT::left
LONG left
Definition:
windef.h:306
toolsModel
ToolsModel toolsModel
Definition:
toolsmodel.cpp:10
UnZoomed
static int UnZoomed(int xy)
Definition:
toolsmodel.h:155
TOOLTYPE
TOOLTYPE
Definition:
toolsmodel.h:11
TOOL_AIRBRUSH
@ TOOL_AIRBRUSH
Definition:
toolsmodel.h:20
TOOL_COLOR
@ TOOL_COLOR
Definition:
toolsmodel.h:16
TOOL_SHAPE
@ TOOL_SHAPE
Definition:
toolsmodel.h:25
TOOL_RUBBER
@ TOOL_RUBBER
Definition:
toolsmodel.h:14
TOOL_MAX
@ TOOL_MAX
Definition:
toolsmodel.h:28
TOOL_BRUSH
@ TOOL_BRUSH
Definition:
toolsmodel.h:19
TOOL_RECT
@ TOOL_RECT
Definition:
toolsmodel.h:24
TOOL_BEZIER
@ TOOL_BEZIER
Definition:
toolsmodel.h:23
TOOL_FILL
@ TOOL_FILL
Definition:
toolsmodel.h:15
TOOL_TEXT
@ TOOL_TEXT
Definition:
toolsmodel.h:21
TOOL_PEN
@ TOOL_PEN
Definition:
toolsmodel.h:18
TOOL_LINE
@ TOOL_LINE
Definition:
toolsmodel.h:22
TOOL_FREESEL
@ TOOL_FREESEL
Definition:
toolsmodel.h:12
TOOL_ZOOM
@ TOOL_ZOOM
Definition:
toolsmodel.h:17
TOOL_ELLIPSE
@ TOOL_ELLIPSE
Definition:
toolsmodel.h:26
TOOL_RRECT
@ TOOL_RRECT
Definition:
toolsmodel.h:27
TOOL_RECTSEL
@ TOOL_RECTSEL
Definition:
toolsmodel.h:13
BrushStyle
BrushStyle
Definition:
toolsmodel.h:32
BrushStyleForeSlash
@ BrushStyleForeSlash
Definition:
toolsmodel.h:35
BrushStyleRound
@ BrushStyleRound
Definition:
toolsmodel.h:33
BrushStyleBackSlash
@ BrushStyleBackSlash
Definition:
toolsmodel.h:36
BrushStyleSquare
@ BrushStyleSquare
Definition:
toolsmodel.h:34
Zoomed
static int Zoomed(int xy)
Definition:
toolsmodel.h:150
INT
int32_t INT
Definition:
typedefs.h:58
WPARAM
UINT_PTR WPARAM
Definition:
windef.h:207
COLORREF
DWORD COLORREF
Definition:
windef.h:300
base
applications
mspaint
toolsmodel.h
Generated on Sun Dec 8 2024 06:02:20 for ReactOS by
1.9.6