3 % This file is part of the FPC documentation.
4 % Copyright (C) 1997,1999-2000 by the Free Pascal Development team
6 % The FPC documentation is free text; you can redistribute it and/or
7 % modify it under the terms of the GNU Library General Public License as
8 % published by the Free Software Foundation; either version 2 of the
9 % License, or (at your option) any later version.
11 % The FPC Documentation is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 % Library General Public License for more details.
16 % You should have received a copy of the GNU Library General Public
17 % License along with the FPC documentation; see the file COPYING.LIB. If not,
18 % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 % Boston, MA 02111-1307, USA.
21 % Documentation for the 'Graph' unit of Free Pascal.
22 % Michael Van Canneyt, July 1997
23 % Carl Eric Codere, April 1999
24 \chapter{The GRAPH unit.
}
25 This
document describes the
\textbf{GRAPH
} unit for Free Pascal. This unit includes
26 more then
50 graphics routines, that range from low-level calls such as putpixel
27 to high level calls like Circle and Bar3D. Different fill styles and line
28 patterns are supported in most of the routines.
33 \subsection{Compatibility
}
34 Since the graph unit included with
\var{fpc
} is a portable implementation of
35 the Turbo Pascal unit, there are some slight differences between the video
38 \subsubsection{Initialization
}
40 Each graph unit implementation, will have a
320x200 resolution refered to
41 \textit{LowResolution
}. If the hardware for the specific platform does
42 not support that resolution, then it will have to be emulated. Apart
43 from that requirement, all other resolutions will be dependant on the
46 The correct way and portable way to initialize to graphics subsystem, is
47 to first query the hardware, and then from that, decide which mode you
48 wish to support. The routine which does this is called
\textit{QueryAdapterInfo
}.
49 This routine returns a linked list of modes availables, and their
50 mode number as well as driver numbers. It is to note that this list is
51 initialized only once during the lifetime of the application (that is,
52 even if CloseGraph is called, the list will still be valid). The memory
53 allocated for this list is automatically freed as part as the graph
54 unit's exit procedure.
56 You can always use Detect as a parameter to
\textit{InitGraph
}
57 which will initialize the graphics to the highest resolution possible.
59 The following constants are also defined for compatiblity with older
60 applications written with Turbo Pascal, they should no longer be used:
62 \begin{tabular
}{|c|c|c|
}
64 Driver Name & Constant Name & Column x Row & Colors \\
\hline
65 VGA & VGAHi &
640x480 &
16 \\
66 VGA & VGALo &
640x200 &
16 \\
67 VGA & VGAMed &
640x350 &
16 \\
68 VGA & VGA256 &
320x200 &
256 \\
72 \subsubsection{Other differences
}
74 Some notable differences with the Turbo Pascal graph unit are noted
78 \item \textit{Rectangle
} do not write
79 the end points twice, which permits the XORPut write mode to be used
80 effectively for erasing these forms on the screen.
81 \item \textit{RegisterBGIDriver
} and
\textit{InstallUserDriver
} always
82 return errors, as they are not directly supported.
83 \item \textit{DrawPoly
} XORPut write mode does not have the same behaviour
84 as the one in the Turbo Pascal graph unit.
85 \item XORPut write mode is not supported by
\textit{Bar3d
}.
86 \item Passing invalid parameters to
\textit{SetTextStyle
} will not
87 result in the same visual appearance. Make sure your input is valid.
88 \item All routines using sines/cosines (e.g:
\textit{circle
}), don't
89 exactly have the same radii, because the aspect ratio correction is
91 \item PutImage supports clipping.
92 \item \textit{SetRGBPalette
} use the LSB's of the RGB components to
93 set the
color values of the palette. This makes the unit more portable.
94 \item \textit{PaletteType
} is different then the Turbo Pascal version,
95 it uses RGB Values for the palettes.
96 \item \textit{SetAllPalette
} is different then the Turbo Pascal version,
97 it uses the PaletteType as a parameter.
98 \item \textit{GetDefaultPalette
} only returns only at most the
256 first
99 default entries of a palette, even if the mode supports more then
103 \subsection{Coordinate system
}
104 The upper left of the graphics screen is located at position (
0,
0). The x
105 value, which represents the column, increments to the right. The y values,
106 or rows, increment downward. The maximum value which can be set for an x
107 value, for the graphics screen is given by the
\textit{GetMaxX
} routine.
108 The same is true for the y coordinate, except a call to
\textit{GetMaxY
}
111 \subsection{Current pointer
}
112 Some graphics routines support the concept of the current pointer (CP). The
113 current pointer is similar in concept to a text cursor, except that it is
116 When you write in text mode, the text cursor is automatically incremented
117 by the number of characters written. The same is true with the graphics
118 current pointer, which is instead incremented on a pixel basis.
120 For example, the following:
128 will leave the current pointer to the (
100,
100) coordinate pair. The
129 pixels might not be drawn depending on your clipping settings, but the
130 CP is never clipped to clipping boundaries.
132 The following routines set the CP to the new position:
135 \item \textit{ClearDevice
}
136 \item \textit{ClearViewPort
}
137 \item \textit{GraphDefaults
}
138 \item \textit{InitGraph
}
139 \item \textit{LineRel
}
140 \item \textit{LineTo
}
141 \item \textit{MoveRel
}
142 \item \textit{MoveTo
}
143 \item \textit{OutText
}
144 \item \textit{SetGraphMode
}
145 \item \textit{SetViewPort
}
148 \subsection{Error handling
}
150 There is only basic error checking in the graph unit. To get the value of
151 the last error returned by a graphics driver call, call the
152 \textit{GraphResult
} routine. The following routines can set error codes,
156 \item \textit{Bar
} --- ok
157 \item \textit{Bar3D
} --- ok
158 \item \textit{ClearViewPort
}
159 \item \textit{CloseGraph
} --- ok
160 \item \textit{DetectGraph
} --- ok
161 \item \textit{DrawPoly
} --- ok
162 \item \textit{FillPoly
} --- ok
163 \item \textit{FloodFill
} --- ok
164 \item \textit{GetModeName
} --- ok
165 \item \textit{GetRGBPalette
} --- ok
166 \item \textit{InitGraph
} --- ok
167 \item \textit{InstallUserDriver
} --- ok
168 \item \textit{InstallUserFont
} --- ok
169 \item \textit{PieSlice
}
170 \item \textit{RegisterBGIDriver
} --- ok
171 \item \textit{RegisterBGIFont
} --- ok
172 \item \textit{SetAllPalette
} --- ok
173 \item \textit{SetFillPattern
} --- ok
174 \item \textit{SetFillStyle
} --- ok
175 \item \textit{SetGraphBufSize
}
176 \item \textit{SetGraphMode
}
177 \item \textit{SetLineStyle
} --- ok
178 \item \textit{SetPalette
} --- ok
179 \item \textit{SetRGBPalette
} --- ok
180 \item \textit{SetTextJustify
} --- ok
181 \item \textit{SetTextStyle
} --- ok
182 \item \textit{SetViewPort
} --- ok
185 \textit{GraphResult
} is reset to zero after it has been called. Therefore
186 the user should store the value returned by this function into a temporary
187 variable and then use it.
189 \subsection{Write modes
}
191 Write modes permits combining colors with already existing on-screen colors,
192 \textit{PutImage
} supports several write modes, while most other routines
193 support only CopyPut/NormalPut and XORPut modes.
195 The following routines support XORPut write modes (all routines support
199 \item \textit{FillEllipse
}
200 \item \textit{FillPoly
}
201 \item \textit{Arc
} with ThickWidth line styles only
202 \item \textit{Circle
} with ThickWidth line styles only
204 \item \textit{LineRel
}
205 \item \textit{LineTo
}
206 \item \textit{Rectangle
}
207 \item \textit{DrawPoly
}
211 An internal bitmap font is included with this implementation of the graph
212 unit. It also possible to load and use standard Borland CHR external
213 vectorized font files. A bitmapped font is defined in this case by
214 a matrix of
8x8 pixels. A vector font (also referred to as a stroked font)
215 is defined by a series of vectors that tell the graphics system how to draw
218 \subsection{Clipping and Viewports
}
220 \textit{SetViewPort
} makes all output commands operate in a rectangular
221 region of the screen. Most output routines are viewport relative until
222 the viewport is changed. If clipping is active, all graphics is output
223 is clipped to the current region.
225 There is always clipping to the screen boundaries, whatever the clipping
228 \subsection{Internals
}
230 To make porting to a new platform easier, some of the graph unit routines
231 have been designed using procedural variables. Some of the routines have
232 default hooks, while others must absolutely be implemented for every new
233 platform to make the graph unit work.
235 The following routines must be created for every new platform supported:
238 \item \textit{CloseGraph
}
239 \item \textit{DirectPutPixel
}
240 \item \textit{PutPixel
}
241 \item \textit{GetPixel
}
242 \item \textit{InitMode
}
243 \item \textit{SaveVideoState
}
244 \item \textit{RestoreVideoState
}
245 \item \textit{QueryAdapterInfo
}
246 \item \textit{SetRGBPalette
}
247 \item \textit{GetRGBPalette
}
250 The following global variables must be setup for every new platform
254 \var{InternalDriverName
}
256 This variable should be set to a string describing the platform driver
257 name. It is returned by the user function GetDriverName. Some examples
258 of driver names are 'DosGX', 'DirectX', 'QuickDrw','CyberGFX', 'Dive'.
265 The CloseGraph routine is called directly by the user and must
266 do the necessary cleanup by freeing up all platform specific
267 memory allocations, and by calling RestoreVideoState.
271 This routine is one of the most important callback routines with
272 PutPixel, it is called by most of the routines in the graph unit. It
273 is about the same as PutPixel except that the coordinates passed to
274 it are already in global (screen) coordinates, and that clipping has
275 already been performed. Note that the current WriteMode has to be taken
276 into account in this procedure.
280 This callback routine is called by SetGraphMode to actualliy change to
281 the correct video mode. (SetGraphMode is called by InitGraph).
285 This routine is called by InitGraph before changing to the graphics video
286 mode, it should save the old video mode, save any internal video state
287 such as the palette entries.
289 \var{RestoreVideoState
}
291 This routine should be called by CloseGraph, it should restore the video
292 mode to the one saved in SaveVideoState, and restore all appropriate video
293 information, so that the video is in the same state as it was when
294 SaveVideoState was called.
296 \var{QueryAdapterInfo
}
298 This routine might be called by the user BEFORE we are in graphics
299 mode. It is called by the initialization code of the graph unit. It
300 creates a linked list of video capabilities and procedural hooks for
301 all supported video modes on the platform. Look at the DOS version,
302 to see how it works. This linked list can be read by the user before a
303 call to InitGraph to determine which mode to use.
305 The linked list is composed of mode information, as well to pointers
306 to the callback routines cited above. Some additional optional hooks
307 are also possible for those who wish to optimize the speed of the unit.
310 -------------------------------------------------------------
311 \begin{function
}{GetModeName
}
313 Function GetModeName (ModeNumber : smallint) : String;
317 Returns a string with the name of the specified graphics mode. The
318 return values are in the form, XRes x YRes NAME. This function is
319 useful for building menus, display status, and so forth.
322 If the specified
\var{ModeNumber
} is invalid, the function returns an
323 empty string and sets GraphResult to grInvalidMode.
325 \seef{GetDriverName
},
\seep{GetModeRange
},
\seep{GetMaxMode
}
327 ------------------------
328 \begin{procedure
}{SetAllPalette
}
330 Procedure SetAllPalette(var Palette: PaletteType) ;
332 \var{Palette
} is of type PaletteType. The first field in Palette
333 contains the length of the palette. The next
\textit{n
} fields of
334 type
\var{RGBRec
} contains the Red-Green-Blue components to replace
335 that specific
color with. A value of -
1 will not change the previous
338 Note that valid colors depend on the current graphics mode.
340 If the number of palette entries to replace is greater then the
341 number of colors possible on the screen,
\var{GraphResult
} returns
342 a value of
\var{grError
} and no changes to the palette settings will
345 Changes to the palette take effect immediately on the screen. Each time
346 a palette
color is changed, that
color will be changed to the new
color
349 This routine returns
\var{grError
} if called in a direct
color mode.
354 \seep{SetRGBPalette
},
\seep{SetPalette
}
356 ------------------------
358 ------------------------
359 \begin{procedure
}{GetDefaultPalette
}
361 Procedure GetDefaultPalette (Var Palette : PaletteType);
364 Returns a
\var{PaletteType
} record containing the default RGB
color
365 values when the graphics mode is initialized. These values are based
366 on the IBM-PC VGA hardware adapter, but do not change from platform
369 On other platforms the colors may not exactly match those
370 on the IBM-PC, but the match should be close enough for most uses. This
371 value is static and does never change.
373 Even if the modes can support more then
256 color entries, only the
374 256 first colors can be considered as having default values. Therefore,
375 at most this function will return
256 entries. To query all colors over
376 256 yourself, use
\var{GetRGBPalette
} for the entire palette range.
381 \seef{GetColor
},
\seef{GetBkColor
},
\seep{GetRGBPalette
}
385 ------------------------
386 \begin{procedure
}{GetPalette
}
388 Procedure GetPalette (Var Palette : PaletteType);
391 \var{GetPalette
} returns in
\var{Palette
} the current palette. The palette
392 is in LSB RGB format.
394 This routine returns
\var{grError
} if called in a direct
color mode.
399 \seef{GetPaletteSize
},
\seep{SetPalette
}
401 ---------------------------
402 ---------------------------
403 \begin{function
}{GetBkColor
}
405 Function GetBkColor : Word;
408 \var{GetBkColor
} returns the current background
color. If in non direct
color
409 mode, this returns the palette entry, otherwise it returns the direct
410 RGB value of the current drawing
color.
414 \seef{GetColor
},
\seep{SetBkColor
}
416 ---------------------------
417 \begin{function
}{GetColor
}
419 Function GetColor : Word;
422 \var{GetColor
} returns the current drawing
color. If in non direct
color
423 mode, this returns the palette entry, otherwise it returns the direct
424 RGB value of the current drawing
color.
428 \seef{GetColor
},
\seep{SetBkColor
}
430 ---------------------------
431 \begin{procedure
}{GetRGBPalette
}
433 Procedure GetRGBPalette (ColorNum: intege; var Red,Green,Blue : smallint);
436 \var{GetRGBPalette
} gets the
\var{ColorNum
}-th entry in the palette.
437 The Red , Green and Blue values returned arein LSB format.
438 If the palette entry could not be read for a reason,
439 the routine returns
\var{grError
}.
441 This routine returns
\var{grError
} if called in a direct
color mode.
446 \seep{SetAllPallette
},
451 ----------------------------
452 ----------------------------
453 \begin{procedure
}{SetDirectVideo
}
455 Procedure SetDirectVideo (DirectAccess : boolean);
458 Determines how the video access should be done, if DirectAccess
459 is set to TRUE then access will be done directly to video memory, if
460 it is supported, otherwise Operating systems calls will be done to
461 access the video memory.
463 The behaviour of this routine depends on the platform, and is required
464 for example to use the graph unit under older multitaskers such as
465 Desqview (DOS platform). Certain modes re simply not supported
466 via Operating system calls, while others are only supported by the
467 operating system. In those cases this routine is simply ignored.
469 Using operating system calls to plot pixels is much slower then using
470 the direct mode, but it provides more compatibility.
472 \textbf{Platform specific
}
473 Windows NT, OS/
2, Windows '
9x, Windows
3.x, Linux DOSEMU support
474 all
\textit{standard
} video DOS modes, even in DirectVideo mode.
475 Others, like Desqview, Topview, DoubleDOS and MultiDOS might not.
476 In that case,
\vaR{SetDirectVideo
} should be called and set to FALSE.
478 VESA modes are not considered as standard DOS video modes,
479 and should simply not be used under such multitaskers/emulators.
481 Mode-X is not considered a standard DOS mode, but is supported in
482 most modern operating systems, since it uses only standard VGA
483 I/O ports and memory. (Exception: older multitaskers such as Desqview).
491 \seef{GetDirectVideo
}
494 ----------------------------
495 \begin{function
}{GetDirectVideo
}
497 Function GetDirectVideo : boolean;
500 Returns the state of the of DirectAccess flag. If this value returns
501 TRUE, then in the case where it is possible, the video memory is directly
502 accessed to plot graphics points, otherwise operating system calls
509 \seep{SetDirectVideo
}
513 ----------------------------
521 \section{Constants, Types and Variables
}
524 ArcCoordsType = record
525 X,Y,Xstart,Ystart,Xend,Yend : smallint;
527 FillPatternType = Array
[1.
.8] of Byte;
528 FillSettingsType = Record
531 LineSettingsType = Record
532 LineStyle,Pattern, Width : Word;
540 TextSettingsType = Record
541 Font,Direction, CharSize, Horiz, Vert : Word
543 ViewPortType = Record
544 X1,Y1,X2,Y2 : smallint;
552 Colors : array
[0..MaxColors
] of RGBRec;
556 This record is used by
\textit{SetAllPalette
} ,
\textit{GetPalette
} and
557 \textit{GetDefaultPalette
}.
\textit{Size
} indicated the number of RGB
558 entries in this record, followed by the RGB records for each
color. It
559 is to note, that contrary to Turbo Pascal, the RGB components are in
560 the LSB's of the RGB component records. This makes easier compatibility
561 across different hardware platforms.
564 \section{Functions and procedures
}
567 \begin{procedure
}{Arc
}
569 Procedure Arc (X,Y : smallint; stAngle,Endangle, radius : Word);
572 \var{Arc
} draws part of a circle with center at
\var{(X,Y)
}, radius
573 \var{radius
}, starting from angle
\var{stAngle
}, stopping at angle
\var{EndAngle
}.
574 These angles are measured counterclockwise. Information about the last call
575 to
\var{Arc
} can be retrieved by
\var{GetArcCoords
}.
579 \seep{Circle
},
\seep{Ellipse
}
580 \seep{GetArcCoords
},
\seep{PieSlice
},
\seep{Sector
}
583 \begin{procedure
}{Bar
}
585 Procedure Bar (X1,Y1,X2,Y2 : smallint);
588 Draws a rectangle with corners at
\var{(X1,Y1)
} and
\var{(X2,Y2)
}
589 and fills it with the current
color and fill-style.
597 \begin{procedure
}{Bar3D
}
599 Procedure Bar3D (X1,Y1,X2,Y2 : smallint; depth : Word; Top : Boolean);
602 Draws a
3-dimensional Bar with corners at
\var{(X1,Y1)
} and
\var{(X2,Y2)
}
603 and fills it with the current
color and fill-style.
604 \var{Depth
} specifies the number of pixels used to show the depth of the
606 If
\var{Top
} is true; then a
3-dimensional top is drawn.
610 \seep{Bar
},
\seep{Rectangle
}
613 \begin{procedure
}{Circle
}
615 Procedure Circle (X,Y : smallint; Radius : Word);
618 \var{Circle
} draws part of a circle with center at
\var{(X,Y)
}, radius
619 \var{radius
} in the current
color. Each graphics driver contains an
620 aspect ratio used by
\var{Circle
},
\var{Arc
} and
\var{PieSlice
}.
624 \seep{Ellipse
},
\seep{Arc
}
625 \seep{GetArcCoords
},
\seep{PieSlice
},
\seep{Sector
}
628 \begin{procedure
}{ClearDevice
}
630 Procedure ClearDevice ;
633 Clears the graphical screen (with the current
634 background
color), and sets the pointer at
\var{(
0,
0)
}
638 \seep{ClearViewPort
},
\seep{SetBkColor
}
641 \begin{procedure
}{ClearViewPort
}
643 Procedure ClearViewPort ;
646 Clears the current viewport. The current background
color is used as filling
647 color. The pointer is set at
\var{(
0,
0)
}
651 \seep{ClearDevice
},
\seep{SetViewPort
},
\seep{SetBkColor
}
654 \begin{procedure
}{CloseGraph
}
656 Procedure CloseGraph ;
659 Closes the graphical system, restores the
660 screen mode which was active before the graphical mode was
661 activated and frees up any memory allocated in InitGraph.
668 \begin{procedure
}{DetectGraph
}
670 Procedure DetectGraph (Var Driver, Modus : smallint);
673 Checks the hardware in the PC and determines the driver and screen-modus to
674 be used. These are returned in
\var{Driver
} and
\var{Modus
}, and can be fed
676 See the
\var{InitGraph
} for a list of drivers and modi.
684 \begin{procedure
}{DrawPoly
}
686 Procedure DrawPoly (NumPoints : Word; Var PolyPoints);
690 Draws a polygon with
\var{NumPoints
} corner points, using the
691 current
color and linestyle. PolyPoints is an array of type
\var{PointType
}.
693 If there are less the two points in
\var{PolyPoints
}, this routine
694 returns
\var{grError
}.
699 \seep{Bar
}, seep
{Bar3D
},
\seep{Rectangle
}
702 \begin{procedure
}{Ellipse
}
704 Procedure Ellipse (X,Y : smallint; StAngle,EndAngle,XRadius,YRadius : Word);
707 \var{Ellipse
} draws part of an ellipse with center at
\var{(X,Y)
}.
708 \var{XRadius
} and
\var{Yradius
} are the horizontal and vertical radii of the
709 ellipse.
\var{StAngle
} and
\var{EndAngle
} are the starting and stopping angles of
710 the part of the ellipse. They are measured counterclockwise from the X-axis.
712 Information about the last call to
\var{Ellipse
} can be retrieved by
718 \seep{Arc
} \seep{Circle
},
\seep{FillEllipse
}
720 \begin{procedure
}{FillEllipse
}
722 Procedure FillEllipse (X,Y : smallint; Xradius,YRadius: Word);
725 \var{Ellipse
} draws an ellipse with center at
\var{(X,Y)
}.
726 \var{XRadius
} and
\var{Yradius
} are the horizontal and vertical radii of the
727 ellipse. The ellipse is filled with the current
color and fill style.
731 \seep{Arc
} \seep{Circle
},
732 \seep{GetArcCoords
},
\seep{PieSlice
},
\seep{Sector
}
735 \begin{procedure
}{FillPoly
}
737 Procedure FillPoly (NumberPoints : Word; Var PolyPoints);
741 Draws a polygon with
\var{NumPoints
} corner points and fills it
742 using the current
color and fill style. The outline of the polygon
743 is drawn in the current line style and
color as set by
\var{SetLineStyle
}.
744 PolyPoints is an array of type
\var{PointType
}.
749 \seep{Bar
}, seep
{Bar3D
},
\seep{Rectangle
}
751 \begin{procedure
}{FloodFill
}
753 Procedure FloodFill (X,Y : smallint; BorderColor : Word);
757 Fills the area containing the point
\var{(X,Y)
}, bounded by the
color
758 \var{BorderColor
}. The flooding is done using the current fill style
759 and fill
color, as set by
\var{SetFillStyle
} or
\var{SetFillPattern
}.
761 This routine is here for compatibility only,
\var{FillPoly
} should be
762 used instead, since it is much faster.
770 \begin{procedure
}{GetArcCoords
}
772 Procedure GetArcCoords (Var ArcCoords : ArcCoordsType);
775 \var{GetArcCoords
} returns the coordinates of the last
\var{Arc
} or
776 \var{Ellipse
} call. The values are useful for connecting a line to
777 the end of an ellipse.
781 \seep{Arc
},
\seep{Ellipse
}
784 \begin{procedure
}{GetAspectRatio
}
786 Procedure GetAspectRatio (Var Xasp,Yasp : Word);
789 \var{GetAspectRatio
} determines the effective resolution of the screen. The aspect ration can
790 the be calculated as
\var{Xasp/Yasp
}.
792 Each graphics driver uses this aspect ratio to make circles and any circular
793 shape look round on the screen.
797 \seep{InitGraph
},
\seep{SetAspectRatio
}
801 \begin{function
}{GetDriverName
}
803 Function GetDriverName : String;
806 \var{GetDriverName
} returns a string containing the name of the
807 current driver. This name can be anything under FPC, but it is
808 usually indicative of the API and/or platform used to perform the
813 \seef{GetModeName
},
\seep{InitGraph
}
816 \begin{procedure
}{GetFillPattern
}
818 Procedure GetFillPattern (Var FillPattern : FillPatternType);
821 \var{GetFillPattern
} returns an array with the current fill pattern in
\var{FillPattern
}.
822 If no user call has been made to
\var{SetFillPattern
}, the pattern will be
823 filled with
\var{$FF
}.
825 It is to note that the user fill pattern is reset to
\var{$FF
} each time
826 \var{GraphDefaults
} is called.
831 \seep{SetFillPattern
},
\seep{GraphDefaults
}
834 \begin{procedure
}{GetFillSettings
}
836 Procedure GetFillSettings (Var FillInfo : FillSettingsType);
839 \var{GetFillSettings
} returns the current fill-settings in
844 \seep{SetFillPattern
}
847 \begin{function
}{GetGraphMode
}
849 Function GetGraphMode : smallint;
852 \var{GetGraphMode
} returns the current graphical mode. This value is
853 entirely dependant on the hardware platform. To look up what this
854 mode number represents from a capabilities standpoint, you should
855 call either
\var{QueryAdapterInfo
} or
\var{GetModeName
} with the
856 value returned by this function.
860 \seep{InitGraph
},
\seep{QueryAdapterInfo
},
\seep{GetModeName
}
863 \begin{procedure
}{GetImage
}
865 Procedure GetImage (X1,Y1,X2,Y2 : smallint, Var Bitmap);
869 Places a copy of the screen area
\var{(X1,Y1)
} to
\var{X2,Y2
} in
\var{BitMap
}.
870 \var{Bitmap
} is an untyped parameter that must be equal to
12 plus the size
871 of the screen area to save. The first two longints of
\var{Bitmap
} store
872 the width and height of the region. The third longint is reserved and should
875 To make access to the screen faster, it is recommended that the starting
876 points and ending point coordinates be modulo
4 and that the width to
877 save be also modulo
4.
879 To get the size of the bitmap required to save the area, you should call
883 Bitmap must have enough room to contain the image.
889 \begin{procedure
}{GetLineSettings
}
891 Procedure GetLineSettings (Var LineInfo : LineSettingsType);
894 \var{GetLineSettings
} returns the current Line settings in
901 \begin{function
}{GetMaxColor
}
903 Function GetMaxColor : Word;
906 \var{GetMaxColor
} returns the maximum
color-number which can
907 be set with
\var{SetColor
}. This value is zero based, so a screen
908 which supports
16 colors, would return
15.
914 \seef{GetPaletteSize
}
916 \begin{function
}{GetMaxMode
}
918 Function GetMaxMode : Word;
921 \var{GetMaxMode
} returns the highest mode for the current driver. Normally
922 the higher the mode number, the resolution it will be, but this might not
930 \begin{function
}{GetMaxX
}
932 Function GetMaxX : Word;
935 \var{GetMaxX
} returns the maximum horizontal screen
936 length (zero based from
0..
\var{MaxX
}).
942 \begin{function
}{GetMaxY
}
944 Function GetMaxY : Word;
947 \var{GetMaxY
} returns the maximum number of screen
948 lines. (zero based from
0..
\var{MaxY
}).
955 \begin{procedure
}{GetModeRange
}
957 Procedure GetModeRange (GraphDriver : smallint; var LoMode, HiMode: smallint);
960 \var{GetModeRange
} returns the Lowest and Highest mode of the currently
961 installed driver. If the value of
\var{GraphDriver
} is invalid,
\var{LoMode
}
962 and var
{HiMode
} are set to -
1.
966 \seep{InitGraph
},
\seep{GetModeName
}
968 \begin{function
}{GetPaletteSize
}
970 Function GetPaletteSize : Word;
973 \var{GetPaletteSize
} returns the maximum number of entries which
974 can be set in the current palette. In direct
color mode, this simply
975 returns the maximum possible of colors on screen.
977 Usually this has the value
\var{GetMaxColor
} +
1.
986 \begin{function
}{GetPixel
}
988 Function GetPixel (X,Y : smallint) : Word;
991 \var{GetPixel
} returns the
color
992 of the point at
\var{(X,Y)
} The coordinates, as all coordinates
993 are viewport relative.
995 In direct
color mode, the value returned is the direct RGB components of
996 the
color. In palette based modes, this indicates the palette entry number.
1003 \begin{procedure
}{GetTextSettings
}
1005 Procedure GetTextSettings (Var TextInfo : TextSettingsType);
1008 \var{GetTextSettings
} returns the current text style settings : The font,
1009 direction, size and placement as set with
\var{SetTextStyle
} and
1010 \var{SetTextJustify
}.
1014 \seep{SetTextStyle
},
\seep{SetTextJustify
}
1017 \begin{procedure
}{GetViewSettings
}
1019 Procedure GetViewSettings (Var ViewPort : ViewPortType);
1022 \var{GetViewSettings
} returns the current view-port and clipping settings in
1030 \begin{function
}{GetX
}
1032 Function GetX : smallint;
1035 \var{GetX
} returns the X-coordinate of the current pointer. This value is
1042 \begin{function
}{GetY
}
1044 Function GetY : smallint;
1047 \var{GetY
} returns the Y-coordinate of the current pointer. This value is
1054 \begin{procedure
}{GraphDefaults
}
1056 Procedure GraphDefaults ;
1059 \var{GraphDefaults
} homes the current pointer, and resets the graphics
1060 system to the default values for:
1063 \item Active Line style is reset to normal width and filled line.
1064 \item The current fill
color is set to the maximum palette
color.
1065 \item The current fill style is set to
\var{solidfill
}.
1066 \item The user fill pattern is reset to
\var{$FF
}.
1067 \item The current drawing
color is set to white.
1068 \item The current background
color is reset to black.
1069 \item The viewport is reset to (
0,
0,
\var{GetMaxX
},
\var{GetMaxY
}).
1070 \item Clipping is enabled.
1071 \item The active write mode is set to normalput.
1072 \item Text settings are reset to : default font,
\var{HorizDir
},
1073 \var{LeftText
} and
\var{TopText
}.
1076 This routine is called by
\var{SetGraphMode
}.
1081 \seep{SetViewPort
},
\seep{SetFillStyle
},
\seep{SetColor
},
1082 \seep{SetBkColor
},
\seep{SetLineStyle
},
\seep{SetGraphMode
}
1085 \begin{function
}{GraphErrorMsg
}
1087 Function GraphErrorMsg (ErrorCode : smallint) : String;
1091 returns a string describing the error
\var{Errorcode
}. This string can be
1092 used to let the user know what went wrong.
1098 \begin{function
}{GraphResult
}
1100 Function GraphResult : smallint;
1103 \var{GraphResult
} returns an error-code for
1104 the last graphical operation. If the returned value is zero, all went well.
1105 A value different from zero means an error has occurred.
1107 Note that
\var{GraphResult
} is reset to zero after it has been called.
1108 Therefore the value should be saved into a temporary location if you wish
1111 To see which routine might return errors, see the introduction section at
1112 the start of this reference.
1117 \seef{GraphErrorMsg
}
1120 \begin{function
}{ImageSize
}
1122 Function ImageSize (X1,Y1,X2,Y2 : smallint) : longint;
1125 \var{ImageSize
} returns the number of bytes needed to store the image
1126 by
\var{GetImage
} in the rectangle defined by
\var{(X1,Y1)
} and
\var{(X2,Y2)
}.
1127 The image size includes space for several words. The first three longints
1128 are reserved for use by
\var{GetImage
}, the first longint containing the
1129 width of the region, the second containing the height, and the third being
1130 reserved,the following words contains the bitmap itself.
1132 \textit{Compatibility:
}
1133 The value returned by this function is a
32-bit value,
1134 and not a
16-bit value.
1142 \begin{procedure
}{InitGraph
}
1144 Procedure InitGraph (var GraphDriver,GraphModus : smallint;\\
1145 const PathToDriver : string);
1149 \var{InitGraph
} initializes the
\var{graph
} package.
1151 \var{GraphDriver
} has two valid values:
\var{GraphDriver=Detect
} which
1152 performs an auto detect and initializes the highest possible mode with the most
1153 colors. This is dependant on the platform, and many of the non-standard
1154 modes amy not be detected automatically.
\var{graphMode
} is the mode you
1157 \var{PathToDriver
} is only needed, if you use the BGI fonts from
1158 Borland, which are fully supported under FPC.
1160 The exact rundown of
\var{InitGraph
} is as follows: First it calls
1161 \var{QueryAdapterInfo
} to get the possible modes supported by the hardware.
1162 It then saves the video state, initalizes some global variables, then if
1163 auto-detection was requested, calls
\var{GetModeRange
} to get the highest
1164 possible mode available and supported, otherwise it searches if the requested
1165 mode is available in the database. Finally , in either case it calls
1168 If the requested driver or mode is invalid, this function returns either
1169 \var{grError
} or
\var{grInvalidMode
}.
1171 Before calling this function, you should call QueryAdapterInfo, and
1172 go through the list of supported modes to determine which mode suites
1173 your needs. As stated in the introduction, each graph unit implementation
1174 should support a
320x200
color mode.
1179 Introduction, (page
\pageref{se:Introduction
}),
1180 \seep{DetectGraph
},
\seep{CloseGraph
},
\seef{GraphResult
},
1181 \seef{QueryAdapterInfo
}
1187 PathToDriver : string;
1189 gd:=detect;
{ highest possible resolution
}
1190 gm:=
0;
{ not needed, auto detection
}
1191 PathToDriver:='C:
\PP\BGI';
{ path to BGI fonts,
1192 drivers aren't needed
}
1193 InitGraph(gd,gm,PathToDriver);
1194 if GraphResult<>grok then
1195 halt; .....
{ whatever you need
}
1196 CloseGraph;
{ restores the old graphics mode
}
1200 \begin{function
}{InstallUserDriver
}
1202 Function InstallUserDriver (DriverPath : String; AutoDetectPtr: Pointer) : smallint;
1205 This routine is not supported in FPC, it is here only for compatiblity and
1206 always returns
\var{grError
}.
1211 \seep{InitGraph
},
\seef{InstallUserFont
}
1213 \begin{function
}{InstallUserFont
}
1215 Function InstallUserFont (FontPath : String) : smallint;
1218 \var{InstallUserFont
} adds the font in
\var{FontPath
} to the list of fonts
1219 available to the text system. If the maximum number of allocated fonts has
1220 been reached, this routine sets
\var{GraphResult
} to
\var{grError
}.
1224 \seep{InitGraph
},
\seef{InstallUserDriver
}
1226 \begin{procedure
}{Line
}
1228 Procedure Line (X1,Y1,X2,Y2 : smallint);
1231 \var{Line
} draws a line starting from
1232 \var{(X1,Y1
} to
\var{(X2,Y2)
}, in the current line style and
color.
1233 The current pointer is not updated after this call.
1235 This is the base routine which is called by several other routines
1236 in this unit. This routine is somewhat faster then the other
1237 LineXXX routines contained herein.
1243 \seep{LineRel
},
\seep{LineTo
}
1245 \begin{procedure
}{LineRel
}
1247 Procedure LineRel (DX,DY : smallint);
1250 \var{LineRel
} draws a line starting from
1251 the current pointer position to the point
\var{(DX,DY
},
\textbf{relative
} to the
1252 current position, in the current line style and
color. The Current Position
1253 is set to the endpoint of the line.
1257 \seep{Line
},
\seep{LineTo
}
1259 \begin{procedure
}{LineTo
}
1261 Procedure LineTo (DX,DY : smallint);
1264 \var{LineTo
} draws a line starting from
1265 the current pointer position to the point
\var{(DX,DY
},
\textbf{relative
} to the
1266 current position, in the current line style and
color. The Current position
1267 is set to the end of the line.
1271 \seep{LineRel
},
\seep{Line
}
1273 \begin{procedure
}{MoveRel
}
1275 Procedure MoveRel (DX,DY : smallint;
1278 \var{MoveRel
} moves the current pointer to the
1279 point
\var{(DX,DY)
}, relative to the current pointer
1286 \begin{procedure
}{MoveTo
}
1288 Procedure MoveTo (X,Y : smallint);
1291 \var{MoveTo
} moves the current pointer to the
1298 \begin{procedure
}{OutText
}
1300 Procedure OutText (Const TextString : String);
1303 \var{OutText
} puts
\var{TextString
} on the screen, at the current pointer
1304 position, using the current font and text settings. The current pointer is
1305 updated only if the text justification is set to left and is horizontal.
1307 The text is truncated according to the current viewport settings if it
1310 In order to maintain compatibility when using several fonts, use
\var{TextWidth
}
1311 and
\var{TextHeight
} calls to determine the dimensions of the string.
1318 \begin{procedure
}{OutTextXY
}
1320 Procedure OutTextXY (X,Y : smallint; Const TextString : String);
1323 \var{OutText
} puts
\var{TextString
} on the screen, at position
\var{(X,Y)
},
1324 using the current font and text settings.
1326 Contrary to
\var{OutText
} , this routine does not update the current pointer.
1328 In order to maintain compatibility when using several fonts, use
\var{TextWidth
}
1329 and
\var{TextHeight
} calls to determine the dimensions of the string.
1336 \begin{procedure
}{PieSlice
}
1338 Procedure PieSlice (X,Y,stangle,endAngle:smallint;Radius: Word);
1342 draws and fills a sector of a circle with center
\var{(X,Y)
} and radius
1343 \var{Radius
}, starting at angle
\var{StAngle
} and ending at angle
\var{EndAngle
}
1344 using the current fill style and fill pattern. The pie slice is outlined
1345 with the current line style and current active
color.
1349 \seep{Arc
},
\seep{Circle
},
\seep{Sector
}
1351 \begin{procedure
}{PutImage
}
1353 Procedure PutImage (X,Y: smallint; var Bitmap; BitBlt: Word);
1357 Places the bitmap in
\var{Bitmap
} on the screen at upper left
1358 corner
\var{(X, Y)
}.
\var{BitBlt
} determines how the bitmap
1359 will be placed on the screen. Possible values are :
1368 \textit{Compatibility
}
1370 Contrary to the Borland graph unit, putimage
\textit{is
} clipped to the
1371 viewport boundaries.
1376 \seef{ImageSize
},
\seep{GetImage
}
1378 \begin{procedure
}{PutPixel
}
1380 Procedure PutPixel (X,Y : smallint; Color : Word);
1384 \var{(X,Y)
} using
color \var{Color
}. This routine is viewport
1391 \begin{procedure
}{Rectangle
}
1393 Procedure Rectangle (X1,Y1,X2,Y2 : smallint);
1396 Draws a rectangle with
1397 corners at
\var{(X1,Y1)
} and
\var{(X2,Y2)
}, using the current
color and
1398 the current line style.
1402 \seep{Bar
},
\seep{Bar3D
}
1404 \begin{function
}{RegisterBGIDriver
}
1406 Function RegisterBGIDriver (Driver : Pointer) : smallint;
1409 This routine is not supported in FPC. It is here for compatibility and it
1410 always returns
\var{grError
}.
1414 \seef{InstallUserDriver
},
1415 \seef{RegisterBGIFont
}
1417 \begin{function
}{RegisterBGIFont
}
1419 Function RegisterBGIFont (Font : Pointer) : smallint;
1422 This routine permits the user to add a font to the list of known fonts
1423 by the graph unit.
\var{Font
} is a pointer to image of the loaded font.
1425 The value returned is either a negative error number (
\var{grInvalidFont
}),
1426 or the font number you need to use when accessing it via
\var{SetTextStyle
}.
1428 This routine may be called before
\var{InitGraph
}.
1431 \textit{Compatibility
}
1432 Watch out for the byte endian when using this routine. This might work
1433 on little endian machines, and not on big endian machines and vice-versa.
1439 \seef{InstallUserFont
},
1440 \seef{RegisterBGIDriver
}
1442 \begin{procedure
}{RestoreCRTMode
}
1444 Procedure RestoreCRTMode ;
1447 Restores the screen mode which was active before
1448 the graphical mode was started. Can be used to switch back and forth
1449 between text and graphics mode.
1467 InitGraph(Gd, Gm, ' ');
1468 if GraphResult <> grOk then
1470 OutText('<ENTER> to leave graphics:');
1473 Writeln('Now in text mode');
1474 Write('<ENTER> to enter graphics mode:');
1476 SetGraphMode(GetGraphMode);
1477 OutTextXY(
0,
0, 'Back in graphics mode');
1478 OutTextXY(
0, TextHeight('H'), '<ENTER> to quit:');
1483 \begin{procedure
}{Sector
}
1485 Procedure Sector (X,Y : smallint; StAngle,EndAngle,XRadius,YRadius : Word);
1489 draws and fills a sector of an ellipse with center
\var{(X,Y)
} and radii
1490 \var{XRadius
} and
\var{YRadius
}, starting at angle
\var{StAngle
} and ending at angle
1491 \var{EndAngle
}. The sector is outlined in the current
color and filled with
1492 the pattern and
color defined by
\var{SetFillStyle
} or
\var{SetFillPattern
}.
1496 \seep{Arc
},
\seep{Circle
},
\seep{PieSlice
}
1498 \begin{procedure
}{SetActivePage
}
1500 Procedure SetActivePage (Page : Word);
1503 Sets
\var{Page
} as the active page
1504 for all graphical output. This means that all drawing will be done on this
1505 graphics, be it visible or not.
1507 The usual way to make fast animation, is to draw to a non visible active page
1508 and the simply call make that active page the visible page by calling
1509 \var{SetVisualPage
}.
1511 \textit{Compatibility
}:
1512 Not all systems and graphics mode support multiple graphics pages, to
1513 determine how many pages are available see
\var{QueryAdapterInfo
}.
1515 Multiple pages are currently not supported with DOS VESA modes.
1520 \seep{SetVisualPage
},
\seep{QueryAdapterInfo
}
1523 \begin{procedure
}{SetAllPallette
}
1525 Procedure SetAllPallette (Var Palette);
1528 Sets the current palette to
1529 \var{Palette
}.
\var{Palette
} is an untyped variable, usually pointing to a
1530 record of type
\var{PaletteType
} which contains the Red, Green and Blue
1531 components of the RGB components to change for each
color entry. If
1532 the Red, Green and Blue components are equal to -
1 for a specific
color
1533 entry, then that palette entry will not be changed. The size should
1534 contain the size of the palette to change (indexed at zero).
1536 \textit{Compatibility
}:
1538 This call is not the same as in Turbo Pascal. RGB components should be
1539 set in LSB if each of the components has less then
16-bits resolution.
1541 This call is not supported in direct
color modes.
1548 \begin{procedure
}{SetAspectRatio
}
1550 Procedure SetAspectRatio (Xasp,Yasp : Word);
1553 Sets the aspect ratio of the
1554 current screen to
\var{Xasp/Yasp
}. The value of the aspect ratio is used
1555 by certain routines herein to draw circles which will actually appear round
1556 depending on the screen mode.
1560 \seep{InitGraph
},
\seep{GetAspectRatio
}
1562 \begin{procedure
}{SetBkColor
}
1564 Procedure SetBkColor (Color : Word);
1567 Sets the background
color to
1570 The behaviour of this routine depends if we are in a direct
color
1571 mode or not. In direct
color mode, this value represents the direct
1572 RGB values to plot to the screen. In non direct
color mode, the value
1573 represents an index to the
color palette entry on the hardware.
1578 \seef{GetBkColor
},
\seep{SetColor
}
1580 \begin{procedure
}{SetColor
}
1582 Procedure SetColor (Color : Word);
1585 Sets the foreground
color to
1588 The behaviour of this routine depends if we are in a direct
color
1589 mode or not. In direct
color mode, this value represents the direct
1590 RGB values to plot to the screen. In non direct
color mode, the value
1591 represents an index to the
color palette entry on the hardware.
1596 \seef{GetColor
},
\seep{SetBkColor
}
1598 \begin{procedure
}{SetFillPattern
}
1600 Procedure SetFillPattern (Pattern : FillPatternType, Color : Word);
1603 \var{SetFillPattern
} sets the current fill-pattern to
\var{Pattern
}, and
1604 the filling
color to
\var{Color
}. If invalid input is passed to
1605 \var{SetFillPattern
},
\var{GraphResult
} will return
\var{grError
}.
1607 The pattern is an
8x8 raster, corresponding to the
64 bits in
1608 \var{FillPattern
}. Whenever a bit in a pattern byte is valued at
1,
1609 a pixel will be plotted. The pattern and
color is used by
\var{Bar
},
1610 \var{FillPoly
},
\var{FloodFill
},
\var{bar3d
},
\var{FillEllipse
},
1611 \var{Sector
}, and
\var{PieSlice
}.
1617 \seep{GetFillPattern
},
\seep{SetFillStyle
}
1619 \begin{procedure
}{SetFillStyle
}
1621 Procedure SetFillStyle (Pattern, Color : word);
1624 \var{SetFillStyle
} sets the filling pattern and
color to one of the
1625 predefined filling patterns.
\var{Pattern
} can be one of the following predefined
1628 \item \var{EmptyFill
} Uses backgroundcolor.
1629 \item \var{SolidFill
} Uses filling
color
1630 \item \var{LineFill
} Fills with horizontal lines.
1631 \item \var{ltSlashFill
} Fills with lines from left-under to top-right.
1632 \item \var{SlashFill
} Idem as previous, thick lines.
1633 \item \var{BkSlashFill
} Fills with thick lines from left-Top to bottom-right.
1634 \item \var{LtBkSlashFill
} Idem as previous, normal lines.
1635 \item \var{HatchFill
} Fills with a hatch-like pattern.
1636 \item \var{XHatchFill
} Fills with a hatch pattern, rotated
45 degrees.
1637 \item \var{InterLeaveFill
}
1638 \item \var{WideDotFill
} Fills with dots, wide spacing.
1639 \item \var{CloseDotFill
} Fills with dots, narrow spacing.
1640 \item \var{UserFill
} Fills with a user-defined pattern.
1643 If invalid input is passed to
\var{SetFillStyle
},
1644 \var{GraphResult
} will return
\var{grError
}.
1649 \seep{SetFillPattern
}
1651 \begin{procedure
}{SetGraphBufSize
}
1653 Procedure SetGraphBufSize (BufSize : Word);
1656 This routine does nothing in FPC, and is here for compatibility.
1662 \begin{procedure
}{SetGraphMode
}
1664 Procedure SetGraphMode (Mode : smallint);
1667 \var{SetGraphMode
} sets the
1668 graphical mode and clears the screen.
\var{Mode
} must be a valid mode,
1669 which can be queried by
\var{QueryAdapterInfo
}.
1671 If invalid input is passed to
\var{SetGraphMode
}, or if the mode cannot
1672 be set for a reason,
\var{GraphResult
} returns
\var{grInvalidMode
}.
1674 \var{SetGraphMode
} resets all graphics variables to their default
1675 settings (such as if
\var{GraphDefaults
} was called, the active page
1676 is reset to page zero, the visual page is reset to page zero, and the viewport
1677 is set to the entire screen.
1682 \seep{InitGraph
},
\seep{QueryAdapterInfo
}
1684 \begin{procedure
}{SetLineStyle
}
1686 Procedure SetLineStyle (LineStyle, Pattern, Thickness : Word);
1690 sets the drawing style for lines. You can specify a
\var{LineStyle
} which is
1691 one of the following pre-defined constants:
1693 \item \var{Solidln=
0;
} draws a solid line.
1694 \item \var{Dottedln=
1;
} Draws a dotted line.
1695 \item \var{Centerln=
2;
} draws a non-broken centered line.
1696 \item \var{Dashedln=
3;
} draws a dashed line.
1697 \item \var{UserBitln=
4;
} Draws a User-defined bit pattern.
1699 If
\var{UserBitln
} is specified then
\var{Pattern
} contains the bit pattern to
1700 use for drawing the line. A bit of
1 specified a pixel which is on.
1702 In all another cases,
\var{Pattern
} is ignored. The parameter
\var{Thickness
}
1703 indicates how thick the line should be. You can specify one of the following
1704 pre-defined constants:
1706 \item \var{NormWidth=
1}
1707 \item \var{ThickWidth=
3}
1710 If invalid input is passed to
\var{SetLineStyle
} ,
\var{GraphResult
} will
1711 return
\var{grError
}.
1716 \seep{GetLineSettings
}
1718 \begin{procedure
}{SetPalette
}
1720 Procedure SetPalette (ColorNum : Word; Color : Shortint);
1723 \var{SetPalette
} changes the
\var{ColorNum
}-th entry in the palette to
1724 \var{Color
}. For examples,
\var{SetPalette(
0, LightCyan)
} makes the first
1725 color in the palette light cyan.
\var{Color
} only accepts certain default
1726 colors, as specified in the
\var{Color constants
} section. If invalid
1727 input is passed to
\var{SetPalette
},
\var{GraphResult
} returns a value
1728 of
\var{grError
} and the palette remains intact.
1730 Changes made to the palette are immediately visible on the screen.
1732 This routine returns
\var{grError
} if called in a direct
color mode.
1737 \seep{SetAllPallette
},
\seep{SetRGBPalette
}
1739 \begin{procedure
}{SetRGBPalette
}
1741 Procedure SetRGBPalette (ColorNum,Red,Green,Blue : smallint);
1744 \var{SetRGBPalette
} sets the
\var{ColorNum
}-th entry in the palette to the
1745 color with RGB values
\var{Red, Green Blue
}. The Red , Green and Blue values
1746 must be in LSB format. If the palette entry could not be changed for a
1747 reason, the routine returns
\var{grError
}.
1749 This routine returns
\var{grError
} if called in a direct
color mode.
1754 \seep{SetAllPallette
},
1756 \seep{GetRGBPalette
}
1758 \begin{procedure
}{SetTextJustify
}
1760 Procedure SetTextJustify (Horiz, Vert : Word);
1763 \var{SetTextJustify
} controls the placement of new text, relative to the
1764 (graphical) cursor position.
\var{Horiz
} controls horizontal placement, and can be
1765 one of the following pre-defined constants:
1767 \item \var{LeftText=
0;
} Text is set left of the current pointer.
1768 \item \var{CenterText=
1;
} Text is set centered horizontally on the current pointer.
1769 \item \var{RightText=
2;
} Text is set to the right of the current pointer.
1771 \var{Vertical
} controls the vertical placement of the text, relative to the
1772 (graphical) cursor position. Its value can be one of the following
1773 pre-defined constants :
1775 \item \var{BottomText=
0;
} Text is placed under the current pointer.
1776 \item \var{CenterText=
1;
} Text is placed centered vertically on the current pointer.
1777 \item \var{TopText=
2;
}Text is placed above the current pointer.
1780 If invalid input is passed
\var{SetTextJustify
} ,
\var{GraphResult
} returns
1786 \seep{OutText
},
\seep{OutTextXY
}
1788 \begin{procedure
}{SetTextStyle
}
1790 Procedure SetTextStyle (Font,Direction,Magnitude : Word);
1793 \var{SetTextStyle
} controls the style of text to be put on the screen.
1794 pre-defined constants for
\var{Font
} are:
1796 \item \var{DefaultFont=
0;
}
1797 \item \var{TriplexFont=
2;
}
1798 \item \var{SmallFont=
2;
}
1799 \item \var{SansSerifFont=
3;
}
1800 \item \var{GothicFont=
4;
}
1804 Pre-defined constants for
\var{Direction
} are :
1806 \item \var{HorizDir=
0;
}
1807 \item \var{VertDir=
1;
}
1810 Charsize indicated the magnification factor to use when drawing the fonts
1811 to the screen. When using the default internal font, this value can be
1812 any value equal or greater to one. In the case of stroked fonts, the
1813 value should always be equal or greater then
4.
1815 Stroked fonts are usually loaded from disk once onto the heap when a call
1816 is made to
\var{SetTextStyle
}.
1818 If there is an error when using this routine,
\var{GraphResult
} might return
1819 \var{grFontNotFound
},
\var{grNoFontMem
},
\var{grError
},
\var{grIoError
},
1820 \var{grInvalidFont
}, or
\var{grInvalidFontNum
}.
1825 \seep{GetTextSettings
}
1827 \begin{procedure
}{SetUserCharSize
}
1829 Procedure SetUserCharSize (Xasp1,Xasp2,Yasp1,Yasp2 : Word);
1832 Sets the width and height of vector-fonts. The horizontal size is given
1833 by
\var{Xasp1/Xasp2
}, and the vertical size by
\var{Yasp1/Yasp2
}.
1839 \begin{procedure
}{SetViewPort
}
1841 Procedure SetViewPort (X1,Y1,X2,Y2 : smallint; Clip : Boolean);
1844 Sets the current graphical view-port (window) to the rectangle defined by
1845 the top-left corner
\var{(X1,Y1)
} and the bottom-right corner
\var{(X2,Y2)
}.
1846 If
\var{Clip
} is true, anything drawn outside the view-port (window) will be
1847 clipped (i.e. not drawn). Coordinates specified after this call are relative
1848 to the top-left corner of the view-port.
1852 \seep{GetViewSettings
}
1854 \begin{procedure
}{SetVisualPage
}
1856 Procedure SetVisualPage (Page : Word);
1859 \var{SetVisualPage
} sets the video page to page number
\var{Page
}.
1863 \seep{SetActivePage
}
1865 \begin{procedure
}{SetWriteMode
}
1867 Procedure SetWriteMode (Mode : smallint);
1870 \var{SetWriteMode
} controls the drawing of lines on the screen. It controls
1871 the binary operation used when drawing lines on the screen.
\var{Mode
} can
1872 be one of the following pre-defined constants:
1878 If you specify another mode, it is mapped to one of the above acoording to
1879 the following table (for TP compatibility, may be changed in the future):
1881 \item Notput, Orput: CopyPut
1882 \item AndPut: XorPut
1890 \begin{function
}{TextHeight
}
1892 Function TextHeight (S : String) : Word;
1895 \var{TextHeight
} returns the height (in pixels) of the string
\var{S
} in
1896 the current font and text-size.
1903 \begin{function
}{TextWidth
}
1905 Function TextWidth (S : String) : Word;
1908 \var{TextHeight
} returns the width (in pixels) of the string
\var{S
} in
1909 the current font and text-size.