home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / Windows.xs < prev   
Text File  |  1998-04-06  |  17KB  |  799 lines

  1. /* $Header: /home/neeri/MacCVS/MacPerl/perl/ext/Mac/Windows/Windows.xs,v 1.3 1997/11/18 00:53:28 neeri Exp $
  2.  *
  3.  *    Copyright (c) 1996 Matthias Neeracher
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log: Windows.xs,v $
  9.  * Revision 1.3  1997/11/18 00:53:28  neeri
  10.  * MacPerl 5.1.5
  11.  *
  12.  * Revision 1.2  1997/09/02 23:06:44  neeri
  13.  * Added Structs, other minor fixes
  14.  *
  15.  * Revision 1.1  1997/04/07 20:51:00  neeri
  16.  * Synchronized with MacPerl 5.1.4a1
  17.  *
  18.  */
  19.  
  20. #define MAC_CONTEXT
  21.  
  22. #include "EXTERN.h"
  23. #include "perl.h"
  24. #include "XSUB.h"
  25. #include <Types.h>
  26. #include <Memory.h>
  27. #include <Windows.h>
  28. #include <QuickDraw.h>
  29.  
  30. Rect    gGrowBounds;
  31.  
  32. typedef struct {
  33.     Rect    userState;
  34.     Rect    stdState;
  35.     SV *    wdef;
  36. } PerlWDEFData, **PerlWDEFDataHdl;
  37.  
  38. static pascal long 
  39. CallWDEF(short varCode, WindowPeek win, short message, long param)
  40. {
  41.     SV *    wdef;
  42.     
  43.     dSP;
  44.     
  45.     wdef = ((PerlWDEFDataHdl)win->dataHandle)[0]->wdef;
  46.     
  47.     ENTER;
  48.     SAVETMPS;
  49.     
  50.     PUSHMARK(sp);
  51.     XS_XPUSH(short, varCode);
  52.     XS_XPUSH(GrafPtr, win);
  53.     XS_XPUSH(short, message);
  54.     switch (message) {
  55.     case wDraw:
  56.         XS_XPUSH(short, (short)param);
  57.         break;
  58.     case wHit:
  59.         XS_XPUSH(Point, *(Point *)¶m);
  60.         break;
  61.     case wGrow:
  62.         XS_XPUSH(Rect, *(Rect *)param);
  63.         break;
  64.     case wNew:
  65.     case wCalcRgns:
  66.     case wDispose:
  67.     case wDrawGIcon:
  68.         break;          /* No parameters */
  69.     default:
  70.         XS_XPUSH(long, param);
  71.         break;
  72.     }
  73.     PUTBACK;
  74.     
  75.     perl_call_sv(wdef, G_SCALAR);
  76.     
  77.     SPAGAIN;
  78.     
  79.     XS_POP(long, param);
  80.     
  81.     PUTBACK;
  82.     FREETMPS;
  83.     LEAVE;
  84.     
  85.     return param;
  86. }
  87.  
  88.  
  89. #if GENERATINGCFM
  90. RoutineDescriptor sCallWDEF = 
  91.     BUILD_ROUTINE_DESCRIPTOR(uppWindowDefProcInfo, CallWDEF);
  92. #else
  93. struct {
  94.     short   jmp;
  95.     void *  addr;
  96. } sCallWDEF = {0x4EF9, CallWDEF};
  97. #endif
  98. static Handle   sWDEF;
  99. static int      sWDEFRefCount;
  100.  
  101. static Rect GlobalBounds(WindowPtr win)
  102. {
  103.     Rect r    = win->portRect;
  104.     r.top    -= win->portBits.bounds.top;
  105.     r.bottom -= win->portBits.bounds.top;
  106.     r.left   -= win->portBits.bounds.left;
  107.     r.right  -= win->portBits.bounds.left;
  108.     
  109.     return r;
  110. }
  111.  
  112. MODULE = Mac::Windows   PACKAGE = Mac::Windows
  113.  
  114. =head2 Types
  115.  
  116. =over 4
  117.  
  118. =item GrafPtr
  119.  
  120. Those C<GrafPtrs> which represent windows have the following fields defined:
  121.  
  122.     short           windowKind;
  123.     Boolean         visible;
  124.     Boolean         hilited;
  125.     Boolean         goAwayFlag;
  126.     Boolean         spareFlag;
  127.     RgnHandle       strucRgn;
  128.     RgnHandle       contRgn;
  129.     RgnHandle       updateRgn;
  130.     SV *            windowDefProc;
  131.     Handle          titleHandle;
  132.     short           titleWidth;
  133.     ControlHandle   controlList;
  134.     GrafPtr         nextWindow;
  135.     PicHandle       windowPic;
  136.     long            refCon;
  137.     Rect            userState;
  138.     Rect            stdState;
  139.     
  140. You should consider most of them read only.
  141.  
  142. =back
  143.  
  144. =cut
  145. STRUCT * GrafPtr
  146.     WindowPeek      STRUCT;
  147.         INPUT:
  148.         XS_INPUT(GrafPtr, *(GrafPtr *)&STRUCT, ST(0));
  149.         OUTPUT:
  150.         XS_PUSH(GrafPtr, STRUCT);
  151.     short           windowKind;
  152.     Boolean         visible;
  153.     Boolean         hilited;
  154.     Boolean         goAwayFlag;
  155.     Boolean         spareFlag;
  156.     RgnHandle       strucRgn;
  157.         READ_ONLY
  158.     RgnHandle       contRgn;
  159.         READ_ONLY
  160.     RgnHandle       updateRgn;
  161.         READ_ONLY
  162.     SV *            windowDefProc;
  163.         INPUT:
  164.         if (STRUCT->windowDefProc == sWDEF) {
  165.             HLock(STRUCT->dataHandle);
  166.             SvREFCNT_dec(((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->wdef);
  167.         } else {
  168.             STRUCT->windowDefProc = sWDEF;
  169.             if (STRUCT->dataHandle) {
  170.                 SetHandleSize(STRUCT->dataHandle, sizeof(PerlWDEFData));
  171.                 HLock(STRUCT->dataHandle);
  172.             } else {
  173.                 STRUCT->dataHandle = NewHandle(sizeof(PerlWDEFData));
  174.                 HLock(STRUCT->dataHandle);
  175.                 ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->userState =
  176.                 ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->stdState =
  177.                     GlobalBounds((WindowPtr)STRUCT);
  178.             }
  179.         }
  180.         ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->wdef = newSVsv($arg);
  181.         HUnlock(STRUCT->dataHandle);
  182.         OUTPUT:
  183.         if (STRUCT->windowDefProc == sWDEF) {
  184.             HLock(STRUCT->dataHandle);
  185.             sv_setsv($arg, ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->wdef);
  186.             HUnlock(STRUCT->dataHandle);
  187.         } else
  188.             $arg = &sv_undef;
  189.     Handle          titleHandle;
  190.         READ_ONLY
  191.     short           titleWidth;
  192.         READ_ONLY
  193.     ControlHandle   controlList;
  194.         READ_ONLY
  195.     GrafPtr         nextWindow;
  196.         READ_ONLY
  197.     PicHandle       windowPic;
  198.     long            refCon;
  199.     Rect            userState;
  200.         INPUT:
  201.         if (STRUCT->dataHandle) {
  202.             HLock(STRUCT->dataHandle);
  203.             XS_INPUT(Rect, ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->userState, $arg);
  204.             HUnlock(STRUCT->dataHandle);
  205.         }
  206.         OUTPUT:
  207.         if (STRUCT->dataHandle) {
  208.             HLock(STRUCT->dataHandle);
  209.             XS_OUTPUT(Rect, ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->userState, $arg);
  210.             HUnlock(STRUCT->dataHandle);
  211.         } else {
  212.             XS_OUTPUT(Rect, GlobalBounds((WindowPtr)STRUCT), $arg);
  213.         }
  214.     Rect            stdState;
  215.         INPUT:
  216.         if (STRUCT->dataHandle) {
  217.             HLock(STRUCT->dataHandle);
  218.             XS_INPUT(Rect, ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->stdState, $arg);
  219.             HUnlock(STRUCT->dataHandle);
  220.         }
  221.         OUTPUT:
  222.         if (STRUCT->dataHandle) {
  223.             HLock(STRUCT->dataHandle);
  224.             XS_OUTPUT(Rect, ((PerlWDEFDataHdl)STRUCT->dataHandle)[0]->stdState, $arg);
  225.             HUnlock(STRUCT->dataHandle);
  226.         } else {
  227.             XS_OUTPUT(Rect, GlobalBounds((WindowPtr)STRUCT), $arg);
  228.         }
  229.  
  230. =head2 Functions
  231.  
  232. =over 4
  233.  
  234. =item GetGrayRgn()
  235.  
  236. Returns a handle to the desktop region.
  237.  
  238. =cut
  239. BOOT:
  240. gGrowBounds = qd.screenBits.bounds;
  241. InsetRect(&gGrowBounds, 10, 10);
  242. gGrowBounds.left = gGrowBounds.top = 80;
  243.  
  244. RgnHandle
  245. GetGrayRgn()
  246.  
  247. =item GetWMgrPort()
  248.  
  249. Return the window manager port.
  250.  
  251. =cut
  252. GrafPtr
  253. GetWMgrPort()
  254.     CODE:
  255.     GetWMgrPort(&RETVAL);
  256.     OUTPUT:
  257.     RETVAL
  258.  
  259. =item NewWindow BOUNDS, TITLE, VISIBLE, PROC, GOAWAY [, REFCON [, BEHIND]]
  260.  
  261. Create a new window.
  262.  
  263. =cut
  264. GrafPtr
  265. NewWindow(boundsRect, title, visible, theProc, goAwayFlag, refCon=0, behind=(GrafPtr)-1)
  266.     Rect       &boundsRect
  267.     Str255      title
  268.     Boolean     visible
  269.     SV *        theProc
  270.     Boolean     goAwayFlag
  271.     long        refCon
  272.     GrafPtr     behind
  273.     CODE:
  274.     {
  275.         short   proc     = zoomDocProc;
  276.         Boolean vis      = visible;
  277.         Boolean userProc = SvROK(theProc) || !looks_like_number(theProc);
  278.         if (!userProc)
  279.             proc = SvIV(theProc);
  280.         else
  281.             vis = false;
  282.         RETVAL = 
  283.             NewWindow(
  284.                 nil, &boundsRect, title, vis, proc, behind, goAwayFlag, refCon);
  285.         if (userProc) {
  286.             WindowPeek peek = (WindowPeek)RETVAL;
  287.             if (!sWDEFRefCount++) {
  288.                 PtrToHand((Ptr)&sCallWDEF, &sWDEF, sizeof(sCallWDEF));
  289. #if !GENERATINGCFM
  290.                 FlushInstructionCache();
  291.                 FlushDataCache();
  292. #endif
  293.             }
  294.             peek->windowDefProc = sWDEF;
  295.             SetHandleSize(peek->dataHandle, sizeof(PerlWDEFData));
  296.             ((PerlWDEFDataHdl)peek->dataHandle)[0]->wdef = newSVsv(theProc);
  297.             CallWDEF(GetWVariant(RETVAL), peek, wNew, 0);
  298.             if (visible)
  299.                 ShowWindow(RETVAL);
  300.         }
  301.     }
  302.     OUTPUT:
  303.     RETVAL
  304.  
  305. =item GetNewWindow ID [, BEHIND]
  306.  
  307. Create a new window from a resource.
  308.  
  309. =cut
  310. GrafPtr
  311. GetNewWindow(windowID, behind=(GrafPtr)-1)
  312.     short   windowID
  313.     GrafPtr behind
  314.     CODE:
  315.     RETVAL = GetNewWindow(windowID, nil, behind);
  316.     OUTPUT:
  317.     RETVAL
  318.  
  319. =item DisposeWindow WINDOW
  320.  
  321. Destroy a window.
  322.  
  323. =cut
  324. void
  325. DisposeWindow(theWindow)
  326.     GrafPtr     theWindow
  327.     CODE:
  328.     if (((WindowPeek)theWindow)->windowDefProc == sWDEF) {
  329.         PerlWDEFDataHdl h = (PerlWDEFDataHdl)((WindowPeek)theWindow)->dataHandle;
  330.         DisposeWindow(theWindow);
  331.         if (!--sWDEFRefCount)
  332.             DisposeHandle(sWDEF);
  333.         HLock((Handle)h);
  334.         SvREFCNT_dec(h[0]->wdef);
  335.         DisposeHandle((Handle)h);
  336.     } else {
  337.         DisposeWindow(theWindow);
  338.     }
  339.  
  340. =item GetWTitle WINDOW
  341.  
  342. Return the title of the window.
  343.  
  344. =cut
  345. Str255
  346. GetWTitle(theWindow)
  347.     GrafPtr     theWindow
  348.     CODE:
  349.     GetWTitle(theWindow, RETVAL);
  350.     OUTPUT:
  351.     RETVAL
  352.  
  353. =item SelectWindow WINDOW
  354.  
  355. Put the window in front.
  356.  
  357. =cut
  358. void
  359. SelectWindow(theWindow)
  360.     GrafPtr     theWindow
  361.  
  362. =item HideWindow WINDOW
  363.  
  364. Make the window invisible.
  365.  
  366. =cut
  367. void
  368. HideWindow(theWindow)
  369.     GrafPtr     theWindow
  370.  
  371. =item ShowWindow WINDOW
  372.  
  373. Make the window visible.
  374.  
  375. =cut
  376. void
  377. ShowWindow(theWindow)
  378.     GrafPtr     theWindow
  379.  
  380. =item ShowHide WINDOW, SHOWIT
  381.  
  382. Set the visibility status of a window.
  383.  
  384. =cut
  385. void
  386. ShowHide(theWindow, showFlag)
  387.     GrafPtr     theWindow
  388.     Boolean     showFlag
  389.  
  390. =item HiliteWindow WINDOW, HILITE
  391.  
  392. Set the hilite status of a window.
  393.  
  394. =cut
  395. void
  396. HiliteWindow(theWindow, fHilite)
  397.     GrafPtr     theWindow
  398.     Boolean     fHilite
  399.  
  400. =item BringToFront WINDOW
  401.  
  402. Put a window in front without changing hiliting.
  403.  
  404. =cut
  405. void
  406. BringToFront(theWindow)
  407.     GrafPtr     theWindow
  408.  
  409. =item SendBehind WINDOW [, BEHIND]
  410.  
  411. Put a window behind another one. If BEHIND is omitted, send the window behind all
  412. other windows.
  413.  
  414. =cut
  415. void
  416. SendBehind(theWindow, behindWindow=NULL)
  417.     GrafPtr     theWindow
  418.     GrafPtr     behindWindow
  419.  
  420. =item FrontWindow()
  421.  
  422. Return the front window.
  423.  
  424. =cut
  425. GrafPtr
  426. FrontWindow()
  427.  
  428. =item DrawGrowIcon WINDOW
  429.  
  430. Draw the grow icon for a window.
  431.  
  432. =cut
  433. void
  434. DrawGrowIcon(theWindow)
  435.     GrafPtr     theWindow
  436.  
  437. =item MoveWindow WINDOW, H, V, FRONT
  438.  
  439. Move a window.
  440.  
  441. =cut
  442. void
  443. MoveWindow(theWindow, hGlobal, vGlobal, front)
  444.     GrafPtr theWindow
  445.     short   hGlobal
  446.     short   vGlobal
  447.     Boolean front
  448.  
  449. =item SizeWindow WINDOW, W, H
  450.  
  451. Set the size of a window.
  452.  
  453. =cut
  454. void
  455. SizeWindow(theWindow, w, h, fUpdate=true)
  456.     GrafPtr theWindow
  457.     short   w
  458.     short   h
  459.     Boolean fUpdate
  460.  
  461. =item ZoomWindow WINDOW, PARTCODE, FRONT
  462.  
  463. Zoom a window.
  464.  
  465. =cut
  466. void
  467. ZoomWindow(theWindow, partCode, front)
  468.     GrafPtr theWindow
  469.     short   partCode
  470.     Boolean front
  471.  
  472. =item InvalRect RECT
  473.  
  474. Invalidate a rectangular area of a window.
  475.  
  476. =cut
  477. void
  478. InvalRect(badRect)
  479.     Rect &badRect
  480.  
  481. =item InvalRgn REGION
  482.  
  483. Invalidate a region in a window.
  484.  
  485. =cut
  486. void
  487. InvalRgn(badRgn)
  488.     RgnHandle   badRgn
  489.  
  490. =item ValidRect RECT
  491.  
  492. Validate a rectangular area.
  493.  
  494. =cut
  495. void
  496. ValidRect(goodRect)
  497.     Rect &goodRect
  498.  
  499. =item ValidRgn REGION
  500.  
  501. Validate a region.
  502.  
  503. =cut
  504. void
  505. ValidRgn(goodRgn)
  506.     RgnHandle   goodRgn
  507.  
  508. =item BeginUpdate WINDOW
  509.  
  510. Begin updating the window.
  511.  
  512. =cut
  513. void
  514. BeginUpdate(theWindow)
  515.     GrafPtr     theWindow
  516.  
  517. =item EndUpdate WINDOW
  518.  
  519. End updating the window.
  520.  
  521. =cut
  522. void
  523. EndUpdate(theWindow)
  524.     GrafPtr     theWindow
  525.  
  526. =item SetWRefCon WINDOW, REFCON
  527.  
  528. Set a user defined value associated with the window.
  529.  
  530. =cut
  531. void
  532. SetWRefCon(theWindow, data)
  533.     GrafPtr theWindow
  534.     long    data
  535.  
  536. =item GetWRefCon WINDOW
  537.  
  538. Return the user defined value.
  539.  
  540. =cut
  541. long
  542. GetWRefCon(theWindow)
  543.     GrafPtr     theWindow
  544.  
  545. =item SetWindowPic WINDOW, PICTURE
  546.  
  547. Set a picture to be displayed as the window's contents.
  548.  
  549. =cut
  550. void
  551. SetWindowPic(theWindow, pic)
  552.     GrafPtr     theWindow
  553.     PicHandle   pic
  554.  
  555. =item GetWindowPic WINDOW
  556.  
  557. Return the picture of the window.
  558.  
  559. =cut
  560. PicHandle
  561. GetWindowPic(theWindow)
  562.     GrafPtr     theWindow
  563.     CODE:
  564.     if (!(RETVAL = GetWindowPic(theWindow))) {
  565.         XSRETURN_UNDEF;
  566.     }
  567.     OUTPUT:
  568.     RETVAL
  569.  
  570. =item GrowWindow WINDOW, PT [, BBOX]
  571.  
  572. Drag the size of a window and return the new suggested width and height.
  573.  
  574.     ($w, $h) = GrowWindow $win, $pt;
  575.  
  576. =cut
  577. void
  578. GrowWindow(theWindow, pt, bBox=gGrowBounds)
  579.     GrafPtr theWindow
  580.     Point   pt
  581.     Rect   &bBox
  582.     PPCODE:
  583.     {
  584.         long res  = GrowWindow(theWindow, pt, &bBox);
  585.         if (!res) {
  586.             XSRETURN_EMPTY;
  587.         }
  588.         XS_XPUSH(short, res & 0x0FFFF);
  589.         XS_XPUSH(short, (res >> 16) & 0x0FFFF);
  590.     }
  591.  
  592. =item FindWindow PT
  593.  
  594. Identify the window and part hit by a point.
  595.  
  596.     ($code, $win) = FindWindow $pt;
  597.  
  598. =cut
  599. void
  600. FindWindow(pt)
  601.     Point   pt
  602.     PREINIT:
  603.     GrafPtr window;
  604.     short   code;
  605.     PPCODE:
  606.     {
  607.         code = FindWindow(pt, &window);
  608.         if (GIMME != G_ARRAY) {
  609.             if (code < inSysWindow) {
  610.                 XSRETURN_UNDEF;
  611.             } else
  612.                 XS_XPUSH(GrafPtr, window);
  613.         } else {
  614.             XS_XPUSH(short, code);
  615.             if (code >= inSysWindow)
  616.                 XS_XPUSH(GrafPtr, window);
  617.         }
  618.     }
  619.  
  620. =item PinRect RECT, PT
  621.  
  622. Pin a point inside a rectangle.
  623.  
  624. =cut
  625. Point
  626. PinRect(theRect, pt)
  627.     Rect   &theRect
  628.     Point   pt
  629.     PREINIT:
  630.     long    res;
  631.     CODE:
  632.     {
  633.         res = PinRect(&theRect, pt);
  634.         RETVAL.h = res & 0x0FFFF;
  635.         RETVAL.v = (res >> 16) & 0x0FFFF;
  636.     }
  637.     OUTPUT:
  638.     RETVAL
  639.  
  640. =item DragGrayRgn REGION, PT, LIMITRECT, SLOPRECT, AXIS
  641.  
  642. Drag a region around and return the movement difference as a point.
  643.  
  644. =cut
  645. Point
  646. DragGrayRgn(theRgn, pt, limitRect, slopRect, axis)
  647.     RgnHandle   theRgn
  648.     Point       pt
  649.     Rect       &limitRect
  650.     Rect       &slopRect
  651.     short       axis
  652.     PREINIT:
  653.     long    res;
  654.     CODE:
  655.     {
  656.         res = DragGrayRgn(theRgn, pt, &limitRect, &slopRect, axis, nil);
  657.         RETVAL.h = res & 0x0FFFF;
  658.         RETVAL.v = (res >> 16) & 0x0FFFF;
  659.     }
  660.     OUTPUT:
  661.     RETVAL
  662.  
  663. =item TrackBox WINDOW, PT, PART
  664.  
  665. Track a click in the zoom box of a window and return whether the mouse was still 
  666. inside when the pointer was released.
  667.  
  668. =cut
  669. Boolean
  670. TrackBox(theWindow, pt, partCode)
  671.     GrafPtr theWindow
  672.     Point   pt
  673.     short   partCode
  674.  
  675. =item GetCWMgrPort()
  676.  
  677. Return the color window manager port.
  678.  
  679. =cut
  680. GrafPtr
  681. GetCWMgrPort()
  682.     CODE:
  683.     GetCWMgrPort(&(CGrafPort *)RETVAL);
  684.     OUTPUT:
  685.     RETVAL
  686.  
  687. =item SetDeskCPat PIXPAT
  688.  
  689. Change the current desktop pattern.
  690.  
  691. =cut
  692. void
  693. SetDeskCPat(deskPixPat)
  694.     PixPatHandle    deskPixPat
  695.  
  696. =item NewCWindow BOUNDS, TITLE, VISIBLE, PROC, GOAWAY [, REFCON [, BEHIND]]
  697.  
  698. Create a color window.
  699.  
  700. =cut
  701. GrafPtr
  702. NewCWindow(boundsRect, title, visible, theProc, goAwayFlag, refCon=0, behind=(GrafPtr)-1)
  703.     Rect       &boundsRect
  704.     Str255      title
  705.     Boolean     visible
  706.     SV *        theProc
  707.     Boolean     goAwayFlag
  708.     long        refCon
  709.     GrafPtr     behind
  710.     CODE:
  711.     {
  712.         short   proc = zoomDocProc;
  713.         Boolean vis  = visible;
  714.         Boolean userProc = SvROK(theProc) || !looks_like_number(theProc);
  715.         if (!userProc)
  716.             proc = SvIV(theProc);
  717.         else
  718.             vis = false;
  719.         RETVAL = 
  720.             NewCWindow(
  721.                 nil, &boundsRect, title, vis, proc, behind, goAwayFlag, refCon);
  722.         if (userProc) {
  723.             WindowPeek peek = (WindowPeek)RETVAL;
  724.             if (!sWDEFRefCount++) {
  725.                 PtrToHand((Ptr)&sCallWDEF, &sWDEF, sizeof(sCallWDEF));
  726. #if !GENERATINGCFM
  727.                 FlushInstructionCache();
  728.                 FlushDataCache();
  729. #endif
  730.             }
  731.             peek->windowDefProc = sWDEF;
  732.             SetHandleSize(peek->dataHandle, sizeof(PerlWDEFData));
  733.             ((PerlWDEFDataHdl)peek->dataHandle)[0]->wdef = newSVsv(theProc);
  734.             CallWDEF(GetWVariant(RETVAL), peek, wNew, 0);
  735.             if (visible)
  736.                 ShowWindow(RETVAL);
  737.         }
  738.     }
  739.     OUTPUT:
  740.     RETVAL
  741.  
  742. =item GetNewCWindow ID [, BEHIND]
  743.  
  744. Create a color window from a resource.
  745.  
  746. =cut
  747. GrafPtr
  748. GetNewCWindow(windowID, behind=(GrafPtr)-1)
  749.     short   windowID
  750.     GrafPtr behind
  751.     CODE:
  752.     RETVAL = GetNewCWindow(windowID, nil, behind);
  753.     OUTPUT:
  754.     RETVAL
  755.  
  756. =item GetWVariant WINDOW
  757.  
  758. Return the variant code of a window.
  759.  
  760. =cut
  761. short
  762. GetWVariant(theWindow)
  763.     GrafPtr     theWindow
  764.  
  765. =item SetWTitle WINDOW, TITLE
  766.  
  767. Change the title of a window.
  768.  
  769. =cut
  770. void
  771. SetWTitle(theWindow, title)
  772.     GrafPtr     theWindow
  773.     Str255      title
  774.  
  775. =item TrackGoAway WINDOW, PT
  776.  
  777. Track a click in the goaway box of a window and return if the mouse remained inside.
  778.  
  779. =cut
  780. Boolean
  781. TrackGoAway(theWindow, pt)
  782.     GrafPtr theWindow
  783.     Point   pt
  784.  
  785. =item DragWindow WINDOW, PT [, BBOX]
  786.  
  787. Drag a window around.
  788.  
  789. =cut
  790. void
  791. DragWindow(theWindow, pt, boundsRect=GetGrayRgn()[0]->rgnBBox)
  792.     GrafPtr  theWindow
  793.     Point    pt
  794.     Rect    &boundsRect
  795.  
  796. =back
  797.  
  798. =cut
  799.