[MSPAINT_NEW] refactoring: move selection management to a dedicated SelectionModel...
[reactos.git] / reactos / base / applications / mspaint_new / winproc.cpp
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/mspaint_new/winproc.cpp
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 "precomp.h"
13
14 #include "dialogs.h"
15 #include "registry.h"
16
17 /* FUNCTIONS ********************************************************/
18
19 void
20 zoomTo(int newZoom, int mouseX, int mouseY)
21 {
22 RECT clientRectScrollbox;
23 RECT clientRectImageArea;
24 int x, y, w, h;
25 scrollboxWindow.GetClientRect(&clientRectScrollbox);
26 imageArea.GetClientRect(&clientRectImageArea);
27 w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * newZoom / toolsModel.GetZoom());
28 h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * newZoom / toolsModel.GetZoom());
29 x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / toolsModel.GetZoom();
30 y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / toolsModel.GetZoom();
31
32 toolsModel.SetZoom(newZoom);
33
34 selectionWindow.ShowWindow(SW_HIDE);
35 imageArea.MoveWindow(3, 3, imageModel.GetWidth() * toolsModel.GetZoom() / 1000, imageModel.GetHeight() * toolsModel.GetZoom() / 1000, FALSE);
36 scrollboxWindow.Invalidate(TRUE);
37 imageArea.Invalidate(FALSE);
38
39 scrollboxWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
40 scrollboxWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
41 }
42
43 void CMainWindow::alignChildrenToMainWindow()
44 {
45 int x, y, w, h;
46 RECT clientRect;
47 GetClientRect(&clientRect);
48
49 if (toolBoxContainer.IsWindowVisible())
50 {
51 x = 56;
52 w = clientRect.right - 56;
53 }
54 else
55 {
56 x = 0;
57 w = clientRect.right;
58 }
59 if (paletteWindow.IsWindowVisible())
60 {
61 y = 49;
62 h = clientRect.bottom - 49;
63 }
64 else
65 {
66 y = 3;
67 h = clientRect.bottom - 3;
68 }
69
70 scrollboxWindow.MoveWindow(x, y, w, ::IsWindowVisible(hStatusBar) ? h - 23 : h, TRUE);
71 paletteWindow.MoveWindow(x, 9, 255, 32, TRUE);
72 }
73
74 void CMainWindow::saveImage(BOOL overwrite)
75 {
76 if (isAFile && overwrite)
77 {
78 imageModel.SaveImage(filepathname);
79 }
80 else if (GetSaveFileName(&sfn) != 0)
81 {
82 TCHAR tempstr[1000];
83 TCHAR resstr[100];
84 imageModel.SaveImage(sfn.lpstrFile);
85 CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename));
86 CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
87 LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
88 _stprintf(tempstr, resstr, filename);
89 SetWindowText(tempstr);
90 isAFile = TRUE;
91 }
92 }
93
94 void CMainWindow::UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename, LPTSTR newfilepathname)
95 {
96 TCHAR tempstr[1000];
97 TCHAR resstr[100];
98 imageModel.Insert(bitmap);
99 CopyMemory(filename, newfilename, sizeof(filename));
100 CopyMemory(filepathname, newfilepathname, sizeof(filepathname));
101 LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
102 _stprintf(tempstr, resstr, filename);
103 SetWindowText(tempstr);
104 imageModel.ClearHistory();
105 isAFile = TRUE;
106 }
107
108 void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
109 {
110 HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
111 SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
112 toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
113
114 imageModel.CopyPrevious();
115 selectionModel.InsertFromHBITMAP(bitmap);
116
117 placeSelWin();
118 selectionWindow.ShowWindow(SW_SHOW);
119 ForceRefreshSelectionContents();
120 }
121
122 LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
123 {
124 HDROP drophandle;
125 TCHAR droppedfile[MAX_PATH];
126 HBITMAP bmNew = NULL;
127 drophandle = (HDROP)wParam;
128 DragQueryFile(drophandle, 0, droppedfile, SIZEOF(droppedfile));
129 DragFinish(drophandle);
130 LoadDIBFromFile(&bmNew, droppedfile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
131 if (bmNew != NULL)
132 {
133 TCHAR *pathend;
134 pathend = _tcsrchr(droppedfile, '\\');
135 pathend++;
136 UpdateApplicationProperties(bmNew, pathend, pathend);
137 }
138 return 0;
139 }
140
141 LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
142 {
143 SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)));
144 SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)));
145 return 0;
146 }
147
148 LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
149 {
150 PostQuitMessage(0); /* send a WM_QUIT to the message queue */
151 return 0;
152 }
153
154 LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
155 {
156 if (!imageModel.IsImageSaved())
157 {
158 TCHAR programname[20];
159 TCHAR saveprompttext[100];
160 TCHAR temptext[500];
161 LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
162 LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
163 _stprintf(temptext, saveprompttext, filename);
164 switch (MessageBox(temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
165 {
166 case IDNO:
167 DestroyWindow();
168 break;
169 case IDYES:
170 saveImage(FALSE);
171 if (imageModel.IsImageSaved())
172 DestroyWindow();
173 break;
174 }
175 }
176 else
177 {
178 DestroyWindow();
179 }
180 return 0;
181 }
182
183 LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
184 {
185 HMENU menu = GetMenu();
186 BOOL trueSelection = (selectionWindow.IsWindowVisible() && ((toolsModel.GetActiveTool() == TOOL_FREESEL) || (toolsModel.GetActiveTool() == TOOL_RECTSEL)));
187 switch (lParam)
188 {
189 case 0: /* File menu */
190 EnableMenuItem(menu, IDM_FILEASWALLPAPERPLANE, ENABLED_IF(isAFile));
191 EnableMenuItem(menu, IDM_FILEASWALLPAPERCENTERED, ENABLED_IF(isAFile));
192 EnableMenuItem(menu, IDM_FILEASWALLPAPERSTRETCHED, ENABLED_IF(isAFile));
193 break;
194 case 1: /* Edit menu */
195 EnableMenuItem(menu, IDM_EDITUNDO, ENABLED_IF(imageModel.HasUndoSteps()));
196 EnableMenuItem(menu, IDM_EDITREDO, ENABLED_IF(imageModel.HasRedoSteps()));
197 EnableMenuItem(menu, IDM_EDITCUT, ENABLED_IF(trueSelection));
198 EnableMenuItem(menu, IDM_EDITCOPY, ENABLED_IF(trueSelection));
199 EnableMenuItem(menu, IDM_EDITDELETESELECTION, ENABLED_IF(trueSelection));
200 EnableMenuItem(menu, IDM_EDITINVERTSELECTION, ENABLED_IF(trueSelection));
201 EnableMenuItem(menu, IDM_EDITCOPYTO, ENABLED_IF(trueSelection));
202 OpenClipboard();
203 EnableMenuItem(menu, IDM_EDITPASTE, ENABLED_IF(GetClipboardData(CF_BITMAP) != NULL));
204 CloseClipboard();
205 break;
206 case 2: /* View menu */
207 CheckMenuItem(menu, IDM_VIEWTOOLBOX, CHECKED_IF(toolBoxContainer.IsWindowVisible()));
208 CheckMenuItem(menu, IDM_VIEWCOLORPALETTE, CHECKED_IF(paletteWindow.IsWindowVisible()));
209 CheckMenuItem(menu, IDM_VIEWSTATUSBAR, CHECKED_IF(::IsWindowVisible(hStatusBar)));
210 CheckMenuItem(menu, IDM_FORMATICONBAR, CHECKED_IF(textEditWindow.IsWindowVisible()));
211 EnableMenuItem(menu, IDM_FORMATICONBAR, ENABLED_IF(toolsModel.GetActiveTool() == TOOL_TEXT));
212
213 CheckMenuItem(menu, IDM_VIEWSHOWGRID, CHECKED_IF(showGrid));
214 CheckMenuItem(menu, IDM_VIEWSHOWMINIATURE, CHECKED_IF(showMiniature));
215 break;
216 case 3: /* Image menu */
217 EnableMenuItem(menu, IDM_IMAGECROP, ENABLED_IF(selectionWindow.IsWindowVisible()));
218 CheckMenuItem(menu, IDM_IMAGEDRAWOPAQUE, CHECKED_IF(!toolsModel.IsBackgroundTransparent()));
219 break;
220 }
221
222 CheckMenuItem(menu, IDM_VIEWZOOM125, CHECKED_IF(toolsModel.GetZoom() == 125));
223 CheckMenuItem(menu, IDM_VIEWZOOM25, CHECKED_IF(toolsModel.GetZoom() == 250));
224 CheckMenuItem(menu, IDM_VIEWZOOM50, CHECKED_IF(toolsModel.GetZoom() == 500));
225 CheckMenuItem(menu, IDM_VIEWZOOM100, CHECKED_IF(toolsModel.GetZoom() == 1000));
226 CheckMenuItem(menu, IDM_VIEWZOOM200, CHECKED_IF(toolsModel.GetZoom() == 2000));
227 CheckMenuItem(menu, IDM_VIEWZOOM400, CHECKED_IF(toolsModel.GetZoom() == 4000));
228 CheckMenuItem(menu, IDM_VIEWZOOM800, CHECKED_IF(toolsModel.GetZoom() == 8000));
229
230 CheckMenuItem(menu, IDM_COLORSMODERNPALETTE, CHECKED_IF(paletteModel.SelectedPalette() == 1));
231 CheckMenuItem(menu, IDM_COLORSOLDPALETTE, CHECKED_IF(paletteModel.SelectedPalette() == 2));
232 return 0;
233 }
234
235 LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
236 {
237 int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
238 SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
239 SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
240 alignChildrenToMainWindow();
241 Invalidate(TRUE);
242 return 0;
243 }
244
245 LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
246 {
247 MINMAXINFO *mm = (LPMINMAXINFO) lParam;
248 mm->ptMinTrackSize.x = 330;
249 mm->ptMinTrackSize.y = 430;
250 return 0;
251 }
252
253 LRESULT CMainWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
254 {
255 SetCursor(LoadCursor(NULL, IDC_ARROW));
256 return 0;
257 }
258
259 LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
260 {
261 if (wParam == VK_ESCAPE)
262 {
263 if (!imageArea.drawing)
264 {
265 /* Deselect */
266 if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_FREESEL))
267 {
268 startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
269 whilePaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
270 endPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
271 selectionWindow.ShowWindow(SW_HIDE);
272 }
273 }
274 /* FIXME: also cancel current drawing underway */
275 }
276 return 0;
277 }
278
279 LRESULT CMainWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
280 {
281 /* Redirect message to common controls */
282 HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
283 SendMessage(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
284 return 0;
285 }
286
287 LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
288 {
289 switch (LOWORD(wParam))
290 {
291 case IDM_HELPINFO:
292 {
293 HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
294 TCHAR infotitle[100];
295 TCHAR infotext[200];
296 LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
297 LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
298 ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
299 DeleteObject(paintIcon);
300 break;
301 }
302 case IDM_HELPHELPTOPICS:
303 HtmlHelp(m_hWnd, _T("help\\Paint.chm"), 0, 0);
304 break;
305 case IDM_FILEEXIT:
306 SendMessage(WM_CLOSE, wParam, lParam);
307 break;
308 case IDM_FILENEW:
309 {
310 BOOL reset = TRUE;
311 if (!imageModel.IsImageSaved())
312 {
313 TCHAR programname[20];
314 TCHAR saveprompttext[100];
315 TCHAR temptext[500];
316 LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
317 LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
318 _stprintf(temptext, saveprompttext, filename);
319 switch (MessageBox(temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
320 {
321 case IDNO:
322 imageModel.imageSaved = TRUE; //TODO: move to ImageModel
323 break;
324 case IDYES:
325 saveImage(FALSE);
326 break;
327 case IDCANCEL:
328 reset = FALSE;
329 break;
330 }
331 }
332 if (reset && imageModel.IsImageSaved()) //TODO: move to ImageModel
333 {
334 imageModel.Clear();
335 imageModel.ClearHistory();
336 }
337 break;
338 }
339 case IDM_FILEOPEN:
340 if (GetOpenFileName(&ofn) != 0)
341 {
342 HBITMAP bmNew = NULL;
343 LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
344 if (bmNew != NULL)
345 {
346 UpdateApplicationProperties(bmNew, ofn.lpstrFileTitle, ofn.lpstrFileTitle);
347 }
348 }
349 break;
350 case IDM_FILESAVE:
351 saveImage(TRUE);
352 break;
353 case IDM_FILESAVEAS:
354 saveImage(FALSE);
355 break;
356 case IDM_FILEASWALLPAPERPLANE:
357 SetWallpaper(filepathname, 1, 1);
358 break;
359 case IDM_FILEASWALLPAPERCENTERED:
360 SetWallpaper(filepathname, 1, 0);
361 break;
362 case IDM_FILEASWALLPAPERSTRETCHED:
363 SetWallpaper(filepathname, 2, 0);
364 break;
365 case IDM_EDITUNDO:
366 imageModel.Undo();
367 imageArea.Invalidate(FALSE);
368 break;
369 case IDM_EDITREDO:
370 imageModel.Redo();
371 imageArea.Invalidate(FALSE);
372 break;
373 case IDM_EDITCOPY:
374 OpenClipboard();
375 EmptyClipboard();
376 SetClipboardData(CF_BITMAP, CopyImage(selectionModel.GetBitmap(), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
377 CloseClipboard();
378 break;
379 case IDM_EDITCUT:
380 /* Copy */
381 SendMessage(WM_COMMAND, IDM_EDITCOPY, 0);
382 /* Delete selection */
383 SendMessage(WM_COMMAND, IDM_EDITDELETESELECTION, 0);
384 break;
385 case IDM_EDITPASTE:
386 OpenClipboard();
387 if (GetClipboardData(CF_BITMAP) != NULL)
388 {
389 InsertSelectionFromHBITMAP((HBITMAP) GetClipboardData(CF_BITMAP), m_hWnd);
390 }
391 CloseClipboard();
392 break;
393 case IDM_EDITDELETESELECTION:
394 {
395 /* remove selection window and already painted content using undo */
396 imageModel.Undo();
397 break;
398 }
399 case IDM_EDITSELECTALL:
400 {
401 HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
402 SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
403 toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
404 //TODO: do this properly
405 startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
406 whilePaintingL(hDrawingDC, imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor());
407 endPaintingL(hDrawingDC, imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor());
408 break;
409 }
410 case IDM_EDITCOPYTO:
411 if (GetSaveFileName(&ofn) != 0)
412 SaveDIBToFile(selectionModel.GetBitmap(), ofn.lpstrFile, hDrawingDC, NULL, NULL, fileHPPM, fileVPPM);
413 break;
414 case IDM_EDITPASTEFROM:
415 if (GetOpenFileName(&ofn) != 0)
416 {
417 HBITMAP bmNew = NULL;
418 LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
419 if (bmNew != NULL)
420 {
421 InsertSelectionFromHBITMAP(bmNew, m_hWnd);
422 DeleteObject(bmNew);
423 }
424 }
425 break;
426 case IDM_COLORSEDITPALETTE:
427 if (ChooseColor(&choosecolor))
428 paletteModel.SetFgColor(choosecolor.rgbResult);
429 break;
430 case IDM_COLORSMODERNPALETTE:
431 paletteModel.SelectPalette(1);
432 break;
433 case IDM_COLORSOLDPALETTE:
434 paletteModel.SelectPalette(2);
435 break;
436 case IDM_IMAGEINVERTCOLORS:
437 {
438 imageModel.InvertColors();
439 break;
440 }
441 case IDM_IMAGEDELETEIMAGE:
442 imageModel.CopyPrevious();
443 Rect(hDrawingDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetBgColor(), paletteModel.GetBgColor(), 0, TRUE);
444 imageArea.Invalidate(FALSE);
445 break;
446 case IDM_IMAGEROTATEMIRROR:
447 switch (mirrorRotateDlg())
448 {
449 case 1: /* flip horizontally */
450 if (selectionWindow.IsWindowVisible())
451 {
452 selectionModel.FlipHorizontally();
453 ForceRefreshSelectionContents();
454 }
455 else
456 {
457 imageModel.CopyPrevious();
458 StretchBlt(hDrawingDC, imageModel.GetWidth() - 1, 0, -imageModel.GetWidth(), imageModel.GetHeight(), hDrawingDC, 0, 0,
459 imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY);
460 imageArea.Invalidate(FALSE);
461 }
462 break;
463 case 2: /* flip vertically */
464 if (selectionWindow.IsWindowVisible())
465 {
466 selectionModel.FlipVertically();
467 ForceRefreshSelectionContents();
468 }
469 else
470 {
471 imageModel.CopyPrevious();
472 StretchBlt(hDrawingDC, 0, imageModel.GetHeight() - 1, imageModel.GetWidth(), -imageModel.GetHeight(), hDrawingDC, 0, 0,
473 imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY);
474 imageArea.Invalidate(FALSE);
475 }
476 break;
477 case 3: /* rotate 90 degrees */
478 break;
479 case 4: /* rotate 180 degrees */
480 if (selectionWindow.IsWindowVisible())
481 {
482 selectionModel.RotateNTimes90Degrees(2);
483 ForceRefreshSelectionContents();
484 }
485 else
486 {
487 imageModel.CopyPrevious();
488 StretchBlt(hDrawingDC, imageModel.GetWidth() - 1, imageModel.GetHeight() - 1, -imageModel.GetWidth(), -imageModel.GetHeight(), hDrawingDC,
489 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY);
490 imageArea.Invalidate(FALSE);
491 }
492 break;
493 case 5: /* rotate 270 degrees */
494 break;
495 }
496 break;
497 case IDM_IMAGEATTRIBUTES:
498 {
499 if (attributesDlg())
500 {
501 imageModel.Crop(widthSetInDlg, heightSetInDlg, 0, 0);
502 }
503 break;
504 }
505 case IDM_IMAGESTRETCHSKEW:
506 {
507 if (changeSizeDlg())
508 {
509 imageModel.StretchSkew(stretchSkew.percentage.x, stretchSkew.percentage.y,
510 stretchSkew.angle.x, stretchSkew.angle.y);
511 }
512 break;
513 }
514 case IDM_IMAGEDRAWOPAQUE:
515 toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
516 break;
517 case IDM_IMAGECROP:
518 imageModel.Insert((HBITMAP) CopyImage(selectionModel.GetBitmap(), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
519 break;
520
521 case IDM_VIEWTOOLBOX:
522 toolBoxContainer.ShowWindow(toolBoxContainer.IsWindowVisible() ? SW_HIDE : SW_SHOW);
523 alignChildrenToMainWindow();
524 break;
525 case IDM_VIEWCOLORPALETTE:
526 paletteWindow.ShowWindow(paletteWindow.IsWindowVisible() ? SW_HIDE : SW_SHOW);
527 alignChildrenToMainWindow();
528 break;
529 case IDM_VIEWSTATUSBAR:
530 ::ShowWindow(hStatusBar, ::IsWindowVisible(hStatusBar) ? SW_HIDE : SW_SHOW);
531 alignChildrenToMainWindow();
532 break;
533 case IDM_FORMATICONBAR:
534 textEditWindow.ShowWindow(textEditWindow.IsWindowVisible() ? SW_HIDE : SW_SHOW);
535
536 case IDM_VIEWSHOWGRID:
537 showGrid = !showGrid;
538 imageArea.Invalidate(FALSE);
539 break;
540 case IDM_VIEWSHOWMINIATURE:
541 showMiniature = !showMiniature;
542 miniature.ShowWindow(showMiniature ? SW_SHOW : SW_HIDE);
543 break;
544
545 case IDM_VIEWZOOM125:
546 zoomTo(125, 0, 0);
547 break;
548 case IDM_VIEWZOOM25:
549 zoomTo(250, 0, 0);
550 break;
551 case IDM_VIEWZOOM50:
552 zoomTo(500, 0, 0);
553 break;
554 case IDM_VIEWZOOM100:
555 zoomTo(1000, 0, 0);
556 break;
557 case IDM_VIEWZOOM200:
558 zoomTo(2000, 0, 0);
559 break;
560 case IDM_VIEWZOOM400:
561 zoomTo(4000, 0, 0);
562 break;
563 case IDM_VIEWZOOM800:
564 zoomTo(8000, 0, 0);
565 break;
566 }
567 return 0;
568 }