home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d911 / psm.lha / PSM / Source / source.lha / extras.c < prev    next >
C/C++ Source or Header  |  1993-07-28  |  3KB  |  101 lines

  1.  
  2. #include "psm.h"
  3.  
  4. // ----------------------------------------------------------------
  5. // Lock a GadOutline.  go_TransHookData must be free to use.
  6. // ----------------------------------------------------------------
  7.  
  8. /* Pointer from Steve Tibbett's PointerX */
  9.  
  10. static USHORT __chip BusyPointerData[] =
  11.     {
  12.     0x0000,0x0000,
  13.     0x0400,0x07C0,0x0000,0x07C0,0x0100,0x0380,0x0000,0x07E0,
  14.     0x07C0,0x1FF8,0x1FF0,0x3FEC,0x3FF8,0x7FDE,0x3FF8,0x7FBE,
  15.     0x7FFC,0xFF7F,0x7EFC,0xFFFF,0x7FFC,0xFFFF,0x3FF8,0x7FFE,
  16.     0x3FF8,0x7FFE,0x1FF0,0x3FFC,0x07C0,0x1FF8,0x0000,0x07E0,
  17.     0x0000,0x0000,
  18.     };
  19.  
  20. void LockGadOutline(struct GadOutline *go)
  21. {
  22.     if(!go || go->go_TransHookData != NULL || !go->go_Window) return;
  23.     
  24.     SetPointer(go->go_Window,BusyPointerData,16,16,-6,0);
  25.     if( (go->go_TransHookData=AllocVec(sizeof(struct Requester),
  26.         MEMF_PUBLIC|MEMF_CLEAR)) != NULL ) {
  27.  
  28.         InitRequester(go->go_TransHookData);
  29.         if(!Request(go->go_TransHookData,go->go_Window)) {
  30.             FreeVec(go->go_TransHookData);
  31.             go->go_TransHookData = NULL;
  32.         }
  33.     }
  34. }
  35.  
  36. void UnlockGadOutline(struct GadOutline *go)
  37. {
  38.     if(!go || !go->go_TransHookData || !go->go_Window) return;
  39.     
  40.     EndRequest(go->go_TransHookData,go->go_Window);
  41.     FreeVec(go->go_TransHookData);
  42.     go->go_TransHookData = NULL;
  43.     ClearPointer(go->go_Window);
  44. }
  45.  
  46.  
  47. // ----------------------------------------------------------------
  48. // Window backfill support.
  49. // ----------------------------------------------------------------
  50.  
  51. struct BackFillMsg
  52. {
  53.     struct Layer     *bf_Layer;
  54.     struct Rectangle  bf_Bounds;
  55.     LONG              bf_OffsetX;
  56.     LONG              bf_OffsetY;
  57. };
  58.  
  59.  
  60. static ULONG __asm __saveds __interrupt
  61. backfill_code(register __a0 struct Hook        *hook,
  62.               register __a2 struct RastPort    *rp,
  63.               register __a1 struct BackFillMsg *bfm)
  64. {
  65.     struct RastPort crp;
  66.     struct GadOutline *go;
  67.     UWORD pen = 0;
  68.  
  69.     go = hook->h_Data;
  70.     if(go) {
  71.         if(go->go_DrI) {
  72.             if(go->go_DrI->dri_Version >= 1) {
  73.                 if(go->go_DrI->dri_NumPens >= BACKGROUNDPEN) {
  74.  
  75.                     pen = go->go_DrI->dri_Pens[BACKGROUNDPEN];
  76.                 }
  77.             }
  78.         }
  79.     }
  80.     
  81.     crp       = *rp;            /* copy the rastport                      */
  82.     crp.Layer = NULL;           /* eliminate bogus clipping from our copy */
  83.  
  84.     SetWrMsk(&crp,0xff);
  85.  
  86.     SetAPen(&crp,pen);                   /* set the pen to background color */
  87.     SetDrMd(&crp,JAM2);                  /* set the rendering mode we need  */
  88.     RectFill(&crp,bfm->bf_Bounds.MinX,   /* clear the whole area            */
  89.                   bfm->bf_Bounds.MinY,
  90.                   bfm->bf_Bounds.MaxX,
  91.                   bfm->bf_Bounds.MaxY);
  92.    return 0;
  93. }
  94.  
  95. void SetupBackFillHook(struct Hook *hk,struct GadOutline *go)
  96. {
  97.     hk->h_Entry = (ULONG (*)())backfill_code;
  98.     hk->h_SubEntry = NULL;
  99.     hk->h_Data = go;
  100. }
  101.