[comp.sys.mac.programmer] when to use NewCWindow?

hairston@henry.ECE.CMU.EDU (David Hairston) (03/16/91)

how do you determine when it is absolutely safe to use NewCWindow
as opposed to NewWindow?  i'm confused by the all things you can
test and their implications (i.e. sys environs and gdFlags, etc.).
i'd like to use NewCWindow unless the hardware absolutely prohibits
this, in which case my newWindow() function would use NewWindow
instead.

  -dave-  
hairston@henry.ece.cmu.edu

2fmlcalls@kuhub.cc.ukans.edu (03/16/91)

In article <12364@pt.cs.cmu.edu>, hairston@henry.ECE.CMU.EDU (David Hairston) writes:
> 
> how do you determine when it is absolutely safe to use NewCWindow
> as opposed to NewWindow?  i'm confused by the all things you can
> test and their implications (i.e. sys environs and gdFlags, etc.).
> i'd like to use NewCWindow unless the hardware absolutely prohibits
> this, in which case my newWindow() function would use NewWindow
> instead.
> 
>   -dave-  
> hairston@henry.ece.cmu.edu

I'm pretty new to color, but I believe you need to call SysEnvirons first for
HasColorQD.  If the machine HasColorQD then you can call NewCWindow.  The only
reason to check gdFlags would be to determine the bit-depth (I think).  But,
even if they're running a bit depth of 1, if they have color QD...it don't
matter.
john calhoun

hairston@henry.ECE.CMU.EDU (David Hairston) (03/17/91)

[hairston@henry.ECE.CMU.EDU (David Hairston) writes:]
[] how do you determine when it is absolutely safe to use NewCWindow
[] as opposed to NewWindow?  i'm confused by the all things you can

let me rephrase this:

assuming theWorld.hasColorQD why shouldn't i use NewCWindow() over
NewWindow()?  i thought that was sufficient but i've read one glimmer
of ambiguous info that leads me to believe that hasColorQD is required
but not sufficient to insure use.  is this correct?  specifically, can
a MacPlus or MacSE have color QD and not be able to support cGrafPorts?
i don't think pixelSize is an issue here.

thanks for any and all info!

  -dave-  
hairston@henry.ece.cmu.edu

2fmlcalls@kuhub.cc.ukans.edu (03/17/91)

In article <12376@pt.cs.cmu.edu>, hairston@henry.ECE.CMU.EDU (David Hairston) writes:
> assuming theWorld.hasColorQD why shouldn't i use NewCWindow() over
> NewWindow()?  i thought that was sufficient but i've read one glimmer
> of ambiguous info that leads me to believe that hasColorQD is required
> but not sufficient to insure use.  is this correct?  specifically, can
> a MacPlus or MacSE have color QD and not be able to support cGrafPorts?
> i don't think pixelSize is an issue here.
> 
> thanks for any and all info!
> 
>   -dave-  
> hairston@henry.ece.cmu.edu

Someone correct me if I'm wrong, but the Mac Plus and SE will not give you a
hasColorQD=TRUE.  The SE 30 I believe does have colorQD, but then also has the
ROM routines to support it (such as NewCWindow()).  So, I would guess that you
could call up a color window on an SE 30, but you would have displayed a black
and white window.

Anyone want to straighten us out?

john calhoun

omh@cs.brown.edu (Owen M. Hartnett) (03/17/91)

In article <12364@pt.cs.cmu.edu> hairston@henry.ECE.CMU.EDU (David Hairston) writes:
>
>how do you determine when it is absolutely safe to use NewCWindow
>as opposed to NewWindow?  i'm confused by the all things you can
>test and their implications (i.e. sys environs and gdFlags, etc.).
>i'd like to use NewCWindow unless the hardware absolutely prohibits
>this, in which case my newWindow() function would use NewWindow
>instead.

The new Gestalt function would let you test for color QD.

However, this should be one of those things that *you shouldn't have to
test* - but you probably do.  Why? a CWindow is just like a Window except
that it has more fields.  NewCWindow on a non color QD machine should
just return a CWindow with the extra fields.  It can't do anything with
them, but at least it won't crash because of a NewCWindow call and it
means that the programmer won't have to put in conditional code if the
user has colorQD or not just to support having color in his window.

