home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 144.lha / Leach_v1.3 / mouseptr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  3.4 KB  |  113 lines

  1. /***************************************************************************
  2.  * MOUSEPOINTER.C
  3.  * This file contains all the stuff involved with generating the custom
  4.  * mousepointer used when the ruler is being shown.
  5.  ***************************************************************************/
  6.  
  7. #include <intuition/intuition.h>
  8. #include <functions.h>
  9. #include <stdio.h>
  10.  
  11.  
  12. USHORT pointer_image[] =    /* MAY HAVE TO BE IN CHIP MEMORY!        */
  13. {
  14.     0x0000, 0x0000,            /* The first 2 words must be zero.        */
  15.     0x0080, 0x0000,            /* The next 8 pairs form the vert. bar    */
  16.     0x0080, 0x0000,
  17.     0x0080, 0x0000,
  18.     0x0080, 0x0000,
  19.     0x0080, 0x0000,
  20.     0x0080, 0x0000,
  21.     0x0080, 0x0000,
  22.     0x0080, 0x0000,
  23.     0x0000, 0x0000,
  24.     0x0080, 0x7EBF,            /* The horizontal bars and hot spot.    */
  25.     0x0000, 0x0000,
  26.     0x0080, 0x0000,            /* The next 8 pairs form the vert. bar    */
  27.     0x0080, 0x0000,
  28.     0x0080, 0x0000,
  29.     0x0080, 0x0000,
  30.     0x0080, 0x0000,
  31.     0x0080, 0x0000,
  32.     0x0080, 0x0000,
  33.     0x0080, 0x0000,
  34.     0x0000, 0x0000,            /* The last 4 words must be zero.    */
  35.     0x0000, 0x0000
  36. };                            /* end of pointer image data.        */
  37.  
  38. #define MPTRSIZE sizeof(pointer_image)
  39.  
  40.  
  41. /*--------------------------------------------------------------------------*
  42.  * This struct mirrors a chunk of the Window struct that describes the 
  43.  * Mouse Pointer. It is used to save the original Host pointer parameters
  44.  * before we call SetPointer() to install our own pointer image.
  45.  *--------------------------------------------------------------------------*/
  46.  
  47. struct Mpointer
  48. {
  49.     USHORT    *Pointer;                /* Image data                            */
  50.     BYTE    Height;                    /* number of scan lines.                */
  51.     BYTE    Width;                    /* in pixels. Must be <= 16             */
  52.     BYTE    Xoffset, Yoffset;        /* Location of Hot Spot within sprite    */
  53. };
  54.  
  55. struct Mpointer Host_pointer;        /* For saving original Host data        */
  56.  
  57. struct Mpointer    Leach_pointer =        /* Data for Leach pointer image.        */
  58. {
  59.     pointer_image,
  60.     (MPTRSIZE / 4) - 4,
  61.     16,
  62.     -9, -9
  63. };
  64.  
  65. extern struct Window    *HostWind;
  66.  
  67.  
  68. /****************************************************************************
  69.  * This function saves the Host's mouse pointer data, then activates its
  70.  * own pointer by calling the Intuition function SetPointer().
  71.  ****************************************************************************/
  72.  
  73. set_pointer()
  74. {
  75.  
  76. Host_pointer.Pointer    = HostWind->Pointer;
  77. Host_pointer.Height        = HostWind->PtrHeight;
  78. Host_pointer.Width        = HostWind->PtrWidth;
  79. Host_pointer.Xoffset    = HostWind->XOffset;
  80. Host_pointer.Yoffset    = HostWind->YOffset;
  81.  
  82. SetPointer(HostWind, Leach_pointer.Pointer, (long) Leach_pointer.Height, 
  83.               (long) Leach_pointer.Width,   (long) Leach_pointer.Xoffset, 
  84.                                             (long) Leach_pointer.Yoffset ); 
  85.  
  86. return;
  87.  
  88. } /*  End of set_pointer()  */
  89.  
  90.  
  91. /****************************************************************************
  92.  * This simple function restores the Host's mouse pointer data, by calling 
  93.  * the Intuition function SetPointer(). Note that no harm is done if this
  94.  * gets called when the Default is already the current one.
  95.  ****************************************************************************/
  96.  
  97. restore_pointer()
  98. {
  99.  
  100. if ( Host_pointer.Pointer)    /* If the Host had a custom pointer, restore it */
  101. {
  102.     SetPointer(HostWind, Host_pointer.Pointer,    (long) Host_pointer.Height, 
  103.                   (long) Host_pointer.Width,    (long) Host_pointer.Xoffset, 
  104.                                                 (long) Host_pointer.Yoffset );
  105. }
  106. else                        /* Reactivate the default Intuition pointer.    */
  107. {
  108.     ClearPointer(HostWind);
  109. }
  110. return;
  111.  
  112. } /* End of restore_pointer()  */ 
  113.