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 if ((HMENU
)wParam
!= GetSubMenu(menu
, 0))
227 EnableMenuItem(menu
, IDM_FILEASWALLPAPERPLANE
, ENABLED_IF(isAFile
));
228 EnableMenuItem(menu
, IDM_FILEASWALLPAPERCENTERED
, ENABLED_IF(isAFile
));
229 EnableMenuItem(menu
, IDM_FILEASWALLPAPERSTRETCHED
, ENABLED_IF(isAFile
));
230 RemoveMenu(menu
, IDM_FILE1
, MF_BYCOMMAND
);
231 RemoveMenu(menu
, IDM_FILE2
, MF_BYCOMMAND
);
232 RemoveMenu(menu
, IDM_FILE3
, MF_BYCOMMAND
);
233 RemoveMenu(menu
, IDM_FILE4
, MF_BYCOMMAND
);
234 if (!registrySettings
.strFile1
.IsEmpty())
236 RemoveMenu(menu
, IDM_FILEMOSTRECENTLYUSEDFILE
, MF_BYCOMMAND
);
237 CPath
pathFile1(registrySettings
.strFile1
);
238 pathFile1
.CompactPathEx(30);
239 if (!registrySettings
.strFile2
.IsEmpty())
241 CPath
pathFile2(registrySettings
.strFile2
);
242 pathFile2
.CompactPathEx(30);
243 if (!registrySettings
.strFile3
.IsEmpty())
245 CPath
pathFile3(registrySettings
.strFile3
);
246 pathFile3
.CompactPathEx(30);
247 if (!registrySettings
.strFile4
.IsEmpty())
249 CPath
pathFile4(registrySettings
.strFile4
);
250 pathFile4
.CompactPathEx(30);
251 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE4
, _T("4 ") + pathFile4
);
253 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE3
, _T("3 ") + pathFile3
);
255 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE2
, _T("2 ") + pathFile2
);
257 InsertMenu((HMENU
)wParam
, 17, MF_BYPOSITION
| MF_STRING
, IDM_FILE1
, _T("1 ") + pathFile1
);
260 case 1: /* Edit menu */
261 EnableMenuItem(menu
, IDM_EDITUNDO
, ENABLED_IF(imageModel
.HasUndoSteps()));
262 EnableMenuItem(menu
, IDM_EDITREDO
, ENABLED_IF(imageModel
.HasRedoSteps()));
263 EnableMenuItem(menu
, IDM_EDITCUT
, ENABLED_IF(trueSelection
));
264 EnableMenuItem(menu
, IDM_EDITCOPY
, ENABLED_IF(trueSelection
));
265 EnableMenuItem(menu
, IDM_EDITDELETESELECTION
, ENABLED_IF(trueSelection
));
266 EnableMenuItem(menu
, IDM_EDITINVERTSELECTION
, ENABLED_IF(trueSelection
));
267 EnableMenuItem(menu
, IDM_EDITCOPYTO
, ENABLED_IF(trueSelection
));
269 EnableMenuItem(menu
, IDM_EDITPASTE
, ENABLED_IF(GetClipboardData(CF_BITMAP
) != NULL
));
272 case 2: /* View menu */
273 CheckMenuItem(menu
, IDM_VIEWTOOLBOX
, CHECKED_IF(toolBoxContainer
.IsWindowVisible()));
274 CheckMenuItem(menu
, IDM_VIEWCOLORPALETTE
, CHECKED_IF(paletteWindow
.IsWindowVisible()));
275 CheckMenuItem(menu
, IDM_VIEWSTATUSBAR
, CHECKED_IF(::IsWindowVisible(hStatusBar
)));
276 CheckMenuItem(menu
, IDM_FORMATICONBAR
, CHECKED_IF(textEditWindow
.IsWindowVisible()));
277 EnableMenuItem(menu
, IDM_FORMATICONBAR
, ENABLED_IF(toolsModel
.GetActiveTool() == TOOL_TEXT
));
279 CheckMenuItem(menu
, IDM_VIEWSHOWGRID
, CHECKED_IF(showGrid
));
280 CheckMenuItem(menu
, IDM_VIEWSHOWMINIATURE
, CHECKED_IF(showMiniature
));
282 case 3: /* Image menu */
283 EnableMenuItem(menu
, IDM_IMAGECROP
, ENABLED_IF(selectionWindow
.IsWindowVisible()));
284 CheckMenuItem(menu
, IDM_IMAGEDRAWOPAQUE
, CHECKED_IF(!toolsModel
.IsBackgroundTransparent()));
288 CheckMenuItem(menu
, IDM_VIEWZOOM125
, CHECKED_IF(toolsModel
.GetZoom() == 125));
289 CheckMenuItem(menu
, IDM_VIEWZOOM25
, CHECKED_IF(toolsModel
.GetZoom() == 250));
290 CheckMenuItem(menu
, IDM_VIEWZOOM50
, CHECKED_IF(toolsModel
.GetZoom() == 500));
291 CheckMenuItem(menu
, IDM_VIEWZOOM100
, CHECKED_IF(toolsModel
.GetZoom() == 1000));
292 CheckMenuItem(menu
, IDM_VIEWZOOM200
, CHECKED_IF(toolsModel
.GetZoom() == 2000));
293 CheckMenuItem(menu
, IDM_VIEWZOOM400
, CHECKED_IF(toolsModel
.GetZoom() == 4000));
294 CheckMenuItem(menu
, IDM_VIEWZOOM800
, CHECKED_IF(toolsModel
.GetZoom() == 8000));
296 CheckMenuItem(menu
, IDM_COLORSMODERNPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 1));
297 CheckMenuItem(menu
, IDM_COLORSOLDPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 2));
301 LRESULT
CMainWindow::OnSize(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
303 int test
[] = { LOWORD(lParam
) - 260, LOWORD(lParam
) - 140, LOWORD(lParam
) - 20 };
304 SendMessage(hStatusBar
, WM_SIZE
, wParam
, lParam
);
305 SendMessage(hStatusBar
, SB_SETPARTS
, 3, (LPARAM
)&test
);
306 alignChildrenToMainWindow();
311 LRESULT
CMainWindow::OnGetMinMaxInfo(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
313 MINMAXINFO
*mm
= (LPMINMAXINFO
) lParam
;
314 mm
->ptMinTrackSize
.x
= 330;
315 mm
->ptMinTrackSize
.y
= 430;
319 LRESULT
CMainWindow::OnSetCursor(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
321 SetCursor(LoadCursor(NULL
, IDC_ARROW
));
326 LRESULT
CMainWindow::OnKeyDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
328 if (wParam
== VK_ESCAPE
)
330 if (!imageArea
.drawing
)
333 if ((toolsModel
.GetActiveTool() == TOOL_RECTSEL
) || (toolsModel
.GetActiveTool() == TOOL_FREESEL
))
335 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
336 whilePaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
337 endPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
338 selectionWindow
.ShowWindow(SW_HIDE
);
341 /* FIXME: also cancel current drawing underway */
346 LRESULT
CMainWindow::OnSysColorChange(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
348 /* Redirect message to common controls */
349 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
350 SendMessage(hToolbar
, WM_SYSCOLORCHANGE
, 0, 0);
354 LRESULT
CMainWindow::OnCommand(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
356 switch (LOWORD(wParam
))
360 HICON paintIcon
= LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
));
361 TCHAR infotitle
[100];
363 LoadString(hProgInstance
, IDS_INFOTITLE
, infotitle
, SIZEOF(infotitle
));
364 LoadString(hProgInstance
, IDS_INFOTEXT
, infotext
, SIZEOF(infotext
));
365 ShellAbout(m_hWnd
, infotitle
, infotext
, paintIcon
);
366 DeleteObject(paintIcon
);
369 case IDM_HELPHELPTOPICS
:
370 HtmlHelp(m_hWnd
, _T("help\\Paint.chm"), 0, 0);
373 SendMessage(WM_CLOSE
, wParam
, lParam
);
378 if (!imageModel
.IsImageSaved())
380 CString strProgramName
;
381 strProgramName
.LoadString(IDS_PROGRAMNAME
);
382 CPath
pathFileName(filepathname
);
383 pathFileName
.StripPath();
384 CString strSavePromptText
;
385 strSavePromptText
.Format(IDS_SAVEPROMPTTEXT
, (LPCTSTR
)pathFileName
);
386 switch (MessageBox(strSavePromptText
, strProgramName
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
389 imageModel
.imageSaved
= TRUE
; //TODO: move to ImageModel
399 if (reset
&& imageModel
.IsImageSaved()) //TODO: move to ImageModel
402 imageModel
.ClearHistory();
407 if (GetOpenFileName(&ofn
) != 0)
409 HBITMAP bmNew
= NULL
;
410 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
413 UpdateApplicationProperties(bmNew
, ofn
.lpstrFile
);
423 case IDM_FILEPAGESETUP
:
424 // DUMMY: Shows the dialog only, no functionality
426 ZeroMemory(&psd
, sizeof(psd
));
427 psd
.lStructSize
= sizeof(psd
);
428 psd
.hwndOwner
= m_hWnd
;
432 // TODO: Test whether it actually works
434 ZeroMemory(&pd
, sizeof(pd
));
435 pd
.lStructSize
= sizeof(pd
);
436 pd
.hwndOwner
= m_hWnd
;
437 pd
.hDevMode
= NULL
; // freed by user
438 pd
.hDevNames
= NULL
; // freed by user
439 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
441 pd
.nFromPage
= 0xffff;
444 pd
.nMaxPage
= 0xffff;
445 if (PrintDlg(&pd
) == TRUE
)
447 BitBlt(pd
.hDC
, 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), imageModel
.GetDC(), 0, 0, SRCCOPY
);
451 GlobalFree(pd
.hDevMode
);
453 GlobalFree(pd
.hDevNames
);
455 case IDM_FILEASWALLPAPERPLANE
:
456 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::TILED
);
458 case IDM_FILEASWALLPAPERCENTERED
:
459 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::CENTERED
);
461 case IDM_FILEASWALLPAPERSTRETCHED
:
462 RegistrySettings::SetWallpaper(filepathname
, RegistrySettings::STRETCHED
);
466 HBITMAP bmNew
= NULL
;
467 LoadDIBFromFile(&bmNew
, registrySettings
.strFile1
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
470 UpdateApplicationProperties(bmNew
, registrySettings
.strFile1
);
476 HBITMAP bmNew
= NULL
;
477 LoadDIBFromFile(&bmNew
, registrySettings
.strFile2
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
480 UpdateApplicationProperties(bmNew
, registrySettings
.strFile2
);
486 HBITMAP bmNew
= NULL
;
487 LoadDIBFromFile(&bmNew
, registrySettings
.strFile3
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
490 UpdateApplicationProperties(bmNew
, registrySettings
.strFile3
);
496 HBITMAP bmNew
= NULL
;
497 LoadDIBFromFile(&bmNew
, registrySettings
.strFile4
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
500 UpdateApplicationProperties(bmNew
, registrySettings
.strFile4
);
506 imageArea
.Invalidate(FALSE
);
510 imageArea
.Invalidate(FALSE
);
515 SetClipboardData(CF_BITMAP
, CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
520 SendMessage(WM_COMMAND
, IDM_EDITCOPY
, 0);
521 /* Delete selection */
522 SendMessage(WM_COMMAND
, IDM_EDITDELETESELECTION
, 0);
526 if (GetClipboardData(CF_BITMAP
) != NULL
)
528 InsertSelectionFromHBITMAP((HBITMAP
) GetClipboardData(CF_BITMAP
), m_hWnd
);
532 case IDM_EDITDELETESELECTION
:
534 /* remove selection window and already painted content using undo */
538 case IDM_EDITSELECTALL
:
540 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
541 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELPARAM(TRUE
, 0));
542 toolBoxContainer
.SendMessage(WM_COMMAND
, ID_RECTSEL
);
543 //TODO: do this properly
544 startPaintingL(imageModel
.GetDC(), 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
545 whilePaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
546 endPaintingL(imageModel
.GetDC(), imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
550 if (GetSaveFileName(&ofn
) != 0)
551 SaveDIBToFile(selectionModel
.GetBitmap(), ofn
.lpstrFile
, imageModel
.GetDC(), NULL
, NULL
, fileHPPM
, fileVPPM
);
553 case IDM_EDITPASTEFROM
:
554 if (GetOpenFileName(&ofn
) != 0)
556 HBITMAP bmNew
= NULL
;
557 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
560 InsertSelectionFromHBITMAP(bmNew
, m_hWnd
);
565 case IDM_COLORSEDITPALETTE
:
566 if (ChooseColor(&choosecolor
))
567 paletteModel
.SetFgColor(choosecolor
.rgbResult
);
569 case IDM_COLORSMODERNPALETTE
:
570 paletteModel
.SelectPalette(1);
572 case IDM_COLORSOLDPALETTE
:
573 paletteModel
.SelectPalette(2);
575 case IDM_IMAGEINVERTCOLORS
:
577 imageModel
.InvertColors();
580 case IDM_IMAGEDELETEIMAGE
:
581 imageModel
.CopyPrevious();
582 Rect(imageModel
.GetDC(), 0, 0, imageModel
.GetWidth(), imageModel
.GetHeight(), paletteModel
.GetBgColor(), paletteModel
.GetBgColor(), 0, TRUE
);
583 imageArea
.Invalidate(FALSE
);
585 case IDM_IMAGEROTATEMIRROR
:
586 switch (mirrorRotateDlg())
588 case 1: /* flip horizontally */
589 if (selectionWindow
.IsWindowVisible())
590 selectionModel
.FlipHorizontally();
592 imageModel
.FlipHorizontally();
594 case 2: /* flip vertically */
595 if (selectionWindow
.IsWindowVisible())
596 selectionModel
.FlipVertically();
598 imageModel
.FlipVertically();
600 case 3: /* rotate 90 degrees */
602 case 4: /* rotate 180 degrees */
603 if (selectionWindow
.IsWindowVisible())
604 selectionModel
.RotateNTimes90Degrees(2);
606 imageModel
.RotateNTimes90Degrees(2);
608 case 5: /* rotate 270 degrees */
612 case IDM_IMAGEATTRIBUTES
:
616 imageModel
.Crop(widthSetInDlg
, heightSetInDlg
, 0, 0);
620 case IDM_IMAGESTRETCHSKEW
:
624 imageModel
.StretchSkew(stretchSkew
.percentage
.x
, stretchSkew
.percentage
.y
,
625 stretchSkew
.angle
.x
, stretchSkew
.angle
.y
);
629 case IDM_IMAGEDRAWOPAQUE
:
630 toolsModel
.SetBackgroundTransparent(!toolsModel
.IsBackgroundTransparent());
633 imageModel
.Insert((HBITMAP
) CopyImage(selectionModel
.GetBitmap(), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
636 case IDM_VIEWTOOLBOX
:
637 toolBoxContainer
.ShowWindow(toolBoxContainer
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
638 alignChildrenToMainWindow();
640 case IDM_VIEWCOLORPALETTE
:
641 paletteWindow
.ShowWindow(paletteWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
642 alignChildrenToMainWindow();
644 case IDM_VIEWSTATUSBAR
:
645 ::ShowWindow(hStatusBar
, ::IsWindowVisible(hStatusBar
) ? SW_HIDE
: SW_SHOW
);
646 alignChildrenToMainWindow();
648 case IDM_FORMATICONBAR
:
649 textEditWindow
.ShowWindow(textEditWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
651 case IDM_VIEWSHOWGRID
:
652 showGrid
= !showGrid
;
653 imageArea
.Invalidate(FALSE
);
655 case IDM_VIEWSHOWMINIATURE
:
656 showMiniature
= !showMiniature
;
657 miniature
.ShowWindow(showMiniature
? SW_SHOW
: SW_HIDE
);
660 case IDM_VIEWZOOM125
:
669 case IDM_VIEWZOOM100
:
672 case IDM_VIEWZOOM200
:
675 case IDM_VIEWZOOM400
:
678 case IDM_VIEWZOOM800
:
682 case IDM_VIEWFULLSCREEN
:
683 fullscreenWindow
.ShowWindow(SW_SHOW
);