Routines overview
Legend: I = identic implementation (as in BP)
P = same implementation but parameters with different meanings / values
D = different implementation
A = additional one
N = found in BP but not implemented here (absolete)
Initialization routines
(I) ClearDevice (I) CloseGraph (A) CloseGraphRequest
(I) DetectGraph (I) GetDriverName (I) GetGraphMode
(D) GetMaxMode (I) GetModeName (D) GetModeRange
(I) GraphDefaults (A) GraphEnabled (I) GraphErrorMsg
(I) GraphResult (P) InitGraph (N) InstallUserDriver
(A) OpenGLEnabled (N) RegisterBGIDriver (I) RestoreCRTMode
(N) SetGraphBufSize (I) SetGraphMode (A) SetOpenGLMode
(A) SetWindowSize (A) UpdateGraph
Screen management routines
(I) ClearViewPort (A) FreeAnim (A) GetAnim
(I) GetAspectRatio (I) GetImage (I) GetMaxX
(I) GetMaxY (I) GetViewSettings (I) GetX
(I) GetY (I) ImageSize (A) PutAnim
(P) PutImage (I) SetActivePage (I) SetAspectRatio
(I) SetViewPort (I) SetVisualPage (P) SetWriteMode
Color management routines
(I) GetBkColor (I) GetColor (I) GetDefaultPalette
(A) GetNamesPalette (I) GetMaxColor (I) GetPalette
(I) GetPaletteSize (I) GetPixel (A) GetRGBColor
(A) GetRGBComponents (A) GetSystemPalette (I) SetAllPalette
(I) SetBkColor (I) SetColor (I) SetPalette
(I) SetRGBPalette
Drawing primitives routines
(I) Arc (I) Circle (A) DrawBezier
(I) DrawPoly (I) Ellipse (I) GetArcCoords
(I) GetLineSettings (I) Line (I) LineRel
(I) LineTo (I) MoveRel (I) MoveTo
(I) PutPixel (I) Rectangle (A) RotEllipse
(P) SetLineStyle
Filled drawings routines
(I) Bar (I) Bar3D (A) Chord
(I) FillEllipse (I) FillPoly (A) FillRect
(I) FloodFill (I) GetFillPattern (I) GetFillSettings
(A) InvertRect (I) PieSlice (A) RoundRect
(I) Sector (I) SetFillPattern (P) SetFillStyle
(A) SetFloodMode
Text and font management routines
(A) GetFontSettings (I) GetTextSettings (P) InstallUserFont
(I) OutText (I) OutTextXY (N) RegisterBGIFont
(P) SetTextJustify (P) SetTextStyle (D) SetUserCharSize
(I) TextHeight (I) TextWidth
Keyboard management routines (requires WinCrt)
(A) Delay (A) KeyPressed (A) ReadBuf
(A) ReadKey (A) Sound (A) WriteBuf
Mouse management routines (requires WinMouse)
(A) GetMouseButtons (A) GetMouseEvent (A) GetMouseX
(A) GetMouseY (A) GetMouseWheel (A) PollMouseEvent
(A) PutMouseEvent (A) SetMouseXY
Types overview
AnimatType = record
bitHnd,maskHnd,bkgHnd: longword;
end;
ArcCoordsType = record
x,y,xstart,ystart,xend,yend: smallint;
end;
FillSettingsType = record
pattern: word;
color: longword;
end;
FillPatternType = array [1..8] of byte;
LineSettingsType = record
linestyle,pattern,thickness: word;
end;
PaletteType = record
size: word;
colors: array[0..255] of longword;
end;
PointType = record
x,y: longint;
end;
TextSettingsType = record
font,direction,charsize,horiz,vert: word;
end;
ViewPortType = record
x1,y1,x2,y2: smallint;
clip: boolean;
end;
MouseEventType = record
action: word;
buttons: word;
x,y: word;
wheel: smallint;
end;
Variables & constants overview
Wingraph version (string)
WinGraphVer
Error codes (smallint)
grOk,grNoInitGraph,grInvalidDriver,grInvalidMode,grNotWindow,grInvalidFont,
grInvalidFontNum,grInvalidParam,grNoPalette,grNoOpenGL,grError
Graphics drivers (smallint)
D1bit,D4bit,D8bit,Detect,NoPalette,HercMono,VGA,SVGA
Graphics modes (smallint)
m320x200,m640x200,m640x350,m640x480,m720x350,m800x600,m1024x768,m1280x1024,
mDefault,mMaximized,mFullScr,mCustom,HercMonoHi,VGALo,VGAMed,VGAHi
Update graphics constants (word)
UpdateOff,UpdateOn,UpdateNow
OpenGL drawing modes (boolean)
DirectOn,DirectOff
Clipping constants (boolean)
ClipOn,ClipOff
Raster operation constants (word)
CopyPut,XorPut,OrPut,AndPut,NotPut,NotOrPut,InvBitOrPut,InvScrAndPut,
NormalPut,TransPut,MaskPut,BkgPut
Drawing modes on screen (smallint)
CopyMode,XorMode,OrMode,AndMode,NotMode,NotScrMode,NotXorMode,NotOrMode,
NotAndMode,InvColAndMode,InvColOrMode,InvScrAndMode,InvScrOrMode,BlackMode,
WhiteMode,EmptyMode,Transparent,Opaque
Alphabetical color names (longword)
AliceBlue,AlizarinCrimson,Amber,Amethyst,AntiqueWhite,Aquamarine,Asparagus,
Azure,Beige,Bisque,Bistre,BitterLemon,Black,BlanchedAlmond,BlazeOrange,Blue,
BlueViolet,BondiBlue,Brass,BrightGreen,BrightTurquoise,BrightViolet,Bronze,
Brown,Buff,Burgundy,BurlyWood,BurntOrange,BurntSienna,BurntUmber,CadetBlue,
CamouflageGreen,Cardinal,Carmine,Carrot,Casper,Celadon,Cerise,Cerulean,
CeruleanBlue,Chartreuse,Chocolate,Cinnamon,Cobalt,Copper,Coral,Corn,
CornflowerBlue,Cornsilk,Cream,Crimson,Cyan,DarkBlue,DarkBrown,DarkCerulean,
DarkChestnut,DarkCoral,DarkCyan,DarkGoldenrod,DarkGray,DarkGreen,DarkIndigo,
DarkKhaki,DarkMagenta,DarkOlive,DarkOliveGreen,DarkOrange,DarkOrchid,
DarkPastelGreen,DarkPink,DarkRed,DarkSalmon,DarkScarlet,DarkSeaGreen,
DarkSlateBlue,DarkSlateGray,DarkSpringGreen,DarkTan,DarkTangerine,
DarkTeaGreen,DarkTerraCotta,DarkTurquoise,DarkViolet,DeepPink,DeepSkyBlue,
Denim,DimGray,DodgerBlue,Emerald,Eggplant,FernGreen,FireBrick,Flax,
FloralWhite,ForestGreen,Fractal,Fuchsia,Gainsboro,Gamboge,GhostWhite,Gold,
Goldenrod,Gray,GrayAsparagus,GrayTeaGreen,Green,GreenYellow,Heliotrope,
Honeydew,HotPink,IndianRed,Indigo,InternationalKleinBlue,InternationalOrange,
Ivory,Jade,Khaki,Lavender,LavenderBlush,LawnGreen,Lemon,LemonChiffon,
LightBlue,LightBrown,LightCoral,LightCyan,LightGoldenrodYellow,LightGray,
LightGreen,LightMagenta,LightPink,LightRed,LightSalmon,LightSeaGreen,
LightSkyBlue,LightSlateGray,LightSteelBlue,LightYellow,Lilac,Lime,LimeGreen,
Linen,Magenta,Malachite,Maroon,Mauve,MediumAquamarine,MediumBlue,
MediumOrchid,MediumPurple,MediumSeaGreen,MediumSlateBlue,MediumSpringGreen,
MediumTurquoise,MediumVioletRed,MidnightBlue,MintCream,MistyRose,Moccasin,
MoneyGreen,Monza,MossGreen,MountbattenPink,Mustard,NavajoWhite,Navy,Ochre,
OldGold,OldLace,Olive,OliveDrab,Orange,OrangeRed,Orchid,PaleBrown,
PaleCarmine,PaleChestnut,PaleCornflowerBlue,PaleGoldenrod,PaleGreen,
PaleMagenta,PaleMauve,PalePink,PaleSandyBrown,PaleTurquoise,PaleVioletRed,
PapayaWhip,PastelGreen,PastelPink,Peach,PeachOrange,PeachPuff,PeachYellow,
Pear,Periwinkle,PersianBlue,Peru,PineGreen,Pink,PinkOrange,Plum,PowderBlue,
PrussianBlue,Puce,Pumpkin,Purple,RawUmber,Red,Reef,RobinEggBlue,RosyBrown,
RoyalBlue,Russet,Rust,SaddleBrown,Saffron,Salmon,SandyBrown,Sangria,Sapphire,
Scarlet,SchoolBusYellow,SeaGreen,SeaShell,SelectiveYellow,Sepia,Sienna,
Silver,SkyBlue,SlateBlue,SlateGray,Snow,SpringGreen,SteelBlue,SwampGreen,
Taupe,Tangerine,Teal,TeaGreen,Tenne,TerraCotta,Thistle,Tomato,Turquoise,
Ultramarine,Vermilion,Violet,VioletEggplant,Viridian,Wheat,White,WhiteSmoke,
Wisteria,Yellow,YellowGreen,Zinnwaldite
Drawing style for lines (word)
SolidLn,DottedLn,DashDotLn,DashedLn,DashDotDotLn,UserBitLn,NullLn
Thick constants for lines (word)
NormWidth,DoubleWidth,TripleWidth,QuadWidth,ThickWidth
Filling patterns (word)
EmptyFill,SolidFill,LineFill,ColFill,HatchFill,SlashFill,BkSlashFill,
XHatchFill,UserFill,NoFill
Bar3D constants (boolean)
TopOn,TopOff
Flood mode constants (smallint)
BorderFlood,SurfaceFlood
Justify constants for text (word)
LeftText,CenterText,RightText,TopText,BottomText,BaselineText
Direction constants for text (word)
HorizDir,VertDir
Font constants for text (word)
CourierNewFont,MSSansSerifFont,TimesNewRomanFont,ArialFont,
DefaultFont
More font constants for text (word)
ItalicFont,UnderlineFont,BoldFont
Caret format: block or underline (boolean)
CaretBlock
Caret blink rate in tenths of a second (word)
BlinkRate
Mouse constants (word)
MouseActionDown,MouseActionUp,MouseActionMove,MouseActionWheel,
MouseLeftButton,MouseRightButton,MouseMiddleButton,MouseShiftKey,
MouseCtrlKey
WinGraph routines
WinGraph is the main unit used to perform graphics in a GUI window using a set of routines similar to those from Borland Pascal (BP) graph unit.
-------------------------------------------------------------------
procedure Arc(x,y:smallint; start,stop,radius:word);
-------------------------------------------------------------------
Draws part of a circle with center at (x,y), radius (radius), starting from
angle (start), stopping at angle (stop). These angles are measured
counter-clockwise. It uses current foreground color. To draw an entire
circle use Circle.
Arc is a particular case of Ellipse.
-------------------------------------------------------------------
procedure Bar(x1,y1,x2,y2:smallint);
-------------------------------------------------------------------
Draws and fills a rectangle with opposite corners at (x1,y1) and (x2,y2), using the current fill style and color. This rectangle has no border. Use FillRect to draw a filled rectangle with border.
-------------------------------------------------------------------
procedure Bar3D(x1,y1,x2,y2:smallint; depth:word; top:boolean);
-------------------------------------------------------------------
Draws and fills a 3-dimensional bar with opposite corners of the front facet
at (x1,y1) and (x2,y2). It uses the current foreground color. Only front facet
is filled with the current fill style and color. Argument (depth) specifies
the number of pixels used to show the depth of the bar. If (top) is true,
then a 3-dimensional top is drawn. Its pre-defined values are
TopOn = true
TopOff = false
Use Bar to draw a 2-dimensional bar.
-------------------------------------------------------------------
procedure Chord(x,y:smallint; start,stop,xradius,yradius:word);
-------------------------------------------------------------------
Draws and fills a chord (a region bounded by the intersection of an ellipse
and a line segment - called a secant). It uses the current foreground color
and fill style. The arguments have the same meaning as in Ellipse. To draw a
sector of an ellipse use Sector.
-------------------------------------------------------------------
procedure Circle(x,y:smallint; radius:word);
-------------------------------------------------------------------
Draws a complete circle with center at (x,y) and radius (radius). To draw
part of a circle use Arc.
Circle is a particular case of Ellipse.
-------------------------------------------------------------------
procedure ClearDevice;
-------------------------------------------------------------------
Clears the entire graphics screen using ClearViewPort routine. See that
routine for details. Current pointer is reset at (0,0), that is top-left corner of the screen.
-------------------------------------------------------------------
procedure ClearViewPort;
-------------------------------------------------------------------
Clears the current viewport. The current background color is used as filling
color. The pointer is set at (0,0), that is top-left corner of the viewport. See also SetViewPort and SetBkColor for more details.
-------------------------------------------------------------------
procedure CloseGraph;
-------------------------------------------------------------------
Closes the graphics window and releases all resources related to it. The
parent console window is shown again in foreground (if any). You can restore back the graphics
window using SetGraphMode or InitGraph.
-------------------------------------------------------------------
function CloseGraphRequest: boolean;
-------------------------------------------------------------------
It checks whether the user clicked the close button of the graphics window
with the mouse. It is up to the programmer to handle this request. Usually,
CloseGraph routine must be invoked. If the window does not have a title bar
such an event cannot be recorded.
If WinCrt unit is included, a sequence of keystrokes #0#107 (Alt-F4) is also generated.
-------------------------------------------------------------------
procedure DetectGraph(out driver,mode:smallint);
-------------------------------------------------------------------
Returns default values for graphics driver (driver) and mode (mode). These
values equal driver=NoPalette and mode=mDefault. That is, a window with
all colors available and with default size. See InitGraph for a list of drivers
and modes.
-------------------------------------------------------------------
procedure DrawBezier(nrpoints:word; var polypoints);
-------------------------------------------------------------------
Draws one or more cubic Bezier curves, using the current foreground color.
A Bezier curve is defined by two endpoints and two control points in between.
A number of 3N+1 vertices will define exactly N Bezier curves. The arguments
are the same as in DrawPoly.
It can be used to draw irregular curves, but a particular case is a rotated ellipse. See RotEllipse for details.
-------------------------------------------------------------------
procedure DrawPoly(nrpoints:word; var polypoints);
-------------------------------------------------------------------
Draws a polygon with (nrpoints) corner points, using the current foreground
color and line style. Argument (polypoints) should be an array of type
PointType containing at least (nrpoints) records. No check is performed.
The last corner point is not drawn.
It is usually faster that using several LineTo calls.
-------------------------------------------------------------------
procedure Ellipse(x,y:smallint; start,stop,xradius,yradius:word);
-------------------------------------------------------------------
Draws part of an ellipse with center at (x,y). Arguments (xradius) and (yradius)
are the horizontal and vertical radii of the ellipse, (start) and (stop) are
the starting and stopping angles of the arc of the ellipse. They are measured
counter-clockwise from the x-axis (3 o’clock is equal to 0 degrees). It uses
current foreground color. To draw part of a circle use Arc.
To draw a rotated ellipse use RotEllipse.
-------------------------------------------------------------------
procedure FillEllipse(x,y:smallint;xradius,yradius:word);
-------------------------------------------------------------------
Draws and fills an entire ellipse with center at (x,y). Arguments (xradius)
and (yradius) are the horizontal and vertical radii of the ellipse. It uses
the current foreground color and fill style. To draw a sector of an ellipse
use Sector.
-------------------------------------------------------------------
procedure FillPoly(nrpoints:word; var polypoints);
-------------------------------------------------------------------
Draws and fills a polygon, using the current foreground color, line and fill
style. The arguments are the same as in DrawPoly. The polygon is closed automatically by drawing a line from the last vertex
to the first.
-------------------------------------------------------------------
procedure FillRect(x1,y1,x2,y2:smallint);
-------------------------------------------------------------------
Draws and fills a rectangle, using the current foreground color, line and fill
style. The arguments are the same as in Rectangle. To draw a borderless
rectangle use Bar instead.
FillRect is a particular case of FillPoly.
-------------------------------------------------------------------
procedure FloodFill(x,y:smallint; color:longword);
-------------------------------------------------------------------
Fills a region surrounding the point (x,y) until a color-condition is met.
This condition depends on (color) and the flood mode. This mode is set with
SetFloodMode routine.
There are some reasons this routine might fail:
(1) the filling could not be completed (out of memory) - unlikely
(2) the specified point has the boundary color specified by the (color)
parameter (in BorderFlood mode)
(3) the specified point does not have the color specified by (color)
parameter (in SurfaceFlood mode)
(4) the point is outside the current viewport, that is, it is not visible
See SetFloodMode for details.
-------------------------------------------------------------------
procedure FreeAnim(var anim:AnimatType);
-------------------------------------------------------------------
Frees the animation resources associated with the animation handle (anim). See GetAnim for more details.
-------------------------------------------------------------------
procedure GetAnim(x1,y1,x2,y2:smallint; color:longword; out anim:AnimatType);
-------------------------------------------------------------------
An animation structure contains a bitmap, its mask and a background image.
With such a structure you can create transparent bitmaps and animations,
but you have no programmatic access to this structure.
GetAnim returns in variable (anim) the handle of an animation with a bitmap image taken from screen in the rectangle defined by coordinates (x1,y1,x2,y2). A mask image is also created and room for background image is reserved. The system stores itself all animation resources into memory. Use FreeAnim to release the memory after use. The (color) is the transparent color to be set. This color is turned into black in the bitmap image and OR-ed with the screen color. Use PutAnim to place the animation back on screen.
-------------------------------------------------------------------
procedure GetArcCoords(out arccoords:ArcCoordsType);
-------------------------------------------------------------------
Returns the coordinates of the last Arc, Circle or Ellipse call.
The structure (arccoords) contains the coordinates of the conic center, start and end arc coordinates.
-------------------------------------------------------------------
procedure GetAspectRatio(out xasp,yasp:word);
-------------------------------------------------------------------
Returns the aspect ratio of the screen as given by xasp/yasp. To set a new
aspect ratio use SetAspectRatio. See that routine for more details.
-------------------------------------------------------------------
function GetBkColor: longword;
-------------------------------------------------------------------
Returns the current background color. This is a palette entry for palette-based
drivers and an absolute RGB color for non-palette driver. Use SetBkColor to set
a new color.
-------------------------------------------------------------------
function GetColor: longword;
-------------------------------------------------------------------
Returns the current drawing color. This is a palette entry for palette-based
drivers and an absolute RGB color for non-palette driver. Use SetColor to set
a new color.
-------------------------------------------------------------------
procedure GetDefaultPalette(out palette:PaletteType);
-------------------------------------------------------------------
Returns default VGA palette with maximum of 256 colors. By default, in
palette-based drivers, all color names are mapped to entries into this palette.
In this manner you get the same composition for each of 16 basic colors as
in BP graph unit. To retrive standard (real) composition for each color name
you should use GetNamesPalette.
-------------------------------------------------------------------
function GetDriverName:shortstring;
-------------------------------------------------------------------
Returns the name of the selected graphics driver (and number of available
colors). See InitGraph for a list of graphics drivers.
-------------------------------------------------------------------
procedure GetFillPattern(out fillpattern:FillPatternType);
-------------------------------------------------------------------
Returns in (fillpattern) the current fill-pattern array. This was set using
SetFillPattern routine.
-------------------------------------------------------------------
procedure GetFillSettings(out fillinfo:FillSettingsType);
-------------------------------------------------------------------
Returns the current fill-settings in (fillinfo). This structure contains the
fill pattern and color, as set by SetFillStyle routine.
-------------------------------------------------------------------
procedure GetFontSettings(out fontname:shortstring; out width,height:word;
out ttfont:boolean);
-------------------------------------------------------------------
Retrieves some information about the current selected font. First argument
contains the full registered name of the font (ex. 'Courier New'). It is the same name used by routine InstallUserFont when the font was installed.
Variables (width) and (height) contain the maximum dimensions of the
characters in the font. If you want to retrive the dimensions of specific
characters use TextWidth and TextHeight routines. Boolean argument (ttfont)
specify if the technology of this font is a TrueType one. If so, the text
can be rotated on screen using SetTextStyle routine. Otherwise, it cannot be
rotated.
-------------------------------------------------------------------
function GetGraphMode:smallint;
-------------------------------------------------------------------
Returns the current (or last used) graphics mode. See InitGraph for a list
of graphics modes.
-------------------------------------------------------------------
procedure GetImage(x1,y1,x2,y2:smallint; out bitmap);
-------------------------------------------------------------------
Places a copy of the screen area given by rectangle with coordinates
(x1,y1,x2,y2) in the variable (bitmap). This variable must have enough room to
accomodate the image (use ImageSize to get the exact size). Afterwards the
image can be put back on screen using PutImage.
The format of bitmap is hardcoded to 24 bits per pixel, so it is driver independent. In fact (bitmap) will contain the complet structure of a BMP image and can be saved on disk and loaded into your favourite image viewer.
See PutImage for more details.
-------------------------------------------------------------------
procedure GetLineSettings(out lineinfo:LineSettingsType);
-------------------------------------------------------------------
Returns the current line settings in (lineinfo). That is, line style, pattern
and thickness, as set by SetLineStyle.
-------------------------------------------------------------------
procedure GetNamesPalette(out palette:PaletteType);
-------------------------------------------------------------------
Returns the palette having entries the color names. It stores the standard
composition for all color names defined by WinGraph. In non-palette driver,
color names are mapped to entries into this palette. This is not the default
palette. The first color entry in this palette is not Black. There is a total
of 256 pre-defined color names. If you feel this is useless for you, or if you
want to retrive the legacy values of 16 color names as in BP, please recompile
the source with conditional 256_COLOR_NAMES disabled.
See the screenshot "colors.gif" in "\doc" folder and also the section Alphabetical color names.
-------------------------------------------------------------------
function GetMaxColor: longword;
-------------------------------------------------------------------
Returns the highest color which can be set with SetColor or other routines
that accept colors. Depending on palette, this color is not always White.
All colors between 0 and GetMaxColor are guarantied to be valid.
In palette-based drivers this function equals GetPaletteSize -1, otherwise it equals $FFFFFF.
-------------------------------------------------------------------
function GetMaxMode: smallint;
-------------------------------------------------------------------
Returns the maximum valid mode number. This is always mFullScr. See
InitGraph for more details. If you want to retrive user screen dimensions
(desktop dimensions) call GetModeRange.
-------------------------------------------------------------------
function GetMaxX: smallint;
-------------------------------------------------------------------
Returns the maximum x-coordinate (horizontal) in pixels. This equals
the client area width minus 1. Maximum is placed on the right side.
-------------------------------------------------------------------
function GetMaxY: smallint;
-------------------------------------------------------------------
Returns the maximum y-coordinate (vertical) in pixels. This equals
the client area height minus 1. Maximum is placed on the bottom side.
-------------------------------------------------------------------
function GetModeName(mode:smallint): shortstring;
-------------------------------------------------------------------
Returns the name of the specified graphics mode (mode). See InitGraph for
a list of graphics modes.
-------------------------------------------------------------------
procedure GetModeRange(driver:smallint; out width,height:smallint);
-------------------------------------------------------------------
Contrary to BP, it returns the width and height, in pixels, of the user
screen (desktop). That is, (width) contains the width and (height) contains
the height. They do not depend on the (driver), which is a dummy argument.
Using this routine you can learn about the dimensions of the user screen
before calling InitGraph.
-------------------------------------------------------------------
procedure GetPalette(out palette:PaletteType);
-------------------------------------------------------------------
Returns in (palette) the current palette. To retrive just the palette size
use GetPaletteSize. See SetAllPalette for more details on palettes.
-------------------------------------------------------------------
function GetPaletteSize: smallint;
-------------------------------------------------------------------
Returns the maximum number of entries in the current palette. To retrive
the entire palette structure use GetPalette. See SetAllPalette for more details on palettes.
-------------------------------------------------------------------
function GetPixel(x,y:smallint): longword;
-------------------------------------------------------------------
Gets the pixel color of the point at position (x,y). This is a palette entry
for palette-based drivers and an absolute RGB color for non-palette driver.
To set a new color for the pixel use PutPixel.
-------------------------------------------------------------------
function GetRGBColor(r,g,b:word): longword;
-------------------------------------------------------------------
For non-palette driver it returns an absolute RGB color value. In palette-based
drivers it returns the color (palette index) nearest to the specified RGB composition.
See SetRGBPalette routine for a description of input parameters.
You can use it before InitGraph to create true color entries into a palette. Use GetRGBComponents to convert an absolute RGB color backward into its RGB
intensity components.
-------------------------------------------------------------------
procedure GetRGBComponents(color:longword; out r,g,b:word);
-------------------------------------------------------------------
Returns the (Red,Green,Blue) intensity components of the color (color) in
(r), (g), (b) variables. Their values range between
0 and 255. For example, Black returns (0,0,0). See also GetRGBColor. Parameter (color) is a palette index in palette-based drivers
and a true RGB color for the non-palette driver.
-------------------------------------------------------------------
procedure GetSystemPalette(out palette:PaletteType);
-------------------------------------------------------------------
Returns a maximum of
256 colors from Windows system palette. This is the palette initialized
by the operating system at start-up. You have no guaranty that this
palette is the same across all systems. In fact, it's not.
-------------------------------------------------------------------
procedure GetTextSettings(out textinfo:TextSettingsType);
-------------------------------------------------------------------
Returns the current font and text settings in argument (textinfo). This
contains the font type, direction, magnification, horizontal and vertical alignment, as set by SetTextStyle and SetTextJustify routines.
-------------------------------------------------------------------
procedure GetViewSettings(out viewport:ViewPortType);
-------------------------------------------------------------------
Returns the current viewport and clipping settings in (viewport). You can
change these settings using SetViewPort.
-------------------------------------------------------------------
function GetX: smallint;
-------------------------------------------------------------------
Returns the x-coordinate of the current position of the graphical pointer
in pixels. It ranges between 0 and GetMaxX. It increases from left to right.
-------------------------------------------------------------------
function GetY: smallint;
-------------------------------------------------------------------
Returns the y-coordinate of the current position of the graphical pointer
in pixels. It ranges between 0 and GetMaxY. It increases from top to bottom.
-------------------------------------------------------------------
procedure GraphDefaults;
-------------------------------------------------------------------
Resets graphics
settings to their default values for palette, line style, foreground
and background colors, filling pattern and style, text style and
placement, viewport, write mode and aspect ratio. This routine is first
used by InitGraph.
-------------------------------------------------------------------
function GraphEnabled: boolean;
-------------------------------------------------------------------
Tests if the graphics window is enabled. If so, you can perform graphics.
Usually, after InitGraph, this routine returns true and, after CloseGraph, it returns false.
-------------------------------------------------------------------
function GraphErrorMsg(errorcode:smallint): shortstring;
-------------------------------------------------------------------
Returns a string describing the error (errorcode). This string can be
used to let the user know what went wrong. We have the following types of error codes:
grOk - no error
grInvalidDriver - invalid graphics driver
grInvalidMode - invalid graphics mode
grNotWindow - creation of graphics window failed
grNoInitGraph - graphics window not initialized
grInvalidFont - invalid font selection
grInvalidFontNum - invalid font number
grInvalidParam - invalid parameter value
grNoPalette - no palette available
grNoOpenGL - OpenGL driver not initialized
grError - general graphics error
Use GraphResult to return an error code.
-------------------------------------------------------------------
function GraphResult: smallint;
-------------------------------------------------------------------
Returns an error code for the last graphics operation. If the returned value
is zero (grOK), all went well. A value different from zero means an error has
occurred. Most of routines which draw something on screen, set or query some
drawing attributes can produce a GraphResult different from zero. Calling this routine once will reset the error code back to zero. GraphResult should be used after InitGraph to discover initialization problems,
since that routine may fail on some situations: graphics driver and mode is
not supported, or default fonts cannot be installed, or OpenGL driver cannot
be initialized, etc.
Each error code has an associated error message. Use GraphErrorMsg to get this message. See that routine for a list of error codes.
-------------------------------------------------------------------
function ImageSize(x1,y1,x2,y2:smallint): longint;
-------------------------------------------------------------------
Returns the number of bytes needed to store the image from the rectangle
defined by coordinates (x1,y1,x2,y2). It should be used before calling GetImage
and PutImage. See those routines for details.
-------------------------------------------------------------------
procedure InitGraph(var driver,mode:smallint; const title:shortstring);
-------------------------------------------------------------------
Initializes the graphics window. Graphics drivers (driver) are:
D1bit - 2 colors
D4bit - 16 colors
D8bit - 256 colors
Detect - routine DetectGraph is used
NoPalette - no palette, all colors in the system are available
HercMono=D1bit
VGA=D4bit
SVGA=D8bit
If you select a driver with palette, you get a limited number of available colors (the palette entries, 256 or less). See also SetAllPalette. If NoPalette driver is selected then all colors generated by the system are available. Color names are mapped to their pre-defined RGB values. If driver=Detect then InitGraph returns in (driver) and (mode) their default values given by DetectGraph and initializes the graphics window.
Graphics modes (mode) are:
m320x200 - 320 by 200 pixels
m640x200 - 640 by 200 pixels
m640x350 - and so on ...
m640x480
m720x350
m800x600
m1024x768
m1280x1024
mDefault - default size given by Windows system
mMaximized - a maximized window (with caption bar)
mFullScr - a full screen window (no caption bar)
mCustom - a custom sized window (use SetWindowSize first to set its dimensions)
HercMonoHi=m720x350
VGALo=m640x200
VGAMed=m640x350
VGAHi=m640x480
All modes for which the graphics window fits into the screen (with or without a caption bar) are valid. The third argument (title), if not empty, sets the title of the graphics window, otherwise this title is set to WinGraph version string (WinGraphVer).
The routine sets the attributes for the graphics window and creates a dedicated thread for messaging the window. Before returning it sets the active page, installs several default fonts, invokes GraphDefaults to get default settings for drawings, enables OpenGL driver (if conditional INIT_OPENGL is set in the source code) and hides the parent console window (if any and if conditional HIDE_CONSOLE is set in the source code as well ). See GraphResult for possible failure problems.
Most of WinGraph routines do nothing useful before InitGraph is invoked. Anyway, the following ones do work:
DetectGraph
GetDefaultPalette
GetNamesPalette
GetMaxMode
GetModeName
GetModeRange
GraphEnabled
GraphErrorMsg
GraphResult
ImageSize
InitGraph
GetRGBColor
GetRGBComponents
SetGraphMode
SetWindowSize
Use CloseGraph to close the graphics window.
-------------------------------------------------------------------
function InstallUserFont(const fontname:shortstring): smallint;
-------------------------------------------------------------------
Installs a new font and returns its index into the installed font table.
This index can be used with SetTextStyle to enable the font for texts. The parameter (fontname) must be a valid family font name registered into the
system (ex: ' Fixedsys'). The name IS case sensitive. If the font cannot be
registered, InstallUserFont will return -1.
InitGraph installs several fonts using this routine. Default font is set to 'Courier New'. Other installed fonts are listed in section Font constants for text. For more info about fonts see SetTextStyle.
-------------------------------------------------------------------
procedure InvertRect(x1,y1,x2,y2:smallint);
-------------------------------------------------------------------
Performs a logical NOT operation on the color values for each pixel in the
specified rectangle defined by coordinates (x1,y1,x2,y2).
On monochrome driver, InvertRect makes white pixels black and black pixels white. On color drivers, the inversion depends on how colors are generated. Calling InvertRect twice for the same rectangle restores the display to its previous colors. It does not perform well on palette-based drivers. See also SetWriteMode.
-------------------------------------------------------------------
procedure Line(x1,y1,x2,y2:smallint);
-------------------------------------------------------------------
Draws a line starting from (x1,y1) to (x2,y2), using the current foregroung
color and line style. The current position is moved to (x2,y2). See LineTo for more details.
-------------------------------------------------------------------
procedure LineRel(dx,dy:smallint);
-------------------------------------------------------------------
Draws a line starting from the current pointer position to the point (dx,dy),
relative to the current position, using the current foreground color and line
style. The current position is moved to the endpoint of the line. See LineTo
for more details.
-------------------------------------------------------------------
procedure LineTo(x,y:smallint);
-------------------------------------------------------------------
Draws a line starting from the current pointer position to the point (x,y),
using the current foregroung color and line style. The current position is moved to (x,y).
Use SetLineStyle routine to set the line attributes and SetColor to set its color. Use MoveTo to change the current pointer position. To draw a line with absolute coordinates use Line routine instead.
-------------------------------------------------------------------
procedure MoveRel(dx,dy:smallint);
-------------------------------------------------------------------
Moves the pointer to coordinates (dx,dy), relative to the current pointer
position. See MoveTo for more details.
-------------------------------------------------------------------
procedure MoveTo(x,y:smallint);
-------------------------------------------------------------------
Moves the pointer to coordinates (x,y) which are viewport-relative. See
SetViewPort for more details. Only the following routines use or move the
current pointer:
ClearDevice
ClearViewPort
GraphDefaults
Line
LineRel
LineTo
MoveRel
MoveTo
OutText
OutTextXY
SetViewPort
No check is made regarding coordinates range.
-------------------------------------------------------------------
function OpenGLEnabled: boolean;
-------------------------------------------------------------------
Checks whether OpenGL driver is initialized. If not, you are not able to
perform OpenGL drawings. This can happen if INIT_OPENGL conditional is not
enabled in the source code, or the current selected graphics driver does
not support OpenGL initialization. D1bit graphics driver does not support
OpenGL drawings. See InitGraph for a description of graphics drivers.
OpenGL driver can be initialized in two ways. See SetOpenGLMode for details.
-------------------------------------------------------------------
procedure OutText(const textstring:shortstring);
-------------------------------------------------------------------
Puts (textstring) on the screen, at the current pointer position, using the
current font and text settings. The current position is moved to the end of
the text. Use SetTextStyle to change font style and SetTextJustify to change
text alignment. To put text on an absolute location use OutTextXY instead.
-------------------------------------------------------------------
procedure OutTextXY(x,y:smallint; const textstring:shortstring);
-------------------------------------------------------------------
Puts (textstring) on the screen, at the coordinates (x,y), using the current
font and text settings. The current position is moved to the end of the text.
See OutText for more details.
-------------------------------------------------------------------
procedure PieSlice(x,y:smallint; start,stop,radius:word);
-------------------------------------------------------------------
Draws and fills a
circular sector (a region bounded by the intersection of a circle and
two radials - called pie slice). It uses the current foreground color
and fill style. The arguments have the same meaning as in Arc. To draw an entire disk use FillEllipse.
PieSlice is a particular case of Sector.
-------------------------------------------------------------------
procedure PutAnim(x1,y1:smallint; var anim:AnimatType; bit:word);
-------------------------------------------------------------------
PutAnim puts the animation with the specified handle (anim) on screen at given
coordinates (x1,y1). Such an animation is previously created with GetAnim.
See that routine for more details. Argument (bit) determines how the animation
will be placed. Pre-defined values include those from PutImage routine and,
in addition:
TransPut - copies the animation to the screen with transparent color enabled
MaskPut - copies the animation mask to the screen
BkgPut - copies the animation background (taken from previous PutAnim)
to the screen
In palette-based drivers the colors in the animation are mapped to the palette entries. Anyway, because the palette is just a logical one, you should use UpdateGraph routine to assure that the animation on screen has the same color composition as appear in the active page. Due to same reason, raster operations do not perform well on such drivers.
PutAnim is usually faster than PutImage.
-------------------------------------------------------------------
procedure PutImage(x1,y1:smallint; var bitmap; bit:word);
-------------------------------------------------------------------
Places the image from (bitmap) on the screen at (x1,y1). Argument (bit)
determines how the bitmap will be placed. Pre-defined values are:
CopyPut - copies the bitmap directly to the screen
XorPut - combines the colors of the bitmap and the screen by using the
logical XOR operator
OrPut - combines the colors of the bitmap and the screen by using the
logical OR operator
AndPut - combines the colors of the bitmap and the screen by using the
logical AND operator
NotPut - copies the inverted bitmap to the screen
NotOrPut - combines the colors of the bitmap and the screen by using the
logical OR operator and then inverts the resultant color
InvBitOrPut - combines the colors of the inverted bitmap with the colors
of the screen by using the logical OR operator
InvScrAndPut - combines the inverted colors of the screen with the colors
of the bitmap by using the logical AND operator
NormalPut=CopyPut
In palette-based drivers the colors in the bitmap are mapped to the palette entries. Anyway, because the palette is just a logical one you should use UpdateGraph routine to assure that the bitmap on screen has the same color composition as appear in the active page. Due to same reason, raster operations do not perform well on such drivers.
With PutImage you can put on screen any external BMP image having 24 bits format. See GetImage for more details.
If you want to perform animations please consider using PutAnim.
-------------------------------------------------------------------
procedure PutPixel(x,y:smallint; color:longword);
-------------------------------------------------------------------
Puts a point at position (x,y) using color (color). Check SetColor to learn
about color values. Use GetPixel to retrive a pixel color.
-------------------------------------------------------------------
procedure Rectangle(x1,y1,x2,y2:smallint);
-------------------------------------------------------------------
Draws a rectangle defined by the top-left corner (x1,y1) and the bottom-right
corner (x2,y2). It uses the current foreground color and line style. To draw
a filled rectangle use FillRect.
Rectangle is a particular case of DrawPoly.
-------------------------------------------------------------------
procedure RestoreCrtMode;
-------------------------------------------------------------------
It is completely equivalent with CloseGraph. See that routine for details.
Can be used in combination with SetGraphMode.
-------------------------------------------------------------------
procedure RotEllipse(x,y,rot:smallint; xradius,yradius:word);
-------------------------------------------------------------------
Draws a rotated ellipse with center at (x,y). Arguments (xradius) and (yradius)
are the horizontal and vertical radii of the ellipse, (rot) defines the rotation
angle measured counter-clockwise in degrees. It uses current foreground color.
It is implemented using DrawBezier.
-------------------------------------------------------------------
procedure RoundRect(x1,y1,x2,y2,r:smallint);
-------------------------------------------------------------------
Draws and fills a rectangle with rounded corners, using the current foreground
color, fill style and color. The argument (r) is the radius of a circle used
to draw the corners. The other parameters are the same as in Rectangle.
-------------------------------------------------------------------
procedure Sector(x,y:smallint; start,stop,xradius,yradius:word);
-------------------------------------------------------------------
Draws and fills an elliptical sector (a region bounded by the intersection
of an ellipse and two radials). It uses the current foreground color and fill
style. The arguments have the same meaning as in Ellipse. To draw a sector
of a circle use PieSlice.
-------------------------------------------------------------------
procedure SetActivePage(page:word);
-------------------------------------------------------------------
Sets the active page
where all drawings are performed. If different than visual page, these
drawings do not appear on screen. At least 4 active pages exist
(starting with 0), but this number can be increased from the source
code. This routine can be used to create multiple outputs. See also
SetVisualPage.
Programmatically, an active page is a memory copy of the graphics window. This copy is also used by the messaging thread to refresh the graphics window as necessary.
You can use UpdateGraph routine to refresh the graphics window with the content of the current active page. This is useful if drawings are not performed directly on the graphics window.
-------------------------------------------------------------------
procedure SetAllPalette(var palette);
-------------------------------------------------------------------
Sets the current palette to the specified one. (palette) is an untyped
variable, usually pointing to a record of type PaletteType. After changing
the palette content, the colors on screen are updated instantly. To change
just some entries into the palette use SetRGBPalette.
The (size) field of PaletteType structure gives the number of colors in the palette and (colors) field should contain absolute RGB color values. Such values can be generated with the GetRGBColor routine, before calling InitGraph.
Color names (Red, Green, ...) are not constants, but variables which are mapped to the nearest entries into the selected palette. Depending on selected palette, the result is not always as their names suggest. See GetNamesPalette for more details.
Because the palette is just a logical one, changing the palette entries might require setting again foreground and background colors. Otherwise, old colors outside the palette range could remain in use.
-------------------------------------------------------------------
procedure SetAspectRatio(xasp,yasp:word);
-------------------------------------------------------------------
Sets the aspect ratio of the screen to the ratio given by xasp/yasp.
It affects only routines for circular shapes. Does not have a practical
use other than backward compatibility with BP. Default values are
(10000,10000).
See also GetAspectRatio.
-------------------------------------------------------------------
procedure SetBkColor(color:longword);
-------------------------------------------------------------------
Sets the background color to (color). Check SetColor to learn about color
values.
The background color is the color used to clear portions of the screen (or the entire viewport). It is also used as dual color in filling patterns. SetBkColor affects only subsequent drawings. Default color is Black.
-------------------------------------------------------------------
procedure SetColor(color:longword);
-------------------------------------------------------------------
Sets the foreground color to (color). For palette-based drivers the value of
(color) is an index into the palette. For non-palette driver (color) stores
a 24 bits RGB value encoded in hexadecimal form. The low-order byte
contains a value for the relative intensity of red, the second byte contains a
value for green and the third byte contains a value for blue (ex $0000FF is Red).
In both cases, pre-defined color names can be used instead of pure numbers. Consult InitGraph about graphics drivers and the section Alphabetical color names. See GetNamesPalette routine for more details on colors.
The foreground color is the color used for drawing contours, lines and text. Other primitives have different ways to specify the color. Default color is White.
-------------------------------------------------------------------
procedure SetFillPattern(fillpattern:FillPatternType; color:longword);
-------------------------------------------------------------------
Selects a user-defined fill pattern which will be used in SetFillStyle routine with
UserFill hatch set. The pattern is an 8x8 raster, corresponding to the
64 bits in (fillpattern). Foreground pattern color is set to (color). Default
is White. Background pattern color is the background color selected by
SetBkColor. Check SetColor to learn more about colors.
Before returning it calls SetFillStyle routine to put the pattern into effect.
-------------------------------------------------------------------
procedure SetFillStyle(pattern:word; color:longword);
-------------------------------------------------------------------
Sets the filling pattern and color for filled drawings routines. Argument
(pattern) can be one of the following constants:
EmptyFill - background color hatch
SolidFill - solid hatch
LineFill - horizontal hatch
ColFill - vertical hatch
HatchFill - horizontal and vertical cross-hatch
SlashFill - 45-degree upward, left-to-right hatch
BkSlashFill - 45-degree downward, left-to-right hatch
XHatchFill - 45-degree cross-hatch
UserFill - user-defined hatch
NoFill - no hatch
If (pattern) equals UserFill, the user-defined pattern set by SetFillPattern becomes the active pattern. In this case, the argument (color) is ignored. Parameter (color) is used to fill the shapes. Default is White. Check SetColor to learn about color values.
-------------------------------------------------------------------
procedure SetFloodMode(floodmode:smallint);
-------------------------------------------------------------------
Sets the mode in witch flood-fills are performed with FloodFill routine.
Argument (floodmode) has the following pre-defined values:
BorderFlood - the fill area is bounded by the color specified in FloodFill;
filling begins at the specified point and continues in all directions until it reaches the color bounding the area; this
is the default.
SurfaceFlood - the fill area is defined by the color that is specified in FloodFill; filling begins at the specified point and continues in all directions over all adjacent regions containing the
specified color; this mode is useful for filling areas with
multicolored boundaries
See also FloodFill routine.
-------------------------------------------------------------------
procedure SetGraphMode(mode:smallint);
-------------------------------------------------------------------
Sets the graphics window back on screen using graphics mode (mode) and
the previous selected driver. All previous graphics settings are lost.
See InitGraph for details.
It should be used after CloseGraph or RestoreCRTMode.
-------------------------------------------------------------------
procedure SetLineStyle(linestyle,pattern,thickness:word);
-------------------------------------------------------------------
Sets the drawing style for lines. The (linestyle) is one of the following
constants:
SolidLn - solid line
DashedLn - dashed line
DottedLn - dotted line
DashDotLn - alternating dashes and dots line
DashDotDotLn - dashes and double dots line
UserBitLn - user defined line
NullLn - invisible line
If UserBitLn is specified then (pattern) should contain the 16-bit pattern. In all
another cases (pattern) is ignored. The parameter (thickness) indicates how
thick the line should be:
NormWidth - one pixel width
DoubleWidth - two pixels width
TripleWidth - three pixels width
QuadWidth - four pixels width
ThickWidth=TripleWidth
If (thickness) <> NormWidth then (linestyle) is ignored and the line is drawn solid, due to Windows GDI limitations.
(thickness) is ignored for UserBitLn style because of missing implementation.
Use SetColor to set the line color.
-------------------------------------------------------------------
procedure SetOpenGLMode(direct:boolean);
-------------------------------------------------------------------
It changes the drawing mode for OpenGL routines. Argument (direct) is one
of the following constants:
DirectOff - OpenGL driver doesn't write directly on screen
DirectOn - OpenGL driver writes directly on screen
In the first mode (DirectOff) all OpenGL drawings are performed into the OpenGL buffer. Because of that you must use OpenGL specific command glFlush() to release this buffer into the active page after each frame. This mode is mainly used for static OpenGL drawings when speed is not so important. In palette-based drivers the OpenGL drawings are affected by the selected palette. This is the default mode.
In the second mode (DirectOn) all OpenGL drawings are performed directly on screen. That means high-speed graphics, but no possibility to keep a copy of OpenGL output into the active page. This mode is mainly used for dynamic images when speed is important. OpenGL drawings are not affected by the selected palette.
In both modes you must use UpdateGraph(UpdateNow) after each frame, in order to update the screen. When changing the OpenGL mode, all previous OpenGL settings are lost.
You can mix OpenGL and WinGraph routines but this is usually not recommended. If you do so keep in mind the following: in (DirectOff) mode WinGraph routines must be called after glFlush() is issued and UpdateGraph(UpdateOff) should be activated first to avoid screen updates between commands; in (DirectOn) mode you can mix these routines as you want but screen flickering may appear.
Before calling OpenGL routines you should check with OpenGLEnabled if OpenGL driver is initialized. See that routine for more details.
-------------------------------------------------------------------
procedure SetPalette(nrcolor,color:word);
-------------------------------------------------------------------
Changes the (nrcolor)-th entry in the current palette with (color) value. This argument (color) is an index into the default VGA palette, returned by
GetDefaultPalette. It ranges between 0 and 255, so is not limited to the
current palette size. To change a palette entry with a true color use
SetRGBPalette instead.
-------------------------------------------------------------------
procedure SetRGBPalette(nrcolor,r,g,b:word);
-------------------------------------------------------------------
Sets current palette entry (nrcolor) with an absolute RGB value: (r)-red,
(g)-green, (b)-blue. These arguments range between 0 and 255. Color names are
not mapped to the new palette entry. See SetAllPalette for details on palette
operation.
-------------------------------------------------------------------
procedure SetTextJustify(horiz,vert:word);
-------------------------------------------------------------------
It controls the placement of new text, relative to the cursor position.
Argument (horiz) controls horizontal placement, and can be one of the following pre-defined constants:
LeftText - text is set left of the pointer
CenterText - text is set centered horizontally on the pointer
RightText - text is set to the right of the pointer
Argument (vert) controls the vertical placement of the text. Its value can be
one of the following pre-defined constants:
TopText - text is placed above the pointer
BottomText - text is placed under the pointer
BaselineText - text is placed relative to its base line
Default text placement is LeftText and TopText.
-------------------------------------------------------------------
procedure SetTextStyle(font,direction,charsize:word);
-------------------------------------------------------------------
It controls the style of text to be put on the screen. Pre-defined constants
for (font) are:
CourierNewFont - Courier New font
MSSansSerifFont - MS Sans Serif font
TimesNewRomanFont - Times New Roman font
ArialFont - Arial font
DefaultFont=CourierNewFont
Besides, any successfully installed user font can be used insted. See InstallUserFont for details. All these fonts can be OR-ed with the following
additional styles to change their appearance:
ItalicFont - italic font
UnderlineFont - underlined font
BoldFont - bold font
Argument (direction) sets the direction of text. It can be any positive value in
degrees or one of the following constants:
HorizDir = 0
VertDir = 90
Between 1 and 5, (charsize) represents the magnification of the characters with a standard font size of 8 pixels. Above 6 it represents an absolute font size. Default is set to 16.
Be aware that some fonts (including pre-defined) do not support all these styles. See GetFontSettings routine for more details. Use SetColor to set text color.
-------------------------------------------------------------------
procedure SetUserCharSize(nCharExtra,nBreakExtra,dummy1,dummy2:word);
-------------------------------------------------------------------
First argument (nCharExtra) sets the intercharacter spacing in text and the
second one (nBreakExtra) sets the amount of space reserved for break character.
The other ones are dummy arguments (not used). This is a major incompatibility
with BP graph unit. Default values are
zero.
See SetTextStyle for other text styles.
-------------------------------------------------------------------
procedure SetViewPort(x1,y1,x2,y2:smallint; clip:boolean);
-------------------------------------------------------------------
Sets the current output viewport to the rectangle defined by the top-left
corner (x1,y1) and the bottom-right corner (x2,y2). If (clip) is true, anything
drawn outside the viewport will be clipped (not drawn). Coordinates specified
after this call are relative to the top-left corner of the viewport. Cursor
position is reset to (0,0). The following clipping constants are defined:
ClipOn = true
ClipOff = false
OpenGL drawings are not bounded to the viewport.
-------------------------------------------------------------------
procedure SetVisualPage(page:word);
-------------------------------------------------------------------
Sets the visual page to be displayed onto the graphics window. For more info
see SetActivePage routine. UpdateGraph uses this routine to force screen refreshes.
-------------------------------------------------------------------
procedure SetWindowSize(width,height:word);
-------------------------------------------------------------------
Sets the dimensions of the graphics window to be created by InitGraph.
In this case you must use mCustom graphics mode. (width) is the width and
(height) is the height in pixels of the window client area. See InitGraph for
more details.
-------------------------------------------------------------------
procedure SetWriteMode(writemode:smallint);
-------------------------------------------------------------------
It specifies what binary operation is performed when drawing on screen. Argument
(writemode) has two components. First component is the foreground mix mode.
It affects contours (including lines) and filled shapes (excluding Bar).
Can be one of the following pre-defined constants:
CopyMode - pixels are simply copied onto the screen
XorMode - pixels are combination of the drawing color and screen color,
but not in both (logical XOR)
OrMode - pixels are combination of the drawing color and screen color
(logical OR)
AndMode - pixels are combination of the colors common to both the drawing
and screen (logical AND)
NotMode - pixels are the inverse of the drawing color (logical NOT)
NotScrMode - pixels are the inverse of the screen color
NotXorMode - pixels are the inverse of the XorMode color
NotOrMode - pixels are the inverse of the OrMode color
NotAndMode - pixels are the inverse of the AndMode color
InvColAndMode - pixels are combination of the colors common to both the
screen and the inverse of drawing color
InvColOrMode - pixels are combination of the screen color and the inverse
of drawing color
InvScrAndMode - pixels are combination of the colors common to both the
drawing and the inverse of screen color
InvScrOrMode - pixels are combination of the drawing color and the inverse
of screen color
BlackMode - pixels are always 0
WhiteMode - pixels are always 1
EmptyMode - screen pixels remain unchanged
Second component is the background mix mode. It affects only texts. Can be one
of the following two pre-defined constants:
Transparent - screen remains untouched (as in BP graph unit)
Opaque - screen is filled with the current background color before the
text is drawn
Argument (writemode) is an OR-ed combination of the foreground and background mix modes. By default it equals CopyMode OR Transparent.
SetWriteMode does not perform well on palette-based drivers, especially if the palette was not retrived by GetSystemPalette routine. Anyway, because the palette is just a logical one you must use UpdateGraph routine to assure that the screen has the same color composition as the active page.
You can use InvertRect to perform logical NOT operations over the screen content.
-------------------------------------------------------------------
function TextHeight(const textstring:shortstring): word;
-------------------------------------------------------------------
Returns the height (in pixels) of the (textstring) in the current font style.
This value might be altered by a call to SetTextStyle or SetUserCharSize.
-------------------------------------------------------------------
function TextWidth(const textstring:shortstring): word;
-------------------------------------------------------------------
Returns the width (in pixels) of the (textstring) in the current font style.
This value might be altered by a call to SetTextStyle or SetUserCharSize.
-------------------------------------------------------------------
procedure UpdateGraph(bit:word);
-------------------------------------------------------------------
This routine is used to manage all graphics operations. By default, these
operations are performed simultaneously onto the graphics window and
in memory (the current active page). However, you can change this behaviour
with UpdateGraph. The meaning of (bit) is the following:
UpdateOff - graphics operations are not performed directly on screen,
only on memory (you can gain some speed here)
UpdateOn - graphics operations are also performed directly on screen
(this is the default)
UpdateNow - screen is updated with the content of the current active page
right now; used in conjunction with UpdateOff.
This routine is useful to synchronize the output of several graphics operations, in order to reduce screen flickering. In addition, you must use UpdateGraph(UpdateNow) to force updating the screen after each OpenGL frame. See SetOpenGLMode for details.
WinCrt routines
WinCrt unit adds keyboard support to WinGraph. Graphics window must be enabled with InitGraph in order to use this unit properly.
-------------------------------------------------------------------
procedure Delay(ms:word);
-------------------------------------------------------------------
It delays the main thread a specified number of milliseconds (ms). Keyboard
and mouse events are still recorded. You can use this routine in a waiting loop (as Delay(10)), if you want your program not consume most of all CPU cycles. ReadBuf and ReadKey routines are using this technique.
The specified number is an approximation, the result may be off a lot, if system load is high.
-------------------------------------------------------------------
function KeyPressed: boolean;
-------------------------------------------------------------------
Scans the keyboard buffer and sees if a key has been pressed. If this is the
case, true is returned. If not, false is returned. The Shift, Alt and Ctrl keys
are not reported. The key is not removed from the buffer, and can hence still
be read after the KeyPressed function has been called, using ReadKey routine.
-------------------------------------------------------------------
procedure ReadBuf(out buf:shortstring; maxchar:byte);
-------------------------------------------------------------------
Emulates the Read console routine for WinGraph. It creates a blinking caret
and waits for the user to input several keys until Enter key (#13) is pressed
or a number of (maxchar) characters is reached. If (maxchar) is set to 0 at
most 255 characters are accepted. Argument (buf) will store the sequence
of input characters. The accepted ASCII range is between ' '(space) to
'~'(tilde). Extended or function keys are ignored. Among usual edit keys only
BackSpace is recognized.
The routine uses DefaultFont to write characters horizontally on screen and manage itself the placement and intercharacter spaces. All other text styles specified by the user are accounted for.
Text is positioned at the current pixel location. The entire screen scrolls up if necessary. Next ReadBuf call places the caret on new line.
-------------------------------------------------------------------
function ReadKey: char;
-------------------------------------------------------------------
Returns one key from the keyboard buffer. If an extended or function key has
been pressed, then the zero ASCII code is returned (#0). You can then read
the scan code of the key with a second ReadKey call.
Most of the key codes from a DOS console are implemented in WinCrt, together with many other ones.
See below for a full list.
Key
Normal Shift Ctrl
Alt
---------------------------------------------------------
A
#97 #65
#1 #0#30
B
#98 #66
#2 #0#48
C
#99 #67
#3 #0#46
D
#100 #68 #4
#0#32
E
#101 #69 #5
#0#18
F
#102 #70 #6
#0#33
G
#103 #71 #7
#0#34
H
#104 #72 #8
#0#35
I
#105 #73 #9
#0#23
J
#106 #74 #10
#0#36
K
#107 #75 #11
#0#37
L
#108 #76 #12
#0#38
M
#109 #77 #13
#0#50
N
#110 #78 #14
#0#49
O
#111 #79 #15
#0#24
P
#112 #80 #16
#0#25
Q
#113 #81 #17
#0#16
R
#114 #82 #18
#0#19
S
#115 #83 #19
#0#31
T
#116 #84 #20
#0#20
U
#117 #85 #21
#0#22
V
#118 #86 #22
#0#47
W
#119 #87 #23
#0#17
X
#120 #88 #24
#0#45
Y
#121 #89 #25
#0#21
Z
#122 #90 #26
#0#44
0 )
#48 #41
#0#10 #0#129
1 !
#49 #33
#0#1 #0#120
2 @
#50 #64
#0#2 #0#121
3 #
#51 #35
#0#3 #0#122
4 $
#52 #36
#0#4 #0#123
5 %
#53 #37
#0#5 #0#124
6 ^
#54 #94
#0#6 #0#125
7 &
#55 #38
#0#7 #0#126
8 *
#56 #42
#0#8 #0#127
9 (
#57 #40
#0#9 #0#128
` ~
#96 #126 -
-
- _
#45 #95
- -
= +
#61 #43 -
-
\ |
#92 #124 #28
-
[ }
#91 #123 #27
-
] }
#93 #125 #29
-
; :
#59 #58 -
-
' "
#39 #34 -
-
, <
#44 #60 -
-
. >
#46 #62 -
-
/ ?
#47 #63 -
-
SPACEBAR #32
#32 #32
#0#11
TAB
#9 #9
#30
-
CAPS LOCK -
-
-
-
BACKSPACE #8
#8
#127 #0#14
ENTER #13
#13 #10
#0#166
APP KEY #0#151
#0#151 #0#151 #0#151
WIN KEY -
-
-
-
INS
#0#82 #0#82 #0#146
#0#162
DEL
#0#83 #0#83 #0#147
#0#163
HOME
#0#71 #0#71 #0#119
#0#164
END
#0#79 #0#79 #0#117
#0#165
PAGE UP #0#73
#0#73 #0#132 #0#153
PAGE DOWN #0#81
#0#81 #0#118 #0#161
ARROW UP
#0#72
#0#72 #0#141 #0#152
ARROW DOWN
#0#80 #0#80
#0#145 #0#160
ARROW LEFT #0#75
#0#75 #0#115 #0#155
ARROW RIGHT #0#77 #0#77 #0#116 #0#157
ESC
#27 #27 -
-
F1
#0#59 #0#84 #0#94
#0#104
F2
#0#60 #0#85 #0#95
#0#105
F3
#0#61 #0#86 #0#96
#0#106
F4
#0#62 #0#87 #0#97
#0#107
F5
#0#63 #0#88 #0#98
#0#108
F6
#0#64 #0#89 #0#99
#0#109
F7
#0#65 #0#90 #0#100
#0#110
F8
#0#66 #0#91 #0#101
#0#111
F9
#0#67 #0#92 #0#102
#0#112
F10
#0#68 #0#93 #0#103
#0#113
F11
#0#133 #0#135 #0#137 #0#139
F12
#0#134 #0#136 #0#138 #0#140
PRINT SCR -
-
-
-
SCROLL LOCK -
-
#3
-
PAUSE
#0#12 #0#12 #3
#0#169
NUMPAD 0
#48
#0#82 -
-
NUMPAD 1
#49
#0#79 -
-
NUMPAD 2 #50
#0#80 -
-
NUMPAD 3 #51
#0#81 -
-
NUMPAD 4 #52
#0#75 -
-
NUMPAD 5 #53
#0#76 -
-
NUMPAD 6 #54
#0#77 -
-
NUMPAD 7 #55
#0#71 -
-
NUMPAD 8 #56
#0#72 -
-
NUMPAD 9 #57
#0#73 -
-
NUMPAD CLEAR #0#76 #0#76 #0#143 #0#76
NUMPAD LOCK -
-
-
-
NUMPAD DIVIDE #47 #47
#0#148 #0#69
NUMPAD MULTIPLY #42 #42
#0#149 #0#70
NUMPAD SUBTRACT #45 #45
#0#142 #0#74
NUMPAD ADD #43
#43
#0#144 #0#78
NUMPAD ENTER #13 #13
#10 #0#166
NUMPAD DECIMAL #46 #0#83 #0#150 #0#114
-------------------------------------------------------------------
procedure Sound(hz,dur:word);
-------------------------------------------------------------------
Generates simple tones on the speaker. Parameter (hz) is the frequency of
the sound in hertz. Its valid range is between 37 through 32767. (dur)
is the duration of the sound in milliseconds.
-------------------------------------------------------------------
procedure WriteBuf(buf:shortstring);
-------------------------------------------------------------------
Emulates the Write console routine for WinGraph. It prints on screen every
character found in (buf), but only in the range ' '(space) to '~'(tilde).
All other characters are silently ignored. Carriage return (#13) is also
recognized.
The routine uses DefaultFont to write characters horizontally on screen and manage itself the placement and intercharacter spaces. All other text styles specified by the user are accounted for.
Text is positioned at the current pixel location. The entire screen scrolls
up if necessary. Next WriteBuf call places the text on the same line, unless a carriage return is encountered.
WinMouse routines
WinMouse unit adds mouse support to WinGraph. Graphics window must be enabled with InitGraph in order to use this unit properly.
-------------------------------------------------------------------
function GetMouseButtons: word;
-------------------------------------------------------------------
Returns the current button state of the mouse and the state of Shift and Ctrl keys. It might be an OR-ed
combination of the following constants:
MouseLeftButton - the left mouse button is held down
MouseRightButton - the right mouse button is held down
MouseMiddleButton - the middle mouse button is held down
MouseShiftKey - the Shift key is held down
MouseCtrlKey - the Ctrl key is held down
If no buttons nor keys are held down the function returns zero.
-------------------------------------------------------------------
procedure GetMouseEvent(out MouseEvent:MouseEventType);
-------------------------------------------------------------------
Returns the next mouse event in the queue (a movement, button press, button
release or wheel scroll), and waits for one if none is available. The field (buttons) of
(MouseEvent) argument is loaded with the mouse buttons, Shift and Ctrl keys which are pressed during
the event (see GetMouseButtons for a description). The fields (x), (y) store mouse position, (wheel) stores mouse wheel rotation (in 120 steps increment, positive away from user) and (action) stores the event. It might be one of the
following constants:
MouseActionDown - a mouse button is pressed
MouseActionUp - a mouse button is released
MouseActionMove - mouse cursor is moved
MouseActionWheel - mouse wheel is rotated
The mouse event queue can hold multiple events till they are fetched.
-------------------------------------------------------------------
function GetMouseX: word;
-------------------------------------------------------------------
Queries the current horizontal position of the mouse cursor. This position is
measured in pixels, starting at 0 on the left side of the screen.
-------------------------------------------------------------------
function GetMouseY: word;
-------------------------------------------------------------------
Queries the current vertical position of the mouse cursor. This position is
measured in pixels, starting at 0 on the top side of the screen.
-------------------------------------------------------------------
function GetMouseWheel: smallint;
-------------------------------------------------------------------
Queries
the mouse wheel rotation status (in 120 steps increment, positive away
from user). It returns zero if wheel is not rotated. Calling this routine once will reset wheel rotation status back to zero.
-------------------------------------------------------------------
function PollMouseEvent(out MouseEvent:MouseEventType): boolean;
-------------------------------------------------------------------
Checks whether a mouse event is available in the queue, and returns it in
(MouseEvent) argument if one is found. The function result is true in that case.
If no mouse event is pending, the function result is false, and the content
of (MouseEvent) is unchanged. Note that after a call to PollMouseEvent, the
event should still be removed from the mouse event queue with a call to
GetMouseEvent. See that routine for a description of (MouseEvent) argument.
-------------------------------------------------------------------
procedure PutMouseEvent(const MouseEvent:MouseEventType);
-------------------------------------------------------------------
Adds (MouseEvent) to the mouse event queue. This can be used to simulate a
mouse event.
-------------------------------------------------------------------
procedure SetMouseXY(x,y:word);
-------------------------------------------------------------------
Places the mouse cursor at position (x,y). It is measured in pixels,
starting at (0,0) from the top-left corner of the screen.
--- end of document ---