[comp.sys.mac.programmer] WDEF Question

252u3129@fergvax.unl.edu (Mike Gleason) (12/12/90)

I have decided that I want to write a custom window definition.  But first, I
grabbed an existing WDEF resource (a Windoid WDEF in Think C's Art Class
project to be exact) and all I want to do for the time being is put up a
window using the windoid.  I could have sworn I used to be able to write

  w = NewWindow(0L,&rekt,"\pBlah",isVisible,ProcID,-1L,hasGoAway,refcon);

where ProcID is the resource ID of my WDEF (the Windoid's is 200).  Why does
one of the plain jane default WDEFs appear as my window instead of the windoid?
My project.rsrc file DOES have the WDEF inside it, and my quick hack program
that is trying to put up the window verifies this.  It seems like the procID
is more like a varCode rather than a WDEF resource ID.

Any help graciously accepted!
--mike gleason
   ***
  ***   mike gleason <252u3129@fergvax.unl.edu>
 ***   "It's Hammer time... NOT!" -- Anthrax
***  .signature randomizer 1.0 * write for free c source

stevec@Apple.COM (Steve Christensen) (12/13/90)

252u3129@fergvax.unl.edu (Mike Gleason) writes:
>[that he wanted to create a window with his own custom window definition
> procedure, but he was getting the default window instead...]

The ProcID you specify in NewWindow is related to the WDEF's resource ID,
but not the same beast.  It's defined as:

	16 * WDEF resource ID + variation code

which means any particular WDEF can support up to 16 variations on a theme.
It also means that WDEF resource IDs come in the range of 0-4095 (that's
2^12 - 1, right?)...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen	|  Apple Computer, Inc.		|  Disclaimer:
			|  20525 Mariani Ave, MS-81CS	|   the above may be
  stevec@apple.com	|  Cupertino, CA  95014		|   a lie...or not.

hairston@henry.ece.cmu.edu (David Hairston) (12/13/90)

[252u3129@fergvax.unl.edu (Mike Gleason) writes:]
[] I have decided that I want to write a custom window definition.  But
[] first, I grabbed an existing WDEF resource (a Windoid WDEF in Think C's
[] Art Class project to be exact) and all I want to do for the time being is
[] put up a window using the windoid.  I could have sworn I used to be able
[] to write
[]
[]   w = NewWindow(0L,&rekt,"\pBlah",isVisible,ProcID,-1L,hasGoAway,refcon);
[]
[] where ProcID is the resource ID of my WDEF (the Windoid's is 200).
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not quite ...

(short) ProcID = (16 * (WDEF rsrc ID)) + (variation code)

assuming a varCode of 0 and WDEF ID of 200 then you want ProcID = 3200.

additional references: IM-I, Window Manager.

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

252u3129@fergvax.unl.edu (Mike Gleason) (12/14/90)

stevec@Apple.COM (Steve Christensen) writes:

>252u3129@fergvax.unl.edu (Mike Gleason) writes:
>>[that he wanted to create a window with his own custom window definition
>> procedure, but he was getting the default window instead...]

>The ProcID you specify in NewWindow is related to the WDEF's resource ID,
>but not the same beast.  It's defined as:

>	16 * WDEF resource ID + variation code

>which means any particular WDEF can support up to 16 variations on a theme.
>It also means that WDEF resource IDs come in the range of 0-4095 (that's
>2^12 - 1, right?)...

Thanks to everyone who pointed that out to me.  Ironically, I spent more time
looking for that little tidbit than to write my entire Amiga WDEF.  I guess I
should have actually read the entire Window Manager chapter, instead of just
skimming it like college students are known for.

Dave Hairston also said to check out Apple's sample code, which I did.  I
didn't find any code directly on WDEFs, but I did have TN 256 "Stand Alone Code"
which had a bunch of useless junk in it.  Basically Apple's sample WDEF is
this:

switch(param) {
	case wDraw: Draw(...); break;
	.
	.
	case wDrawGIcon: DrawGIcon(...); break;
}

That's it.  The actual Draw(...) functions are just stubs with nothing in them.
I was quite disappointed that they hadn't bothered to code an actual WDEF.
Instead, I found the source for a NeXT WDEF, by jbx, E. Celeste, J. Pritikin,
which helped immensely!  There were a lot of tricky nuances that I never would
have caught without their source... Thanks Guys!  I'd like to see TN 256
rewritten with actual working code for WDEFs, LDEFs, MDEFs instead of stubs.
In Apple's defense though, they do provide some assembly source in the defprocs
directory at apple.com, but Ich weisse assembly nicht, and I think anyone would
agree that C or Pascal source is much easier to comprehend.

Of course I'm not blaming you for all this SteveC....



 mike gleason                                "How I've waited for you to come
 252u3129@fergvax.unl.edu                            I've been here all alone
                                  Now that you've arrived, please stay awhile
       And I promise not to keep you long... I'll keep you forever" -- Slayer

murat@farcomp.UUCP (Murat Konar) (12/17/90)

In article <252u3129.660984232@fergvax> 252u3129@fergvax.unl.edu (Mike Gleason)
writes:
>window using the windoid.  I could have sworn I used to be able to write
>
>  w = NewWindow(0L,&rekt,"\pBlah",isVisible,ProcID,-1L,hasGoAway,refcon);
>
>where ProcID is the resource ID of my WDEF (the Windoid's is 200).  Why does
>one of the plain jane default WDEFs appear as my window instead of the windoid?


The correct incanation is:
w = NewWindow(0L,&rekt,"\pBlah",isVisible,(ProcID * 16) + varCode ,-1L,
              hasGoAway,refcon);

If you just want a standard window, 0 works since (16 * 0) = 0.  I suspect that
since the window manager can't find the WDEF you specified (in your case it 
works out to WDEF proc id = 12,  varcode = 8) it just substitutes the 
plain jane version.   Better than crashing.


-- 
____________________________________________________________________
Have a day. :^|             
Murat N. Konar	
murat@farcomp.UUCP             -or-          farcomp!murat@apple.com