2015-07-07 11:02:30 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL
|
2015-09-09 13:13:35 +00:00
|
|
|
* FILE: base/applications/mspaint/imgarea.cpp
|
2015-07-07 11:02:30 +00:00
|
|
|
* PURPOSE: Window procedure of the main window and all children apart from
|
|
|
|
* hPalWin, hToolSettings and hSelection
|
|
|
|
* PROGRAMMERS: Benedikt Freisen
|
2017-07-27 09:29:42 +00:00
|
|
|
* Katayama Hirofumi MZ
|
2015-07-07 11:02:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *********************************************************/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ********************************************************/
|
|
|
|
|
2015-07-07 11:56:37 +00:00
|
|
|
void
|
|
|
|
updateCanvasAndScrollbars()
|
|
|
|
{
|
|
|
|
selectionWindow.ShowWindow(SW_HIDE);
|
2019-12-23 19:30:25 +00:00
|
|
|
|
2021-12-26 10:49:56 +00:00
|
|
|
int zoomedWidth = Zoomed(imageModel.GetWidth());
|
|
|
|
int zoomedHeight = Zoomed(imageModel.GetHeight());
|
2021-12-26 14:05:47 +00:00
|
|
|
imageArea.MoveWindow(GRIP_SIZE, GRIP_SIZE, zoomedWidth, zoomedHeight, FALSE);
|
2019-12-23 19:30:25 +00:00
|
|
|
|
2015-07-07 11:56:37 +00:00
|
|
|
scrollboxWindow.Invalidate(TRUE);
|
|
|
|
imageArea.Invalidate(FALSE);
|
|
|
|
|
|
|
|
scrollboxWindow.SetScrollPos(SB_HORZ, 0, TRUE);
|
|
|
|
scrollboxWindow.SetScrollPos(SB_VERT, 0, TRUE);
|
|
|
|
}
|
|
|
|
|
2015-07-07 11:02:30 +00:00
|
|
|
void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HPEN oldPen;
|
|
|
|
HBRUSH oldBrush;
|
|
|
|
LOGBRUSH logbrush;
|
|
|
|
int rop;
|
|
|
|
|
|
|
|
RECT clientRectScrollbox;
|
|
|
|
RECT clientRectImageArea;
|
|
|
|
int x, y, w, h;
|
|
|
|
scrollboxWindow.GetClientRect(&clientRectScrollbox);
|
|
|
|
GetClientRect(&clientRectImageArea);
|
2018-05-23 21:31:20 +00:00
|
|
|
w = clientRectImageArea.right * 2;
|
|
|
|
h = clientRectImageArea.bottom * 2;
|
|
|
|
if (!w || !h)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
w = clientRectImageArea.right * clientRectScrollbox.right / w;
|
|
|
|
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
|
2015-07-07 11:02:30 +00:00
|
|
|
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
|
|
|
|
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
|
|
|
|
|
|
|
|
hdc = GetDC();
|
|
|
|
oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
|
|
|
|
logbrush.lbStyle = BS_HOLLOW;
|
|
|
|
oldBrush = (HBRUSH) 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(hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2022-01-22 15:59:12 +00:00
|
|
|
if (!IsWindow() || !sizeboxLeftTop.IsWindow())
|
|
|
|
return 0;
|
2015-07-07 11:56:37 +00:00
|
|
|
int imgXRes = imageModel.GetWidth();
|
|
|
|
int imgYRes = imageModel.GetHeight();
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxLeftTop.MoveWindow(
|
|
|
|
0,
|
2021-12-26 14:05:47 +00:00
|
|
|
0, GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxCenterTop.MoveWindow(
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + (Zoomed(imgXRes) - GRIP_SIZE) / 2,
|
|
|
|
0, GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxRightTop.MoveWindow(
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + Zoomed(imgXRes),
|
|
|
|
0, GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxLeftCenter.MoveWindow(
|
|
|
|
0,
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + (Zoomed(imgYRes) - GRIP_SIZE) / 2,
|
|
|
|
GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxRightCenter.MoveWindow(
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + Zoomed(imgXRes),
|
|
|
|
GRIP_SIZE + (Zoomed(imgYRes) - GRIP_SIZE) / 2,
|
|
|
|
GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxLeftBottom.MoveWindow(
|
|
|
|
0,
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + Zoomed(imgYRes), GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxCenterBottom.MoveWindow(
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + (Zoomed(imgXRes) - GRIP_SIZE) / 2,
|
|
|
|
GRIP_SIZE + Zoomed(imgYRes), GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
sizeboxRightBottom.MoveWindow(
|
2021-12-26 14:05:47 +00:00
|
|
|
GRIP_SIZE + Zoomed(imgXRes),
|
|
|
|
GRIP_SIZE + Zoomed(imgYRes), GRIP_SIZE, GRIP_SIZE, TRUE);
|
2015-07-07 11:02:30 +00:00
|
|
|
UpdateScrollbox();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-05 07:26:05 +00:00
|
|
|
LRESULT CImgAreaWindow::OnEraseBkGnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
HDC hdc = (HDC)wParam;
|
|
|
|
|
|
|
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && !toolsModel.IsBackgroundTransparent() &&
|
2022-01-22 15:59:12 +00:00
|
|
|
::IsWindowVisible(textEditWindow))
|
2022-01-05 07:26:05 +00:00
|
|
|
{
|
|
|
|
// Do clipping
|
|
|
|
HWND hChild = textEditWindow;
|
|
|
|
RECT rcChild;
|
|
|
|
::GetWindowRect(hChild, &rcChild);
|
|
|
|
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rcChild, 2);
|
|
|
|
ExcludeClipRect(hdc, rcChild.left, rcChild.top, rcChild.right, rcChild.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(nMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2015-07-07 11:02:30 +00:00
|
|
|
LRESULT CImgAreaWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2022-01-05 07:26:05 +00:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc = BeginPaint(&ps);
|
2015-07-07 11:56:37 +00:00
|
|
|
int imgXRes = imageModel.GetWidth();
|
|
|
|
int imgYRes = imageModel.GetHeight();
|
2021-12-26 10:49:56 +00:00
|
|
|
StretchBlt(hdc, 0, 0, Zoomed(imgXRes), Zoomed(imgYRes), imageModel.GetDC(), 0, 0, imgXRes,
|
2015-07-07 11:02:30 +00:00
|
|
|
imgYRes, SRCCOPY);
|
2015-07-07 11:15:24 +00:00
|
|
|
if (showGrid && (toolsModel.GetZoom() >= 4000))
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0));
|
|
|
|
int counter;
|
|
|
|
for(counter = 0; counter <= imgYRes; counter++)
|
|
|
|
{
|
2021-12-26 10:49:56 +00:00
|
|
|
MoveToEx(hdc, 0, Zoomed(counter), NULL);
|
|
|
|
LineTo(hdc, Zoomed(imgXRes), Zoomed(counter));
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
for(counter = 0; counter <= imgXRes; counter++)
|
|
|
|
{
|
2021-12-26 10:49:56 +00:00
|
|
|
MoveToEx(hdc, Zoomed(counter), 0, NULL);
|
|
|
|
LineTo(hdc, Zoomed(counter), Zoomed(imgYRes));
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
2022-01-05 07:26:05 +00:00
|
|
|
EndPaint(&ps);
|
2022-01-22 15:59:12 +00:00
|
|
|
if (selectionWindow.IsWindow())
|
2022-01-10 12:44:13 +00:00
|
|
|
selectionWindow.Invalidate(FALSE);
|
2022-01-22 15:59:12 +00:00
|
|
|
if (miniature.IsWindow())
|
2022-01-10 12:44:13 +00:00
|
|
|
miniature.Invalidate(FALSE);
|
2022-01-22 15:59:12 +00:00
|
|
|
if (textEditWindow.IsWindow())
|
2022-01-05 07:26:05 +00:00
|
|
|
textEditWindow.Invalidate(FALSE);
|
2015-07-07 11:02:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2015-07-07 11:15:24 +00:00
|
|
|
switch (toolsModel.GetActiveTool())
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
case TOOL_FILL:
|
|
|
|
SetCursor(hCurFill);
|
|
|
|
break;
|
|
|
|
case TOOL_COLOR:
|
|
|
|
SetCursor(hCurColor);
|
|
|
|
break;
|
|
|
|
case TOOL_ZOOM:
|
|
|
|
SetCursor(hCurZoom);
|
|
|
|
break;
|
|
|
|
case TOOL_PEN:
|
|
|
|
SetCursor(hCurPen);
|
|
|
|
break;
|
|
|
|
case TOOL_AIRBRUSH:
|
|
|
|
SetCursor(hCurAirbrush);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_CROSS));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
drawing = TRUE;
|
|
|
|
SetCapture();
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonDown(TRUE, UnZoomed(x), UnZoomed(y), FALSE);
|
|
|
|
Invalidate(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
drawing = FALSE;
|
|
|
|
ReleaseCapture();
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonDown(TRUE, UnZoomed(x), UnZoomed(y), TRUE);
|
|
|
|
toolsModel.resetTool();
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
drawing = TRUE;
|
|
|
|
SetCapture();
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonDown(FALSE, UnZoomed(x), UnZoomed(y), FALSE);
|
|
|
|
Invalidate(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
drawing = FALSE;
|
|
|
|
ReleaseCapture();
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonDown(FALSE, UnZoomed(x), UnZoomed(y), TRUE);
|
|
|
|
toolsModel.resetTool();
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
if (drawing)
|
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
drawing = FALSE;
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonUp(TRUE, UnZoomed(x), UnZoomed(y));
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
|
|
|
}
|
2017-07-27 09:29:42 +00:00
|
|
|
ReleaseCapture();
|
2015-07-07 11:02:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-27 09:29:42 +00:00
|
|
|
void CImgAreaWindow::cancelDrawing()
|
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
drawing = FALSE;
|
|
|
|
toolsModel.OnCancelDraw();
|
|
|
|
Invalidate(FALSE);
|
2017-07-27 09:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
if (drawing)
|
2017-07-27 09:29:42 +00:00
|
|
|
cancelDrawing();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
if (wParam == VK_ESCAPE)
|
|
|
|
{
|
|
|
|
if (GetCapture() == m_hWnd)
|
|
|
|
{
|
|
|
|
ReleaseCapture();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-30 03:05:23 +00:00
|
|
|
if (drawing || ToolBase::pointSP != 0 || selectionWindow.IsWindowVisible())
|
2022-01-01 13:02:36 +00:00
|
|
|
cancelDrawing();
|
2017-07-27 09:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
if (drawing)
|
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
drawing = FALSE;
|
|
|
|
INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
|
|
|
toolsModel.OnButtonUp(FALSE, UnZoomed(x), UnZoomed(y));
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
|
|
|
}
|
2018-05-24 17:11:46 +00:00
|
|
|
ReleaseCapture();
|
2015-07-07 11:02:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2021-12-26 10:49:56 +00:00
|
|
|
LONG xNow = UnZoomed(GET_X_LPARAM(lParam));
|
|
|
|
LONG yNow = UnZoomed(GET_Y_LPARAM(lParam));
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((!drawing) || (toolsModel.GetActiveTool() <= TOOL_AIRBRUSH))
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
|
2015-07-07 11:15:24 +00:00
|
|
|
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
Invalidate(FALSE);
|
|
|
|
UpdateWindow();
|
|
|
|
drawZoomFrame(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
|
|
|
}
|
|
|
|
|
|
|
|
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
|
|
|
tme.dwFlags = TME_LEAVE;
|
2015-07-07 11:56:37 +00:00
|
|
|
tme.hwndTrack = m_hWnd;
|
2015-07-07 11:02:30 +00:00
|
|
|
tme.dwHoverTime = 0;
|
|
|
|
TrackMouseEvent(&tme);
|
|
|
|
|
|
|
|
if (!drawing)
|
|
|
|
{
|
2016-10-09 11:42:37 +00:00
|
|
|
CString strCoord;
|
|
|
|
strCoord.Format(_T("%ld, %ld"), xNow, yNow);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (drawing)
|
|
|
|
{
|
|
|
|
/* values displayed in statusbar */
|
|
|
|
LONG xRel = xNow - start.x;
|
|
|
|
LONG yRel = yNow - start.y;
|
|
|
|
/* freesel, rectsel and text tools always show numbers limited to fit into image area */
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((toolsModel.GetActiveTool() == TOOL_FREESEL) || (toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_TEXT))
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
if (xRel < 0)
|
|
|
|
xRel = (xNow < 0) ? -start.x : xRel;
|
2015-07-07 11:56:37 +00:00
|
|
|
else if (xNow > imageModel.GetWidth())
|
|
|
|
xRel = imageModel.GetWidth() - start.x;
|
2015-07-07 11:02:30 +00:00
|
|
|
if (yRel < 0)
|
|
|
|
yRel = (yNow < 0) ? -start.y : yRel;
|
2015-07-07 11:56:37 +00:00
|
|
|
else if (yNow > imageModel.GetHeight())
|
|
|
|
yRel = imageModel.GetHeight() - start.y;
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
/* rectsel and shape tools always show non-negative numbers when drawing */
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_SHAPE))
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
if (xRel < 0)
|
|
|
|
xRel = -xRel;
|
|
|
|
if (yRel < 0)
|
|
|
|
yRel = -yRel;
|
|
|
|
}
|
|
|
|
/* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
|
2015-07-07 11:15:24 +00:00
|
|
|
switch(toolsModel.GetActiveTool())
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
|
|
|
case TOOL_RUBBER:
|
|
|
|
case TOOL_PEN:
|
|
|
|
case TOOL_BRUSH:
|
|
|
|
case TOOL_AIRBRUSH:
|
|
|
|
case TOOL_SHAPE:
|
|
|
|
{
|
2016-10-09 11:42:37 +00:00
|
|
|
CString strCoord;
|
|
|
|
strCoord.Format(_T("%ld, %ld"), xNow, yNow);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
|
2015-07-07 11:02:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-12-27 14:23:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
2022-01-01 13:02:36 +00:00
|
|
|
if (wParam & MK_LBUTTON)
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
toolsModel.OnMouseMove(TRUE, xNow, yNow);
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((toolsModel.GetActiveTool() >= TOOL_TEXT) || (toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_FREESEL))
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
2016-10-09 11:42:37 +00:00
|
|
|
CString strSize;
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
2015-07-07 11:02:30 +00:00
|
|
|
yRel = xRel;
|
2016-10-09 11:42:37 +00:00
|
|
|
strSize.Format(_T("%ld x %ld"), xRel, yRel);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-01 13:02:36 +00:00
|
|
|
if (wParam & MK_RBUTTON)
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
2022-01-01 13:02:36 +00:00
|
|
|
toolsModel.OnMouseMove(FALSE, xNow, yNow);
|
2015-07-07 11:02:30 +00:00
|
|
|
Invalidate(FALSE);
|
2015-07-07 11:15:24 +00:00
|
|
|
if (toolsModel.GetActiveTool() >= TOOL_TEXT)
|
2015-07-07 11:02:30 +00:00
|
|
|
{
|
2016-10-09 11:42:37 +00:00
|
|
|
CString strSize;
|
2015-07-07 11:15:24 +00:00
|
|
|
if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
2015-07-07 11:02:30 +00:00
|
|
|
yRel = xRel;
|
2016-10-09 11:42:37 +00:00
|
|
|
strSize.Format(_T("%ld x %ld"), xRel, yRel);
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
|
2015-07-07 11:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) _T(""));
|
2015-07-07 11:15:24 +00:00
|
|
|
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
|
2015-07-07 11:56:37 +00:00
|
|
|
Invalidate(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
updateCanvasAndScrollbars();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnImageModelImageChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
Invalidate(FALSE);
|
2015-07-07 11:02:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-27 13:20:22 +00:00
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
return ::SendMessage(GetParent(), nMsg, wParam, lParam);
|
|
|
|
}
|
2022-01-05 07:26:05 +00:00
|
|
|
|
|
|
|
LRESULT CImgAreaWindow::OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
HDC hdc = (HDC)wParam;
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
return (LRESULT)GetStockObject(NULL_BRUSH);
|
|
|
|
}
|
2022-01-30 03:05:23 +00:00
|
|
|
|
|
|
|
void CImgAreaWindow::finishDrawing()
|
|
|
|
{
|
|
|
|
toolsModel.OnFinishDraw();
|
|
|
|
drawing = FALSE;
|
|
|
|
Invalidate(FALSE);
|
|
|
|
}
|