home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / db3.4 / pointers.c < prev    next >
C/C++ Source or Header  |  1995-12-11  |  4KB  |  196 lines

  1. /* WaitPointer.c Two routines to block input on a window */
  2. /* Will use a hires waitpointer on v39+ and a lo-res "clock" in pre v39 */
  3. /* Currently only allows only one invocation at a time */
  4. /* If a a function is called twice in a row, the 2:nd call will be ignored */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/libraries.h>
  8. #include <intuition/intuition.h>
  9. #include <intuition/intuitionbase.h>
  10. #include <intuition/pointerclass.h>
  11. #include <proto/exec.h>
  12. #include <proto/intuition.h>
  13. #include <graphics/gfx.h>
  14.  
  15. #include "Pointers.h"
  16.  
  17. extern struct IntuitionBase *IntuitionBase;
  18.  
  19. /* Data */
  20.  
  21. APTR    Pointer = NULL;
  22.  
  23. UWORD __chip leftright_plOS20[] =
  24. {
  25.     0x0000, 0x0000,
  26.  
  27.    0x1860,    0x1860,
  28.     0x3870,    0x2850,
  29.     0x7FF8,    0x4FC8,
  30.     0xFFFC,    0x8004,
  31.     0x3030,    0x4FC8,
  32.     0x1020,    0x2850,
  33.     0x0000,    0x1860,
  34.  
  35.     0x0000, 0x0000
  36. };
  37.  
  38. UWORD __chip leftright_pl[][10] =
  39. {
  40.     /* Plane 0 */ {
  41.     0x0C30,
  42.     0x1C38,
  43.     0x3C3C,
  44.     0x7FFE,
  45.     0xFFFF,
  46.     0x7FFE,
  47.     0x381C,
  48.     0x1818,
  49.     0x0810,
  50.     0x0000 },
  51.  
  52.     /* Plane 1 */ {
  53.     0x0C30,
  54.     0x1428,
  55.     0x2424,
  56.     0x47E2,
  57.     0x8001,
  58.     0x8001,
  59.     0x47E2,
  60.     0x2424,
  61.     0x1428,
  62.     0x0C30 }
  63. };
  64.  
  65. struct BitMap leftrightBitMap = {
  66.     2,    /* UWORD BytesPerRow */
  67.     10,    /* UWORD Rows */
  68.     0,    /* UBYTE Flags */
  69.     2,    /* UBYTE Depth */
  70.     0,    /* UWORD pad */
  71.     { (PLANEPTR)&leftright_pl[0], (PLANEPTR)&leftright_pl[1] } /* PLANEPTR Planes[8] */
  72. };
  73.  
  74. UWORD __chip easymove_plOS20[] =
  75. {
  76.     /* Plane 0,1 */
  77.     0x0000,    0x0000,
  78.  
  79.     0xC000,    0x4000,
  80.     0x7000,    0xB000,
  81.     0x3C00,    0x4C00,
  82.     0x3F00,    0x4300,
  83.     0x1FC0,    0x20C0,
  84.     0x1FC0,    0x2000,
  85.     0x0F00,    0x1100,
  86.     0x0D80,    0x12AA,
  87.     0x04C0,    0x0955,
  88.     0x0460,    0x08A2,
  89.     0x0020,    0x0141,
  90.     0x0000,    0x0082,
  91.     0x0000,    0x0101,
  92.     0x0000,    0x00AA,
  93.     0x0000,    0x0155,
  94.  
  95.     0x0000,    0x0000
  96. };
  97.  
  98. UWORD __chip easymove_pl[][15] =
  99. {
  100.     /* Plane 0 */ {
  101.     0xC000,
  102.     0x7000,
  103.     0x3C00,
  104.     0x3F00,
  105.     0x1FC0,
  106.     0x1FC0,
  107.     0x0F00,
  108.     0x0D80,
  109.     0x04C0,
  110.     0x0460,
  111.     0x0020,
  112.     0x0000,
  113.     0x0000,
  114.     0x0000,
  115.     0x0000 },
  116.  
  117.     /* Plane 1 */ {
  118.     0x4000,
  119.     0xB000,
  120.     0x4C00,
  121.     0x4300,
  122.     0x20C0,
  123.     0x2000,
  124.     0x1100,
  125.     0x12AA,
  126.     0x0955,
  127.     0x08A2,
  128.     0x0141,
  129.     0x0082,
  130.     0x0101,
  131.     0x00AA,
  132.     0x0155 }
  133. };
  134.  
  135. struct BitMap easymove_bm = {
  136.     2,    /* UWORD BytesPerRow */
  137.     15,    /* UWORD Rows */
  138.     0,    /* UBYTE Flags */
  139.     2,    /* UBYTE Depth */
  140.     0,    /* UWORD pad */
  141.     { (PLANEPTR)&easymove_pl[0], (PLANEPTR)&easymove_pl[1] } /* PLANEPTR Planes[8] */
  142. };
  143.  
  144. void ChangePointer(struct Window *win, char pointertype)
  145. {
  146.     if (Pointer) return;
  147.  
  148.     if (IntuitionBase->LibNode.lib_Version >= 39) {
  149.     switch (pointertype) {
  150.         case LRPointer :
  151.             Pointer = NewObject(NULL, "pointerclass",
  152.                 POINTERA_BitMap, &leftrightBitMap,
  153.                 POINTERA_XOffset, -7,
  154.                 POINTERA_YOffset, -4,
  155.                 POINTERA_XResolution, POINTERXRESN_SCREENRES,
  156.                 POINTERA_YResolution, POINTERYRESN_SCREENRESASPECT
  157.             );
  158.             break;
  159.         case MovePointer:
  160.             Pointer = NewObject(NULL, "pointerclass",
  161.                 POINTERA_BitMap, &easymove_bm,
  162.                 POINTERA_XOffset, 0,
  163.                 POINTERA_YOffset, 0,
  164.                 POINTERA_XResolution, POINTERXRESN_SCREENRES,
  165.                 POINTERA_YResolution, POINTERYRESN_SCREENRESASPECT
  166.             );
  167.             break;
  168.         }
  169.         if (!Pointer) {
  170.             return;
  171.         }                              
  172.         SetWindowPointer(win, WA_Pointer, Pointer, TAG_DONE);
  173.     }
  174.     else {
  175.         switch (pointertype) {
  176.             case LRPointer :
  177.                 SetPointer(win, leftright_plOS20, 7, 16, -8, -3);
  178.                 break;
  179.             case MovePointer:
  180.                 SetPointer(win, easymove_plOS20, 15, 16, -1, 0); // Note -1 not 0 for compatibility.
  181.                 break;
  182.         }
  183.     }
  184. }
  185.  
  186. void RestorePointer(struct Window *win)
  187. {
  188.     if (IntuitionBase->LibNode.lib_Version >= 39) {
  189.         if (!Pointer) return;
  190.         SetWindowPointer(win, TAG_DONE);
  191.         DisposeObject(Pointer);
  192.         Pointer = NULL;
  193.     }
  194.     else ClearPointer(win);
  195. }
  196.