LOCAL void ZoomBox_OnMouseMove(HWND hWnd, int x, int y, UINT keyFlags) /***********************************************************************/ { BOOL fRButton; POINT pt; if ( !fCapture ) return; fRButton = keyFlags & MK_RBUTTON; if (!fSelection) { if (!IsOnImage(hWnd, x, y)) return; if (fSelection = (abs(StartPoint.x-x) > SMALL_MOVEMENT || abs(StartPoint.y-y) > SMALL_MOVEMENT)) { AstralUpdateWindow(hWnd); AstralSetRectEmpty( &SelectRect ); StartSelection( hWnd, NULL, &SelectRect, SL_BOX|SL_SPECIAL|SL_NOLIMIT, StartPoint, 0L ); } } if (fSelection) { pt.x = x; pt.y = y; UpdateSelection( hWnd, NULL, &SelectRect, SL_BOX|SL_NOLIMIT, pt, CONSTRAINASPECT, lAspectX, lAspectY, MOVEKEY||fRButton,FROMCENTER); } }
void CSelection::UpdateSelection(HWND hWnd, HDC hDC, RECT* lpSelectRect, int fFlags, POINT ptCurrent, bool bConstrain, long AspectX, long AspectY, bool bMove, bool bFromCenter) { RECT* pRect; bool fNeedDC; int dx, dy; POINT ptSaved; RECT OldRect, drect; bool fDoc = false; if (Mode == MOVE_MODE) bMove = true; else if (Constrain == (CONSTRAINX | CONSTRAINY)) // It hasn't been started yet StartSelection(hWnd, hDC, lpSelectRect, fFlags, ptCurrent, fScale); if (fDoc) { //j Display2File(hWnd, (LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y); } //j else //j if ((fFlags & SL_TYPE) == SL_GRID) //j Control2Image((LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y); if (!(fFlags & SL_NOLIMIT)) { // Constrain point to window client area //j RECT rBound; //j if ((fFlags & SL_TYPE) == SL_GRID) //j pRect = GetGridBoundRect(&rBound); //j else pRect = GetBoundingRect(hWnd); ptCurrent.x = bound(ptCurrent.x, pRect->left, pRect->right); ptCurrent.y = bound(ptCurrent.y, pRect->top, pRect->bottom); } ptSaved = ptCurrent; if (!bMove) { // Constrain point in x-direction based on where grabbed if (Constrain & CONSTRAINX) ptCurrent.x = lpSelectRect->right; // Constrain point in y-direction based on where grabbed if (Constrain & CONSTRAINY) ptCurrent.y = lpSelectRect->bottom; } if (fNeedDC = (!hDC)) hDC = GetDC(hWnd); switch (fFlags & SL_TYPE) { case SL_BOX: case SL_BOXHANDLES: case SL_GRID: case SL_LINE: case SL_ELLIPSE: { InvertSelection(hWnd, hDC, lpSelectRect, fFlags); if (bMove) { dx = ptCurrent.x - ptAnchor.x; dy = ptCurrent.y - ptAnchor.y; lpSelectRect->right += dx; lpSelectRect->bottom += dy; lpSelectRect->top += dy; lpSelectRect->left += dx; ptCenter.x += dx; ptCenter.y += dy; } else { dx = ptCurrent.x - lpSelectRect->right; dy = ptCurrent.y - lpSelectRect->bottom; lpSelectRect->right = ptCurrent.x; lpSelectRect->bottom = ptCurrent.y; } if (bConstrain) ConstrainSelection(lpSelectRect, AspectX, AspectY, bFromCenter); dx = lpSelectRect->right - lpSelectRect->left; dy = lpSelectRect->bottom - lpSelectRect->top; if (bFromCenter) { lpSelectRect->left = ptCenter.x - dx/2; lpSelectRect->top = ptCenter.y - dy/2; lpSelectRect->right = ptCenter.x + dx - dx/2; lpSelectRect->bottom = ptCenter.y + dy - dy/2; } GetCenter(lpSelectRect, &ptCenter); // Keep the new rectangle inside the window's client area if (!(fFlags & SL_NOLIMIT)) { //j if ((fFlags & SL_TYPE) == SL_GRID) //j MoveInsideRect(lpSelectRect, GetGridBoundRect(&rBound)); //j else MoveInsideRect(lpSelectRect, GetBoundingRect(hWnd)); } InvertSelection(hWnd, hDC, lpSelectRect, fFlags); break; } case SL_BLOCK: { OldRect = *lpSelectRect; dx = ptCurrent.x - lpSelectRect->right; dy = ptCurrent.y - lpSelectRect->bottom; lpSelectRect->right = ptCurrent.x; lpSelectRect->bottom = ptCurrent.y; if (bConstrain) ConstrainSelection(lpSelectRect, AspectX, AspectY, bFromCenter); if (bFromCenter) { lpSelectRect->left = ptCenter.x - dx/2; lpSelectRect->top = ptCenter.y - dy/2; lpSelectRect->right = ptCenter.x + dx - dx/2; lpSelectRect->bottom = ptCenter.y + dy - dy/2; } GetCenter(lpSelectRect, &ptCenter); drect.left = OldRect.left - lpSelectRect->left; drect.right = OldRect.right - lpSelectRect->right; drect.top = OldRect.top - lpSelectRect->top; drect.bottom = OldRect.bottom - lpSelectRect->bottom; PatBlt(hDC, lpSelectRect->left, lpSelectRect->bottom, OldRect.right - lpSelectRect->left, drect.bottom, DSTINVERT); PatBlt(hDC, lpSelectRect->right, OldRect.top, drect.right, lpSelectRect->bottom - OldRect.top, DSTINVERT); PatBlt(hDC, OldRect.left, OldRect.top, lpSelectRect->right-OldRect.left, drect.top, DSTINVERT); PatBlt(hDC, OldRect.left, lpSelectRect->top, drect.left, OldRect.bottom-lpSelectRect->top, DSTINVERT); break; } } ptAnchor = ptSaved; if (fDoc) { //j LPIMAGE lpImage = GetImagePtr(hWnd); //j DisplayInfo(ptCurrent.x, ptCurrent.y, lpSelectRect); //j StatusOfRectangle(lpSelectRect, fScale, FrameResolution(ImgGetBaseEditFrame(lpImage))); } else StatusOfRectangle(lpSelectRect, fScale, 1000); if (fNeedDC) ReleaseDC(hWnd, hDC); }
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { RECT Rect; BOOL fShift; POINT pt; static int Type, Style; static BOOL fConstrain; static RECT SelectRect; int res; FRMDATATYPE type; LPIMAGE lpImage; STRING szString; GRADIENT_PARMS parms; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type); if (type == FDT_LINEART) { AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) ); Message(IDS_NOTWITHLINEART, (LPSTR)szString); break; } AstralUpdateWindow(hWindow); Tool.bActive = YES; // SetMaskingState( x, y ); break; case WM_LBUTTONDOWN: Type = Vignette.Gradient; fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE ); AstralSetRectEmpty( &SelectRect ); if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE ) Style = SL_ELLIPSE; else if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR ) Style = SL_LINE; else Style = SL_BOX; pt.x = x; pt.y = y; StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL, pt, 0L ); break; case WM_LBUTTONUP: Tool.bActive = NO; Rect = SelectRect; // make a copy before it gets ordered EndSelection( hWindow, NULL, &SelectRect, Style, YES ); lpImage = (LPIMAGE)GetImagePtr ( hWindow ); res = FrameResolution(ImgGetBaseEditFrame(lpImage)); type = FrameType(ImgGetBaseEditFrame(lpImage)); parms.VigOpacity = Vignette.VigOpacity; parms.VigMergeMode = Vignette.VigMergeMode; parms.iBaseRes = res; parms.x1 = Rect.left; parms.y1 = Rect.top; parms.x2 = Rect.right; parms.y2 = Rect.bottom; GetActiveColorFromType(type, &parms.StartColor); GetAlternateColorFromType(type, &parms.EndColor); parms.Gradient = Vignette.Gradient; parms.RepeatCount = Vignette.RepeatCount; parms.SoftTransition = Vignette.SoftTransition; parms.Midpoint = Vignette.Midpoint; parms.VigColorModel = Vignette.VigColorModel; ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms); break; case WM_MOUSEMOVE: // sent when ToolActive is on fShift = SHIFT; pt.x = x; pt.y = y; UpdateSelection( hWindow, NULL, &SelectRect, Style, pt, fConstrain^CONSTRAINASPECT, 1L, 1L, MOVEKEY||Window.fRButtonDown, FROMCENTER); break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message if (!Tool.bActive) break; Tool.bActive = NO; EndSelection( hWindow, NULL, &SelectRect, Style, YES ); break; } }