DEFINITION MODULE wingraphics; FROM SYSTEM IMPORT LOC; FROM WIN32 IMPORT *; FROM WINGDI IMPORT BITMAPFILEHEADER,BITMAPINFOHEADER,RGBTRIPLE; CONST AliceBlue = 0FFF8F0H; AlizarinCrimson = 03626E3H; Amber = 000BFFFH; Amethyst = 0CC6699H; AntiqueWhite = 0D7EBFAH; Aquamarine = 0D4FF7FH; Asparagus = 05BA07BH; Azure = 0FFFFF0H; Beige = 0DCF5F5H; Bisque = 0C4E4FFH; Bistre = 01F2B3DH; BitterLemon = 00DE0CAH; Black = 0000000H; BlanchedAlmond = 0CDEBFFH; BlazeOrange = 00099FFH; Blue = 0FF0000H; BlueViolet = 0E22B8AH; BondiBlue = 0B69500H; Brass = 042A6B5H; BrightGreen = 000FF66H; BrightTurquoise = 0DEE808H; BrightViolet = 0CD00CDH; Bronze = 0327FCDH; Brown = 02A2AA5H; Buff = 082DCF0H; Burgundy = 0200090H; BurlyWood = 087B8DEH; BurntOrange = 00055CCH; BurntSienna = 05174E9H; BurntUmber = 024338AH; CadetBlue = 0A09E5FH; CamouflageGreen = 06B8678H; Cardinal = 03A1EC4H; Carmine = 0180096H; Carrot = 02191EDH; Casper = 0D1BEADH; Celadon = 0AFE1ACH; Cerise = 06331DEH; Cerulean = 0A77B00H; CeruleanBlue = 0BE522AH; Chartreuse = 000FF7FH; Chocolate = 01E69D2H; Cinnamon = 0003F7BH; Cobalt = 0AB4700H; Copper = 03373B8H; Coral = 0507FFFH; Corn = 05DECFBH; CornflowerBlue = 0ED9564H; Cornsilk = 0DCF8FFH; Cream = 0D0FDFFH; Crimson = 03C14DCH; Cyan = 0FFFF00H; DarkBlue = 08B0000H; DarkBrown = 0214365H; DarkCerulean = 07E4508H; DarkChestnut = 0606998H; DarkCoral = 0455BCDH; DarkCyan = 08B8B00H; DarkGoldenrod = 00B86B8H; DarkGray = 0545454H; DarkGreen = 0006400H; DarkIndigo = 0620031H; DarkKhaki = 06BB7BDH; DarkMagenta = 08B008BH; DarkOlive = 0326855H; DarkOliveGreen = 02F6B55H; DarkOrange = 0008CFFH; DarkOrchid = 0CC3299H; DarkPastelGreen = 03CC003H; DarkPink = 08054E7H; DarkRed = 000008BH; DarkSalmon = 07A96E9H; DarkScarlet = 0190356H; DarkSeaGreen = 08FBC8FH; DarkSlateBlue = 08B3D48H; DarkSlateGray = 04F4F2FH; DarkSpringGreen = 0457217H; DarkTan = 0518191H; DarkTangerine = 012A8FFH; DarkTeaGreen = 0ADDBBAH; DarkTerraCotta = 05C4ECCH; DarkTurquoise = 0D1CE00H; DarkViolet = 0D30094H; DeepPink = 09314FFH; DeepSkyBlue = 0FFBF00H; Denim = 0BD6015H; DimGray = 0696969H; DodgerBlue = 0FF901EH; Emerald = 078C850H; Eggplant = 0660099H; FernGreen = 042794FH; FireBrick = 02222B2H; Flax = 082DCEEH; FloralWhite = 0F0FAFFH; ForestGreen = 0228B22H; Fractal = 0808080H; Fuchsia = 0A100F4H; Gainsboro = 0DCDCDCH; Gamboge = 00F9BE4H; GhostWhite = 0FFF8F8H; Gold = 000D7FFH; Goldenrod = 020A5DAH; Gray = 07E7E7EH; GrayAsparagus = 0455946H; GrayTeaGreen = 0BADACAH; Green = 0008000H; GreenYellow = 02FFFADH; Heliotrope = 0FF73DFH; Honeydew = 0F0FFF0H; HotPink = 0B469FFH; IndianRed = 05C5CCDH; Indigo = 082004BH; InternationalKleinBlue = 0A72F00H; InternationalOrange = 0004FFFH; Ivory = 0F0FFFFH; Jade = 06BA800H; Khaki = 08CE6F0H; Lavender = 0FAE6E6H; LavenderBlush = 0F5F0FFH; LawnGreen = 000FC7CH; Lemon = 010E9FDH; LemonChiffon = 0CDFAFFH; LightBlue = 0E6D8ADH; LightBrown = 08CB4D2H; LightCoral = 08080F0H; LightCyan = 0FFFFE0H; LightGoldenrodYellow = 0D2FAFAH; LightGray = 0A8A8A8H; LightGreen = 090EE90H; LightMagenta = 0FF80FFH; LightPink = 0C1B6FFH; LightRed = 08080FFH; LightSalmon = 07AA0FFH; LightSeaGreen = 0AAB220H; LightSkyBlue = 0FACE87H; LightSlateGray = 0998877H; LightSteelBlue = 0DEC4B0H; LightYellow = 0E0FFFFH; Lilac = 0C8A2C8H; Lime = 000FF00H; LimeGreen = 032CD32H; Linen = 0E6F0FAH; Magenta = 0FF00FFH; Malachite = 051DA0BH; Maroon = 0000080H; Mauve = 0FFB0E0H; MediumAquamarine = 0AACD66H; MediumBlue = 0CD0000H; MediumOrchid = 0D355BAH; MediumPurple = 0DB7093H; MediumSeaGreen = 071B33CH; MediumSlateBlue = 0EE687BH; MediumSpringGreen = 09AFA00H; MediumTurquoise = 0CCD148H; MediumVioletRed = 08515C7H; MidnightBlue = 0701919H; MintCream = 0FAFFF5H; MistyRose = 0E1E4FFH; Moccasin = 0B5E4FFH; MoneyGreen = 0C0DCC0H; Monza = 01E03C7H; MossGreen = 0ADDFADH; MountbattenPink = 08D7A99H; Mustard = 058DBFFH; NavajoWhite = 0ADDEFFH; Navy = 0800000H; Ochre = 02277CCH; OldGold = 03BB5CFH; OldLace = 0E6F5FDH; Olive = 0008080H; OliveDrab = 0238E6BH; Orange = 000A5FFH; OrangeRed = 00045FFH; Orchid = 0D670DAH; PaleBrown = 0547698H; PaleCarmine = 03540AFH; PaleChestnut = 0AFADDDH; PaleCornflowerBlue = 0EFCDABH; PaleGoldenrod = 0AAE8EEH; PaleGreen = 098FB98H; PaleMagenta = 0E584F9H; PaleMauve = 0666699H; PalePink = 0DDDAFAH; PaleSandyBrown = 0ABBDDAH; PaleTurquoise = 0EEEEAFH; PaleVioletRed = 09370DBH; PapayaWhip = 0D5EFFFH; PastelGreen = 077DD77H; PastelPink = 0DCD1FFH; Peach = 0B4E5FFH; PeachOrange = 099CCFFH; PeachPuff = 0B9DAFFH; PeachYellow = 0ADDFFAH; Pear = 031E2D1H; Periwinkle = 0FFCCCCH; PersianBlue = 0FF0066H; Peru = 03F85CDH; PineGreen = 06F7901H; Pink = 0CBC0FFH; PinkOrange = 06699FFH; Plum = 0DDA0DDH; PowderBlue = 0E6E0B0H; PrussianBlue = 0533100H; Puce = 09988CCH; Pumpkin = 01875FFH; Purple = 0800080H; RawUmber = 0124A73H; Red = 00000FFH; Reef = 0A2FFC9H; RobinEggBlue = 0CCCC00H; RosyBrown = 08F8FBCH; RoyalBlue = 0E16941H; Russet = 01B4680H; Rust = 00E41B7H; SaddleBrown = 013458BH; Saffron = 030C4F4H; Salmon = 07280FAH; SandyBrown = 060A4F4H; Sangria = 00A0092H; Sapphire = 0672508H; Scarlet = 00024FFH; SchoolBusYellow = 000D8FFH; SeaGreen = 0578B2EH; SeaShell = 0EEF5FFH; SelectiveYellow = 000BAFFH; Sepia = 0144270H; Sienna = 02D52A0H; Silver = 0C0C0C0H; SkyBlue = 0EBCE87H; SlateBlue = 0CD5A6AH; SlateGray = 0908070H; Snow = 0FAFAFFH; SpringGreen = 07FFF00H; SteelBlue = 0B48246H; SwampGreen = 08EB7ACH; Taupe = 07E98BCH; Tangerine = 000CCFFH; Teal = 0808000H; TeaGreen = 0C0F0D0H; Tenne = 00057CDH; TerraCotta = 05B72E2H; Thistle = 0D8BFD8H; Tomato = 04763FFH; Turquoise = 0D0E040H; Ultramarine = 08F0A12H; Vermilion = 0004DFFH; Violet = 0EE82EEH; VioletEggplant = 0991199H; Viridian = 06D8240H; Wheat = 0B3DEF5H; White = 0FFFFFFH; WhiteSmoke = 0F5F5F5H; Wisteria = 0DCA0C9H; Yellow = 000FFFFH; YellowGreen = 032CD9AH; Zinnwaldite = 0AFC2EBH; (*error codes*) grOK = 0; grNoInitGraph = - 1; grInvalidDriver = - 2; grInvalidMode = - 3; grNotWindow = - 4; grInvalidFont = - 5; grInvalidFontNum = - 6; grInvalidParam = - 7; grNoPalette = - 8; grNoOpenGL = - 9; grError = -10; (*graphics drivers*) Detect = 0; D1bit = 1; D4bit = 2; D8bit = 3; NoPalette = 9; HercMono = D1bit; VGA = D4bit; SVGA = D8bit; (*graphics modes*) m320x200 = 1; m640x200 = 2; m640x350 = 3; m640x480 = 4; m720x350 = 5; m800x600 = 6; m1024x768 = 7; m1280x1024 = 8; mDefault = 10; mMaximized = 11; mFullScr = 12; mCustom = 13; HercMonoHi = m720x350; VGALo = m640x200; VGAMed = m640x350; VGAHi = m640x480; (*update constants*) UpdateOff = 0; UpdateOn = 1; UpdateNow = 2; (*OpenGL drawing modes*) DirectOn = TRUE; DirectOff = FALSE; (*clipping constants*) ClipOn = TRUE; ClipOff = FALSE; (*raster operation constants*) CopyPut = 0; XorPut = 1; OrPut = 2; AndPut = 3; NotPut = 4; NotOrPut = 5; InvBitOrPut = 6; InvScrAndPut = 7; TransPut = 8; MaskPut = 9; BkgPut = 10; NormalPut = CopyPut; (*drawing modes on screen*) CopyMode = 0; XorMode = 1; OrMode = 2; AndMode = 3; NotMode = 4; NotScrMode = 5; NotXorMode = 6; NotOrMode = 7; NotAndMode = 8; InvColAndMode = 9; InvColOrMode = 10; InvScrAndMode = 11; InvScrOrMode = 12; BlackMode = 13; WhiteMode = 14; EmptyMode = 15; Transparent = 00; Opaque = 16; (*drawing style for lines*) SolidLn = 0; DottedLn = 1; DashDotLn = 2; DashedLn = 3; DashDotDotLn = 4; UserBitLn = 5; NullLn = 6; (*thick constants for lines*) NormWidth = 1; DoubleWidth = 2; TripleWidth = 3; QuadWidth = 4; ThickWidth = TripleWidth; (*filling patterns*) EmptyFill = 0; SolidFill = 1; LineFill = 2; ColFill = 3; HatchFill = 4; SlashFill = 5; BkSlashFill= 6; XHatchFill = 7; UserFill = 8; NoFill = 9; (*Bar3D constants*) TopOn = TRUE; TopOff = FALSE; (*flood mode constants*) BorderFlood = 0; SurfaceFlood = 1; (*justify constants for text*) LeftText = 0; CenterText = 1; RightText = 2; TopText = 0; BottomText = 1; BaselineText = 2; (*direction constants for text*) HorizDir = 0; VertDir = 90; (*font constants for text*) CourierNewFont = 0; MSSansSerifFont = 1; TimesNewRomanFont= 2; ArialFont = 3; DefaultFont = CourierNewFont; ItalicFont = 1000H; UnderlineFont = 0100H; BoldFont = 0010H; UPARROW = 72; DOWNARROW = 80; LEFTARROW = 75; RIGHTARROW = 77; ESC = 27; F1 = 59; F2 = 60; F3 = 61; F4 = 62; F5 = 63; F6 = 64; F7 = 65; F8 = 66; F9 = 67; F10 = 68; F11 = 133; F12 = 134; INS = 82; DEL = 83; HOME = 71; ENDS = 79; PAGEUP = 73; PAGEDOWN = 81; CENTER = 53; TYPE ViewPortType = RECORD x1,y1,x2,y2: INTEGER; clip : BOOLEAN; END; AnimatType = RECORD bitHnd: HBITMAP; maskHnd:HBITMAP; bkgHnd: HBITMAP; END; IMAGE = RECORD bmiInfoHeader: BITMAPINFOHEADER; bmiFileHeader: BITMAPFILEHEADER; bmiBits : POINTER TO ARRAY OF RGBTRIPLE; END; PaletteType = RECORD size : INTEGER; colors: ARRAY[0..255] OF CARDINAL; END; PointType = POINT; ThreeDPointType = RECORD x,y,z: REAL; END; LineSettingsType = RECORD linestyle,pattern,thickness: CARDINAL; END; ArcCoordsType = RECORD x,y,xstart,ystart,xend,yend: INTEGER; END; FillSettingsType = RECORD pattern: CARDINAL; color : CARDINAL; END; FillPatternType = ARRAY [1..8] OF LOC; TextSettingsType = RECORD font,direction,charsize,horiz,vert: CARDINAL; END; (*keyboard & mouse hook variables*) WNDPROC = PROCEDURE(HWND, UINT, WPARAM, LPARAM): LRESULT; ProcHookType = WNDPROC; (*alphabetical color names*) VAR (*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: CARDINAL;*) KeyboardHook,MouseHook: ProcHookType; (*initialization exported routines*) (*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 ClearDevice; (*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.*) PROCEDURE CloseGraph; (*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 CloseGraphRequest(): BOOLEAN; (*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 DetectGraph(VAR driver,mode:INTEGER); (*Returns the name of the selected graphics driver (and number of available colors). See InitGraph for a list of graphics drivers.*) PROCEDURE GetDriverName(VAR nam: ARRAY OF CHAR); (*Returns the current (or last used) graphics mode. See InitGraph for a list of graphics modes.*) PROCEDURE GetGraphMode(): INTEGER; (*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.*) PROCEDURE GetMaxMode(): INTEGER; (*Returns the name of the specified graphics mode (mode). See InitGraph for a list of graphics modes.*) PROCEDURE GetModeName(mode:INTEGER; VAR nam: ARRAY OF CHAR); (*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 GetModeRange(driver:INTEGER; VAR width,height:INTEGER); (*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.*) PROCEDURE GraphDefaults; (*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.*) PROCEDURE GraphEnabled(): BOOLEAN; (*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.*) PROCEDURE GraphErrorMsg(errorcode:INTEGER; VAR msg: ARRAY OF CHAR); (*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.*) PROCEDURE GraphResult(): INTEGER; PROCEDURE InitGraphics(WinX, WinY: INTEGER; title: ARRAY OF CHAR); (*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.*) PROCEDURE InitGraph(VAR driver,mode:INTEGER; title: ARRAY OF CHAR); (*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 OpenGLEnabled(): BOOLEAN; (*It is completely equivalent with CloseGraph. See that routine for details. Can be used in combination with SetGraphMode.*) PROCEDURE RestoreCrtMode; (*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 SetGraphMode(mode:INTEGER); (*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 SetOpenGLMode(direct:BOOLEAN); (*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 SetWindowSize(width,height:CARDINAL); (*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 UpdateGraph(bit:CARDINAL); (*screen management exported routines*) (*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 ClearViewPort; (*Frees the animation resources associated with the animation handle (anim). See GetAnim for more details.*) PROCEDURE FreeAnim(VAR 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 GetAnim(x1,y1,x2,y2:INTEGER; color:CARDINAL; VAR 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 GetAspectRatio(VAR xasp,yasp:CARDINAL); (*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 GetImage(x1,y1,x2,y2:INTEGER; VAR bitmap: IMAGE); (*Returns the maximum x-coordinate (horizontal) in pixels. This equals the client area width minus 1. Maximum is placed on the right side.*) PROCEDURE GetMaxX(): INTEGER; (*Returns the maximum y-coordinate (vertical) in pixels. This equals the client area height minus 1. Maximum is placed on the bottom side.*) PROCEDURE GetMaxY(): INTEGER; (*Returns the current viewport and clipping settings in (viewport). You can change these settings using SetViewPort.*) PROCEDURE GetViewSettings(VAR viewport:ViewPortType); (*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.*) PROCEDURE GetX(): INTEGER; (*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 GetY(): INTEGER; (*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 ImageSize(x1,y1,x2,y2:INTEGER): INTEGER; (*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 PutAnim(x1,y1:INTEGER; VAR anim:AnimatType; bit:CARDINAL); (*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 PutImage(x1,y1:INTEGER; VAR bitmap: IMAGE; bit:CARDINAL); (*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 SetActivePage(page:CARDINAL); (*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 SetAspectRatio(xasp,yasp:CARDINAL); (*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 SetViewPort(x1,y1,x2,y2:INTEGER; clip:BOOLEAN); (*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 SetVisualPage(page:CARDINAL); (*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.*) PROCEDURE SetWriteMode(writemode:INTEGER); (*color management exported routines*) (*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.*) PROCEDURE GetBkColor(): CARDINAL; (*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 GetColor(): CARDINAL; (*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.*) PROCEDURE GetDefaultPalette(VAR 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.*) PROCEDURE GetNamesPalette(VAR palette:PaletteType); (*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 FFFFFFH.*) PROCEDURE GetMaxColor(): CARDINAL; (*Returns in (palette) the current palette. To retrive just the palette size use GetPaletteSize. See SetAllPalette for more details on palettes.*) PROCEDURE GetPalette(VAR palette:PaletteType); (*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.*) PROCEDURE GetPaletteSize(): INTEGER; (*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.*) PROCEDURE GetPixel(x,y:INTEGER): CARDINAL; (*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 GetRGBColor(r,g,b:CARDINAL): CARDINAL; (*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 GetRGBComponents(color:CARDINAL; VAR r,g,b:CARDINAL); (*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 GetSystemPalette(VAR palette:PaletteType); (*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 SetAllPalette(VAR palette:PaletteType); (*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 SetBkColor(color:CARDINAL); (*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 0000FFH 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 SetColor(color:CARDINAL); (*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 SetPalette(nrcolor,color:CARDINAL); (*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 SetRGBPalette(nrcolor,r,g,b:CARDINAL); (*drawing primitives exported routines*) (*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.*) PROCEDURE Arc(x,y:INTEGER; start,stop,radius:CARDINAL); (*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 Circle(x,y:INTEGER; radius:CARDINAL); (*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 DrawBezier(nrpoints:CARDINAL; VAR polypoints: ARRAY OF PointType); (*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 DrawPoly(nrpoints:CARDINAL; VAR polypoints: ARRAY OF PointType); (*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 Ellipse(x,y:INTEGER; start,stop,xradius,yradius:CARDINAL); (*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(VAR arccoords:ArcCoordsType); (*Returns the current line settings in (lineinfo). That is, line style, pattern and thickness, as set by SetLineStyle.*) PROCEDURE GetLineSettings(VAR lineinfo:LineSettingsType); (*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 Line(x1,y1,x2,y2:INTEGER); (*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 LineRel(dx,dy:INTEGER); (*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 LineTo(x,y:INTEGER); (*Moves the pointer to coordinates (dx,dy), relative to the current pointer position. See MoveTo for more details.*) PROCEDURE MoveRel(dx,dy:INTEGER); (*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.*) PROCEDURE MoveTo(x,y:INTEGER); (*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 PutPixel(x,y:INTEGER; color:CARDINAL); (*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 Rectangle(x1,y1,x2,y2:INTEGER); (*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 RotEllipse(x,y,rot:INTEGER; xradius,yradius:CARDINAL); (*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 SetLineStyle(linestyle,pattern,thickness:CARDINAL); (*filled drawings exported routines*) (*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 Bar(x1,y1,x2,y2:INTEGER); (*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 Bar3D(x1,y1,x2,y2:INTEGER; depth:CARDINAL; top:BOOLEAN); (*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 Chord(x,y:INTEGER; start,stop,xradius,yradius:CARDINAL); (*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 FillEllipse(x,y:INTEGER;xradius,yradius:CARDINAL); (*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 FillPoly(nrpoints:CARDINAL; VAR polypoints: ARRAY OF PointType); (*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 FillRect(x1,y1,x2,y2:INTEGER); (*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 FloodFill(x,y:INTEGER; color:CARDINAL); (*Returns in (fillpattern) the current fill-pattern array. This was set using SetFillPattern routine.*) PROCEDURE GetFillPattern(VAR fillpattern:FillPatternType); (*Returns the current fill-settings in (fillinfo). This structure contains the fill pattern and color, as set by SetFillStyle routine*) PROCEDURE GetFillSettings(VAR fillinfo:FillSettingsType); (*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 InvertRect(x1,y1,x2,y2:INTEGER); (*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 PieSlice(x,y:INTEGER; start,stop,radius:CARDINAL); (*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 RoundRect(x1,y1,x2,y2,r:INTEGER); (*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 Sector(x,y:INTEGER; start,stop,xradius,yradius:CARDINAL); (*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 SetFillPattern(fillpattern:FillPatternType; color:CARDINAL); (*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 SetFillStyle(pattern:CARDINAL; color:CARDINAL); (*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 SetFloodMode(floodmode:INTEGER); (*text AND font handling exported routines*) (*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.*) PROCEDURE GetFontSettings(VAR fontname:ARRAY OF CHAR; VAR width,height:CARDINAL; VAR ttfont:BOOLEAN); (*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 GetTextSettings(VAR textinfo:TextSettingsType); (*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 InstallUserFont(fontname: ARRAY OF CHAR): INTEGER; (*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 OutText(textstring:ARRAY OF CHAR); (*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 OutTextXY(x,y:INTEGER; textstring:ARRAY OF CHAR); (*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 SetTextJustify(horiz,vert:CARDINAL); (*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 SetTextStyle(font,direction,charsize:CARDINAL); (*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 SetUserCharSize(nCharExtra,nBreakExtra,dummy1,dummy2:CARDINAL); (*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.*) PROCEDURE TextHeight(textstring:ARRAY OF CHAR): CARDINAL; (*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 TextWidth(textstring:ARRAY OF CHAR): CARDINAL; PROCEDURE THREEDto2DAll(coords, pan, centre, position: ThreeDPointType; zoom: REAL; VAR sx,sy: REAL); PROCEDURE THREEDto2D(coords: ThreeDPointType; zoom: REAL; VAR sx,sy: REAL); (*caret format: block OR underline*) VAR CaretBlock: BOOLEAN = TRUE; (*caret blink rate in tenths OF a second*) VAR BlinkRate: CARDINAL = 2; (*keyboard exported routines*) (*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.*) PROCEDURE Delay(ms:CARDINAL); (*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 KeyPressed(): BOOLEAN; (*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.*) PROCEDURE ReadBuf(VAR buf: ARRAY OF CHAR; maxchar:CARDINAL8); (*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 ReadKey(): CHAR; (*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 Sound(hz,dur:CARDINAL); (*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. *) PROCEDURE WriteBuf(buf: ARRAY OF CHAR); TYPE MouseEventType = RECORD action : CARDINAL; buttons: CARDINAL; x,y : CARDINAL; wheel : INTEGER; END; (*mouse constants*) CONST MouseActionDown = 01H; MouseActionUp = 02H; MouseActionMove = 03H; MouseActionWheel = 04H; MouseLeftButton = 01H; MouseRightButton = 02H; MouseMiddleButton = 04H; MouseShiftKey = 08H; MouseCtrlKey = 10H; (*mouse exported routines*) (*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 GetMouseButtons(): CARDINAL; (*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.*) PROCEDURE GetMouseEvent(VAR mouseEvent:MouseEventType); (*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.*) PROCEDURE GetMouseX(): CARDINAL; (*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.*) PROCEDURE GetMouseY(): CARDINAL; (*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.*) PROCEDURE GetMouseWheel(): INTEGER; (*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 PollMouseEvent(VAR mouseEvent:MouseEventType): BOOLEAN; (*Adds (MouseEvent) to the mouse event queue. This can be used to simulate a mouse event.*) PROCEDURE PutMouseEvent(CONST mouseEvent:MouseEventType); (*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.*) PROCEDURE SetMouseXY(x,y:INTEGER); END wingraphics.