Borland C++ reference

getlinesettings

raw OCR

Gets the current line style, pattern, and thickness.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void far getlinesettings(struct linesettingstype far Hineinfo);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

getlinesettings fills a linesettingstype structure pointed to by lineinfo with information about the current line style, pattern, and thickness.

The linesettingstype structure is defined in graphics.h as follows:

struct linesettingstype { int linestyle; unsigned upattern; int thickness; }; linestyle specifies in which style subsequent Hnes will be drawn (such as solid, dotted, centered, dashed). The enumeration line_styles, defined in graphics.h, gives names to these operators:

NameValueDescription
SOLID LINE0Solid line
DOTTEDLINE1Dotted line
CENTER LINE2Centered line
DASHEDLINE3Dashed line
USERBIT LINE4User-defined line style

thickness specifies whether the width of subsequent lines drawn will be normal or thick.

NameValueDescription
NORM_WIDTH1 pixel wide
THICK WIDTH3 pixels wide

upattern is a 16-bit pattern that applies only if linestyle is USERBIT_L1NE (4). In that case, whenever a bit in the pattern word is 1, the corresponding pixel in the line is drawn in the current drawing color. For example, a solid line corresponds to a upattern of 0xFFFF (all pixels drawn), while a dashed line can correspond to a upattern of 0x3333 or OxOFOF. If the

linestyle parameter to setlinestyle is not USERBIT_L1NE(!=4), the upattern

parameter must still be supplied but is ignored.

Return value

None.

See also

Example

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

/* the names of the line  styles supported */
char *lname[] =  { "SOLID_LINE", "DOTTED_LINE", "CENTER_LINE", "DASHED_LINE"
                   "USERBIT_LINE" };
int main (void)
{
   /* request autodetection  */
   int gdriver = DETECT, gmode,  errorcode;
   struct linesettingstype  lineinfo;
   int midx, midy;
   char lstyle[80], lpattern[80] , lwidth[80];
/* initialize graphics  and local variables */
initgraph(&gdriver,  &gmode, "");

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

midx = getmaxx () / 2;
midy = getmaxy () / 2;
/* get information  about current line settings */
getlinesettings (&lineinfo);

/* convert line  information into strings */
sprintf (Istyle, "%s is the line style.", lname[lineinfo.linestyle]
sprintf (Ipattern, "Ox%X is the user-defined line pattern.",
        lineinfo.upattern) ;
sprintf (Iwidth, "%d is the line thickness.", lineinfo.thickness );

/* display the  information */
settextjustify (CENTER_TEXT, CENTER_TEXT);
outtextxy (midx, midy, Istyle);
outtextxy (midx, midy+2*textheight("W"), Ipattern);
outtextxy (midx, midy+4*textheight("W"), Iwidth);

/* clean up  */
getchO  ;
closegraphO  ;
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.