2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/mspaint/winproc.cpp
5 * PURPOSE: Window procedure of the main window and all children apart from
6 * hPalWin, hToolSettings and hSelection
7 * PROGRAMMERS: Benedikt Freisen
10 /* INCLUDES *********************************************************/
16 /* FUNCTIONS ********************************************************/
19 zoomTo(int newZoom
, int mouseX
, int mouseY
)
21 RECT clientRectScrollbox
;
22 RECT clientRectImageArea
;
24 scrollboxWindow
.GetClientRect(&clientRectScrollbox
);
25 imageArea
.GetClientRect(&clientRectImageArea
);
26 w
= clientRectImageArea
.right
* clientRectScrollbox
.right
/ (clientRectImageArea
.right
* newZoom
/ toolsModel
.GetZoom());
27 h
= clientRectImageArea
.bottom
* clientRectScrollbox
.bottom
/ (clientRectImageArea
.bottom
* newZoom
/ toolsModel
.GetZoom());
28 x
= max(0, min(clientRectImageArea
.right
- w
, mouseX
- w
/ 2)) * newZoom
/ toolsModel
.GetZoom();
29 y
= max(0, min(clientRectImageArea
.bottom
- h
, mouseY
- h
/ 2)) * newZoom
/ toolsModel
.GetZoom();
31 toolsModel
.SetZoom(newZoom
);
33 selectionWindow
.ShowWindow(SW_HIDE
);
34 imageArea
.MoveWindow(3, 3, imageModel
.GetWidth() * toolsModel
.GetZoom() / 1000, imageModel
.GetHeight() * toolsModel
.GetZoom() / 1000, FALSE
);
35 scrollboxWindow
.Invalidate(TRUE
);
36 imageArea
.Invalidate(FALSE
);
38 scrollboxWindow
.SendMessage(WM_HSCROLL
, MAKEWPARAM(SB_THUMBPOSITION
, x
), 0);
39 scrollboxWindow
.SendMessage(WM_VSCROLL
, MAKEWPARAM(SB_THUMBPOSITION
, y
), 0);
42 void CMainWindow::alignChildrenToMainWindow()
46 GetClientRect(&clientRect
);
48 if (toolBoxContainer
.IsWindowVisible())
51 w
= clientRect
.right
- 56;
58 if (paletteWindow
.IsWindowVisible())
61 h
= clientRect
.bottom
- 49;
66 h
= clientRect
.bottom
- 3;
69 scrollboxWindow
.MoveWindow(x
, y
, w
, ::IsWindowVisible(hStatusBar
) ? h
- 23 : h
, TRUE
);
70 paletteWindow
.MoveWindow(x
, 9, 255, 32, TRUE
);
73 void CMainWindow::saveImage(BOOL overwrite
)
75 if (isAFile
&& overwrite
)
77 imageModel
.SaveImage(filepathname
);
79 else if (GetSaveFileName(&sfn
) != 0)
81 imageModel
.SaveImage(sfn
.lpstrFile
);
83 strTitle
.Format(IDS_WINDOWTITLE
, (LPCTSTR
)sfn
.lpstrFileTitle
);
84 SetWindowText(strTitle
);
89 void CMainWindow::UpdateApplicationProperties(HBITMAP bitmap
, LPCTSTR newfilepathname
)
91 imageModel
.Insert(bitmap
);
92 CopyMemory(filepathname
, newfilepathname
, sizeof(filepathname
));
93 CPath
pathFileName(newfilepathname
);
94 pathFileName
.StripPath();
96 strTitle
.Format(IDS_WINDOWTITLE
, (LPCTSTR
)pathFileName
);
97 SetWindowText(strTitle
);
98 imageModel
.ClearHistory();
101 registrySettings
.SetMostRecentFile(newfilepathname
);
104 void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap
, HWND window
)
106 int width
= GetDIBWidth(bitmap
);
107 int height
= GetDIBHeight(bitmap
);
108 int curWidth
= imageModel
.GetWidth();
109 int curHeight
= imageModel
.GetHeight();
111 if (width
> curWidth
|| height
> curHeight
)
113 BOOL shouldEnlarge
= TRUE
;
115 if (askBeforeEnlarging
)
117 TCHAR programname
[20];
118 TCHAR shouldEnlargePromptText
[100];
120 LoadString(hProgInstance
, IDS_PROGRAMNAME
, programname
, SIZEOF(programname
));
121 LoadString(hProgInstance
, IDS_ENLARGEPROMPTTEXT
, shouldEnlargePromptText
, SIZEOF(shouldEnlargePromptText
));
123 switch (MessageBox(shouldEnlargePromptText
, programname
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
128 shouldEnlarge
= FALSE
;
137 if (width
> curWidth
)
140 if (height
> curHeight
)
143 imageModel
.Crop(curWidth
, curHeight
, 0, 0);
147 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
148 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELPARAM(TRUE
, 0));
149 toolBoxContainer
.SendMessage(WM_COMMAND
, ID_RECTSEL
);
151 imageModel
.CopyPrevious();
152 selectionModel
.InsertFromHBITMAP(bitmap
);
155 selectionWindow
.ShowWindow(SW_SHOW
);
156 ForceRefreshSelectionContents();
159 LRESULT
CMainWindow::OnDropFiles(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
162 TCHAR droppedfile
[MAX_PATH
];
163 HBITMAP bmNew
= NULL
;
164 drophandle
= (HDROP
)wParam
;
165 DragQueryFile(drophandle
, 0, droppedfile
, SIZEOF(droppedfile
));
166 DragFinish(drophandle
);
167 LoadDIBFromFile(&bmNew
, droppedfile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
170 UpdateApplicationProperties(bmNew
, droppedfile
);
175 LRESULT
CMainWindow::OnCreate(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
177 SendMessage(WM_SETICON
, ICON_BIG
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
178 SendMessage(WM_SETICON
, ICON_SMALL
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
182 LRESULT
CMainWindow::OnDestroy(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
184 GetWindowPlacement(&(registrySettings
.WindowPlacement
));
185 PostQuitMessage(0); /* send a WM_QUIT to the message queue */
189 LRESULT
CMainWindow::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
191 if (!imageModel
.IsImageSaved())
193 CString strProgramName
;
194 strProgramName
.LoadString(IDS_PROGRAMNAME
);
195 CPath
pathFileName(filepathname
);
196 pathFileName
.StripPath();
197 CString strSavePromptText
;
198 strSavePromptText
.Format(IDS_SAVEPROMPTTEXT
, (LPCTSTR
)pathFileName
);
199 switch (MessageBox(strSavePromptText
, strProgramName
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
206 if (imageModel
.IsImageSaved())
218 LRESULT
CMainWindow::OnInitMenuPopup(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
220 HMENU menu
= GetMenu();
221 BOOL trueSelection
= (selectionWindow
.IsWindowVisible() && ((toolsModel
.GetActiveTool() == TOOL_FREESEL
) || (toolsModel
.GetActiveTool() == TOOL_RECTSEL
)));
224 case 0: /* File menu */
225 EnableMenuItem(menu
, IDM_FILEASWALLPAPERPLANE
, ENABLED_IF(isAFile
));
226 EnableMenuItem(menu
, IDM_FILEASWALLPAPERCENTERED
, ENABLED_IF(isAFile
));
227 EnableMenuItem(menu
, IDM_FILEASWALLPAPERSTRETCHED
, ENABLED_IF(isAFile
));
228 RemoveMenu(menu
, IDM_FILE1
, MF_BYCOMMAND
);
229 RemoveMenu(menu
, IDM_FILE2
, MF_BYCOMMAND
);
230 RemoveMenu(menu
, IDM_FILE3
, MF_BYCOMMAND
);
231 RemoveMenu(menu
, IDM_FILE4
, MF_BYCOMMAND
);
232 if (!registrySettings
.strFile1
.IsEmpty())
234 RemoveMenu(menu
, IDM_FILEMOSTRECENTLYUSEDFILE
, MF_BYCOMMAND
);
235 CPath
pathFile1(registrySettings
.strFile1
);
236 pathFile1
.CompactPathEx(30);
237 if (!registrySettings
.strFile2
.IsEmpty())
239 CPath
pathFile2(registrySettings
.strFile2
);
240 pathFile2
.CompactPathEx(30);
241 if (!registrySettings
.strFile3
.IsEmpty())
243 CPath
pathFile3(registrySettings
.strFile3
);
244 pathFile3
.CompactPathEx(30);
245 if (!registrySettings
.strFile4
.IsEmpty())
247 CPath
pathFile4(registrySettings
.strFile4
);
248 pathFile4
.CompactPathEx(30);
249 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE4
, _T("4 ") + pathFile4
);
251 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE3
, _T("3 ") + pathFile3
);
253 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE2
, _T("2 ") + pathFile2
);
255 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE1
, _T("1 ") + pathFile1
);
258 case 1: /* Edit menu */
259 EnableMenuItem(menu
, IDM_EDITUNDO
, ENABLED_IF(imageModel
.HasUndoSteps()));
260 EnableMenuItem(menu
, IDM_EDITREDO
, ENABLED_IF(imageModel
.HasRedoSteps()));
261 EnableMenuItem(menu
, IDM_EDITCUT
, ENABLED_IF(trueSelection
));
262 EnableMenuItem(menu
, IDM_EDITCOPY
, ENABLED_IF(trueSelection
));
263 EnableMenuItem(menu
, IDM_EDITDELETESELECTION
, ENABLED_IF(trueSelection
));
264 EnableMenuItem(menu
, IDM_EDITINVERTSELECTION
, ENABLED_IF(trueSelection
));
265 EnableMenuItem(menu
, IDM_EDITCOPYTO
, ENABLED_IF(trueSelection
));
267 EnableMenuItem(menu
, IDM_EDITPASTE
, ENABLED_IF(GetClipboardData(CF_BITMAP
) != NULL
));
270 case 2: /* View menu */
271 CheckMenuItem(menu
, IDM_VIEWTOOLBOX
, CHECKED_IF(toolBoxContainer
.IsWindowVisible()));
272 CheckMenuItem(menu
, IDM_VIEWCOLORPALETTE
, CHECKED_IF(paletteWindow
.IsWindowVisible()));
273 CheckMenuItem(menu
, IDM_VIEWSTATUSBAR
, CHECKED_IF(::IsWindowVisible(hStatusBar
)));
274 CheckMenuItem(menu
, IDM_FORMATICONBAR
, CHECKED_IF(textEditWindow
.IsWindowVisible()));
275 EnableMenuItem(menu
, IDM_FORMATICONBAR
, ENABLED_IF(toolsModel
.GetActiveTool() == TOOL_TEXT
));
277 CheckMenuItem(menu
, IDM_VIEWSHOWGRID
, CHECKED_IF(showGrid
));
278 CheckMenuItem(menu
, IDM_VIEWSHOWMINIATURE
, CHECKED_IF(showMiniature
));
280 case 3: /* Image menu */
281 EnableMenuItem(menu
, IDM_IMAGECROP
, ENABLED_IF(selectionWindow
.IsWindowVisible()));
282 CheckMenuItem(menu
, IDM_IMAGEDRAWOPAQUE
, CHECKED_IF(!toolsModel
.IsBackgroundTransparent()));
286 CheckMenuItem(menu
, IDM_VIEWZOOM125
, CHECKED_IF(toolsModel
.GetZoom() == 125));
287 CheckMenuItem(menu
, IDM_VIEWZOOM25
, CHECKED_IF(toolsModel
.GetZoom() == 250));
288 CheckMenuItem(menu
, IDM_VIEWZOOM50
, CHECKED_IF(toolsModel
.GetZoom() == 500));
289 CheckMenuItem(menu
, IDM_VIEWZOOM100
, CHECKED_IF(toolsModel
.GetZoom() == 1000));
290 CheckMenuItem(menu
, IDM_VIEWZOOM200
, CHECKED_IF(toolsModel
.GetZoom() == 2000));
291 CheckMenuItem(menu
, IDM_VIEWZOOM400
, CHECKED_IF(toolsModel
.GetZoom() == 4000));
292 CheckMenuItem(menu
, IDM_VIEWZOOM800
, CHECKED_IF(toolsModel
.GetZoom() == 8000));
294 CheckMenuItem(menu
, IDM_COLORSMODERNPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 1));
295 CheckMenuItem(menu
, IDM_COLORSOLDPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 2));
299 LRESULT
CMainWindow::OnSize(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
301 int test
[] = { LOWORD(lParam
) - 260, LOWORD(lParam
) - 140, LOWORD(lParam
) - 20 };
302 SendMessage(hStatusBar
, WM_SIZE
, wParam
, lParam
);
303 SendMessage(hStatusBar
, SB_SETPARTS
, 3, (LPARAM
)&test
);
304 alignChildrenToMainWindow();
309 LRESULT
CMainWindow::OnGetMinMaxInfo(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
311 MINMAXINFO
*mm
= (LPMINMAXINFO
) lParam
;
312 mm
->ptMinTrackSize
.x
= 330;
313 mm
->ptMinTrackSize
.y
= 430;
317 LRESULT
CMainWindow::OnSetCursor(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
319 SetCursor(LoadCursor(NULL
, IDC_ARROW
));
324 LRESULT
CMainWindow::OnKeyDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
326 if (wParam
== VK_ESCAPE
)
328 if (!imageArea
.drawing
)
331 if ((toolsModel
.GetActiveTool() == TOOL_RECTSEL
) || (toolsModel
.GetActiveTool() == TOOL_FREESEL
))
333 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
334 whilePaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
335 endPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
336 selectionWindow
.ShowWindow(SW_HIDE
);
339 /* FIXME: also cancel current drawing underway */
344 LRESULT
CMainWindow::OnSysColorChange(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
346 /* Redirect message to common controls */
347 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
348 SendMessage(hToolbar
, WM_SYSCOLORCHANGE
, 0, 0);
352 LRESULT
CMainWindow::OnCommand(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
354 switch (LOWORD(wParam
))
358 HICON paintIcon
= LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
));
359 TCHAR infotitle
[100];
361 LoadString(hProgInstance
, IDS_INFOTITLE
, infotitle
, SIZEOF(infotitle
));
362 LoadString(hProgInstance
, IDS_INFOTEXT
, infotext
, SIZEOF(infotext
));
363 ShellAbout(m_hWnd
, infotitle
, infotext
, paintIcon
);
364 DeleteObject(paintIcon
);
367 case IDM_HELPHELPTOPICS
:
368 HtmlHelp(m_hWnd
, _T("help\\Paint.chm"), 0, 0);
371 SendMessage(WM_CLOSE
, wParam
, lParam
);
376 if (!imageModel
.IsImageSaved())
378 CString strProgramName
;
379 strProgramName
.LoadString(IDS_PROGRAMNAME
);
380 CPath
pathFileName(filepathname
);
381 pathFileName
.StripPath();
382 CString strSavePromptText
;
383 strSavePromptText
.Format(IDS_SAVEPROMPTTEXT
, (LPCTSTR
)pathFileName
);
384 switch (MessageBox(strSavePromptText
, strProgramName
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
387 imageModel
.imageSaved
= TRUE
; //TODO: move to ImageModel
397 if (reset
&& imageModel
.IsImageSaved()) //TODO: move to ImageModel
400 imageModel
.ClearHistory();
405 if (GetOpenFileName(&ofn
) != 0)
407 HBITMAP bmNew
= NULL
;
408 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
411 UpdateApplicationProperties(bmNew
, ofn
.lpstrFile
);
421 case IDM_FILEPAGESETUP
:
422 // DUMMY: Shows the dialog only, no functionality
424 ZeroMemory(&psd
, sizeof(psd
));
425 psd
.lStructSize
= sizeof(psd
);
426 psd
.hwndOwner
= m_hWnd
;
430 // TODO: Test whether it actually works
432 ZeroMemory(&pd
, sizeof(pd
));
433 pd
.lStructSize
= sizeof(pd
);
434 pd
.hwndOwner
= m_hWnd
;
435 pd
.hDevMode
= NULL
; // freed by user
436 pd
.hDevNames
= NULL
; // freed by user
437 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
439 pd
.nFromPage
= 0xffff;
442 pd
.nMaxPage
= 0xffff;
443 if (PrintDlg(&pd
) == TRUE
)
445 BitBlt(pd
.hDC
, 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), imageModel
.GetDC(), 0, 0, SRCCOPY
);
449 GlobalFree(pd
.hDevMode
);
451 GlobalFree(pd
.hDevNames
);
453 case IDM_FILEASWALLPAPERPLANE
:
454 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::TILED
);
456 case IDM_FILEASWALLPAPERCENTERED
:
457 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::CENTERED
);
459 case IDM_FILEASWALLPAPERSTRETCHED
:
460 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::STRETCHED
);
464 HBITMAP bmNew
= NULL
;
465 LoadDIBFromFile(&bmNew
, registrySettings
.strFile1
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
468 UpdateApplicationProperties(bmNew
, registrySettings
.strFile1
);
474 HBITMAP bmNew
= NULL
;
475 LoadDIBFromFile(&bmNew
, registrySettings
.strFile2
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
478 UpdateApplicationProperties(bmNew
, registrySettings
.strFile2
);
484 HBITMAP bmNew
= NULL
;
485 LoadDIBFromFile(&bmNew
, registrySettings
.strFile3
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
488 UpdateApplicationProperties(bmNew
, registrySettings
.strFile3
);
494 HBITMAP bmNew
= NULL
;
495 LoadDIBFromFile(&bmNew
, registrySettings
.strFile4
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
498 UpdateApplicationProperties(bmNew
, registrySettings
.strFile4
);
504 imageArea
.Invalidate(FALSE
);
508 imageArea
.Invalidate(FALSE
);
513 SetClipboardData(CF_BITMAP
, CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
518 SendMessage(WM_COMMAND
, IDM_EDITCOPY
, 0);
519 /* Delete selection */
520 SendMessage(WM_COMMAND
, IDM_EDITDELETESELECTION
, 0);
524 if (GetClipboardData(CF_BITMAP
) != NULL
)
526 InsertSelectionFromHBITMAP((HBITMAP
) GetClipboardData(CF_BITMAP
), m_hWnd
);
530 case IDM_EDITDELETESELECTION
:
532 /* remove selection window and already painted content using undo */
536 case IDM_EDITSELECTALL
:
538 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
539 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELPARAM(TRUE
, 0));
540 toolBoxContainer
.SendMessage(WM_COMMAND
, ID_RECTSEL
);
541 //TODO: do this properly
542 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
543 whilePaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
544 endPaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
548 if (GetSaveFileName(&ofn
) != 0)
549 SaveDIBToFile(selectionModel
.GetBitmap(), ofn
.lpstrFile
, imageModel
.GetDC(), NULL
, NULL
, fileHPPM
, fileVPPM
);
551 case IDM_EDITPASTEFROM
:
552 if (GetOpenFileName(&ofn
) != 0)
554 HBITMAP bmNew
= NULL
;
555 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
558 InsertSelectionFromHBITMAP(bmNew
, m_hWnd
);
563 case IDM_COLORSEDITPALETTE
:
564 if (ChooseColor(&choosecolor
))
565 paletteModel
.SetFgColor(choosecolor
.rgbResult
);
567 case IDM_COLORSMODERNPALETTE
:
568 paletteModel
.SelectPalette(1);
570 case IDM_COLORSOLDPALETTE
:
571 paletteModel
.SelectPalette(2);
573 case IDM_IMAGEINVERTCOLORS
:
575 imageModel
.InvertColors();
578 case IDM_IMAGEDELETEIMAGE
:
579 imageModel
.CopyPrevious();
580 Rect(imageModel
.GetDC(), 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetBgColor(), paletteModel
.GetBgColor(), 0, TRUE
);
581 imageArea
.Invalidate(FALSE
);
583 case IDM_IMAGEROTATEMIRROR
:
584 switch (mirrorRotateDlg())
586 case 1: /* flip horizontally */
587 if (selectionWindow
.IsWindowVisible())
588 selectionModel
.FlipHorizontally();
590 imageModel
.FlipHorizontally();
592 case 2: /* flip vertically */
593 if (selectionWindow
.IsWindowVisible())
594 selectionModel
.FlipVertically();
596 imageModel
.FlipVertically();
598 case 3: /* rotate 90 degrees */
600 case 4: /* rotate 180 degrees */
601 if (selectionWindow
.IsWindowVisible())
602 selectionModel
.RotateNTimes90Degrees(2);
604 imageModel
.RotateNTimes90Degrees(2);
606 case 5: /* rotate 270 degrees */
610 case IDM_IMAGEATTRIBUTES
:
614 imageModel
.Crop(widthSetInDlg
, heightSetInDlg
, 0, 0);
618 case IDM_IMAGESTRETCHSKEW
:
622 imageModel
.StretchSkew(stretchSkew
.percentage
.x
, stretchSkew
.percentage
.y
,
623 stretchSkew
.angle
.x
, stretchSkew
.angle
.y
);
627 case IDM_IMAGEDRAWOPAQUE
:
628 toolsModel
.SetBackgroundTransparent(!toolsModel
.IsBackgroundTransparent());
631 imageModel
.Insert((HBITMAP
) CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
634 case IDM_VIEWTOOLBOX
:
635 toolBoxContainer
.ShowWindow(toolBoxContainer
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
636 alignChildrenToMainWindow();
638 case IDM_VIEWCOLORPALETTE
:
639 paletteWindow
.ShowWindow(paletteWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
640 alignChildrenToMainWindow();
642 case IDM_VIEWSTATUSBAR
:
643 ::ShowWindow(hStatusBar
, ::IsWindowVisible(hStatusBar
) ? SW_HIDE
: SW_SHOW
);
644 alignChildrenToMainWindow();
646 case IDM_FORMATICONBAR
:
647 textEditWindow
.ShowWindow(textEditWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
649 case IDM_VIEWSHOWGRID
:
650 showGrid
= !showGrid
;
651 imageArea
.Invalidate(FALSE
);
653 case IDM_VIEWSHOWMINIATURE
:
654 showMiniature
= !showMiniature
;
655 miniature
.ShowWindow(showMiniature
? SW_SHOW
: SW_HIDE
);
658 case IDM_VIEWZOOM125
:
667 case IDM_VIEWZOOM100
:
670 case IDM_VIEWZOOM200
:
673 case IDM_VIEWZOOM400
:
676 case IDM_VIEWZOOM800
:
680 case IDM_VIEWFULLSCREEN
:
681 fullscreenWindow
.ShowWindow(SW_SHOW
);