96fe59db2256895ccc1fe3260e4adfe521fd4d59
[reactos.git] / reactos / base / applications / paint / winproc.c
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: winproc.c
5 * PURPOSE: Window procedure of the main window and all children apart from
6 * hPalWin, hToolSettings and hSelection
7 * PROGRAMMERS: Benedikt Freisen
8 */
9
10 /* INCLUDES *********************************************************/
11
12 #include <windows.h>
13 #include <commctrl.h>
14 //#include <htmlhelp.h>
15 #include <stdio.h>
16 #include <tchar.h>
17 #include "definitions.h"
18 #include "globalvar.h"
19 #include "dialogs.h"
20 #include "dib.h"
21 #include "drawing.h"
22 #include "history.h"
23 #include "mouse.h"
24
25 /* FUNCTIONS ********************************************************/
26
27 void selectTool(int tool)
28 {
29 ShowWindow(hSelection, SW_HIDE);
30 activeTool = tool;
31 SendMessage(hToolSettings, WM_PAINT, 0, 0);
32 }
33
34 void updateCanvasAndScrollbars()
35 {
36 ShowWindow(hSelection, SW_HIDE);
37 MoveWindow(hImageArea, 3, 3, imgXRes*zoom/1000, imgYRes*zoom/1000, FALSE);
38 InvalidateRect(hScrollbox, NULL, TRUE);
39 InvalidateRect(hImageArea, NULL, FALSE);
40
41 SetScrollPos(hScrollbox, SB_HORZ, 0, TRUE);
42 SetScrollPos(hScrollbox, SB_VERT, 0, TRUE);
43 }
44
45 void ZoomTo(int newZoom)
46 {
47 zoom = newZoom;
48 updateCanvasAndScrollbars();
49 }
50
51 HDC hdc;
52 BOOL drawing;
53
54 LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
55 {
56 switch (message) /* handle the messages */
57 {
58 case WM_DESTROY:
59 PostQuitMessage (0); /* send a WM_QUIT to the message queue */
60 break;
61 case WM_CLOSE:
62 if (undoSteps>0)
63 {
64 TCHAR programname[20];
65 TCHAR saveprompttext[100];
66 LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
67 LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
68 TCHAR temptext[500];
69 _stprintf(temptext, saveprompttext, filename);
70 switch (MessageBox(hwnd, temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
71 {
72 case IDNO:
73 DestroyWindow(hwnd);
74 break;
75 case IDYES:
76 SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0);
77 DestroyWindow(hwnd);
78 break;
79 }
80 }
81 else
82 {
83 DestroyWindow(hwnd);
84 }
85 break;
86 case WM_INITMENUPOPUP:
87 switch (lParam)
88 {
89 case 0:
90 if (FALSE)
91 {
92 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, MF_ENABLED | MF_BYCOMMAND);
93 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, MF_ENABLED | MF_BYCOMMAND);
94 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, MF_ENABLED | MF_BYCOMMAND);
95 }
96 else
97 {
98 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, MF_GRAYED | MF_BYCOMMAND);
99 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, MF_GRAYED | MF_BYCOMMAND);
100 EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, MF_GRAYED | MF_BYCOMMAND);
101 }
102 break;
103 case 1:
104 if (undoSteps>0)
105 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITUNDO, MF_ENABLED | MF_BYCOMMAND);
106 else
107 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITUNDO, MF_GRAYED | MF_BYCOMMAND);
108 if (redoSteps>0)
109 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITREDO, MF_ENABLED | MF_BYCOMMAND);
110 else
111 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITREDO, MF_GRAYED | MF_BYCOMMAND);
112 if (IsWindowVisible(hSelection))
113 {
114 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCUT, MF_ENABLED | MF_BYCOMMAND);
115 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCOPY, MF_ENABLED | MF_BYCOMMAND);
116 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITDELETESELECTION, MF_ENABLED | MF_BYCOMMAND);
117 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITINVERTSELECTION, MF_ENABLED | MF_BYCOMMAND);
118 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCOPYTO, MF_ENABLED | MF_BYCOMMAND);
119 }
120 else
121 {
122 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCUT, MF_GRAYED | MF_BYCOMMAND);
123 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCOPY, MF_GRAYED | MF_BYCOMMAND);
124 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITDELETESELECTION, MF_GRAYED | MF_BYCOMMAND);
125 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITINVERTSELECTION, MF_GRAYED | MF_BYCOMMAND);
126 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCOPYTO, MF_GRAYED | MF_BYCOMMAND);
127 }
128 OpenClipboard(hMainWnd);
129 if (GetClipboardData(CF_BITMAP)!=NULL)
130 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITPASTE, MF_ENABLED | MF_BYCOMMAND);
131 else
132 EnableMenuItem(GetMenu(hMainWnd), IDM_EDITPASTE, MF_GRAYED | MF_BYCOMMAND);
133 CloseClipboard();
134 break;
135 case 3:
136 if (IsWindowVisible(hSelection))
137 EnableMenuItem(GetMenu(hMainWnd), IDM_IMAGECROP, MF_ENABLED | MF_BYCOMMAND);
138 else
139 EnableMenuItem(GetMenu(hMainWnd), IDM_IMAGECROP, MF_GRAYED | MF_BYCOMMAND);
140 if (transpBg==0)
141 CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, MF_CHECKED | MF_BYCOMMAND);
142 else
143 CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, MF_UNCHECKED | MF_BYCOMMAND);
144 break;
145 }
146 break;
147 case WM_SIZE:
148 if (hwnd==hMainWnd)
149 {
150 int test[] = {LOWORD(lParam)-260, LOWORD(lParam)-140, LOWORD(lParam)-20};
151 SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
152 SendMessage(hStatusBar, SB_SETPARTS, 3, (int)&test);
153 MoveWindow(hScrollbox, 56, 49,LOWORD(lParam)-56, HIWORD(lParam)-72, TRUE);
154 //InvalidateRect(hwnd, NULL, TRUE);
155 }
156 if ((hwnd==hImageArea)||(hwnd==hScrollbox))
157 {
158 long clientRectScrollbox[4];
159 GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
160 long clientRectImageArea[4];
161 GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
162 MoveWindow(hScrlClient, 0, 0, max(clientRectImageArea[2]+6, clientRectScrollbox[2]), max(clientRectImageArea[3]+6, clientRectScrollbox[3]), TRUE);
163 SCROLLINFO horzScroll;
164 horzScroll.cbSize = sizeof(SCROLLINFO);
165 horzScroll.fMask = SIF_PAGE | SIF_RANGE;
166 horzScroll.nMax = 10000;
167 horzScroll.nMin = 0;
168 horzScroll.nPage = clientRectScrollbox[2]*10000/(clientRectImageArea[2]+6);
169 horzScroll.nPos = 0;
170 horzScroll.nTrackPos = 0;
171 SetScrollInfo(hScrollbox, SB_HORZ, &horzScroll, TRUE);
172 GetClientRect(hScrollbox, (LPRECT)clientRectScrollbox);
173 SCROLLINFO vertScroll;
174 vertScroll.cbSize = sizeof(SCROLLINFO);
175 vertScroll.fMask = SIF_PAGE | SIF_RANGE;
176 vertScroll.nMax = 10000;
177 vertScroll.nMin = 0;
178 vertScroll.nPage = clientRectScrollbox[3]*10000/(clientRectImageArea[3]+6);
179 vertScroll.nPos = 0;
180 vertScroll.nTrackPos = 0;
181 SetScrollInfo(hScrollbox, SB_VERT, &vertScroll, TRUE);
182 }
183 break;
184 case WM_HSCROLL:
185 if (hwnd==hScrollbox)
186 {
187 if ((LOWORD(wParam)==SB_THUMBPOSITION)||(LOWORD(wParam)==SB_THUMBTRACK))
188 {
189 SetScrollPos(hScrollbox, SB_HORZ, HIWORD(wParam), TRUE);
190 MoveWindow(hScrlClient, -(imgXRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_HORZ)/10000,
191 -(imgYRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_VERT)/10000, imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
192 }
193 }
194 break;
195 case WM_VSCROLL:
196 if (hwnd==hScrollbox)
197 {
198 if ((LOWORD(wParam)==SB_THUMBPOSITION)||(LOWORD(wParam)==SB_THUMBTRACK))
199 {
200 SetScrollPos(hScrollbox, SB_VERT, HIWORD(wParam), TRUE);
201 MoveWindow(hScrlClient, -(imgXRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_HORZ)/10000,
202 -(imgYRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_VERT)/10000, imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
203 }
204 }
205 break;
206 case WM_GETMINMAXINFO:
207 if (hwnd==hMainWnd)
208 {
209 MINMAXINFO *mm = (LPMINMAXINFO)lParam;
210 (*mm).ptMinTrackSize.x = 330;
211 (*mm).ptMinTrackSize.y = 430;
212 }
213 break;
214 case WM_PAINT:
215 DefWindowProc (hwnd, message, wParam, lParam);
216 if (hwnd==hImageArea)
217 {
218 HDC hdc = GetDC(hImageArea);
219 StretchBlt(hdc, 0, 0, imgXRes*zoom/1000, imgYRes*zoom/1000, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY);
220 ReleaseDC(hImageArea, hdc);
221 SendMessage(hSelection, WM_PAINT, 0, 0);
222 }
223 break;
224
225 // mouse events used for drawing
226
227 case WM_SETCURSOR:
228 if (hwnd==hImageArea)
229 {
230 switch (activeTool)
231 {
232 case 4:
233 SetCursor(hCurFill);
234 break;
235 case 5:
236 SetCursor(hCurColor);
237 break;
238 case 6:
239 SetCursor(hCurZoom);
240 break;
241 case 7:
242 SetCursor(hCurPen);
243 break;
244 case 9:
245 SetCursor(hCurAirbrush);
246 break;
247 default:
248 SetCursor(LoadCursor(NULL, IDC_CROSS));
249 }
250 } else DefWindowProc(hwnd, message, wParam, lParam);
251 break;
252 case WM_LBUTTONDOWN:
253 if (hwnd==hImageArea)
254 {
255 if ((!drawing)||(activeTool==5))
256 {
257 SetCapture(hImageArea);
258 drawing = TRUE;
259 startPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
260 }else
261 {
262 SendMessage(hwnd, WM_LBUTTONUP, wParam, lParam);
263 undo();
264 }
265 SendMessage(hImageArea, WM_PAINT, 0, 0);
266 if ((activeTool==6)&&(zoom<8000)) ZoomTo(zoom*2);
267 }
268 break;
269 case WM_RBUTTONDOWN:
270 if (hwnd==hImageArea)
271 {
272 if ((!drawing)||(activeTool==5))
273 {
274 SetCapture(hImageArea);
275 drawing = TRUE;
276 startPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
277 }else
278 {
279 SendMessage(hwnd, WM_RBUTTONUP, wParam, lParam);
280 undo();
281 }
282 SendMessage(hImageArea, WM_PAINT, 0, 0);
283 if ((activeTool==6)&&(zoom>125)) ZoomTo(zoom/2);
284 }
285 break;
286 case WM_LBUTTONUP:
287 if ((hwnd==hImageArea)&&drawing)
288 {
289 ReleaseCapture();
290 drawing = FALSE;
291 endPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
292 SendMessage(hImageArea, WM_PAINT, 0, 0);
293 if (activeTool==5)
294 {
295 int tempColor = GetPixel(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom);
296 if (tempColor!=CLR_INVALID) fgColor = tempColor;
297 SendMessage(hPalWin, WM_PAINT, 0, 0);
298 }
299 SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)"");
300 }
301 break;
302 case WM_RBUTTONUP:
303 if ((hwnd==hImageArea)&&drawing)
304 {
305 ReleaseCapture();
306 drawing = FALSE;
307 endPainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
308 SendMessage(hImageArea, WM_PAINT, 0, 0);
309 if (activeTool==5)
310 {
311 int tempColor = GetPixel(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom);
312 if (tempColor!=CLR_INVALID) bgColor = tempColor;
313 SendMessage(hPalWin, WM_PAINT, 0, 0);
314 }
315 SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)"");
316 }
317 break;
318 case WM_MOUSEMOVE:
319 if (hwnd==hImageArea)
320 {
321 if ((!drawing)||(activeTool<=9))
322 {
323 TCHAR coordStr[100];
324 _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom);
325 SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr);
326 }
327 if (drawing)
328 {
329 if ((wParam&MK_LBUTTON)!=0)
330 {
331 whilePainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor);
332 SendMessage(hImageArea, WM_PAINT, 0, 0);
333 if ((activeTool>=10)||(activeTool==2))
334 {
335 TCHAR sizeStr[100];
336 _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY);
337 SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr);
338 }
339 }
340 if ((wParam&MK_RBUTTON)!=0)
341 {
342 whilePainting(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, bgColor, fgColor);
343 SendMessage(hImageArea, WM_PAINT, 0, 0);
344 if (activeTool>=10)
345 {
346 TCHAR sizeStr[100];
347 _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY);
348 SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr);
349 }
350 }
351 }
352 } else
353 {
354 SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)_T(""));
355 }
356 break;
357
358 // menu and button events
359
360 case WM_COMMAND:
361 switch (LOWORD(wParam))
362 {
363 case IDM_HELPINFO:
364 {
365 HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
366 TCHAR infotitle[100];
367 TCHAR infotext[200];
368 LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
369 LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
370 ShellAbout(hMainWnd, infotitle, infotext, paintIcon);
371 DeleteObject(paintIcon);
372 }
373 break;
374 case IDM_HELPHELPTOPICS:
375 //HtmlHelp(hMainWnd, "help\\Paint.chm", 0, 0);
376 break;
377 case IDM_FILEEXIT:
378 SendMessage(hwnd, WM_CLOSE, wParam, lParam);
379 break;
380 case IDM_FILENEW:
381 Rectangle(hDrawingDC, 0-1, 0-1, imgXRes+1, imgYRes+1);
382 SendMessage(hImageArea, WM_PAINT, 0, 0);
383 break;
384 case IDM_FILEOPEN:
385 if (GetOpenFileName(&ofn)!=0)
386 {
387 HBITMAP bmNew = (HBITMAP)LoadDIBFromFile(ofn.lpstrFile);
388 if (bmNew!=NULL)
389 {
390 insertReversible(bmNew);
391 updateCanvasAndScrollbars();
392 TCHAR tempstr[1000];
393 TCHAR resstr[100];
394 CopyMemory(filename, ofn.lpstrFileTitle, sizeof(filename));
395 CopyMemory(filepathname, ofn.lpstrFileTitle, sizeof(filepathname));
396 LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
397 _stprintf(tempstr, resstr, filename);
398 SetWindowText(hMainWnd, tempstr);
399 clearHistory();
400 isAFile = TRUE;
401 }
402 }
403 break;
404 case IDM_FILESAVE:
405 if (isAFile)
406 SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC);
407 else
408 SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0);
409 break;
410 case IDM_FILESAVEAS:
411 if (GetSaveFileName(&sfn)!=0)
412 {
413 SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC);
414 TCHAR tempstr[1000];
415 TCHAR resstr[100];
416 CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename));
417 CopyMemory(filepathname, sfn.lpstrFileTitle, sizeof(filepathname));
418 LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
419 _stprintf(tempstr, resstr, filename);
420 SetWindowText(hMainWnd, tempstr);
421 isAFile = TRUE;
422 }
423 break;
424 case IDM_EDITUNDO:
425 undo();
426 SendMessage(hImageArea, WM_PAINT, 0, 0);
427 break;
428 case IDM_EDITREDO:
429 redo();
430 SendMessage(hImageArea, WM_PAINT, 0, 0);
431 break;
432 case IDM_EDITCOPY:
433 OpenClipboard(hMainWnd);
434 EmptyClipboard();
435 SetClipboardData(CF_BITMAP, CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
436 CloseClipboard();
437 break;
438 case IDM_EDITPASTE:
439 OpenClipboard(hMainWnd);
440 if (GetClipboardData(CF_BITMAP)!=NULL)
441 {
442 DeleteObject(SelectObject(hSelDC, hSelBm = CopyImage(GetClipboardData(CF_BITMAP), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)));
443 newReversible();
444 rectSel_src[0] = rectSel_src[1] = rectSel_src[2] = rectSel_src[3] = 0;
445 rectSel_dest[0] = rectSel_dest[1] = 0;
446 rectSel_dest[2] = GetDIBWidth(hSelBm);
447 rectSel_dest[3] = GetDIBHeight(hSelBm);
448 BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, SRCCOPY);
449 placeSelWin();
450 ShowWindow(hSelection, SW_SHOW);
451 }
452 CloseClipboard();
453 break;
454 case IDM_EDITDELETESELECTION:
455 ShowWindow(hSelection, SW_HIDE);
456 break;
457 case IDM_EDITSELECTALL:
458 if (activeTool==2)
459 {
460 startPainting(hDrawingDC, 0, 0, fgColor, bgColor);
461 whilePainting(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
462 endPainting(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
463 }
464 break;
465 case IDM_EDITCOPYTO:
466 if (GetSaveFileName(&ofn)!=0) SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC);
467 break;
468 case IDM_COLORSEDITPALETTE:
469 if (ChooseColor(&choosecolor))
470 {
471 fgColor = choosecolor.rgbResult;
472 SendMessage(hPalWin, WM_PAINT, 0, 0);
473 }
474 break;
475 case IDM_IMAGEINVERTCOLORS:
476 {
477 newReversible();
478 int tempRect[4] = {0, 0, imgXRes, imgYRes};
479 InvertRect(hDrawingDC, (LPRECT)tempRect);
480 SendMessage(hImageArea, WM_PAINT, 0, 0);
481 }
482 break;
483 case IDM_IMAGEDELETEIMAGE:
484 newReversible();
485 Rect(hDrawingDC, 0, 0, imgXRes, imgYRes, bgColor, bgColor, 0, TRUE);
486 SendMessage(hImageArea, WM_PAINT, 0, 0);
487 break;
488 case IDM_IMAGEROTATEMIRROR:
489 switch (mirrorRotateDlg())
490 {
491 case 1:
492 newReversible();
493 StretchBlt(hDrawingDC, imgXRes-1, 0, -imgXRes, imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY);
494 SendMessage(hImageArea, WM_PAINT, 0, 0);
495 break;
496 case 2:
497 newReversible();
498 StretchBlt(hDrawingDC, 0, imgYRes-1, imgXRes, -imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY);
499 SendMessage(hImageArea, WM_PAINT, 0, 0);
500 break;
501 case 4:
502 newReversible();
503 StretchBlt(hDrawingDC, imgXRes-1, imgYRes-1, -imgXRes, -imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY);
504 SendMessage(hImageArea, WM_PAINT, 0, 0);
505 break;
506 }
507 break;
508 case IDM_IMAGEATTRIBUTES:
509 {
510 //int attrdata[8] = {0, 0, 0, 0, 0, 0, 0, 0};
511 attributesDlg();
512 //cropReversible(640, 200);
513 //ZoomTo(zoom);
514 }
515 break;
516 case IDM_IMAGECHANGESIZE:
517 {
518 int retVal = changeSizeDlg();
519 if ((LOWORD(retVal)!=0)&&(HIWORD(retVal)!=0))
520 {
521 insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP, imgXRes*LOWORD(retVal)/100, imgYRes*HIWORD(retVal)/100, 0));
522 updateCanvasAndScrollbars();
523 }
524 }
525 break;
526 case IDM_IMAGEDRAWOPAQUE:
527 transpBg = 1-transpBg;
528 SendMessage(hToolSettings, WM_PAINT, 0, 0);
529 break;
530 case IDM_IMAGECROP:
531 insertReversible(CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
532 updateCanvasAndScrollbars();
533 break;
534
535 case IDM_VIEWZOOM125:
536 ZoomTo(125);
537 break;
538 case IDM_VIEWZOOM25:
539 ZoomTo(250);
540 break;
541 case IDM_VIEWZOOM50:
542 ZoomTo(500);
543 break;
544 case IDM_VIEWZOOM100:
545 ZoomTo(1000);
546 break;
547 case IDM_VIEWZOOM200:
548 ZoomTo(2000);
549 break;
550 case IDM_VIEWZOOM400:
551 ZoomTo(4000);
552 break;
553 case IDM_VIEWZOOM800:
554 ZoomTo(8000);
555 break;
556 case ID_FREESEL:
557 selectTool(1);
558 break;
559 case ID_RECTSEL:
560 selectTool(2);
561 break;
562 case ID_RUBBER:
563 selectTool(3);
564 break;
565 case ID_FILL:
566 selectTool(4);
567 break;
568 case ID_COLOR:
569 selectTool(5);
570 break;
571 case ID_ZOOM:
572 selectTool(6);
573 break;
574 case ID_PEN:
575 selectTool(7);
576 break;
577 case ID_BRUSH:
578 selectTool(8);
579 break;
580 case ID_AIRBRUSH:
581 selectTool(9);
582 break;
583 case ID_TEXT:
584 selectTool(10);
585 break;
586 case ID_LINE:
587 selectTool(11);
588 break;
589 case ID_BEZIER:
590 selectTool(12);
591 break;
592 case ID_RECT:
593 selectTool(13);
594 break;
595 case ID_SHAPE:
596 selectTool(14);
597 break;
598 case ID_ELLIPSE:
599 selectTool(15);
600 break;
601 case ID_RRECT:
602 selectTool(16);
603 break;
604 }
605 break;
606 default:
607 return DefWindowProc (hwnd, message, wParam, lParam);
608 }
609
610 return 0;
611 }
612