2009-05-12 14:15:48 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL
|
2009-10-21 15:44:31 +00:00
|
|
|
* FILE: base/applications/paint/winproc.c
|
2009-05-12 14:15:48 +00:00
|
|
|
* PURPOSE: Window procedure of the main window and all children apart from
|
|
|
|
* hPalWin, hToolSettings and hSelection
|
|
|
|
* PROGRAMMERS: Benedikt Freisen
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *********************************************************/
|
|
|
|
|
2011-07-26 21:44:53 +00:00
|
|
|
#include "precomp.h"
|
2009-05-12 14:15:48 +00:00
|
|
|
|
2014-02-11 11:48:15 +00:00
|
|
|
#include "winproc.h"
|
2014-01-07 16:27:45 +00:00
|
|
|
#include "dialogs.h"
|
|
|
|
#include "registry.h"
|
2014-02-11 11:48:15 +00:00
|
|
|
#include "scrollbox.h"
|
2014-01-07 16:27:45 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
/* FUNCTIONS ********************************************************/
|
|
|
|
|
2014-02-11 11:48:15 +00:00
|
|
|
void
|
|
|
|
RegisterWclMain()
|
|
|
|
{
|
|
|
|
WNDCLASSEX wclMain;
|
|
|
|
/* initializing and registering the window class used for the main window */
|
|
|
|
wclMain.hInstance = hProgInstance;
|
|
|
|
wclMain.lpszClassName = _T("MainWindow");
|
|
|
|
wclMain.lpfnWndProc = MainWindowProcedure;
|
|
|
|
wclMain.style = CS_DBLCLKS;
|
|
|
|
wclMain.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wclMain.hIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
|
|
|
wclMain.hIconSm = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
|
|
|
wclMain.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
wclMain.lpszMenuName = NULL;
|
|
|
|
wclMain.cbClsExtra = 0;
|
|
|
|
wclMain.cbWndExtra = 0;
|
|
|
|
wclMain.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
|
|
|
RegisterClassEx (&wclMain);
|
|
|
|
}
|
|
|
|
|
2009-10-21 15:44:31 +00:00
|
|
|
void
|
|
|
|
selectTool(int tool)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
ShowWindow(hSelection, SW_HIDE);
|
|
|
|
activeTool = tool;
|
2009-10-21 15:44:31 +00:00
|
|
|
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hToolSettings, NULL, TRUE);
|
2014-02-08 17:49:24 +00:00
|
|
|
ShowWindow(hTrackbarZoom, (tool == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
|
2014-02-10 20:49:15 +00:00
|
|
|
ShowWindow(hwndTextEdit, (tool == TOOL_TEXT) ? SW_SHOW : SW_HIDE);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 15:44:31 +00:00
|
|
|
void
|
|
|
|
updateCanvasAndScrollbars()
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
ShowWindow(hSelection, SW_HIDE);
|
2009-10-21 15:44:31 +00:00
|
|
|
MoveWindow(hImageArea, 3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
InvalidateRect(hScrollbox, NULL, TRUE);
|
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
SetScrollPos(hScrollbox, SB_HORZ, 0, TRUE);
|
|
|
|
SetScrollPos(hScrollbox, SB_VERT, 0, TRUE);
|
|
|
|
}
|
|
|
|
|
2009-10-21 15:44:31 +00:00
|
|
|
void
|
|
|
|
zoomTo(int newZoom, int mouseX, int mouseY)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-19 17:46:29 +00:00
|
|
|
int tbPos = 0;
|
|
|
|
int tempZoom = newZoom;
|
|
|
|
|
2014-02-07 17:54:25 +00:00
|
|
|
RECT clientRectScrollbox;
|
|
|
|
RECT clientRectImageArea;
|
2009-10-19 17:46:29 +00:00
|
|
|
int x, y, w, h;
|
2014-02-07 17:54:25 +00:00
|
|
|
GetClientRect(hScrollbox, &clientRectScrollbox);
|
|
|
|
GetClientRect(hImageArea, &clientRectImageArea);
|
|
|
|
w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * newZoom / zoom);
|
|
|
|
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * newZoom / zoom);
|
|
|
|
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / zoom;
|
|
|
|
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / zoom;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
zoom = newZoom;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-10-18 18:36:46 +00:00
|
|
|
ShowWindow(hSelection, SW_HIDE);
|
2009-10-21 15:44:31 +00:00
|
|
|
MoveWindow(hImageArea, 3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE);
|
2009-10-18 18:36:46 +00:00
|
|
|
InvalidateRect(hScrollbox, NULL, TRUE);
|
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-10-18 18:36:46 +00:00
|
|
|
SendMessage(hScrollbox, WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0);
|
|
|
|
SendMessage(hScrollbox, WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0);
|
2009-10-21 15:44:31 +00:00
|
|
|
|
|
|
|
while (tempZoom > 125)
|
2009-10-03 16:33:41 +00:00
|
|
|
{
|
|
|
|
tbPos++;
|
2009-10-21 15:44:31 +00:00
|
|
|
tempZoom = tempZoom >> 1;
|
2009-10-03 16:33:41 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 15:44:31 +00:00
|
|
|
void
|
|
|
|
drawZoomFrame(int mouseX, int mouseY)
|
2009-10-18 18:36:46 +00:00
|
|
|
{
|
2009-10-19 17:46:29 +00:00
|
|
|
HDC hdc;
|
|
|
|
HPEN oldPen;
|
|
|
|
HBRUSH oldBrush;
|
|
|
|
LOGBRUSH logbrush;
|
|
|
|
int rop;
|
|
|
|
|
2014-02-07 17:54:25 +00:00
|
|
|
RECT clientRectScrollbox;
|
|
|
|
RECT clientRectImageArea;
|
2009-10-19 17:46:29 +00:00
|
|
|
int x, y, w, h;
|
2014-02-07 17:54:25 +00:00
|
|
|
GetClientRect(hScrollbox, &clientRectScrollbox);
|
|
|
|
GetClientRect(hImageArea, &clientRectImageArea);
|
|
|
|
w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * 2);
|
|
|
|
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * 2);
|
|
|
|
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
|
|
|
|
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-10-18 18:36:46 +00:00
|
|
|
hdc = GetDC(hImageArea);
|
|
|
|
oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
|
|
|
|
logbrush.lbStyle = BS_HOLLOW;
|
|
|
|
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
|
|
|
rop = SetROP2(hdc, R2_NOT);
|
|
|
|
Rectangle(hdc, x, y, x + w, y + h);
|
|
|
|
SetROP2(hdc, rop);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
ReleaseDC(hImageArea, hdc);
|
|
|
|
}
|
|
|
|
|
2009-12-27 21:15:08 +00:00
|
|
|
void
|
|
|
|
alignChildrenToMainWindow()
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
RECT clientRect;
|
|
|
|
GetClientRect(hMainWnd, &clientRect);
|
|
|
|
|
|
|
|
if (IsWindowVisible(hToolBoxContainer))
|
|
|
|
{
|
|
|
|
x = 56;
|
|
|
|
w = clientRect.right - 56;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
w = clientRect.right;
|
|
|
|
}
|
|
|
|
if (IsWindowVisible(hPalWin))
|
|
|
|
{
|
|
|
|
y = 49;
|
|
|
|
h = clientRect.bottom - 49;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
y = 3;
|
|
|
|
h = clientRect.bottom - 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
MoveWindow(hScrollbox, x, y, w, IsWindowVisible(hStatusBar) ? h - 23 : h, TRUE);
|
|
|
|
MoveWindow(hPalWin, x, 9, 255, 32, TRUE);
|
|
|
|
}
|
|
|
|
|
2013-09-01 20:13:15 +00:00
|
|
|
void
|
|
|
|
saveImage(BOOL overwrite)
|
|
|
|
{
|
|
|
|
if (isAFile && overwrite)
|
|
|
|
{
|
|
|
|
SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC, &fileTime, &fileSize, fileHPPM,
|
|
|
|
fileVPPM);
|
|
|
|
imageSaved = TRUE;
|
|
|
|
}
|
|
|
|
else if (GetSaveFileName(&sfn) != 0)
|
|
|
|
{
|
|
|
|
TCHAR tempstr[1000];
|
|
|
|
TCHAR resstr[100];
|
|
|
|
SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC, &fileTime, &fileSize,
|
|
|
|
fileHPPM, fileVPPM);
|
|
|
|
CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename));
|
|
|
|
CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
|
|
|
|
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
|
|
|
_stprintf(tempstr, resstr, filename);
|
|
|
|
SetWindowText(hMainWnd, tempstr);
|
|
|
|
isAFile = TRUE;
|
|
|
|
imageSaved = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-28 15:46:28 +00:00
|
|
|
void
|
|
|
|
UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename, LPTSTR newfilepathname)
|
|
|
|
{
|
|
|
|
TCHAR tempstr[1000];
|
|
|
|
TCHAR resstr[100];
|
|
|
|
insertReversible(bitmap);
|
|
|
|
updateCanvasAndScrollbars();
|
|
|
|
CopyMemory(filename, newfilename, sizeof(filename));
|
|
|
|
CopyMemory(filepathname, newfilepathname, sizeof(filepathname));
|
|
|
|
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
|
|
|
_stprintf(tempstr, resstr, filename);
|
|
|
|
SetWindowText(hMainWnd, tempstr);
|
|
|
|
clearHistory();
|
|
|
|
isAFile = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
|
|
|
{
|
2014-02-05 18:58:45 +00:00
|
|
|
HDC hTempDC;
|
|
|
|
HBITMAP hTempMask;
|
|
|
|
|
2014-01-28 15:46:28 +00:00
|
|
|
HWND hToolbar = FindWindowEx(hToolBoxContainer, NULL, TOOLBARCLASSNAME, NULL);
|
|
|
|
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
|
|
|
|
SendMessage(window, WM_COMMAND, ID_RECTSEL, 0);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hSelDC, hSelBm = CopyImage(bitmap,
|
|
|
|
IMAGE_BITMAP, 0, 0,
|
|
|
|
LR_COPYRETURNORG)));
|
|
|
|
newReversible();
|
2014-02-07 17:54:25 +00:00
|
|
|
SetRectEmpty(&rectSel_src);
|
|
|
|
rectSel_dest.left = rectSel_dest.top = 0;
|
|
|
|
rectSel_dest.right = rectSel_dest.left + GetDIBWidth(hSelBm);
|
|
|
|
rectSel_dest.bottom = rectSel_dest.top + GetDIBHeight(hSelBm);
|
2014-02-05 18:58:45 +00:00
|
|
|
|
|
|
|
hTempDC = CreateCompatibleDC(hSelDC);
|
2014-02-07 17:54:25 +00:00
|
|
|
hTempMask = CreateBitmap(RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), 1, 1, NULL);
|
2014-02-05 18:58:45 +00:00
|
|
|
SelectObject(hTempDC, hTempMask);
|
2014-02-07 17:54:25 +00:00
|
|
|
Rect(hTempDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right, rectSel_dest.bottom, 0x00ffffff, 0x00ffffff, 1, 1);
|
2014-02-05 18:58:45 +00:00
|
|
|
DeleteObject(hSelMask);
|
|
|
|
hSelMask = hTempMask;
|
|
|
|
DeleteDC(hTempDC);
|
|
|
|
|
2014-01-28 15:46:28 +00:00
|
|
|
placeSelWin();
|
|
|
|
ShowWindow(hSelection, SW_SHOW);
|
2014-02-07 17:54:25 +00:00
|
|
|
ForceRefreshSelectionContents();
|
2014-01-28 15:46:28 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
BOOL drawing;
|
|
|
|
|
2009-10-21 15:44:31 +00:00
|
|
|
LRESULT CALLBACK
|
2014-02-11 11:48:15 +00:00
|
|
|
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
switch (message) /* handle the messages */
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2014-01-28 15:46:28 +00:00
|
|
|
case WM_DROPFILES:
|
|
|
|
{
|
|
|
|
HDROP drophandle;
|
|
|
|
TCHAR droppedfile[MAX_PATH];
|
2014-01-28 18:22:46 +00:00
|
|
|
HBITMAP bmNew = NULL;
|
2014-01-28 15:46:28 +00:00
|
|
|
drophandle = (HDROP)wParam;
|
2014-01-28 18:25:57 +00:00
|
|
|
DragQueryFile(drophandle, 0, droppedfile, SIZEOF(droppedfile));
|
2014-01-28 15:46:28 +00:00
|
|
|
DragFinish(drophandle);
|
|
|
|
LoadDIBFromFile(&bmNew, droppedfile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
|
|
|
if (bmNew != NULL)
|
|
|
|
{
|
|
|
|
TCHAR *pathend;
|
|
|
|
pathend = _tcsrchr(droppedfile, '\\');
|
|
|
|
pathend++;
|
|
|
|
UpdateApplicationProperties(bmNew, pathend, pathend);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-10 09:57:44 +00:00
|
|
|
case WM_CREATE:
|
|
|
|
ptStack = NULL;
|
|
|
|
ptSP = 0;
|
|
|
|
break;
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_DESTROY:
|
2009-10-21 15:44:31 +00:00
|
|
|
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_CLOSE:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hwndMiniature)
|
2009-07-01 19:24:17 +00:00
|
|
|
{
|
|
|
|
ShowWindow(hwndMiniature, SW_HIDE);
|
|
|
|
showMiniature = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-03 16:33:41 +00:00
|
|
|
if (!imageSaved)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-05-27 17:56:50 +00:00
|
|
|
TCHAR programname[20];
|
|
|
|
TCHAR saveprompttext[100];
|
2009-06-16 21:12:47 +00:00
|
|
|
TCHAR temptext[500];
|
2009-05-27 17:56:50 +00:00
|
|
|
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
|
|
|
|
LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
|
|
|
|
_stprintf(temptext, saveprompttext, filename);
|
|
|
|
switch (MessageBox(hwnd, temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
case IDNO:
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
break;
|
|
|
|
case IDYES:
|
2013-09-01 20:13:15 +00:00
|
|
|
saveImage(FALSE);
|
|
|
|
if (imageSaved)
|
|
|
|
DestroyWindow(hwnd);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_INITMENUPOPUP:
|
2014-02-07 17:54:25 +00:00
|
|
|
{
|
|
|
|
HMENU menu = GetMenu(hMainWnd);
|
2014-02-08 17:49:24 +00:00
|
|
|
BOOL trueSelection = (IsWindowVisible(hSelection) && ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL)));
|
2009-05-12 14:15:48 +00:00
|
|
|
switch (lParam)
|
|
|
|
{
|
2014-02-07 17:54:25 +00:00
|
|
|
case 0: /* File menu */
|
|
|
|
EnableMenuItem(menu, IDM_FILEASWALLPAPERPLANE, ENABLED_IF(isAFile));
|
|
|
|
EnableMenuItem(menu, IDM_FILEASWALLPAPERCENTERED, ENABLED_IF(isAFile));
|
|
|
|
EnableMenuItem(menu, IDM_FILEASWALLPAPERSTRETCHED, ENABLED_IF(isAFile));
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2014-02-07 17:54:25 +00:00
|
|
|
case 1: /* Edit menu */
|
|
|
|
EnableMenuItem(menu, IDM_EDITUNDO, ENABLED_IF(undoSteps > 0));
|
|
|
|
EnableMenuItem(menu, IDM_EDITREDO, ENABLED_IF(redoSteps > 0));
|
|
|
|
EnableMenuItem(menu, IDM_EDITCUT, ENABLED_IF(trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITCOPY, ENABLED_IF(trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITDELETESELECTION, ENABLED_IF(trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITINVERTSELECTION, ENABLED_IF(trueSelection));
|
|
|
|
EnableMenuItem(menu, IDM_EDITCOPYTO, ENABLED_IF(trueSelection));
|
2009-05-12 14:15:48 +00:00
|
|
|
OpenClipboard(hMainWnd);
|
2014-02-07 17:54:25 +00:00
|
|
|
EnableMenuItem(menu, IDM_EDITPASTE, ENABLED_IF(GetClipboardData(CF_BITMAP) != NULL));
|
2009-05-12 14:15:48 +00:00
|
|
|
CloseClipboard();
|
|
|
|
break;
|
2014-02-10 20:49:15 +00:00
|
|
|
case 2: /* View menu */
|
|
|
|
CheckMenuItem(menu, IDM_VIEWTOOLBOX, CHECKED_IF(IsWindowVisible(hToolBoxContainer)));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWCOLORPALETTE, CHECKED_IF(IsWindowVisible(hPalWin)));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWSTATUSBAR, CHECKED_IF(IsWindowVisible(hStatusBar)));
|
|
|
|
CheckMenuItem(menu, IDM_FORMATICONBAR, CHECKED_IF(IsWindowVisible(hwndTextEdit)));
|
|
|
|
EnableMenuItem(menu, IDM_FORMATICONBAR, ENABLED_IF(activeTool == TOOL_TEXT));
|
|
|
|
|
|
|
|
CheckMenuItem(menu, IDM_VIEWSHOWGRID, CHECKED_IF(showGrid));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWSHOWMINIATURE, CHECKED_IF(showMiniature));
|
|
|
|
break;
|
2014-02-07 17:54:25 +00:00
|
|
|
case 3: /* Image menu */
|
|
|
|
EnableMenuItem(menu, IDM_IMAGECROP, ENABLED_IF(IsWindowVisible(hSelection)));
|
|
|
|
CheckMenuItem(menu, IDM_IMAGEDRAWOPAQUE, CHECKED_IF(transpBg == 0));
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-02-07 17:54:25 +00:00
|
|
|
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM125, CHECKED_IF(zoom == 125));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM25, CHECKED_IF(zoom == 250));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM50, CHECKED_IF(zoom == 500));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM100, CHECKED_IF(zoom == 1000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM200, CHECKED_IF(zoom == 2000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM400, CHECKED_IF(zoom == 4000));
|
|
|
|
CheckMenuItem(menu, IDM_VIEWZOOM800, CHECKED_IF(zoom == 8000));
|
|
|
|
|
|
|
|
CheckMenuItem(menu, IDM_COLORSMODERNPALETTE, CHECKED_IF(selectedPalette == 1));
|
|
|
|
CheckMenuItem(menu, IDM_COLORSOLDPALETTE, CHECKED_IF(selectedPalette == 2));
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2014-02-07 17:54:25 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_SIZE:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hMainWnd)
|
|
|
|
{
|
|
|
|
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
|
2009-05-12 14:15:48 +00:00
|
|
|
SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
|
2009-12-15 15:16:01 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
|
2009-12-27 21:15:08 +00:00
|
|
|
alignChildrenToMainWindow();
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hImageArea)
|
2009-07-02 17:02:37 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
MoveWindow(hSizeboxLeftTop,
|
|
|
|
0,
|
|
|
|
0, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxCenterTop,
|
|
|
|
imgXRes * zoom / 2000 + 3 * 3 / 4,
|
|
|
|
0, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxRightTop,
|
|
|
|
imgXRes * zoom / 1000 + 3,
|
|
|
|
0, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxLeftCenter,
|
|
|
|
0,
|
|
|
|
imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxRightCenter,
|
|
|
|
imgXRes * zoom / 1000 + 3,
|
|
|
|
imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxLeftBottom,
|
|
|
|
0,
|
|
|
|
imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxCenterBottom,
|
|
|
|
imgXRes * zoom / 2000 + 3 * 3 / 4,
|
|
|
|
imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
|
|
|
|
MoveWindow(hSizeboxRightBottom,
|
|
|
|
imgXRes * zoom / 1000 + 3,
|
|
|
|
imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
|
2009-07-02 17:02:37 +00:00
|
|
|
}
|
2014-02-11 11:48:15 +00:00
|
|
|
if (hwnd == hImageArea)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2014-02-11 11:48:15 +00:00
|
|
|
UpdateScrollbox();
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_GETMINMAXINFO:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hMainWnd)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
MINMAXINFO *mm = (LPMINMAXINFO) lParam;
|
2013-11-03 14:37:42 +00:00
|
|
|
mm->ptMinTrackSize.x = 330;
|
|
|
|
mm->ptMinTrackSize.y = 430;
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_PAINT:
|
2009-10-21 15:44:31 +00:00
|
|
|
DefWindowProc(hwnd, message, wParam, lParam);
|
|
|
|
if (hwnd == hImageArea)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
HDC hdc = GetDC(hImageArea);
|
2009-10-21 15:44:31 +00:00
|
|
|
StretchBlt(hdc, 0, 0, imgXRes * zoom / 1000, imgYRes * zoom / 1000, hDrawingDC, 0, 0, imgXRes,
|
|
|
|
imgYRes, SRCCOPY);
|
|
|
|
if (showGrid && (zoom >= 4000))
|
2009-07-01 19:24:17 +00:00
|
|
|
{
|
|
|
|
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0));
|
|
|
|
int counter;
|
2009-10-21 15:44:31 +00:00
|
|
|
for(counter = 0; counter <= imgYRes; counter++)
|
2009-07-01 19:24:17 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
MoveToEx(hdc, 0, counter * zoom / 1000, NULL);
|
|
|
|
LineTo(hdc, imgXRes * zoom / 1000, counter * zoom / 1000);
|
2009-07-01 19:24:17 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
for(counter = 0; counter <= imgXRes; counter++)
|
2009-07-01 19:24:17 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
MoveToEx(hdc, counter * zoom / 1000, 0, NULL);
|
|
|
|
LineTo(hdc, counter * zoom / 1000, imgYRes * zoom / 1000);
|
2009-07-01 19:24:17 +00:00
|
|
|
}
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
ReleaseDC(hImageArea, hdc);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hSelection, NULL, FALSE);
|
|
|
|
InvalidateRect(hwndMiniature, NULL, FALSE);
|
2009-10-21 15:44:31 +00:00
|
|
|
}
|
|
|
|
else if (hwnd == hwndMiniature)
|
2009-07-01 19:24:17 +00:00
|
|
|
{
|
2011-05-06 22:02:29 +00:00
|
|
|
RECT mclient;
|
2009-08-03 13:46:37 +00:00
|
|
|
HDC hdc;
|
2011-05-06 22:02:29 +00:00
|
|
|
GetClientRect(hwndMiniature, &mclient);
|
2009-08-03 13:46:37 +00:00
|
|
|
hdc = GetDC(hwndMiniature);
|
2011-05-06 22:02:29 +00:00
|
|
|
StretchBlt(hdc, 0, 0, mclient.right, mclient.bottom, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY);
|
2009-07-01 19:24:17 +00:00
|
|
|
ReleaseDC(hwndMiniature, hdc);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// mouse events used for drawing
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_SETCURSOR:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hImageArea)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
switch (activeTool)
|
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
case TOOL_FILL:
|
2009-05-12 14:15:48 +00:00
|
|
|
SetCursor(hCurFill);
|
|
|
|
break;
|
2010-05-27 12:21:50 +00:00
|
|
|
case TOOL_COLOR:
|
2009-05-12 14:15:48 +00:00
|
|
|
SetCursor(hCurColor);
|
|
|
|
break;
|
2010-05-27 12:21:50 +00:00
|
|
|
case TOOL_ZOOM:
|
2009-05-12 14:15:48 +00:00
|
|
|
SetCursor(hCurZoom);
|
|
|
|
break;
|
2010-05-27 12:21:50 +00:00
|
|
|
case TOOL_PEN:
|
2009-05-12 14:15:48 +00:00
|
|
|
SetCursor(hCurPen);
|
|
|
|
break;
|
2010-05-27 12:21:50 +00:00
|
|
|
case TOOL_AIRBRUSH:
|
2009-05-12 14:15:48 +00:00
|
|
|
SetCursor(hCurAirbrush);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_CROSS));
|
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DefWindowProc(hwnd, message, wParam, lParam);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hImageArea)
|
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((!drawing) || (activeTool == TOOL_COLOR))
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
SetCapture(hImageArea);
|
|
|
|
drawing = TRUE;
|
2011-08-25 11:28:32 +00:00
|
|
|
startPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom,
|
2009-10-21 15:44:31 +00:00
|
|
|
fgColor, bgColor);
|
|
|
|
}
|
|
|
|
else
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
SendMessage(hwnd, WM_LBUTTONUP, wParam, lParam);
|
|
|
|
undo();
|
|
|
|
}
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((activeTool == TOOL_ZOOM) && (zoom < 8000))
|
2011-08-25 11:28:32 +00:00
|
|
|
zoomTo(zoom * 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_RBUTTONDOWN:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hImageArea)
|
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((!drawing) || (activeTool == TOOL_COLOR))
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
SetCapture(hImageArea);
|
|
|
|
drawing = TRUE;
|
2011-08-25 11:28:32 +00:00
|
|
|
startPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom,
|
2009-10-21 15:44:31 +00:00
|
|
|
fgColor, bgColor);
|
|
|
|
}
|
|
|
|
else
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
|
|
|
SendMessage(hwnd, WM_RBUTTONUP, wParam, lParam);
|
|
|
|
undo();
|
|
|
|
}
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((activeTool == TOOL_ZOOM) && (zoom > 125))
|
2011-08-25 11:28:32 +00:00
|
|
|
zoomTo(zoom / 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_LBUTTONUP:
|
2009-10-21 15:44:31 +00:00
|
|
|
if ((hwnd == hImageArea) && drawing)
|
|
|
|
{
|
2009-05-12 14:15:48 +00:00
|
|
|
ReleaseCapture();
|
|
|
|
drawing = FALSE;
|
2011-08-25 11:28:32 +00:00
|
|
|
endPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom, fgColor,
|
2009-10-21 15:44:31 +00:00
|
|
|
bgColor);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool == TOOL_COLOR)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
int tempColor =
|
2011-08-25 11:28:32 +00:00
|
|
|
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom);
|
2009-10-21 15:44:31 +00:00
|
|
|
if (tempColor != CLR_INVALID)
|
|
|
|
fgColor = tempColor;
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hPalWin, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_RBUTTONUP:
|
2009-10-21 15:44:31 +00:00
|
|
|
if ((hwnd == hImageArea) && drawing)
|
|
|
|
{
|
2009-05-12 14:15:48 +00:00
|
|
|
ReleaseCapture();
|
|
|
|
drawing = FALSE;
|
2011-08-25 11:28:32 +00:00
|
|
|
endPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom, fgColor,
|
2009-10-21 15:44:31 +00:00
|
|
|
bgColor);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool == TOOL_COLOR)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
int tempColor =
|
2011-08-25 11:28:32 +00:00
|
|
|
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam) * 1000 / zoom);
|
2009-10-21 15:44:31 +00:00
|
|
|
if (tempColor != CLR_INVALID)
|
|
|
|
bgColor = tempColor;
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hPalWin, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2010-10-10 09:57:44 +00:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
if (wParam == VK_ESCAPE)
|
|
|
|
{
|
|
|
|
if (!drawing)
|
|
|
|
{
|
|
|
|
/* Deselect */
|
|
|
|
if ((activeTool == TOOL_RECTSEL) || (activeTool == TOOL_FREESEL))
|
|
|
|
{
|
|
|
|
startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
|
|
|
whilePaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
|
|
|
endPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
|
|
|
ShowWindow(hSelection, SW_HIDE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIXME: also cancel current drawing underway */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_MOUSEMOVE:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (hwnd == hImageArea)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2011-08-25 11:28:32 +00:00
|
|
|
LONG xNow = GET_X_LPARAM(lParam) * 1000 / zoom;
|
|
|
|
LONG yNow = GET_Y_LPARAM(lParam) * 1000 / zoom;
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((!drawing) || (activeTool <= TOOL_AIRBRUSH))
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-19 17:46:29 +00:00
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool == TOOL_ZOOM)
|
2009-10-18 18:36:46 +00:00
|
|
|
{
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
|
|
|
UpdateWindow(hImageArea);
|
2011-08-25 11:28:32 +00:00
|
|
|
drawZoomFrame(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
2009-10-18 18:36:46 +00:00
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-10-18 18:36:46 +00:00
|
|
|
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
|
|
|
tme.dwFlags = TME_LEAVE;
|
|
|
|
tme.hwndTrack = hImageArea;
|
|
|
|
tme.dwHoverTime = 0;
|
|
|
|
TrackMouseEvent(&tme);
|
2010-05-27 12:21:50 +00:00
|
|
|
|
|
|
|
if (!drawing)
|
|
|
|
{
|
|
|
|
TCHAR coordStr[100];
|
2014-04-30 18:41:39 +00:00
|
|
|
_stprintf(coordStr, _T("%ld, %ld"), xNow, yNow);
|
2010-05-27 12:21:50 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr);
|
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
if (drawing)
|
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
/* values displayed in statusbar */
|
2013-09-01 20:13:15 +00:00
|
|
|
LONG xRel = xNow - start.x;
|
|
|
|
LONG yRel = yNow - start.y;
|
2010-05-27 12:21:50 +00:00
|
|
|
/* freesel, rectsel and text tools always show numbers limited to fit into image area */
|
|
|
|
if ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_TEXT))
|
|
|
|
{
|
|
|
|
if (xRel < 0)
|
2013-09-01 20:13:15 +00:00
|
|
|
xRel = (xNow < 0) ? -start.x : xRel;
|
2010-05-27 12:21:50 +00:00
|
|
|
else if (xNow > imgXRes)
|
2013-09-01 20:13:15 +00:00
|
|
|
xRel = imgXRes-start.x;
|
2010-05-27 12:21:50 +00:00
|
|
|
if (yRel < 0)
|
2013-09-01 20:13:15 +00:00
|
|
|
yRel = (yNow < 0) ? -start.y : yRel;
|
2010-05-27 12:21:50 +00:00
|
|
|
else if (yNow > imgYRes)
|
2013-09-01 20:13:15 +00:00
|
|
|
yRel = imgYRes-start.y;
|
2010-05-27 12:21:50 +00:00
|
|
|
}
|
|
|
|
/* rectsel and shape tools always show non-negative numbers when drawing */
|
|
|
|
if ((activeTool == TOOL_RECTSEL) || (activeTool == TOOL_SHAPE))
|
|
|
|
{
|
|
|
|
if (xRel < 0)
|
|
|
|
xRel = -xRel;
|
|
|
|
if (yRel < 0)
|
|
|
|
yRel = -yRel;
|
|
|
|
}
|
|
|
|
/* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
|
|
|
|
switch(activeTool)
|
|
|
|
{
|
|
|
|
case TOOL_RUBBER:
|
|
|
|
case TOOL_PEN:
|
|
|
|
case TOOL_BRUSH:
|
|
|
|
case TOOL_AIRBRUSH:
|
|
|
|
case TOOL_SHAPE:
|
|
|
|
{
|
|
|
|
TCHAR coordStr[100];
|
2014-04-30 18:41:39 +00:00
|
|
|
_stprintf(coordStr, _T("%ld, %ld"), xNow, yNow);
|
2010-05-27 12:21:50 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
if ((wParam & MK_LBUTTON) != 0)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
whilePaintingL(hDrawingDC, xNow, yNow, fgColor, bgColor);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if ((activeTool >= TOOL_TEXT) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_FREESEL))
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-05-27 17:56:50 +00:00
|
|
|
TCHAR sizeStr[100];
|
2010-10-10 09:57:44 +00:00
|
|
|
if ((activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
|
|
|
yRel = xRel;
|
2014-04-30 18:41:39 +00:00
|
|
|
_stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel);
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-21 15:44:31 +00:00
|
|
|
if ((wParam & MK_RBUTTON) != 0)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2010-05-27 12:21:50 +00:00
|
|
|
whilePaintingR(hDrawingDC, xNow, yNow, fgColor, bgColor);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool >= TOOL_TEXT)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-05-27 17:56:50 +00:00
|
|
|
TCHAR sizeStr[100];
|
2010-10-10 09:57:44 +00:00
|
|
|
if ((activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
|
|
|
yRel = xRel;
|
2014-04-30 18:41:39 +00:00
|
|
|
_stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel);
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-18 18:36:46 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-10-18 18:36:46 +00:00
|
|
|
case WM_MOUSELEAVE:
|
2009-10-21 15:44:31 +00:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) _T(""));
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool == TOOL_ZOOM)
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
// menu and button events
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2011-05-01 12:53:10 +00:00
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
{
|
|
|
|
/* Redirect message to common controls */
|
|
|
|
HWND hToolbar = FindWindowEx(hToolBoxContainer, NULL, TOOLBARCLASSNAME, NULL);
|
|
|
|
SendMessage(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDM_HELPINFO:
|
2009-10-21 15:44:31 +00:00
|
|
|
{
|
|
|
|
HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
|
|
|
TCHAR infotitle[100];
|
|
|
|
TCHAR infotext[200];
|
|
|
|
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
|
|
|
|
LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
|
|
|
|
ShellAbout(hMainWnd, infotitle, infotext, paintIcon);
|
|
|
|
DeleteObject(paintIcon);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_HELPHELPTOPICS:
|
|
|
|
//HtmlHelp(hMainWnd, "help\\Paint.chm", 0, 0);
|
|
|
|
break;
|
|
|
|
case IDM_FILEEXIT:
|
|
|
|
SendMessage(hwnd, WM_CLOSE, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case IDM_FILENEW:
|
2013-03-02 20:44:09 +00:00
|
|
|
{
|
|
|
|
BOOL reset = TRUE;
|
|
|
|
if (!imageSaved)
|
|
|
|
{
|
|
|
|
TCHAR programname[20];
|
|
|
|
TCHAR saveprompttext[100];
|
|
|
|
TCHAR temptext[500];
|
|
|
|
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
|
|
|
|
LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
|
|
|
|
_stprintf(temptext, saveprompttext, filename);
|
|
|
|
switch (MessageBox(hwnd, temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
|
|
|
|
{
|
|
|
|
case IDNO:
|
|
|
|
imageSaved = TRUE;
|
|
|
|
break;
|
|
|
|
case IDYES:
|
2013-09-01 20:13:15 +00:00
|
|
|
saveImage(FALSE);
|
2013-03-02 20:44:09 +00:00
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
reset = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reset && imageSaved)
|
|
|
|
{
|
|
|
|
Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2013-03-02 20:44:09 +00:00
|
|
|
updateCanvasAndScrollbars();
|
|
|
|
clearHistory();
|
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2013-03-02 20:44:09 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_FILEOPEN:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (GetOpenFileName(&ofn) != 0)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-18 18:36:46 +00:00
|
|
|
HBITMAP bmNew = NULL;
|
|
|
|
LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
2009-10-21 15:44:31 +00:00
|
|
|
if (bmNew != NULL)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2014-01-28 15:46:28 +00:00
|
|
|
UpdateApplicationProperties(bmNew, ofn.lpstrFileTitle, ofn.lpstrFileTitle);
|
2013-11-03 14:37:42 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_FILESAVE:
|
2013-09-01 20:13:15 +00:00
|
|
|
saveImage(TRUE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILESAVEAS:
|
2013-09-01 20:13:15 +00:00
|
|
|
saveImage(FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-05-29 19:36:35 +00:00
|
|
|
case IDM_FILEASWALLPAPERPLANE:
|
2009-06-15 15:04:56 +00:00
|
|
|
SetWallpaper(filepathname, 1, 1);
|
2009-05-29 19:36:35 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEASWALLPAPERCENTERED:
|
2009-06-15 15:04:56 +00:00
|
|
|
SetWallpaper(filepathname, 1, 0);
|
2009-05-29 19:36:35 +00:00
|
|
|
break;
|
|
|
|
case IDM_FILEASWALLPAPERSTRETCHED:
|
2009-06-15 15:04:56 +00:00
|
|
|
SetWallpaper(filepathname, 2, 0);
|
2009-05-29 19:36:35 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_EDITUNDO:
|
|
|
|
undo();
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDITREDO:
|
|
|
|
redo();
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDITCOPY:
|
|
|
|
OpenClipboard(hMainWnd);
|
|
|
|
EmptyClipboard();
|
|
|
|
SetClipboardData(CF_BITMAP, CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
|
|
|
|
CloseClipboard();
|
|
|
|
break;
|
2011-05-06 18:00:41 +00:00
|
|
|
case IDM_EDITCUT:
|
|
|
|
/* Copy */
|
|
|
|
SendMessage(hwnd, WM_COMMAND, IDM_EDITCOPY, 0);
|
|
|
|
/* Delete selection */
|
|
|
|
SendMessage(hwnd, WM_COMMAND, IDM_EDITDELETESELECTION, 0);
|
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_EDITPASTE:
|
|
|
|
OpenClipboard(hMainWnd);
|
2009-10-21 15:44:31 +00:00
|
|
|
if (GetClipboardData(CF_BITMAP) != NULL)
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2014-01-28 15:46:28 +00:00
|
|
|
InsertSelectionFromHBITMAP(GetClipboardData(CF_BITMAP), hwnd);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
CloseClipboard();
|
|
|
|
break;
|
|
|
|
case IDM_EDITDELETESELECTION:
|
2009-12-18 20:33:22 +00:00
|
|
|
{
|
2010-01-16 23:21:45 +00:00
|
|
|
/* remove selection window and already painted content using undo(),
|
2010-10-10 09:57:44 +00:00
|
|
|
paint Rect for rectangular selections and Poly for freeform selections */
|
2010-01-16 23:21:45 +00:00
|
|
|
undo();
|
2010-05-27 12:21:50 +00:00
|
|
|
if (activeTool == TOOL_RECTSEL)
|
2010-01-16 23:21:45 +00:00
|
|
|
{
|
|
|
|
newReversible();
|
2014-02-07 17:54:25 +00:00
|
|
|
Rect(hDrawingDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right,
|
|
|
|
rectSel_dest.bottom, bgColor, bgColor, 0, TRUE);
|
2010-01-16 23:21:45 +00:00
|
|
|
}
|
2010-10-10 09:57:44 +00:00
|
|
|
if (activeTool == TOOL_FREESEL)
|
|
|
|
{
|
|
|
|
newReversible();
|
|
|
|
Poly(hDrawingDC, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
|
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2009-12-18 20:33:22 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_EDITSELECTALL:
|
2010-10-10 09:57:44 +00:00
|
|
|
{
|
|
|
|
HWND hToolbar = FindWindowEx(hToolBoxContainer, NULL, TOOLBARCLASSNAME, NULL);
|
|
|
|
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
|
|
|
|
SendMessage(hwnd, WM_COMMAND, ID_RECTSEL, 0);
|
|
|
|
startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
|
|
|
|
whilePaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
|
|
|
endPaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_EDITCOPYTO:
|
2009-10-21 15:44:31 +00:00
|
|
|
if (GetSaveFileName(&ofn) != 0)
|
|
|
|
SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC, NULL, NULL, fileHPPM, fileVPPM);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2014-01-28 15:46:28 +00:00
|
|
|
case IDM_EDITPASTEFROM:
|
|
|
|
if (GetOpenFileName(&ofn) != 0)
|
|
|
|
{
|
|
|
|
HBITMAP bmNew = NULL;
|
|
|
|
LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
|
|
|
if (bmNew != NULL)
|
|
|
|
{
|
|
|
|
InsertSelectionFromHBITMAP(bmNew, hwnd);
|
|
|
|
DeleteObject(bmNew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_COLORSEDITPALETTE:
|
|
|
|
if (ChooseColor(&choosecolor))
|
|
|
|
{
|
|
|
|
fgColor = choosecolor.rgbResult;
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hPalWin, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-01 20:13:15 +00:00
|
|
|
case IDM_COLORSMODERNPALETTE:
|
|
|
|
selectedPalette = 1;
|
|
|
|
CopyMemory(palColors, modernPalColors, sizeof(palColors));
|
|
|
|
InvalidateRect(hPalWin, NULL, FALSE);
|
|
|
|
break;
|
|
|
|
case IDM_COLORSOLDPALETTE:
|
|
|
|
selectedPalette = 2;
|
|
|
|
CopyMemory(palColors, oldPalColors, sizeof(palColors));
|
|
|
|
InvalidateRect(hPalWin, NULL, FALSE);
|
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_IMAGEINVERTCOLORS:
|
2009-10-21 15:44:31 +00:00
|
|
|
{
|
|
|
|
RECT tempRect;
|
|
|
|
newReversible();
|
|
|
|
SetRect(&tempRect, 0, 0, imgXRes, imgYRes);
|
|
|
|
InvertRect(hDrawingDC, &tempRect);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_IMAGEDELETEIMAGE:
|
|
|
|
newReversible();
|
|
|
|
Rect(hDrawingDC, 0, 0, imgXRes, imgYRes, bgColor, bgColor, 0, TRUE);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_IMAGEROTATEMIRROR:
|
|
|
|
switch (mirrorRotateDlg())
|
|
|
|
{
|
2010-10-10 09:57:44 +00:00
|
|
|
case 1: /* flip horizontally */
|
|
|
|
if (IsWindowVisible(hSelection))
|
|
|
|
{
|
|
|
|
SelectObject(hSelDC, hSelMask);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, RECT_WIDTH(rectSel_dest) - 1, 0, -RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
2010-10-10 09:57:44 +00:00
|
|
|
SelectObject(hSelDC, hSelBm);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, RECT_WIDTH(rectSel_dest) - 1, 0, -RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
|
|
|
ForceRefreshSelectionContents();
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newReversible();
|
|
|
|
StretchBlt(hDrawingDC, imgXRes - 1, 0, -imgXRes, imgYRes, hDrawingDC, 0, 0,
|
|
|
|
imgXRes, imgYRes, SRCCOPY);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: /* flip vertically */
|
|
|
|
if (IsWindowVisible(hSelection))
|
|
|
|
{
|
|
|
|
SelectObject(hSelDC, hSelMask);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, 0, RECT_HEIGHT(rectSel_dest) - 1, RECT_WIDTH(rectSel_dest), -RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
2010-10-10 09:57:44 +00:00
|
|
|
SelectObject(hSelDC, hSelBm);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, 0, RECT_HEIGHT(rectSel_dest) - 1, RECT_WIDTH(rectSel_dest), -RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
|
|
|
ForceRefreshSelectionContents();
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newReversible();
|
|
|
|
StretchBlt(hDrawingDC, 0, imgYRes - 1, imgXRes, -imgYRes, hDrawingDC, 0, 0,
|
|
|
|
imgXRes, imgYRes, SRCCOPY);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2010-10-10 09:57:44 +00:00
|
|
|
case 3: /* rotate 90 degrees */
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
2010-10-10 09:57:44 +00:00
|
|
|
case 4: /* rotate 180 degrees */
|
|
|
|
if (IsWindowVisible(hSelection))
|
|
|
|
{
|
|
|
|
SelectObject(hSelDC, hSelMask);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, RECT_WIDTH(rectSel_dest) - 1, RECT_HEIGHT(rectSel_dest) - 1, -RECT_WIDTH(rectSel_dest), -RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
2010-10-10 09:57:44 +00:00
|
|
|
SelectObject(hSelDC, hSelBm);
|
2014-02-07 17:54:25 +00:00
|
|
|
StretchBlt(hSelDC, RECT_WIDTH(rectSel_dest) - 1, RECT_HEIGHT(rectSel_dest) - 1, -RECT_WIDTH(rectSel_dest), -RECT_HEIGHT(rectSel_dest), hSelDC,
|
|
|
|
0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), SRCCOPY);
|
|
|
|
ForceRefreshSelectionContents();
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newReversible();
|
|
|
|
StretchBlt(hDrawingDC, imgXRes - 1, imgYRes - 1, -imgXRes, -imgYRes, hDrawingDC,
|
|
|
|
0, 0, imgXRes, imgYRes, SRCCOPY);
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2010-10-10 09:57:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: /* rotate 270 degrees */
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_IMAGEATTRIBUTES:
|
2009-10-21 15:44:31 +00:00
|
|
|
{
|
2013-09-01 20:13:15 +00:00
|
|
|
if (attributesDlg())
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2013-09-01 20:13:15 +00:00
|
|
|
cropReversible(widthSetInDlg, heightSetInDlg, 0, 0);
|
2009-10-21 15:44:31 +00:00
|
|
|
updateCanvasAndScrollbars();
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
}
|
2013-09-01 20:13:15 +00:00
|
|
|
case IDM_IMAGESTRETCHSKEW:
|
2009-10-21 15:44:31 +00:00
|
|
|
{
|
2013-09-01 20:13:15 +00:00
|
|
|
if (changeSizeDlg())
|
2009-05-12 14:15:48 +00:00
|
|
|
{
|
2009-10-21 15:44:31 +00:00
|
|
|
insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP,
|
2013-09-01 20:13:15 +00:00
|
|
|
imgXRes * stretchSkew.percentage.x / 100,
|
|
|
|
imgYRes * stretchSkew.percentage.y / 100, 0));
|
2009-10-21 15:44:31 +00:00
|
|
|
updateCanvasAndScrollbars();
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
}
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_IMAGEDRAWOPAQUE:
|
2009-10-21 15:44:31 +00:00
|
|
|
transpBg = 1 - transpBg;
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hToolSettings, NULL, TRUE);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_IMAGECROP:
|
|
|
|
insertReversible(CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
|
|
|
|
updateCanvasAndScrollbars();
|
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-12-27 21:15:08 +00:00
|
|
|
case IDM_VIEWTOOLBOX:
|
|
|
|
ShowWindow(hToolBoxContainer, IsWindowVisible(hToolBoxContainer) ? SW_HIDE : SW_SHOW);
|
|
|
|
alignChildrenToMainWindow();
|
|
|
|
break;
|
|
|
|
case IDM_VIEWCOLORPALETTE:
|
|
|
|
ShowWindow(hPalWin, IsWindowVisible(hPalWin) ? SW_HIDE : SW_SHOW);
|
|
|
|
alignChildrenToMainWindow();
|
|
|
|
break;
|
2009-10-18 18:36:46 +00:00
|
|
|
case IDM_VIEWSTATUSBAR:
|
2009-10-21 15:44:31 +00:00
|
|
|
ShowWindow(hStatusBar, IsWindowVisible(hStatusBar) ? SW_HIDE : SW_SHOW);
|
2009-12-27 21:15:08 +00:00
|
|
|
alignChildrenToMainWindow();
|
2009-10-18 18:36:46 +00:00
|
|
|
break;
|
2014-02-10 20:49:15 +00:00
|
|
|
case IDM_FORMATICONBAR:
|
|
|
|
ShowWindow(hwndTextEdit, IsWindowVisible(hwndTextEdit) ? SW_HIDE : SW_SHOW);
|
2009-07-01 19:24:17 +00:00
|
|
|
|
|
|
|
case IDM_VIEWSHOWGRID:
|
|
|
|
showGrid = !showGrid;
|
2013-09-01 20:13:15 +00:00
|
|
|
InvalidateRect(hImageArea, NULL, FALSE);
|
2009-07-01 19:24:17 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWSHOWMINIATURE:
|
|
|
|
showMiniature = !showMiniature;
|
2009-10-21 15:44:31 +00:00
|
|
|
ShowWindow(hwndMiniature, showMiniature ? SW_SHOW : SW_HIDE);
|
2009-07-01 19:24:17 +00:00
|
|
|
break;
|
2009-10-21 15:44:31 +00:00
|
|
|
|
2009-05-12 14:15:48 +00:00
|
|
|
case IDM_VIEWZOOM125:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(125, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM25:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(250, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM50:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(500, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM100:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(1000, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM200:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(2000, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM400:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(4000, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIEWZOOM800:
|
2009-10-18 18:36:46 +00:00
|
|
|
zoomTo(8000, 0, 0);
|
2009-05-12 14:15:48 +00:00
|
|
|
break;
|
|
|
|
case ID_FREESEL:
|
|
|
|
selectTool(1);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_RECTSEL:
|
|
|
|
selectTool(2);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_RUBBER:
|
|
|
|
selectTool(3);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_FILL:
|
|
|
|
selectTool(4);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_COLOR:
|
|
|
|
selectTool(5);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_ZOOM:
|
|
|
|
selectTool(6);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_PEN:
|
|
|
|
selectTool(7);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_BRUSH:
|
|
|
|
selectTool(8);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_AIRBRUSH:
|
|
|
|
selectTool(9);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_TEXT:
|
|
|
|
selectTool(10);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_LINE:
|
|
|
|
selectTool(11);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_BEZIER:
|
|
|
|
selectTool(12);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_RECT:
|
|
|
|
selectTool(13);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_SHAPE:
|
|
|
|
selectTool(14);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_ELLIPSE:
|
|
|
|
selectTool(15);
|
2009-10-21 15:44:31 +00:00
|
|
|
break;
|
2009-05-12 14:15:48 +00:00
|
|
|
case ID_RRECT:
|
|
|
|
selectTool(16);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-21 15:44:31 +00:00
|
|
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
2009-05-12 14:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|