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;
70 SendMessage(hStatusBar
, SB_GETRECT
, 0, (LPARAM
)&statusBarRect0
);
71 int statusBarBorders
[3];
72 SendMessage(hStatusBar
, SB_GETBORDERS
, 0, (LPARAM
)&statusBarBorders
);
73 int statusBarHeight
= statusBarRect0
.bottom
- statusBarRect0
.top
+ statusBarBorders
[1];
75 scrollboxWindow
.MoveWindow(x
, y
, w
, ::IsWindowVisible(hStatusBar
) ? h
- statusBarHeight
: h
, TRUE
);
76 paletteWindow
.MoveWindow(x
, 9, 255, 32, TRUE
);
79 void CMainWindow::saveImage(BOOL overwrite
)
81 if (isAFile
&& overwrite
)
83 imageModel
.SaveImage(filepathname
);
85 else if (GetSaveFileName(&sfn
) != 0)
87 imageModel
.SaveImage(sfn
.lpstrFile
);
89 strTitle
.Format(IDS_WINDOWTITLE
, (LPCTSTR
)sfn
.lpstrFileTitle
);
90 SetWindowText(strTitle
);
95 void CMainWindow::UpdateApplicationProperties(HBITMAP bitmap
, LPCTSTR newfilepathname
)
97 imageModel
.Insert(bitmap
);
98 CopyMemory(filepathname
, newfilepathname
, sizeof(filepathname
));
99 CPath
pathFileName(newfilepathname
);
100 pathFileName
.StripPath();
102 strTitle
.Format(IDS_WINDOWTITLE
, (LPCTSTR
)pathFileName
);
103 SetWindowText(strTitle
);
104 imageModel
.ClearHistory();
107 registrySettings
.SetMostRecentFile(newfilepathname
);
110 void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap
, HWND window
)
112 int width
= GetDIBWidth(bitmap
);
113 int height
= GetDIBHeight(bitmap
);
114 int curWidth
= imageModel
.GetWidth();
115 int curHeight
= imageModel
.GetHeight();
117 if (width
> curWidth
|| height
> curHeight
)
119 BOOL shouldEnlarge
= TRUE
;
121 if (askBeforeEnlarging
)
123 TCHAR programname
[20];
124 TCHAR shouldEnlargePromptText
[100];
126 LoadString(hProgInstance
, IDS_PROGRAMNAME
, programname
, SIZEOF(programname
));
127 LoadString(hProgInstance
, IDS_ENLARGEPROMPTTEXT
, shouldEnlargePromptText
, SIZEOF(shouldEnlargePromptText
));
129 switch (MessageBox(shouldEnlargePromptText
, programname
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
134 shouldEnlarge
= FALSE
;
143 if (width
> curWidth
)
146 if (height
> curHeight
)
149 imageModel
.Crop(curWidth
, curHeight
, 0, 0);
153 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
154 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELPARAM(TRUE
, 0));
155 toolBoxContainer
.SendMessage(WM_COMMAND
, ID_RECTSEL
);
157 imageModel
.CopyPrevious();
158 selectionModel
.InsertFromHBITMAP(bitmap
);
161 selectionWindow
.ShowWindow(SW_SHOW
);
162 ForceRefreshSelectionContents();
165 LRESULT
CMainWindow::OnDropFiles(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
168 TCHAR droppedfile
[MAX_PATH
];
169 HBITMAP bmNew
= NULL
;
170 drophandle
= (HDROP
)wParam
;
171 DragQueryFile(drophandle
, 0, droppedfile
, SIZEOF(droppedfile
));
172 DragFinish(drophandle
);
173 LoadDIBFromFile(&bmNew
, droppedfile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
176 UpdateApplicationProperties(bmNew
, droppedfile
);
181 LRESULT
CMainWindow::OnCreate(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
183 SendMessage(WM_SETICON
, ICON_BIG
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
184 SendMessage(WM_SETICON
, ICON_SMALL
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
188 LRESULT
CMainWindow::OnDestroy(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
190 GetWindowPlacement(&(registrySettings
.WindowPlacement
));
191 PostQuitMessage(0); /* send a WM_QUIT to the message queue */
195 LRESULT
CMainWindow::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
197 if (!imageModel
.IsImageSaved())
199 CString strProgramName
;
200 strProgramName
.LoadString(IDS_PROGRAMNAME
);
201 CPath
pathFileName(filepathname
);
202 pathFileName
.StripPath();
203 CString strSavePromptText
;
204 strSavePromptText
.Format(IDS_SAVEPROMPTTEXT
, (LPCTSTR
)pathFileName
);
205 switch (MessageBox(strSavePromptText
, strProgramName
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
212 if (imageModel
.IsImageSaved())
224 LRESULT
CMainWindow::OnInitMenuPopup(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
226 HMENU menu
= GetMenu();
227 BOOL trueSelection
= (selectionWindow
.IsWindowVisible() && ((toolsModel
.GetActiveTool() == TOOL_FREESEL
) || (toolsModel
.GetActiveTool() == TOOL_RECTSEL
)));
230 case 0: /* File menu */
231 if ((HMENU
)wParam
!= GetSubMenu(menu
, 0))
233 EnableMenuItem(menu
, IDM_FILEASWALLPAPERPLANE
, ENABLED_IF(isAFile
));
234 EnableMenuItem(menu
, IDM_FILEASWALLPAPERCENTERED
, ENABLED_IF(isAFile
));
235 EnableMenuItem(menu
, IDM_FILEASWALLPAPERSTRETCHED
, ENABLED_IF(isAFile
));
236 RemoveMenu(menu
, IDM_FILE1
, MF_BYCOMMAND
);
237 RemoveMenu(menu
, IDM_FILE2
, MF_BYCOMMAND
);
238 RemoveMenu(menu
, IDM_FILE3
, MF_BYCOMMAND
);
239 RemoveMenu(menu
, IDM_FILE4
, MF_BYCOMMAND
);
240 if (!registrySettings
.strFile1
.IsEmpty())
242 RemoveMenu(menu
, IDM_FILEMOSTRECENTLYUSEDFILE
, MF_BYCOMMAND
);
243 CPath
pathFile1(registrySettings
.strFile1
);
244 pathFile1
.CompactPathEx(30);
245 if (!registrySettings
.strFile2
.IsEmpty())
247 CPath
pathFile2(registrySettings
.strFile2
);
248 pathFile2
.CompactPathEx(30);
249 if (!registrySettings
.strFile3
.IsEmpty())
251 CPath
pathFile3(registrySettings
.strFile3
);
252 pathFile3
.CompactPathEx(30);
253 if (!registrySettings
.strFile4
.IsEmpty())
255 CPath
pathFile4(registrySettings
.strFile4
);
256 pathFile4
.CompactPathEx(30);
257 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE4
, _T("4 ") + pathFile4
);
259 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE3
, _T("3 ") + pathFile3
);
261 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE2
, _T("2 ") + pathFile2
);
263 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE1
, _T("1 ") + pathFile1
);
266 case 1: /* Edit menu */
267 EnableMenuItem(menu
, IDM_EDITUNDO
, ENABLED_IF(imageModel
.HasUndoSteps()));
268 EnableMenuItem(menu
, IDM_EDITREDO
, ENABLED_IF(imageModel
.HasRedoSteps()));
269 EnableMenuItem(menu
, IDM_EDITCUT
, ENABLED_IF(trueSelection
));
270 EnableMenuItem(menu
, IDM_EDITCOPY
, ENABLED_IF(trueSelection
));
271 EnableMenuItem(menu
, IDM_EDITDELETESELECTION
, ENABLED_IF(trueSelection
));
272 EnableMenuItem(menu
, IDM_EDITINVERTSELECTION
, ENABLED_IF(trueSelection
));
273 EnableMenuItem(menu
, IDM_EDITCOPYTO
, ENABLED_IF(trueSelection
));
275 EnableMenuItem(menu
, IDM_EDITPASTE
, ENABLED_IF(GetClipboardData(CF_BITMAP
) != NULL
));
278 case 2: /* View menu */
279 CheckMenuItem(menu
, IDM_VIEWTOOLBOX
, CHECKED_IF(toolBoxContainer
.IsWindowVisible()));
280 CheckMenuItem(menu
, IDM_VIEWCOLORPALETTE
, CHECKED_IF(paletteWindow
.IsWindowVisible()));
281 CheckMenuItem(menu
, IDM_VIEWSTATUSBAR
, CHECKED_IF(::IsWindowVisible(hStatusBar
)));
282 CheckMenuItem(menu
, IDM_FORMATICONBAR
, CHECKED_IF(textEditWindow
.IsWindowVisible()));
283 EnableMenuItem(menu
, IDM_FORMATICONBAR
, ENABLED_IF(toolsModel
.GetActiveTool() == TOOL_TEXT
));
285 CheckMenuItem(menu
, IDM_VIEWSHOWGRID
, CHECKED_IF(showGrid
));
286 CheckMenuItem(menu
, IDM_VIEWSHOWMINIATURE
, CHECKED_IF(showMiniature
));
288 case 3: /* Image menu */
289 EnableMenuItem(menu
, IDM_IMAGECROP
, ENABLED_IF(selectionWindow
.IsWindowVisible()));
290 CheckMenuItem(menu
, IDM_IMAGEDRAWOPAQUE
, CHECKED_IF(!toolsModel
.IsBackgroundTransparent()));
294 CheckMenuItem(menu
, IDM_VIEWZOOM125
, CHECKED_IF(toolsModel
.GetZoom() == 125));
295 CheckMenuItem(menu
, IDM_VIEWZOOM25
, CHECKED_IF(toolsModel
.GetZoom() == 250));
296 CheckMenuItem(menu
, IDM_VIEWZOOM50
, CHECKED_IF(toolsModel
.GetZoom() == 500));
297 CheckMenuItem(menu
, IDM_VIEWZOOM100
, CHECKED_IF(toolsModel
.GetZoom() == 1000));
298 CheckMenuItem(menu
, IDM_VIEWZOOM200
, CHECKED_IF(toolsModel
.GetZoom() == 2000));
299 CheckMenuItem(menu
, IDM_VIEWZOOM400
, CHECKED_IF(toolsModel
.GetZoom() == 4000));
300 CheckMenuItem(menu
, IDM_VIEWZOOM800
, CHECKED_IF(toolsModel
.GetZoom() == 8000));
302 CheckMenuItem(menu
, IDM_COLORSMODERNPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 1));
303 CheckMenuItem(menu
, IDM_COLORSOLDPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 2));
307 LRESULT
CMainWindow::OnSize(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
309 int test
[] = { LOWORD(lParam
) - 260, LOWORD(lParam
) - 140, LOWORD(lParam
) - 20 };
310 SendMessage(hStatusBar
, WM_SIZE
, wParam
, lParam
);
311 SendMessage(hStatusBar
, SB_SETPARTS
, 3, (LPARAM
)&test
);
312 alignChildrenToMainWindow();
317 LRESULT
CMainWindow::OnGetMinMaxInfo(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
319 MINMAXINFO
*mm
= (LPMINMAXINFO
) lParam
;
320 mm
->ptMinTrackSize
.x
= 330;
321 mm
->ptMinTrackSize
.y
= 430;
325 LRESULT
CMainWindow::OnSetCursor(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
327 SetCursor(LoadCursor(NULL
, IDC_ARROW
));
332 LRESULT
CMainWindow::OnKeyDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
334 if (wParam
== VK_ESCAPE
)
336 if (!imageArea
.drawing
)
339 if ((toolsModel
.GetActiveTool() == TOOL_RECTSEL
) || (toolsModel
.GetActiveTool() == TOOL_FREESEL
))
341 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
342 whilePaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
343 endPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
344 selectionWindow
.ShowWindow(SW_HIDE
);
347 /* FIXME: also cancel current drawing underway */
352 LRESULT
CMainWindow::OnSysColorChange(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
354 /* Redirect message to common controls */
355 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
356 SendMessage(hToolbar
, WM_SYSCOLORCHANGE
, 0, 0);
360 LRESULT
CMainWindow::OnCommand(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
362 switch (LOWORD(wParam
))
366 HICON paintIcon
= LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
));
367 TCHAR infotitle
[100];
369 LoadString(hProgInstance
, IDS_INFOTITLE
, infotitle
, SIZEOF(infotitle
));
370 LoadString(hProgInstance
, IDS_INFOTEXT
, infotext
, SIZEOF(infotext
));
371 ShellAbout(m_hWnd
, infotitle
, infotext
, paintIcon
);
372 DeleteObject(paintIcon
);
375 case IDM_HELPHELPTOPICS
:
376 HtmlHelp(m_hWnd
, _T("help\\Paint.chm"), 0, 0);
379 SendMessage(WM_CLOSE
, wParam
, lParam
);
384 if (!imageModel
.IsImageSaved())
386 CString strProgramName
;
387 strProgramName
.LoadString(IDS_PROGRAMNAME
);
388 CPath
pathFileName(filepathname
);
389 pathFileName
.StripPath();
390 CString strSavePromptText
;
391 strSavePromptText
.Format(IDS_SAVEPROMPTTEXT
, (LPCTSTR
)pathFileName
);
392 switch (MessageBox(strSavePromptText
, strProgramName
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
395 imageModel
.imageSaved
= TRUE
; //TODO: move to ImageModel
405 if (reset
&& imageModel
.IsImageSaved()) //TODO: move to ImageModel
408 imageModel
.ClearHistory();
413 if (GetOpenFileName(&ofn
) != 0)
415 HBITMAP bmNew
= NULL
;
416 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
419 UpdateApplicationProperties(bmNew
, ofn
.lpstrFile
);
429 case IDM_FILEPAGESETUP
:
430 // DUMMY: Shows the dialog only, no functionality
432 ZeroMemory(&psd
, sizeof(psd
));
433 psd
.lStructSize
= sizeof(psd
);
434 psd
.hwndOwner
= m_hWnd
;
438 // TODO: Test whether it actually works
440 ZeroMemory(&pd
, sizeof(pd
));
441 pd
.lStructSize
= sizeof(pd
);
442 pd
.hwndOwner
= m_hWnd
;
443 pd
.hDevMode
= NULL
; // freed by user
444 pd
.hDevNames
= NULL
; // freed by user
445 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
447 pd
.nFromPage
= 0xffff;
450 pd
.nMaxPage
= 0xffff;
451 if (PrintDlg(&pd
) == TRUE
)
453 BitBlt(pd
.hDC
, 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), imageModel
.GetDC(), 0, 0, SRCCOPY
);
457 GlobalFree(pd
.hDevMode
);
459 GlobalFree(pd
.hDevNames
);
461 case IDM_FILEASWALLPAPERPLANE
:
462 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::TILED
);
464 case IDM_FILEASWALLPAPERCENTERED
:
465 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::CENTERED
);
467 case IDM_FILEASWALLPAPERSTRETCHED
:
468 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::STRETCHED
);
472 HBITMAP bmNew
= NULL
;
473 LoadDIBFromFile(&bmNew
, registrySettings
.strFile1
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
476 UpdateApplicationProperties(bmNew
, registrySettings
.strFile1
);
482 HBITMAP bmNew
= NULL
;
483 LoadDIBFromFile(&bmNew
, registrySettings
.strFile2
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
486 UpdateApplicationProperties(bmNew
, registrySettings
.strFile2
);
492 HBITMAP bmNew
= NULL
;
493 LoadDIBFromFile(&bmNew
, registrySettings
.strFile3
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
496 UpdateApplicationProperties(bmNew
, registrySettings
.strFile3
);
502 HBITMAP bmNew
= NULL
;
503 LoadDIBFromFile(&bmNew
, registrySettings
.strFile4
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
506 UpdateApplicationProperties(bmNew
, registrySettings
.strFile4
);
512 imageArea
.Invalidate(FALSE
);
516 imageArea
.Invalidate(FALSE
);
521 SetClipboardData(CF_BITMAP
, CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
526 SendMessage(WM_COMMAND
, IDM_EDITCOPY
, 0);
527 /* Delete selection */
528 SendMessage(WM_COMMAND
, IDM_EDITDELETESELECTION
, 0);
532 if (GetClipboardData(CF_BITMAP
) != NULL
)
534 InsertSelectionFromHBITMAP((HBITMAP
) GetClipboardData(CF_BITMAP
), m_hWnd
);
538 case IDM_EDITDELETESELECTION
:
540 /* remove selection window and already painted content using undo */
544 case IDM_EDITSELECTALL
:
546 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
547 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELPARAM(TRUE
, 0));
548 toolBoxContainer
.SendMessage(WM_COMMAND
, ID_RECTSEL
);
549 //TODO: do this properly
550 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
551 whilePaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
552 endPaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
556 if (GetSaveFileName(&ofn
) != 0)
557 SaveDIBToFile(selectionModel
.GetBitmap(), ofn
.lpstrFile
, imageModel
.GetDC(), NULL
, NULL
, fileHPPM
, fileVPPM
);
559 case IDM_EDITPASTEFROM
:
560 if (GetOpenFileName(&ofn
) != 0)
562 HBITMAP bmNew
= NULL
;
563 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
566 InsertSelectionFromHBITMAP(bmNew
, m_hWnd
);
571 case IDM_COLORSEDITPALETTE
:
572 if (ChooseColor(&choosecolor
))
573 paletteModel
.SetFgColor(choosecolor
.rgbResult
);
575 case IDM_COLORSMODERNPALETTE
:
576 paletteModel
.SelectPalette(1);
578 case IDM_COLORSOLDPALETTE
:
579 paletteModel
.SelectPalette(2);
581 case IDM_IMAGEINVERTCOLORS
:
583 imageModel
.InvertColors();
586 case IDM_IMAGEDELETEIMAGE
:
587 imageModel
.CopyPrevious();
588 Rect(imageModel
.GetDC(), 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetBgColor(), paletteModel
.GetBgColor(), 0, TRUE
);
589 imageArea
.Invalidate(FALSE
);
591 case IDM_IMAGEROTATEMIRROR
:
592 switch (mirrorRotateDlg())
594 case 1: /* flip horizontally */
595 if (selectionWindow
.IsWindowVisible())
596 selectionModel
.FlipHorizontally();
598 imageModel
.FlipHorizontally();
600 case 2: /* flip vertically */
601 if (selectionWindow
.IsWindowVisible())
602 selectionModel
.FlipVertically();
604 imageModel
.FlipVertically();
606 case 3: /* rotate 90 degrees */
608 case 4: /* rotate 180 degrees */
609 if (selectionWindow
.IsWindowVisible())
610 selectionModel
.RotateNTimes90Degrees(2);
612 imageModel
.RotateNTimes90Degrees(2);
614 case 5: /* rotate 270 degrees */
618 case IDM_IMAGEATTRIBUTES
:
622 imageModel
.Crop(widthSetInDlg
, heightSetInDlg
, 0, 0);
626 case IDM_IMAGESTRETCHSKEW
:
630 imageModel
.StretchSkew(stretchSkew
.percentage
.x
, stretchSkew
.percentage
.y
,
631 stretchSkew
.angle
.x
, stretchSkew
.angle
.y
);
635 case IDM_IMAGEDRAWOPAQUE
:
636 toolsModel
.SetBackgroundTransparent(!toolsModel
.IsBackgroundTransparent());
639 imageModel
.Insert((HBITMAP
) CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
642 case IDM_VIEWTOOLBOX
:
643 toolBoxContainer
.ShowWindow(toolBoxContainer
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
644 alignChildrenToMainWindow();
646 case IDM_VIEWCOLORPALETTE
:
647 paletteWindow
.ShowWindow(paletteWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
648 alignChildrenToMainWindow();
650 case IDM_VIEWSTATUSBAR
:
651 ::ShowWindow(hStatusBar
, ::IsWindowVisible(hStatusBar
) ? SW_HIDE
: SW_SHOW
);
652 alignChildrenToMainWindow();
654 case IDM_FORMATICONBAR
:
655 textEditWindow
.ShowWindow(textEditWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
657 case IDM_VIEWSHOWGRID
:
658 showGrid
= !showGrid
;
659 imageArea
.Invalidate(FALSE
);
661 case IDM_VIEWSHOWMINIATURE
:
662 showMiniature
= !showMiniature
;
663 miniature
.ShowWindow(showMiniature
? SW_SHOW
: SW_HIDE
);
666 case IDM_VIEWZOOM125
:
675 case IDM_VIEWZOOM100
:
678 case IDM_VIEWZOOM200
:
681 case IDM_VIEWZOOM400
:
684 case IDM_VIEWZOOM800
:
688 case IDM_VIEWFULLSCREEN
:
689 fullscreenWindow
.ShowWindow(SW_SHOW
);