home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / cdity / EasyTM_src.lha / EasyTM-src / GuiExtras.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-27  |  5.6 KB  |  206 lines

  1. //************************************
  2. //
  3. // Name : GuiExtras.c
  4. //
  5. //************************************
  6.  
  7. //**** Header files
  8.  
  9. //** OS Include files
  10. #include <intuition/intuition.h>
  11. #include <intuition/gadgetclass.h>
  12. #include <libraries/asl.h>
  13. #include <libraries/gadtools.h>
  14.  
  15. //** OS function prototypes
  16. #include <clib/asl_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include <clib/gadtools_protos.h>
  19.  
  20. //** OS function inline calls
  21. #include <pragmas/asl_pragmas.h>
  22. #include <pragmas/intuition_pragmas.h>
  23. #include <pragmas/gadtools_pragmas.h>
  24.  
  25. //** ANSI C includes
  26. #include <string.h>
  27.  
  28. //** Application includes
  29. #include "Librarian.h"
  30. #include "GadToolsBox.h"
  31. #include "Node.h"
  32. #include "GuiExtras.h"
  33.  
  34.  
  35. //**** Local storage
  36.  
  37. static struct Requester waitReq;
  38.  
  39. UWORD __chip waitPointer[] = {
  40.     0x0000, 0x0000,     /* reserved, must be NULL */
  41.     0x0400, 0x07C0,    0x0000, 0x07C0,    0x0100, 0x0380,    0x0000, 0x07E0,
  42.     0x07C0, 0x1FF8,    0x1FF0, 0x3FEC,    0x3FF8, 0x7FDE,    0x3FF8, 0x7FBE,
  43.     0x7FFC, 0xFF7F,    0x7EFC, 0xFFFF,    0x7FFC, 0xFFFF,    0x3FF8, 0x7FFE,
  44.     0x3FF8, 0x7FFE,    0x1FF0, 0x3FFC,    0x07C0, 0x1FF8,    0x0000, 0x07E0,
  45.     0x0000, 0x0000,     /* reserved, must be NULL */
  46. }; // waitPointer
  47.  
  48. LONG sig_g;
  49.  
  50.  
  51. //**** wait code
  52.  
  53. BOOL beginWait(struct Window *win) {
  54.   InitRequester(&waitReq);
  55.   if (Request(&waitReq, win)) {
  56.     SetPointer(win, waitPointer, 16, 16, -6, 0);
  57.     return(TRUE);
  58.   } else
  59.   return(FALSE);
  60. } // beginWait
  61.  
  62. VOID endWait(struct Window *win) {
  63.   ClearPointer(win);
  64.   EndRequest(&waitReq, win);
  65. } // endWait
  66.  
  67.  
  68. //**** Requesters
  69.  
  70. void Request_About(void) {
  71.   static struct EasyStruct myES =  {
  72.     sizeof(struct EasyStruct),
  73.     0,
  74.     "EasyTM Prefs - About",
  75.     "EasyTM Prefs version 1.0\n"
  76.     "\n"
  77.     "Copyright © 1996 Tak Tang\n"
  78.     "All Rights Reserved.",
  79.     "Ok",
  80.   }; // myES
  81.  
  82.   beginWait(ETMPWnd);
  83.   EasyRequest(ETMPWnd, &myES, NULL);
  84.   endWait(ETMPWnd);
  85. } // Request_About
  86.  
  87.  
  88. void Request_StackLow(void) {
  89.   static struct EasyStruct myES =  {
  90.     sizeof(struct EasyStruct),
  91.     0,
  92.     "EasyTM Prefs - Stack",
  93.     "Minimum stack is 4096 bytes\n",
  94.     "Ok",
  95.   }; // myES
  96.  
  97.   beginWait(ETMPWnd);
  98.   EasyRequest(ETMPWnd, &myES, NULL);
  99.   endWait(ETMPWnd);
  100. } // Request_StackLow
  101.  
  102. void Request_PriRange(void) {
  103.   static struct EasyStruct myES =  {
  104.     sizeof(struct EasyStruct),
  105.     0,
  106.     "EasyTM Prefs - Priority",
  107.     "Priorities range from -128 to 127\n",
  108.     "Ok",
  109.   }; // myES
  110.  
  111.   beginWait(ETMPWnd);
  112.   EasyRequest(ETMPWnd, &myES, NULL);
  113.   endWait(ETMPWnd);
  114. } // Request_PriRange
  115.  
  116. void Request_FileTrouble(char *op, char *file) {
  117.   static struct EasyStruct myES =  {
  118.     sizeof(struct EasyStruct),
  119.     0,
  120.     "EasyTM Prefs",
  121.     "Help!  Trouble %s\n"
  122.     "\"%s\"",
  123.     "Ok",
  124.   }; // myES
  125.  
  126.   beginWait(ETMPWnd);
  127.   EasyRequest(ETMPWnd, &myES, NULL,op,file);
  128.   endWait(ETMPWnd);
  129. } // Request_FileTrouble
  130.  
  131. int Request_File(char *Hail,char *File, char *Dir) {
  132.   struct FileRequester *fr;
  133.   int rc=0;
  134.   if (fr = (struct FileRequester *) AllocAslRequestTags(ASL_FileRequest,
  135.       ASL_Hail,       Hail,
  136.       ASL_File,       File,
  137.       ASL_Dir,        Dir,
  138.       TAG_DONE))
  139.   {
  140.     if (AslRequest(fr, NULL)) {
  141.       strcpy(File,fr->rf_File);
  142.       strcpy(Dir ,fr->rf_Dir );
  143.       rc=1;
  144.     }
  145.     FreeAslRequest(fr);
  146.   } // if Alloc
  147.   return rc;
  148. } // RequestOpen
  149.  
  150.  
  151. //**** Window
  152.  
  153. void CX_Show(void) {
  154.   if ( (NULL==sig_g) && (0==OpenETMPWindow()) ) {
  155.     sig_g = 1 << ETMPWnd->UserPort->mp_SigBit;
  156.     GT_SetGadgetAttrs(ETMPGadgets[GDX_MenuItems],ETMPWnd,NULL,GTLV_Labels, List, TAG_END);
  157.   }
  158. } // CX_Show
  159.  
  160. void CX_Hide(void) {
  161.   if (NULL!=sig_g) {
  162.     CloseETMPWindow();
  163.     sig_g=NULL;
  164.   }
  165. } // CX_Hide
  166.  
  167.  
  168. //**** Display
  169.  
  170. void DisplayNode(struct ProgNode *pn) {
  171.   if (pn) {
  172.     GT_SetGadgetAttrs(ETMPGadgets[GD_Tool],ETMPWnd,NULL,GTST_String,pn->pn_Filename);
  173.     GT_SetGadgetAttrs(ETMPGadgets[GD_Drawer],ETMPWnd,NULL,GTST_String,pn->pn_Directory);
  174.     GT_SetGadgetAttrs(ETMPGadgets[GD_Stack],ETMPWnd,NULL,GTIN_Number,pn->pn_Stack);
  175.     GT_SetGadgetAttrs(ETMPGadgets[GD_Pri],ETMPWnd,NULL,GTIN_Number,pn->pn_Priority);
  176.     GT_SetGadgetAttrs(ETMPGadgets[GD_Args],ETMPWnd,NULL,GTCY_Active,pn->pn_LaunchCode & LC_ARG_MASK);
  177.     GT_SetGadgetAttrs(ETMPGadgets[GD_Env],ETMPWnd,NULL,GTCY_Active,((pn->pn_LaunchCode & LC_ENV_MASK)>>4)-1);
  178.   } else {
  179.     GT_SetGadgetAttrs(ETMPGadgets[GD_Tool],ETMPWnd,NULL,GTST_String,NULL);
  180.     GT_SetGadgetAttrs(ETMPGadgets[GD_Drawer],ETMPWnd,NULL,GTST_String,NULL);
  181.     GT_SetGadgetAttrs(ETMPGadgets[GD_Stack],ETMPWnd,NULL,GTIN_Number,4096L);
  182.     GT_SetGadgetAttrs(ETMPGadgets[GD_Pri],ETMPWnd,NULL,GTIN_Number,0L);
  183.     GT_SetGadgetAttrs(ETMPGadgets[GD_Args],ETMPWnd,NULL,GTCY_Active,0);
  184.     GT_SetGadgetAttrs(ETMPGadgets[GD_Env],ETMPWnd,NULL,GTCY_Active,0);
  185.   }
  186. } // DisplayNode
  187.  
  188. void PropertyAble(BOOL b) {
  189.   BOOL d;
  190.   d=(TRUE==b)?FALSE:TRUE;
  191.   GT_SetGadgetAttrs(ETMPGadgets[GD_Del],ETMPWnd,NULL,GA_Disabled,d);
  192.   GT_SetGadgetAttrs(ETMPGadgets[GD_Up],ETMPWnd,NULL,GA_Disabled,d);
  193.   GT_SetGadgetAttrs(ETMPGadgets[GD_Down],ETMPWnd,NULL,GA_Disabled,d);
  194.   GT_SetGadgetAttrs(ETMPGadgets[GD_Args],ETMPWnd,NULL,GA_Disabled,d);
  195.   GT_SetGadgetAttrs(ETMPGadgets[GD_Env],ETMPWnd,NULL,GA_Disabled,d);
  196.   GT_SetGadgetAttrs(ETMPGadgets[GD_GetFile],ETMPWnd,NULL,GA_Disabled,d);
  197.   GT_SetGadgetAttrs(ETMPGadgets[GD_GetS],ETMPWnd,NULL,GA_Disabled,d);
  198.   GT_SetGadgetAttrs(ETMPGadgets[GD_GetP],ETMPWnd,NULL,GA_Disabled,d);
  199.   GT_SetGadgetAttrs(ETMPGadgets[GD_Tool],ETMPWnd,NULL,GA_Disabled,d);
  200.   GT_SetGadgetAttrs(ETMPGadgets[GD_Drawer],ETMPWnd,NULL,GA_Disabled,d);
  201.   GT_SetGadgetAttrs(ETMPGadgets[GD_Stack],ETMPWnd,NULL,GA_Disabled,d);
  202.   GT_SetGadgetAttrs(ETMPGadgets[GD_Pri],ETMPWnd,NULL,GA_Disabled,d);
  203. } // PropertyAble
  204.  
  205. //**** End of file
  206.