[comp.sys.mac.programmer] hilite color

rolf@sparc1.isgs.uiuc.edu (Rolf Wilson) (02/12/91)

  Question 1: How do you hilite something in the user-selected
     hilite color? I don't mean text. InvertRect always?
     uses black.
  Question 2: Is there a way of doing the above while still
     using the "old" color model?
--

Rolf Wilson   Illinois State Geological Survey   rolf@sparc1.isgs.uiuc.edu

anders@verity.com (Anders Wallgren) (02/12/91)

In article <1991Feb11.200302.424@ux1.cso.uiuc.edu>, rolf@sparc1 (Rolf Wilson) writes:
>  Question 1: How do you hilite something in the user-selected
>     hilite color? I don't mean text. InvertRect always?
>     uses black.
>  Question 2: Is there a way of doing the above while still
>     using the "old" color model?
>--


In pascal, call:

	BitClr(Ptr(HiliteMode, pHiliteBit));

before calls to InvertRect, InvertRgn, etc.  This is compatible with
all versions of QuickDraw and doesn't what the bit-depth of the
monitor is.  This is documented in the Color QuickDraw chapter in IM
V, I think.

peirce@outpost.UUCP (Michael Peirce) (02/13/91)

In article <1991Feb12.014247.7709@verity.com>, anders@verity.com (Anders Wallgren) writes:
> 
> In article <1991Feb11.200302.424@ux1.cso.uiuc.edu>, rolf@sparc1 (Rolf Wilson) writes:
> >  Question 1: How do you hilite something in the user-selected
> >     hilite color? I don't mean text. InvertRect always?
> >     uses black.
> >  Question 2: Is there a way of doing the above while still
> >     using the "old" color model?
> >--
> 
> 
> In pascal, call:
> 
> 	BitClr(Ptr(HiliteMode, pHiliteBit));
> 
> before calls to InvertRect, InvertRgn, etc.  This is compatible with
> all versions of QuickDraw and doesn't what the bit-depth of the
> monitor is.  This is documented in the Color QuickDraw chapter in IM
> V, I think.

Another useful variation is to draw in the hilite color.  It's stored
as an RGBColor in low memory.  For example, Public Folder draws its 
progress bar using the hilite color. 

CONST kHiLiteColor = $0DA0;

IF colorOK
	THEN BEGIN
		BlockMove(Ptr(kHiLiteColor),@hiLiteColor,SIZEOF(RGBColor));
		RGBForeColor(hiLiteColor);
		PaintRect(theRect);
		ForeColor(blackColor);
	END
	ELSE BEGIN
		FillRect(theRect,dkGreyPattern);
	END;

The only thing to remember here is that you need to have a color window
to work with (unlike the BitClr technique that will work in non-color
windows).

-- michael


--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE

-- Ask me about AppSizer (and ask Claris about Public Folder :-)