home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 206.lha / Flist_v1.2 / Sources / misc.c < prev    next >
C/C++ Source or Header  |  1988-12-28  |  3KB  |  143 lines

  1. /*
  2.     String gadgets and misc functions.
  3.  
  4.     Written by: Steve (Raz) Berry
  5. */
  6.  
  7. #include "flist.h"
  8.  
  9. char strbuf[256];
  10. char undo[256];
  11.  
  12. struct IntuiText AutoText = {
  13.    REDP,     WHTP,
  14.    JAM2,  15,
  15.    5,    NL,
  16.    " Flist ", NULL
  17. };
  18.  
  19. /** TRUE TEXT **/
  20. struct IntuiText TRUEtext = {
  21.    BLUP,  WHTP,
  22.    JAM2,
  23.    7,                       /* LeftEdge */
  24.    3,                       /* TopEdge  */
  25.    NL,                      /* Default font */
  26.    "OK",                    /* Text */
  27.    NL                       /* No pointer to next text */
  28. };
  29.  
  30. /** FALSE TEXT **/
  31. struct IntuiText FALSEtext = {
  32.    REDP,  WHTP,
  33.    JAM2,
  34.     7,                       /* LeftEdge */
  35.     3,                       /* TopEdge  */
  36.    NL,                       /* Default font */
  37.    "NO!",                    /* Text */
  38.    NL
  39. };
  40.  
  41. struct StringInfo strinfo = {
  42.     strbuf,
  43.     undo,
  44.     0,
  45.     200,
  46.     0, 0,
  47.     0, 0,
  48.     0, 0,
  49.     0, 0,
  50.     0
  51. };
  52.     
  53. struct Gadget str = {
  54.     NULL,
  55.     20, 20, 240, 10,
  56.     GADGHCOMP,
  57.     GADGIMMEDIATE|RELVERIFY,
  58.     STRGADGET,
  59.     NULL,
  60.     NULL,
  61.     NULL,
  62.     NULL,
  63.     (APTR)&strinfo,
  64.     0, NULL
  65. };
  66.  
  67. struct  NewWindow strwin = {
  68.    140,70,                                /* LeftEdge and TopEdge */
  69.    300, 40,                               /* Width and Height */
  70.    0, 1,                                  /* DetailPen and BlockPen */
  71.    CLOSEWINDOW|GADGETUP,                  /* IDCMP Flags */
  72.    WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE     /* Flags */
  73.    |SMART_REFRESH|ACTIVATE,
  74.    &str, NULL,                            /* Gadget and Image pointers */
  75.    NULL,                                  /* Title string */
  76.    NULL,                                  /* Screen ptr null (this screen) */
  77.    NULL,                                  /* BitMap pointer */
  78.    50, 20,                                /* MinWidth and MinHeight */
  79.    320, 200,                              /* MaxWidth and MaxHeight */
  80.    WBENCHSCREEN                           /* Type of window */
  81. };
  82.  
  83. /* Make a string gadget in it's own window */
  84.  
  85. struct Window *make_gadget(title)
  86. char *title;
  87. {
  88.     struct Window *strptr;
  89.  
  90.     strwin.Title = title;
  91.     strptr = OpenWindow(&strwin);
  92.  
  93.     if(strptr != NULL) {
  94.         RefreshGadgets(&str, strptr, NULL);
  95.         ActivateGadget(&str, strptr, NULL);
  96.     }
  97.     return strptr;
  98. }
  99.  
  100. /* Wait for one event from a window, then return */
  101.  
  102. wait_for_event(win)
  103. struct Window *win;
  104. {
  105.     ULONG imask,signals;
  106.     struct IntuiMessage *imsg;
  107.  
  108.     imask = 1 << win->UserPort->mp_SigBit;
  109.  
  110.     signals = Wait(imask);
  111.  
  112.     if(signals & imask) {
  113.         while(imsg = (struct IntuiMessage *)GetMsg(win->UserPort))
  114.             ReplyMsg(imsg);
  115.     } 
  116.     if (win) {
  117.         while(imsg = (struct IntuiMessage *)GetMsg(win->UserPort))
  118.             ReplyMsg(imsg);
  119.         CloseWindow(win);
  120.     }
  121. }
  122.  
  123. int auto_req();
  124. /***************************************************************************
  125.                             HANDLE AUTO-REQUESTS
  126. ***************************************************************************/
  127. int auto_req (text)
  128. char *text;         /* Pointer to the text */
  129. {
  130.     struct Process *proc;
  131.     int   val, temp;
  132.  
  133.     AutoText.IText = text;               /* Text pointer          */
  134.  
  135.     temp = ((CHARW + 1) * strlen(text)) + (4 * CHARW);
  136.     temp = (temp < 150) ? 150: temp;
  137.  
  138.     proc = (struct Process *)FindTask(NULL);
  139.     val = AutoRequest(proc->pr_WindowPtr, &AutoText, &TRUEtext, &FALSEtext, 
  140.             0L, 0L, (LONG)temp, 60L );
  141.     return val;
  142. }
  143.