/***************************************
 *                                     *
 * Program: Make_Text.c                *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/16/1987  Make text       *
 * JLD     01/16/1988  Structures      *
 *                                     *
 ***************************************/


#include <exec/types.h>
#include <intuition/intuition.h>


struct IntuitionBase *IntuitionBase;
struct Window        *FirstWindow;


struct NewWindow FirstNewWindow =
   {
   160, 50,             /* LeftEdge, TopEdge   */
   400, 150,            /* Width, Height       */
   0, 1,                /* DetailPen, BlockPen */
   NULL,                /* IDCMP Flags         */
   WINDOWDEPTH |        /* Flags               */
   WINDOWSIZING |
   WINDOWDRAG |
   WINDOWCLOSE |
   SMART_REFRESH,
   NULL,                /* First Gadget        */
   NULL,                /* CheckMark           */
   (UBYTE *)"System programming test",
   NULL,                /* Screen              */
   NULL,                /* BitMap              */
   100, 50,             /* Min Width, Height   */
   640, 200,            /* Max Width, Height   */
   WBENCHSCREEN,        /* Typ                 */
   };

struct TextAttr DefaultFont =
   {
   (STRPTR)"topaz.font",
   TOPAZ_EIGHTY,
   FS_NORMAL,
   FPF_ROMFONT
   };

struct IntuiText DefaultText =
   {
   1, 0,                /* FrontPen, BackPen   */
   JAM2,                /* DrawMode            */
   1, 1,                /* LeftEdge, TopEdge   */
   &DefaultFont,        /* Font                */
   NULL,                /* Textpointer         */
   NULL                 /* NextText            */
   };

char *Textfield[] =
   {
   "First Text text",
   "here is the second",
   "and one more",
   "here is the last and the longest text!"
   };

struct IntuiText AllText[4];



main()
   {
   struct RastPort *MyWindowsRastPort;

   Open_All();
   Make_Text(4, Textfield, AllText);
   
   MyWindowsRastPort = FirstWindow->RPort;

   PrintIText(MyWindowsRastPort, &AllText[0], 10L, 10L);

   Delay(180L);
   
   Close_All();
   }


/***************************************
 *                                     *
 * Function: Library and Window open   *
 * =================================== *
 *                                     *
 ***************************************/

Open_All()

   {
   void          *OpenLibrary();
   struct Window *OpenWindow();
   
   if (!(IntuitionBase = (struct IntuitionBase *)
       OpenLibrary("intuition.library", 0L)))
      {
      printf("Intuition Library not found!\n");
      Close_All();
      exit(FALSE);
      }
   
   if (!(FirstWindow = (struct Window *)
       OpenWindow(&FirstNewWindow)))
      {
      printf("Window will not open!\n");
      Close_All();
      exit(FALSE);
      }
   }


/***************************************
 *                                     *
 * Function: Close all                 *
 * =================================== *
 *                                     *
 ***************************************/

Close_All()

   {
   if (FirstWindow)     CloseWindow(FirstWindow);
   if (IntuitionBase)   CloseLibrary(IntuitionBase);
   }


Make_Text(Number, Text, Struktur)

int               Number;
char             *Text[];
struct IntuiText  Struktur[];

   {
   int i;
   
   for (i=0; i<Number; i++)
      {
      Struktur[i]          = DefaultText;
      Struktur[i].IText    = (UBYTE *) Text[i];
      Struktur[i].TopEdge  = 20+i*10;
      Struktur[i].NextText = &Struktur[i+1];
      }
   Struktur[Number-1].NextText = NULL;
   }

