home *** CD-ROM | disk | FTP | other *** search
- # include "BlobMgr.h"
-
-
-
- /* -------------------------------------------------------------------- */
- /* Blob Tracking and Dragging Routines */
- /* -------------------------------------------------------------------- */
-
-
- /*
- * Blob dragging variables. See discussion of DragGrayRgn in
- * the WIndow Manager section of Inside Mac. The defaults for the
- * limit and slop rects are inappropriate and really should be set
- * by the application.
- */
-
- static Rect blobLimitRect = { -30000, -30000, 30000, 30000 };
- static Rect blobSlopRect = { -30000, -30000, 30000, 30000 };
- static short blobAxis = noConstraint;
-
-
- /* Set blob dragging limit and slop rectangles */
-
- pascal void
- SetBDragRects (Rect *limitRect, Rect *slopRect)
- {
- blobLimitRect = *limitRect;
- blobSlopRect = *slopRect;
- }
-
-
- /* get current blob dragging limit and slop rectangles */
-
- pascal void
- GetBDragRects (Rect *limitRect, Rect *slopRect)
- {
- *limitRect = blobLimitRect;
- *slopRect = blobSlopRect;
- }
-
-
- /* Set blob dragging axis constraints */
-
- pascal void
- SetBDragAxis (short axis)
- {
- blobAxis = axis;
- }
-
-
- /* Get current blob dragging axis constraints */
-
- pascal short
- GetBDragAxis (void)
- {
- return (blobAxis);
- }
-
-
- /*
- * Track blob by dragging an outline of the indicated part around
- * until the mouse button is released. Return the difference between
- * the starting and ending x and y coordinates in the low and high
- * order words of the result.
- */
-
- pascal long
- TrackBlob (BlobHandle b, short partCode, Point startPoint,
- Rect * limitRect, Rect * slopRect, short axis)
- {
- RgnHandle rgn;
- Rect limit, bounds;
- long result;
-
- rgn = BCalcRegion (b, partCode);
- /*
- * Adjust the limit rectangle so the outline of the dragged regiopn
- * always fits completely within the bounds rectangle
- */
- limit = *limitRect;
- bounds = (**rgn).rgnBBox;
- limit.left += startPoint.h - bounds.left;
- limit.top += startPoint.v - bounds.top;
- limit.right -= bounds.right - startPoint.h - 1;
- limit.bottom -= bounds.bottom - startPoint.v - 1;
-
- result = DragGrayRgn (rgn, startPoint, &limit, slopRect, axis, nil);
- DisposeRgn (rgn);
- return (result);
- }
-
-
- /*
- * Track a blob, using the default limit and slop rects
- */
-
- pascal long
- DTrackBlob (BlobHandle b, short partCode, Point startPoint)
- {
-
- return (TrackBlob (b, partCode, startPoint,
- &blobLimitRect, &blobSlopRect, blobAxis));
- }
-
-
- /*
- * Drag a blob by tracking it, and then moving it to the point
- * where the mouse button was released.
- */
-
- pascal void
- DragBlob (BlobHandle b, Point startPoint,
- Rect *limitRect, Rect *slopRect, short axis)
- {
- long result;
-
- result = TrackBlob (b, inFullBlob, startPoint, limitRect, slopRect, axis);
- if ((result != badDragResult) && (result != 0))
- OffsetBlob (b, inFullBlob, LoWord (result), HiWord (result));
- }
-
-
- pascal void
- DDragBlob (BlobHandle b, Point startPoint)
- {
- DragBlob (b, startPoint, &blobLimitRect, &blobSlopRect, blobAxis);
- }
-