PROGRAM   TextJust ;
USES   Graph ;

VAR
   G_GraphDriver : Integer ;
   G_GraphMode   : Integer ;
BEGIN
   G_GraphDriver := Detect ;
   G_GraphMode   := Detect ;
   InitGraph ( G_GraphDriver , G_GraphMode , 'C:\Lib\BGI' );

   OutTextXY ( 50 , 50   ,   'Default=Left,Top'   );
   Line ( 40 , 40   ,   50 , 50   );
   Line ( 45 , 50   ,   50 , 50   );
   Line ( 50 , 45   ,   50 , 50   );


   {----- "Top" justify }
   SetTextJustify ( LeftText , TopText );
   OutTextXY ( 0 , 0   ,   'Left,Top'   );

   SetTextJustify ( CenterText , TopText );
   OutTextXY ( GetMaxX div 2 , 0   ,   '+++++----- Center,Top -----+++++'   );

   SetTextJustify ( RightText , TopText );
   OutTextXY ( GetMaxX , 0   ,   'Right,Top'   );

   {----- "Bottom" justify }
   SetTextJustify ( LeftText , BottomText );
   OutTextXY ( 0 , GetMaxY   ,   'Left,Bottom'   );

   SetTextJustify ( CenterText , BottomText );
   OutTextXY ( GetMaxX div 2 , GetMaxY   ,   '+++++----- Center,Bottom -----+++++'   );

   SetTextJustify ( RightText , BottomText );
   OutTextXY ( GetMaxX , GetMaxY   ,   'Right,Bottom'   );

   {----- Vertical "Center" justify }
   SetColor ( Green );
   Line ( 0 , GetMaxY div 2   ,   GetMaxX , GetMaxY div 2   );
   SetColor ( White );

   SetTextJustify ( LeftText , CenterText );
   OutTextXY ( 0 , GetMaxY div 2   ,   'Left,Center'   );

   SetTextJustify ( CenterText , CenterText );
   OutTextXY ( GetMaxX div 2 , GetMaxY div 2   ,   '+++++----- Center,Center -----+++++'   );

   SetTextJustify ( RightText , CenterText );
   OutTextXY ( GetMaxX , GetMaxY div 2   ,   'Right,Center'   );

   ReadLn ;
   CloseGraph ;
END.
