ReactOS  0.4.15-dev-5126-g3bb451b
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;
21  m_airBrushWidth = 5;
22  m_rubberRadius = 4;
23  m_transpBg = FALSE;
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 
48 void ToolsModel::SetLineWidth(int nLineWidth)
49 {
50  m_lineWidth = nLineWidth;
52 }
53 
55 {
56  return m_shapeStyle;
57 }
58 
59 void ToolsModel::SetShapeStyle(int nShapeStyle)
60 {
61  m_shapeStyle = nShapeStyle;
63 }
64 
66 {
67  return m_brushStyle;
68 }
69 
70 void 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 {
88  OnFinishDraw();
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 
118 void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
119 {
120  m_airBrushWidth = nAirBrushWidth;
122 }
123 
125 {
126  return m_rubberRadius;
127 }
128 
129 void 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 
153 void 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 
191 void 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 
207 void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
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 {
233  m_pToolObject->reset();
234 }
235 
237 {
239  OnButtonDown(TRUE, 0, 0, FALSE);
242 }
ToolBase * m_pToolObject
Definition: toolsmodel.h:85
CToolBox toolBoxContainer
Definition: main.cpp:66
void resetTool()
Definition: toolsmodel.cpp:231
#define TRUE
Definition: types.h:120
void OnCancelDraw()
Definition: toolsmodel.cpp:215
int m_rubberRadius
Definition: toolsmodel.h:81
BOOL IsWindow() const
Definition: atlwin.h:941
void SetLineWidth(int nLineWidth)
Definition: toolsmodel.cpp:48
#define ZeroMemory
Definition: winbase.h:1667
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define ATLTRACE(format,...)
Definition: atltrace.h:276
TOOLTYPE m_oldActiveTool
Definition: toolsmodel.h:79
int GetBrushStyle() const
Definition: toolsmodel.cpp:65
int m_zoom
Definition: toolsmodel.h:83
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.cpp:191
int GetRubberRadius() const
Definition: toolsmodel.cpp:124
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.cpp:199
virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.h:50
BOOL m_transpBg
Definition: toolsmodel.h:82
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
void OnFinishDraw()
Definition: toolsmodel.cpp:223
int m_airBrushWidth
Definition: toolsmodel.h:80
virtual void OnCancelDraw()
Definition: mouse.cpp:85
void SetBackgroundTransparent(BOOL bTransparent)
Definition: toolsmodel.cpp:140
void endEvent()
Definition: mouse.cpp:102
void SetAirBrushWidth(int nAirBrushWidth)
Definition: toolsmodel.cpp:118
int GetWidth() const
Definition: history.cpp:215
void updateStartAndLast(LONG x, LONG y)
Definition: mouse.cpp:64
void updateLast(LONG x, LONG y)
Definition: mouse.cpp:70
TOOLTYPE m_activeTool
Definition: toolsmodel.h:78
ToolBase * m_tools[TOOL_MAX+1]
Definition: toolsmodel.h:84
static ToolBase * createToolObject(TOOLTYPE type)
Definition: mouse.cpp:764
int GetLineWidth() const
Definition: toolsmodel.cpp:43
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.cpp:207
int GetShapeStyle() const
Definition: toolsmodel.cpp:54
int m_brushStyle
Definition: toolsmodel.h:77
void NotifyZoomChanged()
Definition: toolsmodel.cpp:181
void NotifyToolChanged()
Definition: toolsmodel.cpp:159
virtual void OnFinishDraw()
Definition: mouse.cpp:90
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:81
void NotifyToolSettingsChanged()
Definition: toolsmodel.cpp:171
int GetZoom() const
Definition: toolsmodel.cpp:148
void selectAll()
Definition: toolsmodel.cpp:236
void reset()
Definition: mouse.cpp:76
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76
#define WM_TOOLSMODELSETTINGSCHANGED
Definition: precomp.h:33
virtual void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.h:54
ImageModel imageModel
Definition: main.cpp:32
void SetZoom(int nZoom)
Definition: toolsmodel.cpp:153
virtual void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: toolsmodel.h:58
void ForceRefreshSelectionContents()
Definition: selection.cpp:24
void SetShapeStyle(int nShapeStyle)
Definition: toolsmodel.cpp:59
void beginEvent()
Definition: mouse.cpp:95
int GetHeight() const
Definition: history.cpp:220
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
void SetBrushStyle(int nBrushStyle)
Definition: toolsmodel.cpp:70
CFontsDialog fontsDialog
Definition: dialogs.cpp:22
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:86
ToolBase * GetOrCreateTool(TOOLTYPE nTool)
Definition: toolsmodel.cpp:35
int GetAirBrushWidth() const
Definition: toolsmodel.cpp:113
void SetRubberRadius(int nRubberRadius)
Definition: toolsmodel.cpp:129
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WM_TOOLSMODELTOOLCHANGED
Definition: precomp.h:32
#define WM_TOOLSMODELZOOMCHANGED
Definition: precomp.h:34
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110
TOOLTYPE
Definition: toolsmodel.h:11
CTextEditWindow textEditWindow
Definition: main.cpp:81
int m_lineWidth
Definition: toolsmodel.h:75
CToolSettingsWindow toolSettingsWindow
Definition: main.cpp:67
CSelectionWindow selectionWindow
Definition: main.cpp:71
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:135
int m_shapeStyle
Definition: toolsmodel.h:76