[comp.sys.mac.programmer] Plotting SICN items

bin@primate.wisc.edu (Brain in Neutral) (01/18/89)

Here's some info on SICN's and how to use them.  The code fragments
below are in Rascal (which is what SicnEdit is written in).  Similar
to Pascal, for the most part.

A SICN resource is actually a set of SICN items, or SITM's as I call
them.  One SITM is usually what you see, when you see one, not the
whole SICN.  A SITM is a 16x16 bitmap, similar to an ICON, which is a
32x32 bitmap.  A SICN is just a bunch of SITM's end-to-end; an array
of SITM's, as it were.

The way a SITM is drawn is very similar to drawing an ICON: create a
small bitmap and blat it into the window.


Const
    sitmSize = 16;  (* SICN items are 16 bits wide x 16 words down *)

Type

    Sitm = Integer[sitmSize];
    SicnHandle = ^^Sitm[1];          (* actually variable-length *)


(*
    Plot sicn item in given rectangle.  This is pretty analogous to PlotIcon.
*)

Proc PlotSitm (r: Rect; s: Sitm);
Var
    thePort: GrafPtr;
    bm: BitMap;
    tmpSitm: Sitm;
{
    (*  create a small bitmap *)
    tmpSitm := s;         (* make non-relocatable copy of item data *)
    bm.baseAddr := @tmpSitm;
    bm.rowBytes := 2;       (* items are 16 bits wide *)
    SetRect (bm.bounds, 0, 0, sitmSize, sitmSize);
    GetPort (@thePort);
    CopyBits (bm, thePort^.portBits, bm.bounds, r, srcCopy, nil);
};


(*
	Plot the (i)th sitm in a sicn
*)

Proc PlotSicn (r: Rect; s: SicnHandle; i: Integer);
Var
    sitm: Sitm;
{
    sitm := s^^[i];
    PlotSitm (r, sitm);
};

---
Paul DuBois
dubois@primate.wisc.edu		rhesus!dubois
bin@primate.wisc.edu		rhesus!bin