[comp.sys.mac.programmer] when color bits are changed...

hh0x+@andrew.cmu.edu (Hiroshi Rit Howell) (07/10/90)

Does anyone know how an application can be noticed for user changing
the current color bits (I don't know the technical term),eg, from 8bit to 1bit
from the control panel's monitor?  I suppose this is followed by an update
event of some sort.....or do I have toonstantly check by placing 256 different
colors and see how meny of them become same color?  no...... there got to be
a better way....


hiroshi howell (hh0x@andrew.cmu.edu)

pierre@ClarisII.claris.com (Pierre Omidyar) (07/11/90)

hh0x+@andrew.cmu.edu (Hiroshi Rit Howell) writes:


>Does anyone know how an application can be noticed for user changing
>the current color bits (I don't know the technical term),eg, from 8bit to 1bit
>from the control panel's monitor?  I suppose this is followed by an update
>event of some sort.....or do I have toonstantly check by placing 256 different
>colors and see how meny of them become same color?  no...... there got to be
>a better way....


>hiroshi howell (hh0x@andrew.cmu.edu)

Your app should get an update event when the user changes monitor depth,
and you can check the new depth by checking the pixelSize field of the
pixMap of the GDevice your window is on.  GDevices are covered in IM Volume
5 Chapter 5, and PixMaps are covered in Volume 5 Chapter 4.

Essentially, you would do a GetMaxDevice, passing it the global rect of
your window, and then check the field, (*(*maxDevice)->gdPMap)->pixelSize.
You can compare this value to one you have saved somewhere to see if it has
changed.  Typically, this value will be 1,2,4,8,16, or 32.

This is probably a sketchy description of what you really need to do, but
you should be able to find it all in Volume 5.

Pierre

--
--
Pierre Omidyar         {ames,apple,portal,sun,voder}!claris!pierre
Claris Corporation     pierre@claris.com  Opinions are mine and not Claris'

aries@rhi.hi.is (Reynir Hugason) (07/11/90)

>Does anyone know how an application can be noticed for user changing
>the current color bits (I don't know the technical term),eg, from 8bit to 1bit
>from the control panel's monitor?  I suppose this is followed by an update
>event of some sort.....or do I have toonstantly check by placing 256 different
>colors and see how meny of them become same color?  no...... there got to be
>a better way....

Well, you could use the run through the device list every now and then, like
once through your event loop, and check if anything has changed there.

Pretty neat, at least better then using color mapping 8)

---
Mimir (aries@rhi.hi.is) - Aries, Inc.

pierre@ClarisII.claris.com (Pierre Omidyar) (07/12/90)

aries@rhi.hi.is (Reynir Hugason) writes:

>>Does anyone know how an application can be noticed for user changing
>>the current color bits (I don't know the technical term),eg, from 8bit to 1bit
>>from the control panel's monitor?  I suppose this is followed by an update
>>event of some sort.....or do I have toonstantly check by placing 256 different
>>colors and see how meny of them become same color?  no...... there got to be
>>a better way....

>Well, you could use the run through the device list every now and then, like
>once through your event loop, and check if anything has changed there.

>---
>Mimir (aries@rhi.hi.is) - Aries, Inc.

I think that might be a tad excessive.  You only need to check for a color
environment change at every update.  Devices can't change without your
windows getting an update event (supposedly :-)).

Pierre

--
Pierre Omidyar         {ames,apple,portal,sun,voder}!claris!pierre
Claris Corporation     pierre@claris.com  Opinions are mine and not Claris'