/***************************************
 *                                     *
 * Program: Calc_Border.c              *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/16/1987  for testing     *
 *                     only            *
 *                                     *
 ***************************************/


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


struct IntuitionBase *IntuitionBase;
struct Window        *FirstWindow;


struct NewWindow FirstNewWindow =
   {
   160, 50,             /* LeftEdge, TopEdge   */
   320, 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                 */
   };

SHORT Values[] =
   {
    0, 0,
  999, 0,
  999,10,
    0,10,
    0, 0
   };

struct Border Bord =
   {
   0, 0,
   1, 0,
   JAM1,
   5,
   Values,
   NULL
   };

struct IntuiText Text =
   {
   1, 0,                /* FrontPen, BackPen   */
   JAM2,                /* DrawMode            */
   2, 2,                /* LeftEdge, TopEdge   */
   NULL,                /* Font (Standard)     */
   (UBYTE *) "Test",    /* Textpointer         */
   NULL                 /* NextText            */
   };

void Open_All(), Close_All();

main()
   {

   struct RastPort *RP;

   Open_All();
   
   RP = FirstWindow->RPort;

   Calc_Border(&Text);


   DrawBorder(RP, &Bord, 10L, 30L);
   PrintIText(RP, &Text, 10L, 30L);

   Delay(180L);
   
   Close_All();
   }
/********************************
*                               *
* Function: Open All            *
*                               *
********************************/


   void 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                 *
 *                                     *
 ***************************************/

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


Calc_Border(Text)

struct IntuiText  *Text;

   {
   int Width = 0;
   
   Width = IntuiTextLength(Text);
   
   Values[2] = Width+4;
   Values[4] = Width+4;
   }

