[comp.sys.mac.programmer] Drawing SICNs

mnkonar@gorby.SRC.Honeywell.COM (Murat N. Konar) (03/22/89)

Does anyone out there have a code fragment that demonstrates how
to plot a SICN?  I can't find anything about this in IM or the 
Tech Notes.  I did find out that SICN stands for "Script Symbol
Icon" and not "Small Icon" as is the popular interpretation.  
They are apparently used in conjunction with the Script Manager
to display which script is in current use (i.e. Arabic, Kanji,
whatever).  The 2.0 Script Manager documentation says nothing
about drawing these little buggers though. 

Thanks.



______________________________________________________________________
Have a day. :^|
Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
mnkonar@SRC.honeywell.com (internet) | {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)

oster@dewey.soe.berkeley.edu (David Phillip Oster) (03/22/89)

Here is what I use to draw a sicn:

/* DrawSicn - draw a sicn at the current cursor position.
	Move the cursor past the sicn.
	A sicn is treated like a kind of character, so use the character's
	transfer mode.
 */
void DrawSicn(id)Integer id;{
	static Rect src  = {0, 0, 16, 16};

	DrawSicnPart(id, &src);
}

/* DrawSicnPart - draw a sicn at the current cursor position.
	Like DrawSicn, see above, but takes a sicn relative rectangle as
	the src.
 */
void DrawSicnPart(id, srcP)Integer id;Rect *srcP;{
	Rect dest;
	static BitMap b  = { NIL, 2, {0, 0, 16, 16}};

	dest = *srcP;
	OffsetRect(&dest, thePort->pnLoc.h, thePort->pnLoc.v - (dest.bottom -
dest.top));
	Move(2 + (dest.right - dest.left), 0);
	HLock(sicnHandle);
	b.baseAddr = *sicnHandle + id*2*16;
	CopyBits(&b, &thePort->portBits, srcP, &dest, thePort->txMode, NIL);
	HUnlock(sicnHandle);
}

--- David Phillip Oster            --"When we replace the mouse with a pen,
Arpa: oster@dewey.soe.berkeley.edu --3 button mouse fans will need saxophone
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu --lessons." - Gasee

jackiw@cs.swarthmore.edu (Nick Jackiw) (03/22/89)

In article <19167@srcsip.UUCP> mnkonar@srcsip.UUCP (Murat N. Konar) writes:
> Does anyone out there have a code fragment that demonstrates how
> to plot a SICN?  I can't find anything about this in IM or the 
> Tech Notes.  I did find out that SICN stands for "Script Symbol
> Icon" and not "Small Icon" as is the popular interpretation.  
> 
> Murat N. Konar        Honeywell Systems & Research Center, Camden, MN

SICNs are simply 16x16 bit-images, so you have to generate a bitmap
structure containing this image and use CopyBits or somesuch to plot it.
E.g.

	theSICN:=GetResource('SICN',Resource_ID);	{Read it}
	if theSICN<>nil then
	 begin {Successful resource-read}
	  with junkBitMap do
	   begin
	    rowBytes:=2;				{16 bits=2 bytes}
	    SetRect(bounds,0,0,15,15);
	    Hlock(theSICN);
	    baseAddr:=theSICN^			{Install ptr to bit-image}
	   end;
	  Copybits(junkBitMap,thePort^.portBits,junkBitMap.bounds,
	           destRect,srcCopy,NIL);	{Draw it}
	  HUnlock(theSICN);
	  ReleaseResource(theSICN)
	 end; {Successful resource-read}

This should work, although I haven't tested it. 


-- 
+-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+
|  nicholas jackiw  | jackiw%campus.swarthmore.edu@swarthmr.bitnet           |
+-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+
"Ah...I've got this CHRONIC pain."                             _True Believer_

thecloud@dhw68k.cts.com (Ken McLeod) (03/23/89)

In article <19167@srcsip.UUCP> mnkonar@srcsip.UUCP (Murat N. Konar) writes:
>Does anyone out there have a code fragment that demonstrates how
>to plot a SICN?  I can't find anything about this in IM or the 
>Tech Notes.  I did find out that SICN stands for "Script Symbol
>Icon" and not "Small Icon" as is the popular interpretation.  

 The following code appeared in MacTutor a while back. I think it came
