2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/paint/toolsettings.c
5 * PURPOSE: Window procedure of the tool settings window
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
12 #include "toolsettings.h"
14 /* FUNCTIONS ********************************************************/
16 extern void zoomTo(int, int, int);
18 void RegisterWclSettings()
20 WNDCLASSEX wclSettings
;
21 /* initializing and registering the window class for the settings window */
22 wclSettings
.hInstance
= hProgInstance
;
23 wclSettings
.lpszClassName
= _T("ToolSettings");
24 wclSettings
.lpfnWndProc
= SettingsWinProc
;
25 wclSettings
.style
= CS_DBLCLKS
;
26 wclSettings
.cbSize
= sizeof(WNDCLASSEX
);
27 wclSettings
.hIcon
= NULL
;
28 wclSettings
.hIconSm
= NULL
;
29 wclSettings
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
30 wclSettings
.lpszMenuName
= NULL
;
31 wclSettings
.cbClsExtra
= 0;
32 wclSettings
.cbWndExtra
= 0;
33 wclSettings
.hbrBackground
= GetSysColorBrush(COLOR_BTNFACE
);
34 RegisterClassEx (&wclSettings
);
38 SettingsWinProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
43 zoomTo(125 << SendMessage(hTrackbarZoom
, TBM_GETPOS
, 0, 0), 0, 0);
47 HDC hdc
= GetDC(hwnd
);
48 RECT rect1
= { 0, 0, 42, 66 };
49 RECT rect2
= { 0, 70, 42, 136 };
51 DefWindowProc(hwnd
, message
, wParam
, lParam
);
53 DrawEdge(hdc
, &rect1
, BDR_SUNKENOUTER
, (activeTool
== TOOL_ZOOM
) ? BF_RECT
: BF_RECT
| BF_MIDDLE
);
54 DrawEdge(hdc
, &rect2
, (activeTool
>= TOOL_RECT
) ? BDR_SUNKENOUTER
: 0, BF_RECT
| BF_MIDDLE
);
61 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
62 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
63 Rectangle(hdc
, 2, transpBg
* 31 + 2, 41, transpBg
* 31 + 33);
64 DeleteObject(SelectObject(hdc
, oldPen
));
65 DrawIconEx(hdc
, 1, 2, hNontranspIcon
, 40, 30, 0, NULL
, DI_NORMAL
);
66 DrawIconEx(hdc
, 1, 33, hTranspIcon
, 40, 30, 0, NULL
, DI_NORMAL
);
72 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
73 for(i
= 0; i
< 4; i
++)
75 if (rubberRadius
== i
+ 2)
77 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
78 Rectangle(hdc
, 14, i
* 15 + 2, 29, i
* 15 + 17);
79 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
82 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
83 Rectangle(hdc
, 19 - i
, i
* 14 + 7, 24 + i
, i
* 16 + 12);
85 DeleteObject(SelectObject(hdc
, oldPen
));
91 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
92 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
93 Rectangle(hdc
, brushStyle
% 3 * 13 + 2, brushStyle
/ 3 * 15 + 2, brushStyle
% 3 * 13 + 15,
94 brushStyle
/ 3 * 15 + 17);
95 DeleteObject(SelectObject(hdc
, oldPen
));
96 for(i
= 0; i
< 12; i
++)
97 Brush(hdc
, i
% 3 * 13 + 7, i
/ 3 * 15 + 8, i
% 3 * 13 + 7, i
/ 3 * 15 + 8,
98 GetSysColor((i
== brushStyle
) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), i
);
103 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
104 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
105 switch (airBrushWidth
)
108 Rectangle(hdc
, 2, 2, 21, 31);
111 Rectangle(hdc
, 20, 2, 41, 31);
114 Rectangle(hdc
, 2, 30, 16, 61);
117 Rectangle(hdc
, 15, 30, 41, 61);
120 Airbrush(hdc
, 10, 15,
121 GetSysColor((airBrushWidth
== 5) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 5);
122 Airbrush(hdc
, 30, 15,
123 GetSysColor((airBrushWidth
== 8) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 8);
125 GetSysColor((airBrushWidth
== 3) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 3);
126 Airbrush(hdc
, 27, 45,
127 GetSysColor((airBrushWidth
== 12) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
), 12);
128 DeleteObject(SelectObject(hdc
, oldPen
));
135 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
136 for(i
= 0; i
< 5; i
++)
138 if (lineWidth
== i
+ 1)
140 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
141 Rectangle(hdc
, 2, i
* 12 + 2, 41, i
* 12 + 14);
142 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
145 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
146 Rectangle(hdc
, 5, i
* 12 + 6, 38, i
* 12 + 8 + i
);
148 DeleteObject(SelectObject(hdc
, oldPen
));
157 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_NULL
, 0, 0));
158 for(i
= 0; i
< 3; i
++)
162 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
163 Rectangle(hdc
, 2, i
* 20 + 2, 41, i
* 20 + 22);
166 Rect(hdc
, 5, 6, 37, 16,
167 GetSysColor((shapeStyle
== 0) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
),
168 GetSysColor(COLOR_APPWORKSPACE
), 1, 0);
169 Rect(hdc
, 5, 26, 37, 36,
170 GetSysColor((shapeStyle
== 1) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
),
171 GetSysColor(COLOR_APPWORKSPACE
), 1, 1);
172 Rect(hdc
, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE
), GetSysColor(COLOR_APPWORKSPACE
),
174 for(i
= 0; i
< 5; i
++)
176 if (lineWidth
== i
+ 1)
178 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHT
));
179 Rectangle(hdc
, 2, i
* 12 + 72, 41, i
* 12 + 84);
180 SelectObject(hdc
, GetSysColorBrush(COLOR_HIGHLIGHTTEXT
));
183 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOWTEXT
));
184 Rectangle(hdc
, 5, i
* 12 + 76, 38, i
* 12 + 78 + i
);
186 DeleteObject(SelectObject(hdc
, oldPen
));
190 ReleaseDC(hwnd
, hdc
);
195 int x
= GET_X_LPARAM(lParam
);
196 int y
= GET_Y_LPARAM(lParam
);
202 if ((y
> 1) && (y
< 64))
204 transpBg
= (y
- 2) / 31;
205 InvalidateRect(hwnd
, NULL
, TRUE
);
207 ForceRefreshSelectionContents();
211 if ((y
> 1) && (y
< 62))
213 rubberRadius
= (y
- 2) / 15 + 2;
214 InvalidateRect(hwnd
, NULL
, TRUE
);
218 if ((x
> 1) && (x
< 40) && (y
> 1)
221 brushStyle
= (y
- 2) / 15 * 3 + (x
- 2) / 13;
222 InvalidateRect(hwnd
, NULL
, TRUE
);
242 InvalidateRect(hwnd
, NULL
, TRUE
);
249 lineWidth
= (y
- 2) / 12 + 1;
250 InvalidateRect(hwnd
, NULL
, TRUE
);
259 shapeStyle
= (y
- 2) / 20;
260 InvalidateRect(hwnd
, NULL
, TRUE
);
262 if ((y
>= 70) && (y
<= 132))
264 lineWidth
= (y
- 72) / 12 + 1;
265 InvalidateRect(hwnd
, NULL
, TRUE
);
273 return DefWindowProc(hwnd
, message
, wParam
, lParam
);