Create a branch for header work.
[reactos.git] / base / applications / paint / toolsettings.c
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/paint/toolsettings.c
5 * PURPOSE: Window procedure of the tool settings window
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9 /* INCLUDES *********************************************************/
10
11 #include <windows.h>
12 #include <commctrl.h>
13 #include "globalvar.h"
14 #include "drawing.h"
15 #include "winproc.h"
16
17 /* FUNCTIONS ********************************************************/
18
19 extern void zoomTo(int, int, int);
20
21 LRESULT CALLBACK
22 SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
23 {
24 switch (message)
25 {
26 case WM_VSCROLL:
27 zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
28 break;
29 case WM_PAINT:
30 {
31 HDC hdc = GetDC(hwnd);
32 RECT rect1 = { 0, 0, 42, 66 };
33 RECT rect2 = { 0, 70, 42, 136 };
34
35 DefWindowProc(hwnd, message, wParam, lParam);
36
37 DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == 6) ? BF_RECT : BF_RECT | BF_MIDDLE);
38 DrawEdge(hdc, &rect2, (activeTool >= 13) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
39 switch (activeTool)
40 {
41 case 1:
42 case 2:
43 case 10:
44 {
45 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
46 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
47 Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33);
48 DeleteObject(SelectObject(hdc, oldPen));
49 DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL);
50 DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL);
51 break;
52 }
53 case 3:
54 {
55 int i;
56 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
57 for(i = 0; i < 4; i++)
58 {
59 if (rubberRadius == i + 2)
60 {
61 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
62 Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17);
63 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
64 }
65 else
66 SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
67 Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12);
68 }
69 DeleteObject(SelectObject(hdc, oldPen));
70 break;
71 }
72 case 8:
73 {
74 int i;
75 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
76 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
77 Rectangle(hdc, brushStyle % 3 * 13 + 2, brushStyle / 3 * 15 + 2, brushStyle % 3 * 13 + 15,
78 brushStyle / 3 * 15 + 17);
79 DeleteObject(SelectObject(hdc, oldPen));
80 for(i = 0; i < 12; i++)
81 Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8,
82 GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i);
83 break;
84 }
85 case 9:
86 {
87 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
88 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
89 switch (airBrushWidth)
90 {
91 case 5:
92 Rectangle(hdc, 2, 2, 21, 31);
93 break;
94 case 8:
95 Rectangle(hdc, 20, 2, 41, 31);
96 break;
97 case 3:
98 Rectangle(hdc, 2, 30, 16, 61);
99 break;
100 case 12:
101 Rectangle(hdc, 15, 30, 41, 61);
102 break;
103 }
104 Airbrush(hdc, 10, 15,
105 GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5);
106 Airbrush(hdc, 30, 15,
107 GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8);
108 Airbrush(hdc, 8, 45,
109 GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3);
110 Airbrush(hdc, 27, 45,
111 GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12);
112 DeleteObject(SelectObject(hdc, oldPen));
113 break;
114 }
115 case 11:
116 case 12:
117 {
118 int i;
119 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
120 for(i = 0; i < 5; i++)
121 {
122 if (lineWidth == i + 1)
123 {
124 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
125 Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14);
126 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
127 }
128 else
129 SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
130 Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i);
131 }
132 DeleteObject(SelectObject(hdc, oldPen));
133 break;
134 }
135 case 13:
136 case 14:
137 case 15:
138 case 16:
139 {
140 int i;
141 HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
142 for(i = 0; i < 3; i++)
143 {
144 if (shapeStyle == i)
145 {
146 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
147 Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22);
148 }
149 }
150 Rect(hdc, 5, 6, 37, 16,
151 GetSysColor((shapeStyle == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
152 GetSysColor(COLOR_APPWORKSPACE), 1, 0);
153 Rect(hdc, 5, 26, 37, 36,
154 GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
155 GetSysColor(COLOR_APPWORKSPACE), 1, 1);
156 Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE),
157 1, 1);
158 for(i = 0; i < 5; i++)
159 {
160 if (lineWidth == i + 1)
161 {
162 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
163 Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84);
164 SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
165 }
166 else
167 SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
168 Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i);
169 }
170 DeleteObject(SelectObject(hdc, oldPen));
171 break;
172 }
173 }
174 ReleaseDC(hwnd, hdc);
175 break;
176 }
177 case WM_LBUTTONDOWN:
178 {
179 switch (activeTool)
180 {
181 case 1:
182 case 2:
183 case 10:
184 if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 64))
185 {
186 transpBg = (HIWORD(lParam) - 2) / 31;
187 SendMessage(hwnd, WM_PAINT, 0, 0);
188 }
189 break;
190 case 3:
191 if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 62))
192 {
193 rubberRadius = (HIWORD(lParam) - 2) / 15 + 2;
194 SendMessage(hwnd, WM_PAINT, 0, 0);
195 }
196 break;
197 case 8:
198 if ((LOWORD(lParam) > 1) && (LOWORD(lParam) < 40) && (HIWORD(lParam) > 1)
199 && (HIWORD(lParam) < 62))
200 {
201 brushStyle = (HIWORD(lParam) - 2) / 15 * 3 + (LOWORD(lParam) - 2) / 13;
202 SendMessage(hwnd, WM_PAINT, 0, 0);
203 }
204 break;
205 case 9:
206 if (HIWORD(lParam) < 62)
207 {
208 if (HIWORD(lParam) < 30)
209 {
210 if (LOWORD(lParam) < 20)
211 airBrushWidth = 5;
212 else
213 airBrushWidth = 8;
214 }
215 else
216 {
217 if (LOWORD(lParam) < 15)
218 airBrushWidth = 3;
219 else
220 airBrushWidth = 12;
221 }
222 SendMessage(hwnd, WM_PAINT, 0, 0);
223 }
224 break;
225 case 11:
226 case 12:
227 if (HIWORD(lParam) <= 62)
228 {
229 lineWidth = (HIWORD(lParam) - 2) / 12 + 1;
230 SendMessage(hwnd, WM_PAINT, 0, 0);
231 }
232 break;
233 case 13:
234 case 14:
235 case 15:
236 case 16:
237 if (HIWORD(lParam) <= 60)
238 {
239 shapeStyle = (HIWORD(lParam) - 2) / 20;
240 SendMessage(hwnd, WM_PAINT, 0, 0);
241 }
242 if ((HIWORD(lParam) >= 70) && (HIWORD(lParam) <= 132))
243 {
244 lineWidth = (HIWORD(lParam) - 72) / 12 + 1;
245 SendMessage(hwnd, WM_PAINT, 0, 0);
246 }
247 break;
248 }
249 break;
250 }
251
252 default:
253 return DefWindowProc(hwnd, message, wParam, lParam);
254 }
255
256 return 0;
257 }