home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / misc / sci / gfft / source / wbcopyrt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-10  |  7.1 KB  |  268 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        wbcopyrt.c
  13.  * Purpose:     copyright dialog requester
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     11-Feb-1994 CPP; Created.
  16.  *              10-Jul-1994 CPP (0.76); Fixed "fast click" bug
  17.  * Comments:    Workbench GUI.  Amiga Dependent!
  18.  */
  19.  
  20. #ifdef AMIGA  /* This module is AMIGA dependent */
  21.  
  22. #include <stdio.h>     /* sprintf() */
  23. #include <string.h>
  24.  
  25. /*
  26.  * Amiga includes
  27.  */
  28. #include <exec/types.h>
  29. #include <workbench/workbench.h>
  30. #include <intuition/intuition.h>
  31. #include <clib/intuition_protos.h>
  32. #include <clib/exec_protos.h>
  33. #include <dos.h> /* chkabort() */
  34.  
  35. /*
  36.  * GFFT includes
  37.  */
  38. #include "gfft.h"
  39. #include "settings.h"  /* for testing */
  40. #include "wbench.h"
  41.  
  42. /*
  43.  * External globals
  44.  */
  45. extern struct Window *dialog_window_p;
  46. extern char *Author_Strings[];
  47. extern short Max_Columns;
  48. extern char *Copyrt_Req_Prolog;
  49. extern char *Author_Info_Button;
  50. extern char *No_Warranty_Button;
  51. extern char *Sharing_Rights_Button;
  52. extern char *Idea_Contributor_Button;
  53. extern char *Code_Contributor_Button;
  54.  
  55. #define FIRST_AUTHOR_LINE 1  /* Line 0 is blank */
  56.  
  57. static struct Requester *copyright_rp = NULL;
  58. static struct Requester *author_rp = NULL;
  59.  
  60. static struct Gadget *author_gadgetp;
  61. static struct Gadget *copying_gadgetp, *nowarranty_gadgetp;
  62. static struct Gadget *idea_contributor_gadgetp, *code_contributor_gadgetp;
  63. static struct Gadget *financial_contributor_gadgetp;
  64. static struct Gadget *end_copyright_gadgetp, *ok_author_gadgetp;
  65.  
  66. #define MAX_AUTHOR_LINES 7
  67.  
  68. static struct IntuiText *prolog_textp;
  69. static struct IntuiText *author_textp[MAX_AUTHOR_LINES];
  70. static struct Gadget *next_author_gadgetp;
  71. static struct Gadget *previous_author_gadgetp;
  72.  
  73. static void author (int start_line);
  74.  
  75. void copyright_requester (void)
  76. {
  77.     struct IntuiMessage *message;
  78.     APTR *address = NULL;
  79.     ULONG class = 0;
  80.  
  81.     if (!copyright_rp)
  82.     {
  83.     gadget__begin (GTYP_REQGADGET);
  84. /*
  85.  * Setup Text
  86.  */
  87.     prolog_textp = requester_text__new (Copyrt_Req_Prolog, 0, 0);
  88.  
  89. /*
  90.  * Setup Gadgets
  91.  */
  92.     author_gadgetp = text_button__new (Author_Info_Button, 0, 1);
  93.  
  94.     nowarranty_gadgetp = text_button__new (No_Warranty_Button, 0, 2);
  95.  
  96.     copying_gadgetp = text_button__new (Sharing_Rights_Button, 0, 3);
  97.  
  98.     idea_contributor_gadgetp = text_button__new 
  99.       (Idea_Contributor_Button, 0, 4);
  100.  
  101.     code_contributor_gadgetp = text_button__new
  102.       (Code_Contributor_Button, 0, 5);
  103.  
  104. /*
  105.  *    financial_contributor_gadgetp = text_button__new
  106.  *      ("Financial support has been contributed by...",
  107.  *       0, 6);
  108.  */
  109.  
  110.     end_copyright_gadgetp = text_button__new
  111.       ("...OK", Max_Columns - 5, 7);
  112.  
  113.     copyright_rp = requester__new ();
  114.     copyright_rp->ReqGadget = end_copyright_gadgetp;
  115.     copyright_rp->ReqText = prolog_textp;
  116.  
  117.     } /* Ok, copyright_rp has been created */
  118.     
  119.     if (requester__display (copyright_rp, dialog_window_p))
  120.     {
  121.     while (TRUE)
  122.     {
  123.         Wait (1 << dialog_window_p->UserPort->mp_SigBit);
  124.         while (message = (struct IntuiMessage *) GetMsg 
  125.            (dialog_window_p->UserPort))
  126.         {
  127.         CATCH_ERROR
  128.         class = message->Class;
  129.         address = message->IAddress;
  130.         ReplyMsg ((struct Message *) message);
  131.         if (address == (APTR) author_gadgetp)
  132.         {
  133.             author (FIRST_AUTHOR_LINE);
  134.         }
  135.         else if (address == (APTR) copying_gadgetp)
  136.         {
  137.             copying_message (NullString);
  138.         }
  139.         else if (address == (APTR) nowarranty_gadgetp)
  140.         {
  141.             no_warranty_message (NullString);
  142.         }
  143.         else if (address == (APTR) idea_contributor_gadgetp)
  144.         {
  145.             help_message ("idea contributors");
  146.         }
  147.         else if (address == (APTR) code_contributor_gadgetp)
  148.         {
  149.             help_message ("code contributors");
  150.         }
  151.         else if (address == (APTR) financial_contributor_gadgetp)
  152.         {
  153.             help_message ("financial contributors");
  154.         }
  155.         else if (address == (APTR) end_copyright_gadgetp)
  156.         {
  157.             requester__remove (copyright_rp, dialog_window_p);
  158.             return;
  159.         }
  160.         END_CATCH_ERROR
  161.         }
  162.     }
  163.     }
  164. }
  165.  
  166. static void author (int start_line)
  167. {
  168.     struct IntuiMessage *message;
  169.     APTR *address = NULL;
  170.     ULONG class = 0;
  171.     static int author_line_count = 0;
  172.     int start_line_here = start_line;
  173.     int end_line_here;
  174.     int line_count_here;
  175.     int i, j;
  176.     int col;
  177.     static BOOLEAN all_pages_seen = FALSE;
  178.  
  179.     if (!author_line_count)
  180.     {
  181.     while (Author_Strings[author_line_count++]);
  182.     }
  183.     if (author_rp)
  184.     {
  185.     gfree (author_rp);  /* should free text also... */
  186.     author_rp = NULL;
  187.     }
  188.  
  189.     while (Author_Strings[start_line_here] && 
  190.        strlen (Author_Strings[start_line_here++]) <= 1);
  191.     end_line_here = --start_line_here;
  192.  
  193.     while (Author_Strings[end_line_here])
  194.     {
  195.     col = strlen (Author_Strings[end_line_here]);
  196.     if (col <= 1) break;
  197.     end_line_here++;
  198.     }
  199.     end_line_here--;
  200.  
  201.     line_count_here = 1 + end_line_here - start_line_here;
  202.     if (line_count_here < 1 || line_count_here > MAX_AUTHOR_LINES) return;
  203.  
  204.     gadget__begin (GTYP_REQGADGET);
  205.  
  206.     for (i = start_line_here, j = 0; i <= end_line_here; i++, j++)
  207.     {
  208.     author_textp[j] = requester_text__new (Author_Strings[i], 0, j);
  209.     }
  210.  
  211.     next_author_gadgetp = text_button__new ("Next", 11, j);
  212.     if (end_line_here + 3 >= author_line_count)
  213.     {
  214.     next_author_gadgetp->Flags |= GFLG_DISABLED;
  215.     all_pages_seen = TRUE;
  216.     }
  217.  
  218.     previous_author_gadgetp = text_button__new ("Previous", 0, j);
  219.     if (start_line_here <= FIRST_AUTHOR_LINE || !all_pages_seen)
  220.       previous_author_gadgetp->Flags |= GFLG_DISABLED;
  221.  
  222.     ok_author_gadgetp = text_button__new ("...OK", Max_Columns - 5, j);
  223.     if (!all_pages_seen)
  224.       ok_author_gadgetp->Flags |= GFLG_DISABLED;
  225.  
  226.     author_rp = requester__new ();
  227.     author_rp->ReqGadget = ok_author_gadgetp;
  228.     author_rp->ReqText = author_textp[j-1];
  229.  
  230.     if (requester__display (author_rp, dialog_window_p))
  231.     {
  232.     while (TRUE)
  233.     {
  234.         Wait (1 << dialog_window_p->UserPort->mp_SigBit);
  235.         while (message = (struct IntuiMessage *) GetMsg 
  236.            (dialog_window_p->UserPort))
  237.         {
  238.         class = message->Class;
  239.         address = message->IAddress;
  240.         ReplyMsg ((struct Message *) message);
  241.         if (address == (APTR) ok_author_gadgetp)
  242.         {
  243.             requester__remove (author_rp, dialog_window_p);
  244.             return;
  245.         }
  246.         else if (address == (APTR) next_author_gadgetp)
  247.         {
  248.             requester__remove (author_rp, dialog_window_p);
  249.             author (end_line_here + 2);
  250.             return;
  251.         }
  252.         else if (address == (APTR) previous_author_gadgetp)
  253.         {
  254.             i = start_line_here - 1;
  255.             if (i-1 < FIRST_AUTHOR_LINE) break;
  256.             while (Author_Strings[i] &&
  257.                (strlen (Author_Strings[--i]) > 1));
  258.             requester__remove (author_rp, dialog_window_p);
  259.             author (i);
  260.             return;
  261.         }
  262.         }
  263.     }
  264.     }
  265. }
  266.  
  267. #endif /* end ifdef AMIGA */
  268.