ReactOS 0.4.15-dev-5666-gc548b97
toolsmodel.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/mspaint/toolsmodel.cpp
5 * PURPOSE: Keep track of tool parameters, notify listeners
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9/* INCLUDES *********************************************************/
10
11#include "precomp.h"
12
13/* FUNCTIONS ********************************************************/
14
16{
17 m_lineWidth = 1;
18 m_shapeStyle = 0;
19 m_brushStyle = 0;
24 m_zoom = 1000;
25 ZeroMemory(&m_tools, sizeof(m_tools));
27}
28
30{
31 for (size_t i = 0; i < TOOL_MAX + 1; ++i)
32 delete m_tools[i];
33}
34
36{
37 if (!m_tools[nTool])
38 m_tools[nTool] = ToolBase::createToolObject(nTool);
39
40 return m_tools[nTool];
41}
42
44{
45 return m_lineWidth;
46}
47
48void ToolsModel::SetLineWidth(int nLineWidth)
49{
50 m_lineWidth = nLineWidth;
52}
53
55{
56 return m_shapeStyle;
57}
58
59void ToolsModel::SetShapeStyle(int nShapeStyle)
60{
61 m_shapeStyle = nShapeStyle;
63}
64
66{
67 return m_brushStyle;
68}
69
70void ToolsModel::SetBrushStyle(int nBrushStyle)
71{
72 m_brushStyle = nBrushStyle;
74}
75
77{
78 return m_activeTool;
79}
80
82{
83 return m_oldActiveTool;
84}
85
87{
89
90 if (m_activeTool == nActiveTool)
91 return;
92
93 switch (m_activeTool)
94 {
95 case TOOL_FREESEL:
96 case TOOL_RECTSEL:
97 case TOOL_RUBBER:
98 case TOOL_COLOR:
99 case TOOL_ZOOM:
100 case TOOL_TEXT:
101 break;
102
103 default:
105 break;
106 }
107
108 m_activeTool = nActiveTool;
111}
112
114{
115 return m_airBrushWidth;
116}
117
118void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
119{
120 m_airBrushWidth = nAirBrushWidth;
122}
123
125{
126 return m_rubberRadius;
127}
128
129void ToolsModel::SetRubberRadius(int nRubberRadius)
130{
131 m_rubberRadius = nRubberRadius;
133}
134
136{
137 return m_transpBg;
138}
139
141{
142 m_transpBg = bTransparent;
144 if (selectionWindow.IsWindow())
146}
147
149{
150 return m_zoom;
151}
152
153void ToolsModel::SetZoom(int nZoom)
154{
155 m_zoom = nZoom;
157}
158
160{
163 if (toolSettingsWindow.IsWindow())
165 if (fontsDialog.IsWindow())
167 if (textEditWindow.IsWindow())
169}
170
172{
173 if (toolSettingsWindow.IsWindow())
175 if (selectionWindow.IsWindow())
177 if (textEditWindow.IsWindow())
179}
180
182{
183 if (toolSettingsWindow.IsWindow())
185 if (textEditWindow.IsWindow())
187 if (selectionWindow.IsWindow())
189}
190
191void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
192{
195 m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
197}
198
200{
202 m_pToolObject->OnMouseMove(bLeftButton, x, y);
203 updateLast(x, y);
205}
206
208{
210 m_pToolObject->OnButtonUp(bLeftButton, x, y);
211 updateLast(x, y);
213}
214
216{
217 ATLTRACE("ToolsModel::OnCancelDraw()\n");
221}
222
224{
225 ATLTRACE("ToolsModel::OnFinishDraw()\n");
229}
230
232{
234}
235
237{
239 OnButtonDown(TRUE, 0, 0, FALSE);
242}
#define ATLTRACE(format,...)
Definition: atltrace.h:276
void updateLast(LONG x, LONG y)
Definition: mouse.cpp:70
void updateStartAndLast(LONG x, LONG y)
Definition: mouse.cpp:64
CFontsDialog fontsDialog
Definition: dialogs.cpp:22
#define WM_TOOLSMODELZOOMCHANGED
Definition: precomp.h:34
#define WM_TOOLSMODELTOOLCHANGED
Definition: precomp.h:32
#define WM_TOOLSMODELSETTINGSCHANGED
Definition: precomp.h:33
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110
BOOL IsWindow() const
Definition: atlwin.h:941
void ForceRefreshSelectionContents()
Definition: selection.cpp:24
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
int GetZoom() const
Definition: toolsmodel.cpp:148
int GetAirBrushWidth() const
Definition: toolsmodel.cpp:113
TOOLTYPE m_oldActiveTool
Definition: toolsmodel.h:79
int GetLineWidth() const
Definition: toolsmodel.cpp:43
int m_airBrushWidth
Definition: toolsmodel.h:80
int GetShapeStyle() const
Definition: toolsmodel.cpp:54
int m_brushStyle
Definition: toolsmodel.h:77
int m_rubberRadius
Definition: toolsmodel.h:81
int m_lineWidth
Definition: toolsmodel.h:75
void resetTool()
Definition: toolsmodel.cpp:231
BOOL m_transpBg
Definition: toolsmodel.h:82
void SetAirBrushWidth(int nAirBrushWidth)
Definition: toolsmodel.cpp:118
int m_shapeStyle
Definition: toolsmodel.h:76
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:81
void SetShapeStyle(int nShapeStyle)
Definition: toolsmodel.cpp:59
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:86
ToolBase * m_tools[TOOL_MAX+1]
Definition: toolsmodel.h:84
void SetRubberRadius(int nRubberRadius)
Definition: toolsmodel.cpp:129
void OnFinishDraw()
Definition: toolsmodel.cpp:223
void NotifyToolChanged()
Definition: toolsmodel.cpp:159
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.cpp:199
void SetBrushStyle(int nBrushStyle)
Definition: toolsmodel.cpp:70
int m_zoom
Definition: toolsmodel.h:83
int GetBrushStyle() const
Definition: toolsmodel.cpp:65
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.cpp:191
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:135
void SetZoom(int nZoom)
Definition: toolsmodel.cpp:153
void SetBackgroundTransparent(BOOL bTransparent)
Definition: toolsmodel.cpp:140
TOOLTYPE m_activeTool
Definition: toolsmodel.h:78
int GetRubberRadius() const
Definition: toolsmodel.cpp:124
ToolBase * m_pToolObject
Definition: toolsmodel.h:85
void NotifyToolSettingsChanged()
Definition: toolsmodel.cpp:171
ToolBase * GetOrCreateTool(TOOLTYPE nTool)
Definition: toolsmodel.cpp:35
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76
void OnCancelDraw()
Definition: toolsmodel.cpp:215
void selectAll()
Definition: toolsmodel.cpp:236
void NotifyZoomChanged()
Definition: toolsmodel.cpp:181
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.cpp:207
void SetLineWidth(int nLineWidth)
Definition: toolsmodel.cpp:48
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CSelectionWindow selectionWindow
Definition: main.cpp:71
ImageModel imageModel
Definition: main.cpp:32
CToolBox toolBoxContainer
Definition: main.cpp:66
CTextEditWindow textEditWindow
Definition: main.cpp:81
CToolSettingsWindow toolSettingsWindow
Definition: main.cpp:67
long LONG
Definition: pedump.c:60
void endEvent()
Definition: mouse.cpp:102
virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.h:50
virtual void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.h:58
virtual void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.h:54
virtual void OnCancelDraw()
Definition: mouse.cpp:85
void reset()
Definition: mouse.cpp:76
virtual void OnFinishDraw()
Definition: mouse.cpp:90
static ToolBase * createToolObject(TOOLTYPE type)
Definition: mouse.cpp:764
void beginEvent()
Definition: mouse.cpp:95
TOOLTYPE
Definition: toolsmodel.h:12
@ TOOL_COLOR
Definition: toolsmodel.h:17
@ TOOL_RUBBER
Definition: toolsmodel.h:15
@ TOOL_MAX
Definition: toolsmodel.h:29
@ TOOL_TEXT
Definition: toolsmodel.h:22
@ TOOL_PEN
Definition: toolsmodel.h:19
@ TOOL_FREESEL
Definition: toolsmodel.h:13
@ TOOL_ZOOM
Definition: toolsmodel.h:18
@ TOOL_RECTSEL
Definition: toolsmodel.h:14
#define ZeroMemory
Definition: winbase.h:1670