home *** CD-ROM | disk | FTP | other *** search
- /*
- * Concentration library routines
- */
-
- # include "TransSkel.h"
- # if ENABLE_DEBUG
- # include "Debug.h"
- # endif
-
- # include "Concentration.h"
-
-
- /* ---------------------------------------------------------------- */
- /* Blob Operations */
- /* ---------------------------------------------------------------- */
-
-
-
- /*
- * Blobs are used in a way that may not be immediately obvious.
- *
- * Procedure blobs are used. A blob is either an ICON or a SICN item
- * (which comprises the drag region), with a frame around it (which
- * comprises the static region). The drawing procedure is called to
- * draw one region at a time. If the region to be drawn is the static
- * region, then just the frame is drawn. If the region to be drawn
- * is the drag region, then it's drawn either black (piece is covered)
- * or the ICON/SICN item is drawn. A piece is considered covered when
- * it's glued to itself. To uncover it, it's unglued from itself.
- * Thus, the drawing procedure need only check whether the blob
- * has a glob or not, and respond appropriately. If the blob is
- * uncovered, the ICON or SICN item to draw is indicated by the
- * reference constant.
- */
-
-
- # define kFrameInset (-2)
-
-
- /*
- * Draw an icon blob
- *
- * bDst blob to draw in
- * bSrc blob to be drawn in bDst
- */
-
- static pascal void
- DrawIconBlob (BlobHandle bDst, BlobHandle bSrc, short partCode)
- {
- Rect r;
- Piece *p;
-
- if (partCode ==inStatBlob)
- {
- r = BStatBox (bDst);
- FrameRect (&r);
- }
- else
- {
- r = BDragBox (bDst);
- if (BGlob (bDst) != nil) /* covered */
- PaintRect (&r);
- else /* draw image according to resource type */
- {
- p = &gb->piece[GetBRefCon (bDst)];
- switch (p->pieceType)
- {
- case iconType:
- PlotIcon (&r, p->pieceData);
- break;
- case cicnType:
- EraseRect (&r);
- PlotCIcon (&r, (CIconHandle) p->pieceData);
- break;
- default:
- Bail ("\pDrawIconBlob: unknown resource type");
- }
- }
- }
- }
-
-
- /*
- * Plot SICN item in given rectangle.
- * This is exactly analogous to the ToolBox PlotIcon routine,
- * except that the item number within the SICN must be specified.
- */
-
-
- static void
- PlotSicn (Rect *r, SitmHandle s)
- {
- GrafPtr thePort;
- BitMap bm;
-
- /* create a small bitmap that points to the SICN item */
- HLock ((Handle) s);
- bm.baseAddr = (Ptr) *s;
- bm.rowBytes = sitmSize / 8; /* items are 2 bytes wide */
- SetRect (&bm.bounds, 0, 0, sitmSize, sitmSize);
- GetPort (&thePort);
- CopyBits (&bm, &thePort->portBits, &bm.bounds, r, srcCopy, nil);
- HUnlock ((Handle) s);
- }
-
-
- static pascal void
- DrawSicnBlob (BlobHandle bDst, BlobHandle bSrc, short partCode)
- {
- Rect r;
- Piece *p;
-
- if (partCode == inStatBlob)
- {
- r = BStatBox (bDst);
- FrameRect (&r);
- }
- else
- {
- r = BDragBox (bDst);
- if (BGlob (bDst) != nil) /* covered */
- PaintRect (&r);
- else
- {
- p = &gb->piece[GetBRefCon (bDst)];
- PlotSicn (&r, (SitmHandle) p->pieceData);
- }
- }
- }
-
-
- /*
- * Make a blob to display an icon or sicn item with a frame around it.
- * Pass the blob set to attach the blob to, and the horizontal and
- * vertical coordinates of the upper left of the drag region. (The
- * static region is drawn outside that.) The reference number of the
- * icon or sicn item to draw in the blob is assigned later.
- */
-
- void
- MakeBlob (BlobSetHandle bSet, short h, short v, short sizeType)
- {
- BlobHandle b;
- Rect dr, sr; /* drag, static rectangles */
- short size;
- BDrawProcPtr p;
-
- switch (sizeType)
- {
- case largePiece:
- size = iconSize;
- p = DrawIconBlob;
- break;
- case smallPiece:
- size = sitmSize;
- p = DrawSicnBlob;
- break;
- default:
- Bail ("\pMakeBlob: unknown blob type.");
- }
-
- b = NewBlob (bSet, false, infiniteGlue, false, 0L);
- SetRect (&dr, h, v, h + size, v + size);
- sr = dr;
- InsetRect (&sr, kFrameInset, kFrameInset); /* for frame around image */
- SetProcRectBlob (b, p, &dr, &sr);
- }
-