Borland C++ reference

settextjustify

raw OCR

Sets text justification for graphics functions.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void  far settextjustify(int horiz, int vert);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

Text output after a call to settextjustify is justified around the current position (CP) horizontally and vertically, as specified. The default

justification settings are LEFT_TEXT(for horizontal) and TOP_TEXT(for

vertical). The enumeration text Just in graphics.h provides names for the horiz and vert settings passed to settextjustify.

Description NameValue Action
horizLEFT_TEXT0left-justify text
CENTER_TEXT1center text
RIGHT_TEXT2right-justify text
vertBOTTOM_TEXT0justify from bottom
CENTER_TEXT1center text
TOP TEXT2justify from top
If horiz is equal to LEFT_TEXTand direction equals HORIZ_DIR,the CP's x

component is advanced after a call to o\Mex\{string) by textwidth(sfrm^).

settextjustify affects text written with outtext and cannot be used with text mode and stream functions.

Return value

If invalid input is passed to settextjustify, graphresult returns -11, and the current text justification remains unchanged.

See also

Example

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

/* function prototype  */
void xat (int x, int y);

/* horizontal text  justification settings */
char *hjust[] =  { "LEFT_TEXT", "CENTER_TEXT", 'RIGHT_TEXT" };
/* vertical text justification  settings */
char *vjust[] =  { "LEFT_TEXT", "CENTER_TEXT", 'RIGHT TEXT"

int main (void)

   /* request autodetection  */
   int gdriver = DETECT, gmode,  errorcode;
   int midx, midy, hj , vj;
   char msg[80] ;
   /* initialize graphics  and local variables */
   initgraph(&gdriver, &gmode,  "");

   /* read result of initialization  */
   errorcode = graphresult ();
   if (errorcode  != grOk) {  /* an error occurred */
      printf ("Graphics error: %s\n", grapherrormsg(errorcode)
      printf ("Press any key to halt:");
      getchO ;
      exit(l);                /* terminate with an error code */
   }
   midx = getmaxxO  / 2;
   midy = getmaxy () / 2;

   /* loop through text justifications  */
   for (hj=LEFT_TEXT; hj<=RIGHT_TEXT;  hj++)
      for (vj=LEFT_TEXT; vj<=RIGHT_TEXT;  vj++) {
         cleardeviceO  ;

         /* set the text justification  */
         settextjustify (hj, vj);

         /* create a message  string */
         sprintf(msg,  "%s %s", hjust[hj],  vjust[vj]);

         /* create crosshairs on  the screen */
         xat (midx, midy);

         /* output the message  */
         outtextxy (midx, midy, msg);
         getchO  ;
      }
   /* clean up */
   closegraphO  ;
   return 0;

void xat (int x, int y)       /* draw an x at (x,y) */
{
  line(x-4, y, x+4, y) ;
  line(x, y-4, x, y+4) ;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.