home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Resources / System / BoingBag1 / Contributions / Workbench / RexxArpLib3p6 / src / sreq / gadmxsel.c next >
C/C++ Source or Header  |  1998-06-17  |  3KB  |  119 lines

  1. /** GadMXSel.c
  2.  *
  3.  * Routines to select/deselect gadgets. These particularly seem to work
  4.  * reliably with gadgets with IntuiText and Borders with GADGHCOMP
  5.  * highlighting. Jim Mackraz will probably say that they will break
  6.  * with 1.4, but sofar I'm not worried... ;-)
  7.  *
  8.  * An earlier version of this appeared on Fish Disk 52, with
  9.  * a little demo, but this is muchly improved, if I say so myself...
  10.  *
  11.  *                                            W.G.J. Langeveld
  12.  *
  13. **/
  14. #include <exec/types.h>
  15. #include <exec/io.h>
  16. #include <exec/memory.h>
  17. #include <libraries/dos.h>
  18. #include <intuition/intuition.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <functions.h>
  22.  
  23. #include <simpreq.h>
  24.  
  25. /**
  26.  *
  27.  *   Function to select one gadget (1) and deselect others (2 - 6).
  28.  *
  29. **/
  30. void GadMXSel( struct Window *win, struct Gadget *gad1, struct Gadget *gad2, struct Gadget *gad3, struct Gadget *gad4, struct Gadget *gad5, struct Gadget *gad6 )
  31. {
  32.     GadMXSet(win, gad1);
  33.     GadMXClr(win, gad2);
  34.     GadMXClr(win, gad3);
  35.     GadMXClr(win, gad4);
  36.     GadMXClr(win, gad5);
  37.     GadMXClr(win, gad6);
  38.     
  39.     return;
  40. }
  41.  
  42. /**
  43.  *
  44.  *   Function to select a gadget. Sideeffect: adds gadget to the END of the
  45.  *   gadgetlist. Not a problem for me, and extension to put it back where
  46.  *   it belongs is obvious, but I don't need it.
  47.  *
  48. **/
  49. void GadMXSet( struct Window *win, struct Gadget *gad1 )
  50. {
  51.     /*
  52.      *   Now select gad1 and refresh.
  53.      */
  54.     if (win && gad1) 
  55.     {
  56.         if ((gad1->Flags & SELECTED) == 0) 
  57.         {
  58.             RemoveGadget(win, gad1);
  59.             gad1->Flags |= SELECTED;
  60.             AddGadget(win, gad1, -1L);
  61.             RefreshGadgets(gad1, win, NULL);
  62.         }
  63.     }
  64.     
  65.     return;
  66. }
  67.  
  68. /**
  69.  *
  70.  *   Function to DEselect a gadget. Sideeffect: adds gadget to the END of the
  71.  *   gadgetlist.
  72.  *
  73. **/
  74. void GadMXClr( struct Window *win, struct Gadget *gad1 )
  75. {
  76.     /*
  77.      *   First select gad1 (yes!) and refresh it.
  78.      */
  79.     if (win && gad1) 
  80.     {
  81.         if (gad1->Flags & SELECTED) 
  82.         {
  83.             RemoveGadget(win, gad1);
  84.             gad1->Flags |= SELECTED;
  85.             AddGadget(win, gad1, -1L);
  86.             RefreshGadgets(gad1, win, NULL);
  87.             /*
  88.              *   Now deselect gad1 and refresh.
  89.              */
  90.             RemoveGadget(win, gad1);
  91.             gad1->Flags &= ~SELECTED;
  92.             AddGadget(win, gad1, -1L);
  93.             RefreshGadgets(gad1, win, NULL);
  94.         }
  95.     }
  96.     
  97.     return;
  98. }
  99.  
  100. /**
  101.  *
  102.  *   Function to toggle a gadget's select status. Side effect: adds gadget
  103.  *   back to the END of the list.
  104.  *
  105. **/
  106. void GadMXToggle( struct Window *win, struct Gadget *gad1 )
  107. {
  108.     if (win && gad1) 
  109.     {
  110.         if (gad1->Flags & SELECTED)
  111.             GadMXClr(win, gad1);
  112.         else
  113.             GadMXSet(win, gad1);
  114.     }
  115.     
  116.     return;
  117. }
  118.  
  119.