Previous: SetSVGAMode procedure To the Table of Content Next: SetTextStyle procedure

- 4.37.2.112 -
Standard Units
Graph Unit
Graph Unit Procedures and Functions

SetTextJustify procedure

Targets: MS-DOS, Win32


Sets text justification values used by OutText and OutTextXY.

Declaration:
procedure SetTextJustify(Horiz, Vert: DWORD);
Return Value: None Typical Usage:
SetTextJustify(LeftText,CenterText);
SetTextJustify(1,2);
Remarks: Text output after a SetTextJustify will be justified around the current pointer in the manner specified. Given the following,
  SetTextJustify(CenterText, CenterText);
  OutTextXY(100, 100, 'ABC');
The point (100, 100) will appear in the middle of the letter B. The default justification settings can be restored by SetTextJustify (LeftText, TopText). If an invalid input is passed to SetTextJustify, GraphResult returns a value of grError, and the current text justification settings will be unchanged.
Sample Code:
Program JustifyStyle;
{ Linquistic High School # 20    }
{ SetTextJustify Sample program  }
uses
  Crt,Graph;
var
  {A loop variable}
  i: Integer;
  {Y coordinate}
  y: Integer;
begin
  { Set graphics mode at 256 colours}
  SetSVGAMode(640,480,8,LfbOrBanked);
  { Sets Y coordinate at first}
  y:=50;
  { Repeat for each combinations of the styles }
  for i:=1 to 9 do
    begin
      { Shows current CP as LightRed pixel}
      PutPixel( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,LightRed);
      { Increment the Y coordinates }
      inc(y,50);
    end;
  { Sets original Y coordinate }
  y:=50;
  { Sets Left and Bottom Text justification }
  SetTextJustify(LeftText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Bottom Text justification }
  SetTextJustify(CenterText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Bottom Text justification }
  SetTextJustify(RightText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Left and Center Text justification }
  SetTextJustify(LeftText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Center Text justification }
  SetTextJustify(CenterText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Center Text justification }
  SetTextJustify(RightText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Left and Top Text justification }
  SetTextJustify(LeftText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Top Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Top Text justification }
  SetTextJustify(CenterText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Top Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Top Text justification }
  SetTextJustify(RightText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Top Text');
  { Get the key pressed }
  ReadKey;
  { Return to the text mode }
  CloseGraph;
end.



Previous: SetSVGAMode procedure To the Table of Content Next: SetTextStyle procedure
SetSVGAMode procedure Table of Content SetTextStyle procedure

- 4.37.2.112 -