ReactOS 0.4.15-dev-5895-g2687c1b
toolsmodel.h
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/mspaint/toolsmodel.h
5 * PURPOSE: Keep track of tool parameters, notify listeners
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9#pragma once
10
12{
30};
31
32/* CLASSES **********************************************************/
33
35{
39 static INT pointSP;
40 static POINT pointStack[256];
41
43 {
44 }
45
46 virtual ~ToolBase()
47 {
48 }
49
50 virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
51 {
52 }
53
54 virtual void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
55 {
56 }
57
58 virtual void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
59 {
60 }
61
62 virtual void OnCancelDraw();
63 virtual void OnFinishDraw();
64
65 void beginEvent();
66 void endEvent();
67 void reset();
68
70};
71
73{
74private:
83 int m_zoom;
86
88
89public:
90 ToolsModel();
92 int GetLineWidth() const;
93 void SetLineWidth(int nLineWidth);
94 int GetShapeStyle() const;
95 void SetShapeStyle(int nShapeStyle);
96 int GetBrushStyle() const;
97 void SetBrushStyle(int nBrushStyle);
98 TOOLTYPE GetActiveTool() const;
100 void SetActiveTool(TOOLTYPE nActiveTool);
101 int GetAirBrushWidth() const;
102 void SetAirBrushWidth(int nAirBrushWidth);
103 int GetRubberRadius() const;
104 void SetRubberRadius(int nRubberRadius);
106 void SetBackgroundTransparent(BOOL bTransparent);
107 int GetZoom() const;
108 void SetZoom(int nZoom);
109
110 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick);
111 void OnMouseMove(BOOL bLeftButton, LONG x, LONG y);
112 void OnButtonUp(BOOL bLeftButton, LONG x, LONG y);
113 void OnCancelDraw();
114 void OnFinishDraw();
115
116 void resetTool();
117 void selectAll();
118
119 void NotifyToolChanged();
121 void NotifyZoomChanged();
122};
123
125
126static inline int Zoomed(int xy)
127{
128 return xy * toolsModel.GetZoom() / 1000;
129}
130
131static inline int UnZoomed(int xy)
132{
133 return xy * 1000 / toolsModel.GetZoom();
134}
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 NULL
Definition: types.h:112
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
static HDC
Definition: imagelist.c:92
long LONG
Definition: pedump.c:60
void endEvent()
Definition: mouse.cpp:106
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
HDC m_hdc
Definition: toolsmodel.h:37
TOOLTYPE m_tool
Definition: toolsmodel.h:36
static INT pointSP
Definition: toolsmodel.h:39
virtual void OnCancelDraw()
Definition: mouse.cpp:89
void reset()
Definition: mouse.cpp:80
virtual void OnFinishDraw()
Definition: mouse.cpp:94
static ToolBase * createToolObject(TOOLTYPE type)
Definition: mouse.cpp:763
COLORREF m_fg
Definition: toolsmodel.h:38
void beginEvent()
Definition: mouse.cpp:99
virtual ~ToolBase()
Definition: toolsmodel.h:46
static POINT pointStack[256]
Definition: toolsmodel.h:40
COLORREF m_bg
Definition: toolsmodel.h:38
ToolBase(TOOLTYPE tool)
Definition: toolsmodel.h:42
ToolsModel toolsModel
Definition: toolsmodel.cpp:11
static int UnZoomed(int xy)
Definition: toolsmodel.h:131
TOOLTYPE
Definition: toolsmodel.h:12
@ TOOL_AIRBRUSH
Definition: toolsmodel.h:21
@ TOOL_COLOR
Definition: toolsmodel.h:17
@ TOOL_SHAPE
Definition: toolsmodel.h:26
@ TOOL_RUBBER
Definition: toolsmodel.h:15
@ TOOL_MAX
Definition: toolsmodel.h:29
@ TOOL_BRUSH
Definition: toolsmodel.h:20
@ TOOL_RECT
Definition: toolsmodel.h:25
@ TOOL_BEZIER
Definition: toolsmodel.h:24
@ TOOL_FILL
Definition: toolsmodel.h:16
@ TOOL_TEXT
Definition: toolsmodel.h:22
@ TOOL_PEN
Definition: toolsmodel.h:19
@ TOOL_LINE
Definition: toolsmodel.h:23
@ TOOL_FREESEL
Definition: toolsmodel.h:13
@ TOOL_ZOOM
Definition: toolsmodel.h:18
@ TOOL_ELLIPSE
Definition: toolsmodel.h:27
@ TOOL_RRECT
Definition: toolsmodel.h:28
@ TOOL_RECTSEL
Definition: toolsmodel.h:14
static int Zoomed(int xy)
Definition: toolsmodel.h:126
int32_t INT
Definition: typedefs.h:58
DWORD COLORREF
Definition: windef.h:300