A function is provided to draw lines in a window. You can specify whether you want the function to (1) simply write the line characters, or (2) use intersecting line characters if the line crosses a box or another line.
To draw horizontal or vertical lines, call the video line function, v_line():
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the call, you specify the window coordinates where you want the line to begin (wn_rb and wn_cb) and the length you want the line to extend (length).
For the direction of the line (dir), specify the direction you want the line to be drawn from its origin—UP, DOWN, LEFT, or RIGHT. If you specify UP, DOWN, LEFT or RIGHT, the function simply draws the line characters in the window. It does not draw intersection characters.
You can control whether lines use the proper intersection character when intersecting with other lines. If you want the function to draw intersection characters if the line overwrites a box or another line, OR the direction with X_LINE (e.g., UP | X_LINE).
On terminal-based systems, intersecting lines, boxes, and borders will use the proper intersection character only when two lines of the same type intersect. If you are operating under PCDOS or OS/2, lines will always use the proper intersection characters.
There are a number of limitations associated with output of block graphics characters in terminal versions. If you are using a terminal-based version of Vermont Views, see Chapter 54, "Writing Portable Code," for more information on drawing borders and lines using the block graphics attribute.
Note: If the window has a border, the line will not intersect with the border characters. The border is part of the frame around the window and has no connection to the lines in the buffer.
For the attribute (att), specify the logical attribute with which to display the line.
Specify the style of the line (ln_stylep) to be one of the line styles listed in Table 24.6. Appearance of lines is operating system dependent.
Table 24.6: Line Styles
| Line Style | Description |
| LINE_SLNP | Line using the single-line graphics character |
| LINE_DLNP | Line using the double-line graphics character |
| LINE_SPACEP | Line using the space character |
| LINE_DOTP | Line using the stippled block graphics character or periods |
| LINE_STARP | Line using asterisks |
| LINE_SOLIDP | Line using the solid block graphics or space character |
Drawing lines while observing the intersection of lines is slower than simply drawing a line with UP, DOWN, LEFT, or RIGHT. To draw intersecting lines, the function looks at each character it is overwriting. If the character is a graphics character, the appropriate intersecting graphic character will be used instead of the line character. On terminal-based systems, the speed difference is significant. To speed your program, only use intersecting lines when necessary.