home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 176-200 / scopedisk194 / newgadsv1.0 / gadinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-20  |  2.9 KB  |  149 lines

  1. /*
  2. ** Gadinfo - get full info on the system gadgets
  3. **
  4. ** Version 1.0
  5. **
  6. ** Author: Edward Hutchins
  7. **
  8. ** This program will probably die a horrible death under 1.4!
  9. */
  10.  
  11. #define INTUITIONPRIVATE
  12.  
  13. #include <local/typedefs.h>
  14. #include <intuition/intuition.h>
  15. #include <intuition/intuitionbase.h>
  16.  
  17. /*
  18. ** Global variables
  19. */
  20.  
  21. IBASE            *IntuitionBase;
  22.  
  23. typedef struct
  24. {
  25.     WORD        Res;
  26.     WORD        Index;
  27. } GadList;
  28.  
  29. GadList            NewGads[] =
  30. {
  31.     { HIRESGADGET, UPFRONTGADGET },
  32.     { HIRESGADGET, DOWNBACKGADGET },
  33.     { HIRESGADGET, SIZEGADGET },
  34.     { HIRESGADGET, CLOSEGADGET },
  35.     { HIRESGADGET, SUPFRONTGADGET },
  36.     { HIRESGADGET, SDOWNBACKGADGET },
  37.     { LOWRESGADGET, UPFRONTGADGET },
  38.     { LOWRESGADGET, DOWNBACKGADGET },
  39.     { LOWRESGADGET, SIZEGADGET },
  40.     { LOWRESGADGET, CLOSEGADGET },
  41.     { LOWRESGADGET, SUPFRONTGADGET },
  42.     { LOWRESGADGET, SDOWNBACKGADGET },
  43.     { RESCOUNT, 0 }
  44. };
  45.  
  46. char            *GadNames[] =
  47. {
  48. "UPFRONTGADGET",
  49. "DOWNBACKGADGET",
  50. "SIZEGADGET",
  51. "CLOSEGADGET",
  52. "DRAGGADGET",
  53. "SUPFRONTGADGET",
  54. "SDOWNBACKGADGET",
  55. "SDRAGGADGET"
  56. };
  57.  
  58. /*
  59. ** printimage - print the contents of an image structure
  60. */
  61.  
  62. void printimage( IMAGE *img )
  63. {
  64.     int            x, y, w, h, d, bit;
  65.     USHORT        *Bitplanes, *bitplane;
  66.     char        Bits[6*16+1];
  67.     char        *p;
  68.  
  69.     if (img == NULL)
  70.     {
  71.         printf( "Not an image.\n" );
  72.         return;
  73.     }
  74.     
  75.     printf( "Image at :%lx\n", (long)img );
  76.     printf( "(%d,%d)-(%d,%d) × %d\n", img->TopEdge, img->LeftEdge, img->Width, img->Height, img->Depth );
  77.     printf( "PlanePick: %x  PlaneOnOff: %x\n", img->PlanePick, img->PlaneOnOff );
  78.  
  79.     w = ((img->Width + 15) & ~15);
  80.     h = (w / 16) * img->Height;
  81.     Bitplanes = img->ImageData;
  82.  
  83.     for (y = 0; y < img->Height; ++y)
  84.     {
  85.         p = Bits;
  86.         for (x = 0; x < w; ++x)
  87.         {
  88.             *p = '\0';
  89.             bit = 1 << (15-(x & 15));
  90.             bitplane = Bitplanes + (x / 16);
  91.             for (d = 0; d < 2 /* img->Depth */; ++d)
  92.             {
  93.                 *p |= (*bitplane & bit) ? (1 << d) : 0;
  94.                 bitplane += h;
  95.             }
  96.             *p += (*p < 10) ? '0' : 'A';
  97.             ++p;
  98.         }
  99.         *p = '\0';
  100.         printf( ">%s\n", Bits );
  101.         Bitplanes += (w / 16);
  102.     }
  103. }
  104.  
  105. /*
  106. ** printgad - print the specs on a gadget
  107. */
  108.  
  109. void printgad( GADGET *gad )
  110. {
  111.     printf( "Gadget at :%lx\n", (long)gad );
  112.     printf( "(%d,%d)-(%d,%d)\n", gad->TopEdge, gad->LeftEdge, gad->Width, gad->Height );
  113.     printf( "Flags: %x  Acitvation: %x  Type: %x\n", gad->Flags, gad->Activation, gad->GadgetType );
  114.     printimage( gad->GadgetRender );
  115.     printimage( gad->SelectRender );
  116. }
  117.  
  118. /*
  119. ** main - just look for now
  120. */
  121.  
  122. void main( int argv, char *argc[] )
  123. {
  124.     GadList            *glist = NewGads;
  125.     GADGET            *gad;
  126.     int                t;
  127.  
  128.     IntuitionBase = OpenLibrary( "intuition.library", 33 );
  129.     if (IntuitionBase == NULL) return;
  130.  
  131.     while (glist->Res != RESCOUNT)
  132.     {
  133.         gad = IntuitionBase->SysGadgets[glist->Res][glist->Index];
  134.         printf( "\n%s mode: %d\n", GadNames[glist->Index], glist->Res );
  135.         printgad( gad );
  136.         ++glist;        
  137.     }
  138.  
  139.     printf( "\nSystem patterns:\nDrag Bar\n" );
  140.  
  141.     for (t = 0; t < 8; ++t)
  142.         printf( ">%4x\n", IntuitionBase->apattern[t] );
  143.  
  144.     printf( "\nDots:\n" );
  145.  
  146.     for (t = 0; t < 4; ++t)
  147.         printf( ">%4x\n", IntuitionBase->bpattern[t] );
  148. }
  149.