[comp.sys.mac.programmer] Floating Windows

sdh@flash.bellcore.com (Stephen D Hawley) (01/11/90)

I need a pointer for making windows that float on top of the rest of the
world no matter what.  I tried setting GostWindow to the window I wanted
on top, but that doesn't work.  I want the kind of windows in FullPaint.

Do i have to dick around with the window list pulling them in front
constantly?

Show me the light...

Steve Hawley
sdh@flash.bellcore.com
A noun's a special kind of word.
It's ev'ry name you ever heard.
I find it quite interesting,
A noun's a person place or thing.

pepke@loligo (Eric Pepke) (01/11/90)

In article <18786@bellcore.bellcore.com> sdh@flash.UUCP (Stephen D Hawley) writes:
>I need a pointer for making windows that float on top of the rest of the
>world no matter what.  I tried setting GostWindow to the window I wanted
>on top, but that doesn't work.  I want the kind of windows in FullPaint.
>
>Do i have to dick around with the window list pulling them in front
>constantly?

April 1988 MacTutor had a bit on this.  I wouldn't do it exactly the way
they did (and, in fact, I didn't) because, for one thing, Apple people have 
suggested that it would probably break.  Most of the reason for this seems
to have to do with accessing the Window Manager port directly to change the
region where the drag window rectangle shows.

There is no real trick, just a lot of special cases.  Don't use GhostWindow.
The first order solution is to keep a floating window on the top, put it on
the top and never allow another window to come in front of it.  This is
relatively easy; don't use SelectWindow on a document window, but rather 
activate the window and bring it to just behind the rearmost floating window.
The trickiness comes with desk accessory windows.  You want the floating
windows to be in front of all the application windows, but not in front
of the desk accessory windows.  

I found that the easiest way to solve the problem was to think about all the
special cases in the context of the structure of my main loop.  What should
happen when you bring up a desk accessory in front of the floating windows?
What then should happen when you bring up a document window in front of that?
Do you disallow that, as HyperCard does, or do you do it somewhat more
cleverly?  What window should be highlighted as active?  (HyperCard does it 
stupidly.)

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu

Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.

ejd@iris.brown.edu (Ed Devinney) (01/11/90)

In article <18786@bellcore.bellcore.com> sdh@flash.bellcore.com (Stephen D 
Hawley) writes:
> I need a pointer for making windows that float on top of the rest of the
> world no matter what.  I tried setting GostWindow to the window I wanted
> on top, but that doesn't work.  I want the kind of windows in FullPaint.
> 
> Do i have to dick around with the window list pulling them in front
> constantly?
> 
> Show me the light...

Sadly, you must dick around with the window list to do this.  MacTutor of 
December 1988 has a very nice article by Thomas Fruin describing a decent 
implementation; the source code is available from them on disk and can 
pretty much be dropped into your application with changes only to the 
Window Mgr calls.  It's probably not the be-all-and-end-all of floating 
window libraries, (you have to extend it for CWindows, etc), but it's 
non-tricky (ie, unlikely to break later) and robust enough to be used in at 
least 1 commercial product that I know of.

ed


Ed Devinney ... ejd@iris.brown.edu ... IRIS/Brown University
"My brain?! That's my second-favorite organ!" - Woody Allen

chaffee@reed.UUCP (Alex Chaffee) (01/12/90)

In article <18786@bellcore.bellcore.com> sdh@flash.UUCP (Stephen D Hawley) writes:
>
>I need a pointer for making windows that float on top of the rest of the
>world no matter what.

Of course, the easy way is to buy Think C 4.0, which has a floating window
object already written for you.  Even if you don't want to use the Class
LIbrary, you can look at the source.

>Show me the light...

Or did you mean "Bud Light?"

>Steve Hawley
>sdh@flash.bellcore.com
>A noun's a special kind of word.
>It's ev'ry name you ever heard.
>I find it quite interesting,
>A noun's a person place or thing.

"I can see the future... and it's a place about 70 miles west of here..."
					- Laurie Anderson
	
-- 
Alex Chaffee
chaffee@reed.UUCP
____________________