Index: applications/paint/winproc.c =================================================================== --- applications/paint/winproc.c (revision 47299) +++ applications/paint/winproc.c (working copy) @@ -568,15 +568,12 @@ case WM_MOUSEMOVE: if (hwnd == hImageArea) { + short xNow = (short)LOWORD(lParam) * 1000 / zoom; + short yNow = (short)HIWORD(lParam) * 1000 / zoom; if ((!drawing) || (activeTool <= 9)) { TRACKMOUSEEVENT tme; - TCHAR coordStr[100]; - _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam) * 1000 / zoom, - (short)HIWORD(lParam) * 1000 / zoom); - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); - if (activeTool == 6) { SendMessage(hImageArea, WM_PAINT, 0, 0); @@ -591,33 +588,73 @@ } if (drawing) { + /* values displayed in statusbar */ + hort xRel = xNow - startX; + short yRel = yNow - startY; + /* freesel, rectsel and text tools are limited to fit into image area */ + if ((activeTool == 1) || (activeTool == 2) || (activeTool == 10)) + { + if (xRel < 0) + xRel = (xNow < 0) ? -startX : xRel; + else if (xNow > imgXRes) + xRel = imgXRes-startX; + if (yRel < 0) + yRel = (yNow < 0) ? -startY : yRel; + else if (yNow > imgYRes) + yRel = imgYRes-startY; + } + /* rectsel and shape tools always show non-negative numbers when drawing */ + if ((activeTool == 2) || (activeTool == 14)) + { + 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 3: /* rubber */ + case 7: /* pencil */ + case 8: /* brush */ + case 9: /* airbrush */ + case 14: /* shape */ + { + TCHAR coordStr[100]; + _stprintf(coordStr, _T("%d, %d"), xNow, yNow); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); + break; + } + } if ((wParam & MK_LBUTTON) != 0) { - whilePaintingL(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom, - (short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor); + whilePaintingL(hDrawingDC, xNow, yNow, fgColor, bgColor); SendMessage(hImageArea, WM_PAINT, 0, 0); if ((activeTool >= 10) || (activeTool == 2)) { TCHAR sizeStr[100]; - _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX, - (short)HIWORD(lParam) * 1000 / zoom - startY); + _stprintf(sizeStr, _T("%d x %d"), xRel, yRel); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); } } if ((wParam & MK_RBUTTON) != 0) { - whilePaintingR(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom, - (short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor); + whilePaintingR(hDrawingDC, xNow, yNow, fgColor, bgColor); SendMessage(hImageArea, WM_PAINT, 0, 0); if (activeTool >= 10) { TCHAR sizeStr[100]; - _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX, - (short)HIWORD(lParam) * 1000 / zoom - startY); + _stprintf(sizeStr, _T("%d x %d"), xRel, yRel); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); } } } + if (!drawing) + { + TCHAR coordStr[100]; + _stprintf(coordStr, _T("%d, %d"), xNow, yNow); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); + } } break;