I'm not saying that NewCWindow works like this, or that it doesn't work
like this (I haven't tried it on a non color machine) but this is how it
should work.

-Owen


Owen Hartnett				omh@cs.brown.edu.CSNET
Brown University Computer Science	omh@cs.brown.edu
					uunet!brunix!omh
"Don't wait up for me tonight because I won't be home for a month."

francis@magrathea.zaphod.uchicago.edu (Francis Stracke) (03/17/91)

In article <68833@brunix.UUCP> omh@cs.brown.edu (Owen M. Hartnett) writes:

   I'm not saying that NewCWindow works like this, or that it doesn't work

Good, because it doesn't.  Think about it--it isn't even *present*
unless CQD is installed!

Or do you think Apple foresaw what fields a CWindow would have and put
them into the original QuickDraw?


--
/============================================================================\
| Francis Stracke	       | My opinions are my own.  I don't steal them.|
| Department of Mathematics    |=============================================|
| University of Chicago	       | Until you stalk and overrun,	     	     |
| francis@zaphod.uchicago.edu  |  you can't devour anyone. -- Hobbes 	     |
\============================================================================/

francis@zaphod.uchicago.edu (03/17/91)

In article <1991Mar16.225917.29112@kuhub.cc.ukans.edu> 2fmlcalls@kuhub.cc.ukans.edu writes:

>Someone correct me if I'm wrong, but the Mac Plus and SE will not give you a
>hasColorQD=TRUE.  The SE 30 I believe does have colorQD, but then also has the
>ROM routines to support it (such as NewCWindow()).  So, I would guess that you
>could call up a color window on an SE 30, but you would have displayed a black
>and white window.

Yes, that's exactly what happens.

CQD is exactly "the set of routines to support it"--I think.  :-)
That is, there's nothing that an 030 has wrt QuickDraw that isn't CQD.
(Provided you include things like the Palette and gDevice Managers in
CQD, of course.  :-)

--
/============================================================================\
| Francis Stracke	       | My opinions are my own.  I don't steal them.|
| Department of Mathematics    |=============================================|
| University of Chicago	       | Until you stalk and overrun,	     	     |
| francis@zaphod.uchicago.edu  |  you can't devour anyone. -- Hobbes 	     |
\============================================================================/

omh@cs.brown.edu (Owen M. Hartnett) (03/18/91)

In article <FRANCIS.91Mar17044152@magrathea.zaphod.uchicago.edu> francis@magrathea.zaphod.uchicago.edu (Francis Stracke) writes:
>In article <68833@brunix.UUCP> omh@cs.brown.edu (Owen M. Hartnett) writes:
>
>   I'm not saying that NewCWindow works like this, or that it doesn't work
>
>Good, because it doesn't.  Think about it--it isn't even *present*
>unless CQD is installed!
>
>Or do you think Apple foresaw what fields a CWindow would have and put
>them into the original QuickDraw?

Of course not.  But many of the traps are patched to enable them to work
retroactively with new features.  Why should I have to test if colorQD is
present and open a non-color window on old machines?  Why not get a 
color window structure for both machines and eliminate the test?  The only
difference is that the color window has more fields.  The additional
fields shouldn't put that much of a burden on the memory of B/W machines.

-Owen


Owen Hartnett				omh@cs.brown.edu.CSNET
Brown University Computer Science	omh@cs.brown.edu
					uunet!brunix!omh
"Don't wait up for me tonight because I won't be home for a month."

ksand@Apple.COM (Kent Sandvik) (03/18/91)

In article <1991Mar16.225917.29112@kuhub.cc.ukans.edu> 2fmlcalls@kuhub.cc.ukans.edu writes:
>In article <12376@pt.cs.cmu.edu>, hairston@henry.ECE.CMU.EDU (David Hairston) writes:

>Someone correct me if I'm wrong, but the Mac Plus and SE will not give you a
>hasColorQD=TRUE.  The SE 30 I believe does have colorQD, but then also has the
>ROM routines to support it (such as NewCWindow()).  So, I would guess that you
>could call up a color window on an SE 30, but you would have displayed a black
>and white window.

68000 based Macs don't have colorQD, the rest has. Gestalt is the best
way to test for colorQD in the long run, even if SysEnvirons does the job
well (i.e. no need to check for the machine type).

Kent Sandvik, MacDTS, on Sunday assignment :-)

PS: The local book shop has a large discount on any book that had green
(St. Patrics day today) - it was the first time I made my book choices
based on cover colors. Oh happy day.


-- 
Disclaimer: Private activity on the Net, in no way connected to any company.
Zippy++ says: END, END; or END. is sure clearer than "}".