2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/mspaint/toolsettings.cpp
5 * PURPOSE: Window procedure of the tool settings window
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
13 /* FUNCTIONS ********************************************************/
15 extern void zoomTo(int, int, int);
17 LRESULT
CToolSettingsWindow::OnCreate(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, WINBOOL
& bHandled
)
19 RECT trackbarZoomPos
= {1, 1, 1 + 40, 1 + 64};
20 trackbarZoom
.Create(TRACKBAR_CLASS
, m_hWnd
, trackbarZoomPos
, NULL
, WS_CHILD
| TBS_VERT
| TBS_AUTOTICKS
);
21 trackbarZoom
.SendMessage(TBM_SETRANGE
, (WPARAM
) TRUE
, MAKELPARAM(0, 6));
22 trackbarZoom
.SendMessage(TBM_SETPOS
, (WPARAM
) TRUE
, (LPARAM
) 3);
26 LRESULT
CToolSettingsWindow::OnVScroll(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
28 zoomTo(125 << trackbarZoom
.SendMessage(TBM_GETPOS
, 0, 0), 0, 0);
32 LRESULT
CToolSettingsWindow::OnPaint(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
35 RECT rect1
= { 0, 0, 42, 66 };
36 RECT rect2
= { 0, 70, 42, 136 };
38 DefWindowProc(WM_PAINT
, wParam
, lParam
);
40 DrawEdge(hdc
, &rect1
, BDR_SUNKENOUTER
, (toolsModel
.GetActiveTool() == TOOL_ZOOM
) ? BF_RECT
: BF_RECT
| BF_MIDDLE
);
41 DrawEdge(hdc
, &rect2
, (toolsModel
.GetActiveTool() >= TOOL_RECT
) ? BDR_SUNKENOUTER
: 0, BF_RECT
| BF_MIDDLE
);
42 switch (toolsModel
.GetActiveTool())
48 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
49 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
50 Rectangle(hdc
, 2, toolsModel
.IsBackgroundTransparent() * 31 + 2, 41, toolsModel
.IsBackgroundTransparent() * 31 + 33);
51 DeleteObject(SelectObject(hdc
, oldPen
));
52 DrawIconEx(hdc
, 1, 2, hNontranspIcon
, 40, 30, 0, NULL
, DI_NORMAL
);
53 DrawIconEx(hdc
, 1, 33, hTranspIcon
, 40, 30, 0, NULL
, DI_NORMAL
);
59 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
60 for(i
= 0; i
< 4; i
++)
62 if (toolsModel
.GetRubberRadius() == i
+ 2)
64 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
65 Rectangle(hdc
, 14, i
* 15 + 2, 29, i
* 15 + 17);
66 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
69 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
70 Rectangle(hdc
, 19 - i
, i
* 14 + 7, 24 + i
, i
* 16 + 12);
72 DeleteObject(SelectObject(hdc
, oldPen
));
78 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
79 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
80 Rectangle(hdc
, toolsModel
.GetBrushStyle() % 3 * 13 + 2, toolsModel
.GetBrushStyle() / 3 * 15 + 2, toolsModel
.GetBrushStyle() % 3 * 13 + 15,
81 toolsModel
.GetBrushStyle() / 3 * 15 + 17);
82 DeleteObject(SelectObject(hdc
, oldPen
));
83 for(i
= 0; i
< 12; i
++)
84 Brush(hdc
, i
% 3 * 13 + 7, i
/ 3 * 15 + 8, i
% 3 * 13 + 7, i
/ 3 * 15 + 8,
85 GetSysColor((i
== toolsModel
.GetBrushStyle()) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), i
);
90 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
91 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
92 switch (toolsModel
.GetAirBrushWidth())
95 Rectangle(hdc
, 2, 2, 21, 31);
98 Rectangle(hdc
, 20, 2, 41, 31);
101 Rectangle(hdc
, 2, 30, 16, 61);
104 Rectangle(hdc
, 15, 30, 41, 61);
107 Airbrush(hdc
, 10, 15,
108 GetSysColor((toolsModel
.GetAirBrushWidth() == 5) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 5);
109 Airbrush(hdc
, 30, 15,
110 GetSysColor((toolsModel
.GetAirBrushWidth() == 8) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 8);
112 GetSysColor((toolsModel
.GetAirBrushWidth() == 3) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 3);
113 Airbrush(hdc
, 27, 45,
114 GetSysColor((toolsModel
.GetAirBrushWidth() == 12) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 12);
115 DeleteObject(SelectObject(hdc
, oldPen
));
122 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
123 for(i
= 0; i
< 5; i
++)
125 if (toolsModel
.GetLineWidth() == i
+ 1)
127 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
128 Rectangle(hdc
, 2, i
* 12 + 2, 41, i
* 12 + 14);
129 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
132 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
133 Rectangle(hdc
, 5, i
* 12 + 6, 38, i
* 12 + 8 + i
);
135 DeleteObject(SelectObject(hdc
, oldPen
));
144 HPEN oldPen
= (HPEN
) SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
145 for(i
= 0; i
< 3; i
++)
147 if (toolsModel
.GetShapeStyle() == i
)
149 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
150 Rectangle(hdc
, 2, i
* 20 + 2, 41, i
* 20 + 22);
153 Rect(hdc
, 5, 6, 37, 16,
154 GetSysColor((toolsModel
.GetShapeStyle() == 0) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
),
155 GetSysColor(COLOR_APPWORKSPACE
), 1, 0);
156 Rect(hdc
, 5, 26, 37, 36,
157 GetSysColor((toolsModel
.GetShapeStyle() == 1) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
),
158 GetSysColor(COLOR_APPWORKSPACE
), 1, 1);
159 Rect(hdc
, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE
), GetSysColor(COLOR_APPWORKSPACE
),
161 for(i
= 0; i
< 5; i
++)
163 if (toolsModel
.GetLineWidth() == i
+ 1)
165 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
166 Rectangle(hdc
, 2, i
* 12 + 72, 41, i
* 12 + 84);
167 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
170 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
171 Rectangle(hdc
, 5, i
* 12 + 76, 38, i
* 12 + 78 + i
);
173 DeleteObject(SelectObject(hdc
, oldPen
));
181 LRESULT
CToolSettingsWindow::OnLButtonDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
183 int x
= GET_X_LPARAM(lParam
);
184 int y
= GET_Y_LPARAM(lParam
);
185 switch (toolsModel
.GetActiveTool())
190 if ((y
> 1) && (y
< 64))
191 toolsModel
.SetBackgroundTransparent((y
- 2) / 31);
194 if ((y
> 1) && (y
< 62))
195 toolsModel
.SetRubberRadius((y
- 2) / 15 + 2);
198 if ((x
> 1) && (x
< 40) && (y
> 1) && (y
< 62))
199 toolsModel
.SetBrushStyle((y
- 2) / 15 * 3 + (x
- 2) / 13);
207 toolsModel
.SetAirBrushWidth(5);
209 toolsModel
.SetAirBrushWidth(8);
214 toolsModel
.SetAirBrushWidth(3);
216 toolsModel
.SetAirBrushWidth(12);
223 toolsModel
.SetLineWidth((y
- 2) / 12 + 1);
230 toolsModel
.SetShapeStyle((y
- 2) / 20);
231 if ((y
>= 70) && (y
<= 132))
232 toolsModel
.SetLineWidth((y
- 72) / 12 + 1);
238 LRESULT
CToolSettingsWindow::OnToolsModelToolChanged(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
241 trackbarZoom
.ShowWindow((wParam
== TOOL_ZOOM
) ? SW_SHOW
: SW_HIDE
);
245 LRESULT
CToolSettingsWindow::OnToolsModelSettingsChanged(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
251 LRESULT
CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
254 int tempZoom
= toolsModel
.GetZoom();
256 while (tempZoom
> 125)
259 tempZoom
= tempZoom
>> 1;
261 trackbarZoom
.SendMessage(TBM_SETPOS
, (WPARAM
) TRUE
, (LPARAM
) tbPos
);