[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-rectangular window



> I'd like to be able to have non-rectangular windows.
> According to Inside Mac, I need to create my own WDEF
> resource in C or Pascal to do this.  I'm not really
> excited at the idea of creating a WDEF.  Thus my
> question: Is there a way to do this entirely in MCL,
> without writing a WDEF?
 
    6 bytes short of how to write a WDEF/LDEF/CDEF/anythingDEF
    in lisp, by John Montbriand, 1993.
 
I've done similar things in other languages, and since MCL
allows you to define callback routines, it's something you
can do here.
 
Here's an example:
 
* Make a WDEF resource using ResEdit. In the hex editor
the resource should only contain these three words:
 
      4EF9 0000 0000
 
here's the Rez source for a WDEF=128:
 
    /* file Tweek.r resource
    	Copyright (C) 1993 John Montbriand. All Rights Reserved.
    	you may freely re-distribute this so long as this
    	notice remains intact.
    */
    
    type 'WDEF' {	/* use this for any resource code type */
    	integer;
    	longint;
    };
    
    resource 'WDEF' (128, "Tweeked definition") {
        0x4EF9, 0 };  /* JMP abs.L  -- 68000 instruction */
    
    /* end of file Tweek.r */
 
then, your lisp code would look something like this:
 
(require 'resources)
 
;; first, define your WDEF procedure as a pascal callable function
;; in lisp:
(defpascal MyWindow (:word varCode :ptr theWindow :word message
                           :long param :long)
  "a custom window definition in lisp!"
 .............)
 
;; then Tweek the resource to point to it when you start
;; up your application:
(let (my-wdef (get-resource "WDEF" 128))
    (%hput-long my-wdef (%ptr-to-int MyWindow) 2))
 
why do it this way?  1. it's elegant, 2. who needs to bother with 
stand alone code resources anyways (they've been a drag since day 1
with many A5 world hacks, etc surrounding them), 3. you can write
your entire wdef in Lisp!!!!! :)  4. it's almost impossible for someone
to steal a WDEF written this way using ResEdit.  5. it's elegant...
6. you can write it all in LISP!!
 
tips.  create a separate Tweek resource for every different kind of
WDEF/CDEF/...  you define--ie. you can't use the same resource for
4 different WDEFs.
 
If I have time....*gasp*...would anyone be interested in a
tweek-it.lisp library to do this sort of thing more easily?
 
    -john