from David Dunham, but I'm not positive. I also recall that there were
some caveats attached, but I don't remember them. Hope it helps anyway.

/*
	PlotSICN.c
	Draw the sicnNumth small icon of sicn in sicnRect of window.

	Note that a dereferenced handle is used (*sicn), but there's no need
	to lock it, since CopyBits() won't alter the heap configuration
	unless a picture or region is being recorded.
*/

PlotSICN (sicn, sicnRect, sicnNum, window)
Handle	sicn;
Rect	*sicnRect;
short	sicnNum;
WindowPtr	window;
{
	BitMap	sicnBits;

	/* set up the bitmap */
	sicnBits.rowBytes = 2;
	SetRect(&sicnBits.bounds, 0, 0, 16, 16);
	sicnBits.baseAddr = *sicn + (sicnNum * 32);
	/* blit the sicn */
	CopyBits(&sicnBits, &window->portBits,
		&sicnBits.bounds, sicnRect, srcCopy, NIL);
}


-- 
==========     .......     =============================================
Ken McLeod    :.     .:    felix!dhw68k!thecloud@ics.uci.edu
==========   :::.. ..:::   InterNet: thecloud@dhw68k.cts.com
                ////       =============================================

wilkins@jarthur.Claremont.EDU (Mark Wilkins) (03/28/89)

In article <19167@srcsip.UUCP> mnkonar@srcsip.UUCP (Murat N. Konar) writes:

[stuff deleted]

>Tech Notes.  I did find out that SICN stands for "Script Symbol
>Icon" and not "Small Icon" as is the popular interpretation.  

Interesting.  Page 25 of Apple's ResEdit 1.2b3 manual says: "SICN (small icon)
resources are edited much as other..."

However, working draft 5 of Inside Mac V (cute, huh?) says on p. 4 "SICN:
script symbol"

My only comment on the matter is that since Apple has SICN's for the
application symbol, open folder, and closed folder icons in the system file,
they are not intended only for script manager use, so why complain if people
say "small icon."  No harm done, and it doesn't seem quite wrong either.

                        -- Mark Wilkins

cyosta@taux01.UUCP ( Yossie Silverman ) (03/29/89)

In article <2599@ilium.cs.swarthmore.edu> jackiw@ilium.UUCP (Nick Jackiw) writes:
.In article <19167@srcsip.UUCP> mnkonar@srcsip.UUCP (Murat N. Konar) writes:
.> Does anyone out there have a code fragment that demonstrates how
.> to plot a SICN?  I can't find anything about this in IM or the 
.> Tech Notes.  I did find out that SICN stands for "Script Symbol
.> Icon" and not "Small Icon" as is the popular interpretation.  
.> 
.> Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
.
.SICNs are simply 16x16 bit-images, so you have to generate a bitmap
.structure containing this image and use CopyBits or somesuch to plot it.
.E.g.
.
.	theSICN:=GetResource('SICN',Resource_ID);	{Read it}
.	if theSICN<>nil then
.	 begin {Successful resource-read}
.	  with junkBitMap do
.	   begin
.	    rowBytes:=2;				{16 bits=2 bytes}
.	    SetRect(bounds,0,0,15,15);
	    SetRect(bounds,0,0,16,16); <<<<=====
.	    Hlock(theSICN);
.	    baseAddr:=theSICN^			{Install ptr to bit-image}
.	   end;
.	  Copybits(junkBitMap,thePort^.portBits,junkBitMap.bounds,
.	           destRect,srcCopy,NIL);	{Draw it}
.	  HUnlock(theSICN);
.	  ReleaseResource(theSICN)
.	 end; {Successful resource-read}
.
.This should work, although I haven't tested it. 
.
.
.-- 
.+-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+
.|  nicholas jackiw  | jackiw%campus.swarthmore.edu@swarthmr.bitnet           |
.+-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+
."Ah...I've got this CHRONIC pain."                             _True Believer_


-- 
Yossie Silverman                                   What did the Caspian sea?
National Semiconductor Ltd. (Israel)				- Saki
UUCP: cyosta%taux01@nsc.COM
NSA LSD FBI KGB PCP CIA MOSAD NUCLEAR MI5 SPY ASSASSINATE SDI -- OOCLAY ITAY