home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / toollib_438.lzh / ToolLib / Examples / GadgetDEMO.c < prev    next >
C/C++ Source or Header  |  1991-01-17  |  5KB  |  114 lines

  1. /*
  2.  * GadgetDEMO.c - © Copyright 1990-91 Jaba Development
  3.  *
  4.  * Just a little demo of some of the gadget functions of the
  5.  * tool.library V7++
  6.  */
  7. #include "functions.h"
  8. #include "tool.h"
  9. #include "GadgetDEMO.h"
  10.  
  11. struct ToolBase      *ToolBase;
  12. struct IntuitionBase *IntuitionBase;
  13.  
  14. struct Window        *window;
  15. struct IntuiMessage  *msg;
  16. struct Gadget        *pressed;
  17.  
  18. ULONG                 class;
  19. USHORT                id;
  20.  
  21. BOOL    OnOff  = FALSE, DeSel = FALSE, Erase = FALSE;
  22. LONG    Shadow = 0;
  23.  
  24. void main()
  25. {
  26.     if(ToolBase = (struct ToolBase *)
  27.      OpenLibrary("tool.library",TOOL_VERSION))
  28.     {
  29.         IntuitionBase = ToolBase->IntuitionBase;
  30.  
  31.         if(window = (struct Window *)OpenWindow(NEWWINDOW))
  32.         {
  33.             FOREVER
  34.             {
  35.                 Wait(1 << window->UserPort->mp_SigBit);
  36.                 while(msg = (struct IntuiMessage *)GetMsg(window->UserPort))
  37.                 {
  38.                     class   =   msg->Class;
  39.                     pressed =   (struct Gadget *)msg->IAddress;
  40.                     id      =   pressed->GadgetID;
  41.                     ReplyMsg((struct Message *)msg);
  42.  
  43.                     switch(class)
  44.                     {
  45.                         case CLOSEWINDOW:   CloseWindow(window);
  46.                                             CloseLibrary(ToolBase);
  47.                                             exit(0);
  48.                                             break;
  49.  
  50.                         case GADGETUP:  switch(id)
  51.                                         {
  52.                                             case mutex_ID:
  53.                                                 MutualExclude(window,pressed,&first_ex,NULL);
  54.                                                 break;
  55.  
  56.                                             case mutin_ID:
  57.                                                 MutualInclude(window,pressed,&first_in,NULL);
  58.                                                 break;
  59.  
  60.                                             case ongd_ID:
  61.                                                 if(! OnOff)
  62.                                                 {
  63.                                                     OffGList(window,&first_on,NULL,4);
  64.                                                     OnOff = TRUE;
  65.                                                 }
  66.                                                 else
  67.                                                 {
  68.                                                     OnGList(window,&first_on,NULL,4);
  69.                                                     OnOff = FALSE;
  70.                                                 }
  71.                                                 break;
  72.  
  73.                                             case ergd_ID:
  74.                                                 if(! Erase)
  75.                                                 {
  76.                                                     EraseGList(window,&first_er,NULL,4);
  77.                                                     Erase = TRUE;
  78.                                                 }
  79.                                                 else
  80.                                                 {
  81.                                                     RefreshGList(&first_er,window,NULL,4);
  82.                                                     Erase = FALSE;
  83.                                                 }
  84.                                                 break;
  85.  
  86.                                             case segd_ID:
  87.                                                 if(! DeSel)
  88.                                                 {
  89.                                                     SelectGList(window,&first_se,NULL,4);
  90.                                                     DeSel = TRUE;
  91.                                                 }
  92.                                                 else
  93.                                                 {
  94.                                                     DeSelectGList(window,&first_se,NULL,4);
  95.                                                     DeSel = FALSE;
  96.                                                 }
  97.                                                 break;
  98.  
  99.                                             case shgd_ID:
  100.                                                 if(Shadow++ > 3)
  101.                                                     Shadow = 0;
  102.                                                 ShadowGList(window,&first_sh,NULL,Shadow,4);
  103.                                                 break;
  104.                                         }
  105.                                         break;
  106.                             default:    break;
  107.                     }
  108.                 }
  109.             }
  110.         }
  111.         CloseLibrary(ToolBase);
  112.     }
  113. }
  114.