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
11{
29};
30
32{
37};
38
39/* CLASSES **********************************************************/
40
42{
45
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
65};
66
68{
69private:
80 int m_zoom;
82
84
85public:
86 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
107 void SetBrushStyle(BrushStyle nBrushStyle);
108
109 TOOLTYPE GetActiveTool() 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
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);
135
136 void resetTool();
137 void selectAll();
138
139 void NotifyToolChanged();
141 void NotifyZoomChanged();
142
143 void SpecialTweak(BOOL bMinus);
144
146};
147
149
150static inline int Zoomed(int xy)
151{
152 return xy * toolsModel.GetZoom() / 1000;
153}
154
155static inline int UnZoomed(int xy)
156{
157 return xy * 1000 / toolsModel.GetZoom();
158}
159
160static inline void Zoomed(POINT& pt)
161{
162 pt = { Zoomed(pt.x), Zoomed(pt.y) };
163}
164
165static inline void Zoomed(RECT& rc)
166{
167 rc = { Zoomed(rc.left), Zoomed(rc.top), Zoomed(rc.right), Zoomed(rc.bottom) };
168}
169
170static inline void UnZoomed(POINT& pt)
171{
172 pt = { UnZoomed(pt.x), UnZoomed(pt.y) };
173}
174
175static inline void UnZoomed(RECT& rc)
176{
177 rc = { UnZoomed(rc.left), UnZoomed(rc.top), UnZoomed(rc.right), UnZoomed(rc.bottom) };
178}
void MakeAirBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:100
void OnDrawOverlayOnCanvas(HDC hdc)
Definition: mouse.cpp:1191
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1186
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1178
void SetBrushStyle(BrushStyle nBrushStyle)
Definition: toolsmodel.cpp:128
void MakeBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:94
int GetZoom() const
Definition: toolsmodel.cpp:261
TOOLTYPE m_oldActiveTool
Definition: toolsmodel.h:76
int GetLineWidth() const
Definition: toolsmodel.cpp:46
INT m_airBrushRadius
Definition: toolsmodel.h:77
INT m_brushWidth
Definition: toolsmodel.h:72
BOOL IsSelection() const
Definition: toolsmodel.cpp:41
int GetShapeStyle() const
Definition: toolsmodel.cpp:112
int m_rubberRadius
Definition: toolsmodel.h:78
int m_lineWidth
Definition: toolsmodel.h:70
void SetAirBrushRadius(INT nAirBrushRadius)
Definition: toolsmodel.cpp:188
void resetTool()
Definition: toolsmodel.cpp:302
BOOL m_transpBg
Definition: toolsmodel.h:79
int m_shapeStyle
Definition: toolsmodel.h:73
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:139
void SetShapeStyle(int nShapeStyle)
Definition: toolsmodel.cpp:117
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:144
void DrawWithMouseTool(POINT pt, WPARAM wParam)
Definition: mouse.cpp:1201
void SetRubberRadius(int nRubberRadius)
Definition: toolsmodel.cpp:199
void NotifyToolChanged()
Definition: toolsmodel.cpp:272
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1160
BrushStyle m_brushStyle
Definition: toolsmodel.h:74
INT GetPenWidth() const
Definition: toolsmodel.cpp:58
int m_zoom
Definition: toolsmodel.h:80
BrushStyle GetBrushStyle() const
Definition: toolsmodel.cpp:123
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: mouse.cpp:1152
void MakeRubberThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:106
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:249
void SetZoom(int nZoom)
Definition: toolsmodel.cpp:266
void SetBackgroundTransparent(BOOL bTransparent)
Definition: toolsmodel.cpp:254
TOOLTYPE m_activeTool
Definition: toolsmodel.h:75
int GetRubberRadius() const
Definition: toolsmodel.cpp:194
ToolBase * m_pToolObject
Definition: toolsmodel.h:81
void NotifyToolSettingsChanged()
Definition: toolsmodel.cpp:284
ToolBase * GetOrCreateTool(TOOLTYPE nTool)
Definition: toolsmodel.cpp:34
void MakeLineThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:82
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:134
void MakePenThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:88
void SpecialTweak(BOOL bMinus)
Definition: mouse.cpp:1196
void selectAll()
Definition: toolsmodel.cpp:307
void NotifyZoomChanged()
Definition: toolsmodel.cpp:292
void SetPenWidth(INT nPenWidth)
Definition: toolsmodel.cpp:63
void SetBrushWidth(INT nBrushWidth)
Definition: toolsmodel.cpp:75
INT GetAirBrushRadius() const
Definition: toolsmodel.cpp:183
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1169
void SetLineWidth(int nLineWidth)
Definition: toolsmodel.cpp:51
INT GetBrushWidth() const
Definition: toolsmodel.cpp:70
SIZE GetToolSize() const
Definition: toolsmodel.cpp:205
INT m_penWidth
Definition: toolsmodel.h:71
WPARAM wParam
Definition: combotst.c:138
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
long LONG
Definition: pedump.c:60
void endEvent()
Definition: mouse.cpp:138
virtual BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y)
Definition: toolsmodel.h:50
virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.h:49
HDC m_hdc
Definition: toolsmodel.h:43
virtual void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:125
virtual void OnSpecialTweak(BOOL bMinus)
Definition: toolsmodel.h:56
void reset()
Definition: mouse.cpp:106
static ToolBase * createToolObject(TOOLTYPE type)
Definition: mouse.cpp:1127
COLORREF m_fg
Definition: toolsmodel.h:44
virtual void OnDrawOverlayOnImage(HDC hdc)
Definition: toolsmodel.h:53
void beginEvent()
Definition: mouse.cpp:131
ToolBase()
Definition: toolsmodel.h:46
virtual void OnDrawOverlayOnCanvas(HDC hdc)
Definition: toolsmodel.h:54
virtual BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y)
Definition: toolsmodel.h:51
virtual ~ToolBase()
Definition: toolsmodel.h:47
COLORREF m_bg
Definition: toolsmodel.h:44
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
ToolsModel toolsModel
Definition: toolsmodel.cpp:10
static int UnZoomed(int xy)
Definition: toolsmodel.h:155
TOOLTYPE
Definition: toolsmodel.h:11
@ TOOL_AIRBRUSH
Definition: toolsmodel.h:20
@ TOOL_COLOR
Definition: toolsmodel.h:16
@ TOOL_SHAPE
Definition: toolsmodel.h:25
@ TOOL_RUBBER
Definition: toolsmodel.h:14
@ TOOL_MAX
Definition: toolsmodel.h:28
@ TOOL_BRUSH
Definition: toolsmodel.h:19
@ TOOL_RECT
Definition: toolsmodel.h:24
@ TOOL_BEZIER
Definition: toolsmodel.h:23
@ TOOL_FILL
Definition: toolsmodel.h:15
@ TOOL_TEXT
Definition: toolsmodel.h:21
@ TOOL_PEN
Definition: toolsmodel.h:18
@ TOOL_LINE
Definition: toolsmodel.h:22
@ TOOL_FREESEL
Definition: toolsmodel.h:12
@ TOOL_ZOOM
Definition: toolsmodel.h:17
@ TOOL_ELLIPSE
Definition: toolsmodel.h:26
@ TOOL_RRECT
Definition: toolsmodel.h:27
@ TOOL_RECTSEL
Definition: toolsmodel.h:13
BrushStyle
Definition: toolsmodel.h:32
@ BrushStyleForeSlash
Definition: toolsmodel.h:35
@ BrushStyleRound
Definition: toolsmodel.h:33
@ BrushStyleBackSlash
Definition: toolsmodel.h:36
@ BrushStyleSquare
Definition: toolsmodel.h:34
static int Zoomed(int xy)
Definition: toolsmodel.h:150
int32_t INT
Definition: typedefs.h:58
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300