[comp.sys.mac.programmer] TransSkel update events

dlmnm@dcatla.UUCP (Michael N. Moran) (03/31/89)

I'm trying to use TransSkel for the first time to create an
application. I would like to use a common update procedure
for all windows of a particular type. I plan to keep the 
particulars for a given window in a structure pointed to by
the refCon field of the window record.

The problem is that TransSkel does not provide the window update
procedure with the window pointer. I suppose it assumes the
update procedure is associated with a particular window. For most
events this works fine since FrontWindow can be used to get the
window pointer. In the case where a window other than the one
in front receives an update event, there is no way for the update
procedure to know with which window the event is associated.

Why isn't the window pointer passed as an argument to this procedure?
Or... am *I* missing something?

Any ideas? I could modify my version of TransSkel ... but ...

Comments? Suggestions?

    thanks,
	mike

kaufman@polya.Stanford.EDU (Marc T. Kaufman) (03/31/89)

In article <16127@dcatla.UUCP> dlmnm@dcatla.UUCP () writes:

.The problem is that TransSkel does not provide the window update
.procedure with the window pointer. I suppose it assumes the
.update procedure is associated with a particular window. For most
.events this works fine since FrontWindow can be used to get the
.window pointer. In the case where a window other than the one
.in front receives an update event, there is no way for the update
.procedure to know with which window the event is associated.

.Why isn't the window pointer passed as an argument to this procedure?
.Or... am *I* missing something?

The Current Grafport [c.f: Getport(&thisport)] is the port you want, not
the front window.  You should check the source code when you have questions
of this type.

Marc Kaufman (kaufman@polya.stanford.edu)

bin@primate.wisc.edu (Brain in Neutral) (04/01/89)

From article <16127@dcatla.UUCP>, by dlmnm@dcatla.UUCP (Michael N. Moran):
> The problem is that TransSkel does not provide the window update
> procedure with the window pointer. I suppose it assumes the
> update procedure is associated with a particular window. For most
> events this works fine since FrontWindow can be used to get the
> window pointer. In the case where a window other than the one
> in front receives an update event, there is no way for the update
> procedure to know with which window the event is associated.

It isn't necessary, because the port is set to the window to be updated
before the update procedure associated with the window is called (and
restored afterward).  Therefore, you can get the window pointer with
GetPort().  I believe that this is documented in the manual.

By the way, you do *not* want to use FrontWindow(), because you
can get update events for windows other than the frontmost one.
Use of FW will lead you to update the wrong window under such
circumstances.

Paul DuBois
dubois@primate.wisc.edu		rhesus!dubois
bin@primate.wisc.edu		rhesus!bin

jkjl@.cs.mu.oz (John Lim) (04/04/89)

In article <16127@dcatla.UUCP> dlmnm@dcatla.UUCP () writes:
>
>The problem is that TransSkel does not provide the window update
>procedure with the window pointer. I suppose it assumes the
>update procedure is associated with a particular window. For most
>events this works fine since FrontWindow can be used to get the
>window pointer. In the case where a window other than the one
>in front receives an update event, there is no way for the update
>procedure to know with which window the event is associated.
>
>Why isn't the window pointer passed as an argument to this procedure?
>Or... am *I* missing something?
>

Simply use thePort to access your windowPtr.

I.e.

WindowRecord WRecs[10];

DoUpdate(resized)
int resized;
{
int update_index;

	for (update_index = 0; update_index < 10 ; update_index++)
		if (WRecs[update_index] == thePort) break;

	if (update_index == 10) Debugger(); /* Tough luck ;-( */
/* Do updating */

}


Hope this helps.

	john lim