2 * PROJECT: PAINT for ReactOS
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
10 /* INCLUDES *********************************************************/
17 /* FUNCTIONS ********************************************************/
19 void CMainWindow::selectTool(int tool
)
21 selectionWindow
.ShowWindow(SW_HIDE
);
22 toolsModel
.SetActiveTool(tool
);
23 pointSP
= 0; // resets the point-buffer of the polygon and bezier functions
24 toolSettingsWindow
.Invalidate(TRUE
);
25 ::ShowWindow(hTrackbarZoom
, (tool
== TOOL_ZOOM
) ? SW_SHOW
: SW_HIDE
);
26 textEditWindow
.ShowWindow((tool
== TOOL_TEXT
) ? SW_SHOW
: SW_HIDE
);
30 updateCanvasAndScrollbars()
32 selectionWindow
.ShowWindow(SW_HIDE
);
33 imageArea
.MoveWindow(3, 3, imgXRes
* toolsModel
.GetZoom() / 1000, imgYRes
* toolsModel
.GetZoom() / 1000, FALSE
);
34 scrollboxWindow
.Invalidate(TRUE
);
35 imageArea
.Invalidate(FALSE
);
37 scrollboxWindow
.SetScrollPos(SB_HORZ
, 0, TRUE
);
38 scrollboxWindow
.SetScrollPos(SB_VERT
, 0, TRUE
);
42 zoomTo(int newZoom
, int mouseX
, int mouseY
)
45 int tempZoom
= newZoom
;
47 RECT clientRectScrollbox
;
48 RECT clientRectImageArea
;
50 scrollboxWindow
.GetClientRect(&clientRectScrollbox
);
51 imageArea
.GetClientRect(&clientRectImageArea
);
52 w
= clientRectImageArea
.right
* clientRectScrollbox
.right
/ (clientRectImageArea
.right
* newZoom
/ toolsModel
.GetZoom());
53 h
= clientRectImageArea
.bottom
* clientRectScrollbox
.bottom
/ (clientRectImageArea
.bottom
* newZoom
/ toolsModel
.GetZoom());
54 x
= max(0, min(clientRectImageArea
.right
- w
, mouseX
- w
/ 2)) * newZoom
/ toolsModel
.GetZoom();
55 y
= max(0, min(clientRectImageArea
.bottom
- h
, mouseY
- h
/ 2)) * newZoom
/ toolsModel
.GetZoom();
57 toolsModel
.SetZoom(newZoom
);
59 selectionWindow
.ShowWindow(SW_HIDE
);
60 imageArea
.MoveWindow(3, 3, imgXRes
* toolsModel
.GetZoom() / 1000, imgYRes
* toolsModel
.GetZoom() / 1000, FALSE
);
61 scrollboxWindow
.Invalidate(TRUE
);
62 imageArea
.Invalidate(FALSE
);
64 scrollboxWindow
.SendMessage(WM_HSCROLL
, SB_THUMBPOSITION
| (x
<< 16), 0);
65 scrollboxWindow
.SendMessage(WM_VSCROLL
, SB_THUMBPOSITION
| (y
<< 16), 0);
67 while (tempZoom
> 125)
70 tempZoom
= tempZoom
>> 1;
72 SendMessage(hTrackbarZoom
, TBM_SETPOS
, (WPARAM
) TRUE
, (LPARAM
) tbPos
);
75 void CMainWindow::alignChildrenToMainWindow()
79 mainWindow
.GetClientRect(&clientRect
);
81 if (toolBoxContainer
.IsWindowVisible())
84 w
= clientRect
.right
- 56;
91 if (paletteWindow
.IsWindowVisible())
94 h
= clientRect
.bottom
- 49;
99 h
= clientRect
.bottom
- 3;
102 scrollboxWindow
.MoveWindow(x
, y
, w
, ::IsWindowVisible(hStatusBar
) ? h
- 23 : h
, TRUE
);
103 paletteWindow
.MoveWindow(x
, 9, 255, 32, TRUE
);
106 void CMainWindow::saveImage(BOOL overwrite
)
108 if (isAFile
&& overwrite
)
110 SaveDIBToFile(hBms
[currInd
], filepathname
, hDrawingDC
, &fileTime
, &fileSize
, fileHPPM
,
114 else if (GetSaveFileName(&sfn
) != 0)
118 SaveDIBToFile(hBms
[currInd
], sfn
.lpstrFile
, hDrawingDC
, &fileTime
, &fileSize
,
120 CopyMemory(filename
, sfn
.lpstrFileTitle
, sizeof(filename
));
121 CopyMemory(filepathname
, sfn
.lpstrFile
, sizeof(filepathname
));
122 LoadString(hProgInstance
, IDS_WINDOWTITLE
, resstr
, SIZEOF(resstr
));
123 _stprintf(tempstr
, resstr
, filename
);
124 mainWindow
.SetWindowText(tempstr
);
130 void CMainWindow::UpdateApplicationProperties(HBITMAP bitmap
, LPTSTR newfilename
, LPTSTR newfilepathname
)
134 insertReversible(bitmap
);
135 updateCanvasAndScrollbars();
136 CopyMemory(filename
, newfilename
, sizeof(filename
));
137 CopyMemory(filepathname
, newfilepathname
, sizeof(filepathname
));
138 LoadString(hProgInstance
, IDS_WINDOWTITLE
, resstr
, SIZEOF(resstr
));
139 _stprintf(tempstr
, resstr
, filename
);
140 SetWindowText(tempstr
);
145 void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap
, HWND window
)
150 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
151 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELONG(TRUE
, 0));
152 SendMessage(window
, WM_COMMAND
, ID_RECTSEL
, 0);
154 DeleteObject(SelectObject(hSelDC
, hSelBm
= (HBITMAP
) CopyImage(bitmap
,
158 SetRectEmpty(&rectSel_src
);
159 rectSel_dest
.left
= rectSel_dest
.top
= 0;
160 rectSel_dest
.right
= rectSel_dest
.left
+ GetDIBWidth(hSelBm
);
161 rectSel_dest
.bottom
= rectSel_dest
.top
+ GetDIBHeight(hSelBm
);
163 hTempDC
= CreateCompatibleDC(hSelDC
);
164 hTempMask
= CreateBitmap(RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), 1, 1, NULL
);
165 SelectObject(hTempDC
, hTempMask
);
166 Rect(hTempDC
, rectSel_dest
.left
, rectSel_dest
.top
, rectSel_dest
.right
, rectSel_dest
.bottom
, 0x00ffffff, 0x00ffffff, 1, 1);
167 DeleteObject(hSelMask
);
168 hSelMask
= hTempMask
;
172 selectionWindow
.ShowWindow(SW_SHOW
);
173 ForceRefreshSelectionContents();
176 LRESULT
CMainWindow::OnDropFiles(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
179 TCHAR droppedfile
[MAX_PATH
];
180 HBITMAP bmNew
= NULL
;
181 drophandle
= (HDROP
)wParam
;
182 DragQueryFile(drophandle
, 0, droppedfile
, SIZEOF(droppedfile
));
183 DragFinish(drophandle
);
184 LoadDIBFromFile(&bmNew
, droppedfile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
188 pathend
= _tcsrchr(droppedfile
, '\\');
190 UpdateApplicationProperties(bmNew
, pathend
, pathend
);
195 LRESULT
CMainWindow::OnCreate(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
197 SendMessage(WM_SETICON
, ICON_BIG
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
198 SendMessage(WM_SETICON
, ICON_SMALL
, (LPARAM
) LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
)));
204 LRESULT
CMainWindow::OnDestroy(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
206 PostQuitMessage(0); /* send a WM_QUIT to the message queue */
210 LRESULT
CMainWindow::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
214 TCHAR programname
[20];
215 TCHAR saveprompttext
[100];
217 LoadString(hProgInstance
, IDS_PROGRAMNAME
, programname
, SIZEOF(programname
));
218 LoadString(hProgInstance
, IDS_SAVEPROMPTTEXT
, saveprompttext
, SIZEOF(saveprompttext
));
219 _stprintf(temptext
, saveprompttext
, filename
);
220 switch (MessageBox(temptext
, programname
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
239 LRESULT
CMainWindow::OnInitMenuPopup(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
241 HMENU menu
= GetMenu();
242 BOOL trueSelection
= (selectionWindow
.IsWindowVisible() && ((toolsModel
.GetActiveTool() == TOOL_FREESEL
) || (toolsModel
.GetActiveTool() == TOOL_RECTSEL
)));
245 case 0: /* File menu */
246 EnableMenuItem(menu
, IDM_FILEASWALLPAPERPLANE
, ENABLED_IF(isAFile
));
247 EnableMenuItem(menu
, IDM_FILEASWALLPAPERCENTERED
, ENABLED_IF(isAFile
));
248 EnableMenuItem(menu
, IDM_FILEASWALLPAPERSTRETCHED
, ENABLED_IF(isAFile
));
250 case 1: /* Edit menu */
251 EnableMenuItem(menu
, IDM_EDITUNDO
, ENABLED_IF(undoSteps
> 0));
252 EnableMenuItem(menu
, IDM_EDITREDO
, ENABLED_IF(redoSteps
> 0));
253 EnableMenuItem(menu
, IDM_EDITCUT
, ENABLED_IF(trueSelection
));
254 EnableMenuItem(menu
, IDM_EDITCOPY
, ENABLED_IF(trueSelection
));
255 EnableMenuItem(menu
, IDM_EDITDELETESELECTION
, ENABLED_IF(trueSelection
));
256 EnableMenuItem(menu
, IDM_EDITINVERTSELECTION
, ENABLED_IF(trueSelection
));
257 EnableMenuItem(menu
, IDM_EDITCOPYTO
, ENABLED_IF(trueSelection
));
259 EnableMenuItem(menu
, IDM_EDITPASTE
, ENABLED_IF(GetClipboardData(CF_BITMAP
) != NULL
));
262 case 2: /* View menu */
263 CheckMenuItem(menu
, IDM_VIEWTOOLBOX
, CHECKED_IF(toolBoxContainer
.IsWindowVisible()));
264 CheckMenuItem(menu
, IDM_VIEWCOLORPALETTE
, CHECKED_IF(paletteWindow
.IsWindowVisible()));
265 CheckMenuItem(menu
, IDM_VIEWSTATUSBAR
, CHECKED_IF(::IsWindowVisible(hStatusBar
)));
266 CheckMenuItem(menu
, IDM_FORMATICONBAR
, CHECKED_IF(textEditWindow
.IsWindowVisible()));
267 EnableMenuItem(menu
, IDM_FORMATICONBAR
, ENABLED_IF(toolsModel
.GetActiveTool() == TOOL_TEXT
));
269 CheckMenuItem(menu
, IDM_VIEWSHOWGRID
, CHECKED_IF(showGrid
));
270 CheckMenuItem(menu
, IDM_VIEWSHOWMINIATURE
, CHECKED_IF(showMiniature
));
272 case 3: /* Image menu */
273 EnableMenuItem(menu
, IDM_IMAGECROP
, ENABLED_IF(selectionWindow
.IsWindowVisible()));
274 CheckMenuItem(menu
, IDM_IMAGEDRAWOPAQUE
, CHECKED_IF(!toolsModel
.IsBackgroundTransparent()));
278 CheckMenuItem(menu
, IDM_VIEWZOOM125
, CHECKED_IF(toolsModel
.GetZoom() == 125));
279 CheckMenuItem(menu
, IDM_VIEWZOOM25
, CHECKED_IF(toolsModel
.GetZoom() == 250));
280 CheckMenuItem(menu
, IDM_VIEWZOOM50
, CHECKED_IF(toolsModel
.GetZoom() == 500));
281 CheckMenuItem(menu
, IDM_VIEWZOOM100
, CHECKED_IF(toolsModel
.GetZoom() == 1000));
282 CheckMenuItem(menu
, IDM_VIEWZOOM200
, CHECKED_IF(toolsModel
.GetZoom() == 2000));
283 CheckMenuItem(menu
, IDM_VIEWZOOM400
, CHECKED_IF(toolsModel
.GetZoom() == 4000));
284 CheckMenuItem(menu
, IDM_VIEWZOOM800
, CHECKED_IF(toolsModel
.GetZoom() == 8000));
286 CheckMenuItem(menu
, IDM_COLORSMODERNPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 1));
287 CheckMenuItem(menu
, IDM_COLORSOLDPALETTE
, CHECKED_IF(paletteModel
.SelectedPalette() == 2));
291 LRESULT
CMainWindow::OnSize(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
293 if (m_hWnd
== mainWindow
.m_hWnd
)
295 int test
[] = { LOWORD(lParam
) - 260, LOWORD(lParam
) - 140, LOWORD(lParam
) - 20 };
296 SendMessage(hStatusBar
, WM_SIZE
, wParam
, lParam
);
297 SendMessage(hStatusBar
, SB_SETPARTS
, 3, (LPARAM
)&test
);
298 alignChildrenToMainWindow();
304 LRESULT
CMainWindow::OnGetMinMaxInfo(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
306 if (m_hWnd
== mainWindow
.m_hWnd
)
308 MINMAXINFO
*mm
= (LPMINMAXINFO
) lParam
;
309 mm
->ptMinTrackSize
.x
= 330;
310 mm
->ptMinTrackSize
.y
= 430;
315 LRESULT
CMainWindow::OnSetCursor(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
317 SetCursor(LoadCursor(NULL
, IDC_ARROW
));
321 LRESULT
CMainWindow::OnKeyDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
323 if (wParam
== VK_ESCAPE
)
325 if (!imageArea
.drawing
)
328 if ((toolsModel
.GetActiveTool() == TOOL_RECTSEL
) || (toolsModel
.GetActiveTool() == TOOL_FREESEL
))
330 startPaintingL(hDrawingDC
, 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
331 whilePaintingL(hDrawingDC
, 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
332 endPaintingL(hDrawingDC
, 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
333 selectionWindow
.ShowWindow(SW_HIDE
);
336 /* FIXME: also cancel current drawing underway */
341 LRESULT
CMainWindow::OnSysColorChange(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
343 /* Redirect message to common controls */
344 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
345 SendMessage(hToolbar
, WM_SYSCOLORCHANGE
, 0, 0);
349 LRESULT
CMainWindow::OnCommand(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
351 switch (LOWORD(wParam
))
355 HICON paintIcon
= LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
));
356 TCHAR infotitle
[100];
358 LoadString(hProgInstance
, IDS_INFOTITLE
, infotitle
, SIZEOF(infotitle
));
359 LoadString(hProgInstance
, IDS_INFOTEXT
, infotext
, SIZEOF(infotext
));
360 ShellAbout(mainWindow
.m_hWnd
, infotitle
, infotext
, paintIcon
);
361 DeleteObject(paintIcon
);
364 case IDM_HELPHELPTOPICS
:
365 HtmlHelp(mainWindow
.m_hWnd
, _T("help\\Paint.chm"), 0, 0);
368 SendMessage(WM_CLOSE
, wParam
, lParam
);
375 TCHAR programname
[20];
376 TCHAR saveprompttext
[100];
378 LoadString(hProgInstance
, IDS_PROGRAMNAME
, programname
, SIZEOF(programname
));
379 LoadString(hProgInstance
, IDS_SAVEPROMPTTEXT
, saveprompttext
, SIZEOF(saveprompttext
));
380 _stprintf(temptext
, saveprompttext
, filename
);
381 switch (MessageBox(temptext
, programname
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
394 if (reset
&& imageSaved
)
396 Rectangle(hDrawingDC
, 0 - 1, 0 - 1, imgXRes
+ 1, imgYRes
+ 1);
397 imageArea
.Invalidate(FALSE
);
398 updateCanvasAndScrollbars();
404 if (GetOpenFileName(&ofn
) != 0)
406 HBITMAP bmNew
= NULL
;
407 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
410 UpdateApplicationProperties(bmNew
, ofn
.lpstrFileTitle
, ofn
.lpstrFileTitle
);
420 case IDM_FILEASWALLPAPERPLANE
:
421 SetWallpaper(filepathname
, 1, 1);
423 case IDM_FILEASWALLPAPERCENTERED
:
424 SetWallpaper(filepathname
, 1, 0);
426 case IDM_FILEASWALLPAPERSTRETCHED
:
427 SetWallpaper(filepathname
, 2, 0);
431 imageArea
.Invalidate(FALSE
);
435 imageArea
.Invalidate(FALSE
);
440 SetClipboardData(CF_BITMAP
, CopyImage(hSelBm
, IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
445 SendMessage(WM_COMMAND
, IDM_EDITCOPY
, 0);
446 /* Delete selection */
447 SendMessage(WM_COMMAND
, IDM_EDITDELETESELECTION
, 0);
451 if (GetClipboardData(CF_BITMAP
) != NULL
)
453 InsertSelectionFromHBITMAP((HBITMAP
) GetClipboardData(CF_BITMAP
), m_hWnd
);
457 case IDM_EDITDELETESELECTION
:
459 /* remove selection window and already painted content using undo(),
460 paint Rect for rectangular selections and Poly for freeform selections */
462 if (toolsModel
.GetActiveTool() == TOOL_RECTSEL
)
465 Rect(hDrawingDC
, rectSel_dest
.left
, rectSel_dest
.top
, rectSel_dest
.right
,
466 rectSel_dest
.bottom
, paletteModel
.GetBgColor(), paletteModel
.GetBgColor(), 0, TRUE
);
468 if (toolsModel
.GetActiveTool() == TOOL_FREESEL
)
471 Poly(hDrawingDC
, ptStack
, ptSP
+ 1, 0, 0, 2, 0, FALSE
, TRUE
);
475 case IDM_EDITSELECTALL
:
477 HWND hToolbar
= FindWindowEx(toolBoxContainer
.m_hWnd
, NULL
, TOOLBARCLASSNAME
, NULL
);
478 SendMessage(hToolbar
, TB_CHECKBUTTON
, ID_RECTSEL
, MAKELONG(TRUE
, 0));
479 SendMessage(WM_COMMAND
, ID_RECTSEL
, 0);
480 startPaintingL(hDrawingDC
, 0, 0, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
481 whilePaintingL(hDrawingDC
, imgXRes
, imgYRes
, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
482 endPaintingL(hDrawingDC
, imgXRes
, imgYRes
, paletteModel
.GetFgColor(), paletteModel
.GetBgColor());
486 if (GetSaveFileName(&ofn
) != 0)
487 SaveDIBToFile(hSelBm
, ofn
.lpstrFile
, hDrawingDC
, NULL
, NULL
, fileHPPM
, fileVPPM
);
489 case IDM_EDITPASTEFROM
:
490 if (GetOpenFileName(&ofn
) != 0)
492 HBITMAP bmNew
= NULL
;
493 LoadDIBFromFile(&bmNew
, ofn
.lpstrFile
, &fileTime
, &fileSize
, &fileHPPM
, &fileVPPM
);
496 InsertSelectionFromHBITMAP(bmNew
, m_hWnd
);
501 case IDM_COLORSEDITPALETTE
:
502 if (ChooseColor(&choosecolor
))
504 paletteModel
.SetFgColor(choosecolor
.rgbResult
);
505 paletteWindow
.Invalidate(FALSE
);
508 case IDM_COLORSMODERNPALETTE
:
509 paletteModel
.SelectPalette(1);
510 paletteWindow
.Invalidate(FALSE
);
512 case IDM_COLORSOLDPALETTE
:
513 paletteModel
.SelectPalette(2);
514 paletteWindow
.Invalidate(FALSE
);
516 case IDM_IMAGEINVERTCOLORS
:
520 SetRect(&tempRect
, 0, 0, imgXRes
, imgYRes
);
521 InvertRect(hDrawingDC
, &tempRect
);
522 imageArea
.Invalidate(FALSE
);
525 case IDM_IMAGEDELETEIMAGE
:
527 Rect(hDrawingDC
, 0, 0, imgXRes
, imgYRes
, paletteModel
.GetBgColor(), paletteModel
.GetBgColor(), 0, TRUE
);
528 imageArea
.Invalidate(FALSE
);
530 case IDM_IMAGEROTATEMIRROR
:
531 switch (mirrorRotateDlg())
533 case 1: /* flip horizontally */
534 if (selectionWindow
.IsWindowVisible())
536 SelectObject(hSelDC
, hSelMask
);
537 StretchBlt(hSelDC
, RECT_WIDTH(rectSel_dest
) - 1, 0, -RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), hSelDC
,
538 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
539 SelectObject(hSelDC
, hSelBm
);
540 StretchBlt(hSelDC
, RECT_WIDTH(rectSel_dest
) - 1, 0, -RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), hSelDC
,
541 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
542 ForceRefreshSelectionContents();
547 StretchBlt(hDrawingDC
, imgXRes
- 1, 0, -imgXRes
, imgYRes
, hDrawingDC
, 0, 0,
548 imgXRes
, imgYRes
, SRCCOPY
);
549 imageArea
.Invalidate(FALSE
);
552 case 2: /* flip vertically */
553 if (selectionWindow
.IsWindowVisible())
555 SelectObject(hSelDC
, hSelMask
);
556 StretchBlt(hSelDC
, 0, RECT_HEIGHT(rectSel_dest
) - 1, RECT_WIDTH(rectSel_dest
), -RECT_HEIGHT(rectSel_dest
), hSelDC
,
557 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
558 SelectObject(hSelDC
, hSelBm
);
559 StretchBlt(hSelDC
, 0, RECT_HEIGHT(rectSel_dest
) - 1, RECT_WIDTH(rectSel_dest
), -RECT_HEIGHT(rectSel_dest
), hSelDC
,
560 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
561 ForceRefreshSelectionContents();
566 StretchBlt(hDrawingDC
, 0, imgYRes
- 1, imgXRes
, -imgYRes
, hDrawingDC
, 0, 0,
567 imgXRes
, imgYRes
, SRCCOPY
);
568 imageArea
.Invalidate(FALSE
);
571 case 3: /* rotate 90 degrees */
573 case 4: /* rotate 180 degrees */
574 if (selectionWindow
.IsWindowVisible())
576 SelectObject(hSelDC
, hSelMask
);
577 StretchBlt(hSelDC
, RECT_WIDTH(rectSel_dest
) - 1, RECT_HEIGHT(rectSel_dest
) - 1, -RECT_WIDTH(rectSel_dest
), -RECT_HEIGHT(rectSel_dest
), hSelDC
,
578 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
579 SelectObject(hSelDC
, hSelBm
);
580 StretchBlt(hSelDC
, RECT_WIDTH(rectSel_dest
) - 1, RECT_HEIGHT(rectSel_dest
) - 1, -RECT_WIDTH(rectSel_dest
), -RECT_HEIGHT(rectSel_dest
), hSelDC
,
581 0, 0, RECT_WIDTH(rectSel_dest
), RECT_HEIGHT(rectSel_dest
), SRCCOPY
);
582 ForceRefreshSelectionContents();
587 StretchBlt(hDrawingDC
, imgXRes
- 1, imgYRes
- 1, -imgXRes
, -imgYRes
, hDrawingDC
,
588 0, 0, imgXRes
, imgYRes
, SRCCOPY
);
589 imageArea
.Invalidate(FALSE
);
592 case 5: /* rotate 270 degrees */
596 case IDM_IMAGEATTRIBUTES
:
600 cropReversible(widthSetInDlg
, heightSetInDlg
, 0, 0);
601 updateCanvasAndScrollbars();
605 case IDM_IMAGESTRETCHSKEW
:
609 insertReversible((HBITMAP
) CopyImage(hBms
[currInd
], IMAGE_BITMAP
,
610 imgXRes
* stretchSkew
.percentage
.x
/ 100,
611 imgYRes
* stretchSkew
.percentage
.y
/ 100, 0));
612 updateCanvasAndScrollbars();
616 case IDM_IMAGEDRAWOPAQUE
:
617 toolsModel
.SetBackgroundTransparent(!toolsModel
.IsBackgroundTransparent());
618 toolSettingsWindow
.Invalidate(TRUE
);
621 insertReversible((HBITMAP
) CopyImage(hSelBm
, IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
622 updateCanvasAndScrollbars();
625 case IDM_VIEWTOOLBOX
:
626 toolBoxContainer
.ShowWindow(toolBoxContainer
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
627 alignChildrenToMainWindow();
629 case IDM_VIEWCOLORPALETTE
:
630 paletteWindow
.ShowWindow(paletteWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
631 alignChildrenToMainWindow();
633 case IDM_VIEWSTATUSBAR
:
634 ::ShowWindow(hStatusBar
, ::IsWindowVisible(hStatusBar
) ? SW_HIDE
: SW_SHOW
);
635 alignChildrenToMainWindow();
637 case IDM_FORMATICONBAR
:
638 textEditWindow
.ShowWindow(textEditWindow
.IsWindowVisible() ? SW_HIDE
: SW_SHOW
);
640 case IDM_VIEWSHOWGRID
:
641 showGrid
= !showGrid
;
642 imageArea
.Invalidate(FALSE
);
644 case IDM_VIEWSHOWMINIATURE
:
645 showMiniature
= !showMiniature
;
646 miniature
.ShowWindow(showMiniature
? SW_SHOW
: SW_HIDE
);
649 case IDM_VIEWZOOM125
:
658 case IDM_VIEWZOOM100
:
661 case IDM_VIEWZOOM200
:
664 case IDM_VIEWZOOM400
:
667 case IDM_VIEWZOOM800
: