home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l044 / 2.ddi / INTRFACE.ZIP / GRAPH.INT < prev    next >
Encoding:
Text File  |  1990-10-23  |  11.4 KB  |  338 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal Version 6.0                        }
  5. {       Graph Interface Unit                            }
  6. {                                                       }
  7. {       Copyright (C) 1987,90 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Graph;
  12.  
  13. interface
  14.  
  15. const
  16.   { GraphResult error return codes: }
  17.   grOk               =   0;
  18.   grNoInitGraph      =  -1;
  19.   grNotDetected      =  -2;
  20.   grFileNotFound     =  -3;
  21.   grInvalidDriver    =  -4;
  22.   grNoLoadMem        =  -5;
  23.   grNoScanMem        =  -6;
  24.   grNoFloodMem       =  -7;
  25.   grFontNotFound     =  -8;
  26.   grNoFontMem        =  -9;
  27.   grInvalidMode      = -10;
  28.   grError            = -11;   { generic error }
  29.   grIOerror          = -12;
  30.   grInvalidFont      = -13;
  31.   grInvalidFontNum   = -14;
  32.  
  33.   { define graphics drivers }
  34.   CurrentDriver = -128; { passed to GetModeRange }
  35.   Detect        = 0;    { requests autodetection }
  36.   CGA           = 1;
  37.   MCGA          = 2;
  38.   EGA           = 3;
  39.   EGA64         = 4;
  40.   EGAMono       = 5;
  41.   IBM8514       = 6;
  42.   HercMono      = 7;
  43.   ATT400        = 8;
  44.   VGA           = 9;
  45.   PC3270        = 10;
  46.  
  47.   { graphics modes for each driver }
  48.   CGAC0      = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  49.   CGAC1      = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  50.   CGAC2      = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  51.   CGAC3      = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  52.   CGAHi      = 4;  { 640x200 1 page }
  53.   MCGAC0     = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  54.   MCGAC1     = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  55.   MCGAC2     = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  56.   MCGAC3     = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  57.   MCGAMed    = 4;  { 640x200 1 page }
  58.   MCGAHi     = 5;  { 640x480 1 page }
  59.   EGALo      = 0;  { 640x200 16 color 4 page }
  60.   EGAHi      = 1;  { 640x350 16 color 2 page }
  61.   EGA64Lo    = 0;  { 640x200 16 color 1 page }
  62.   EGA64Hi    = 1;  { 640x350 4 color  1 page }
  63.   EGAMonoHi  = 3;  { 640x350 64K on card, 1 page; 256K on card, 2 page }
  64.   HercMonoHi = 0;  { 720x348 2 page }
  65.   ATT400C0   = 0;  { 320x200 palette 0: LightGreen, LightRed, Yellow; 1 page }
  66.   ATT400C1   = 1;  { 320x200 palette 1: LightCyan, LightMagenta, White; 1 page }
  67.   ATT400C2   = 2;  { 320x200 palette 2: Green, Red, Brown; 1 page }
  68.   ATT400C3   = 3;  { 320x200 palette 3: Cyan, Magenta, LightGray; 1 page }
  69.   ATT400Med  = 4;  { 640x200 1 page }
  70.   ATT400Hi   = 5;  { 640x400 1 page }
  71.   VGALo      = 0;  { 640x200 16 color 4 page }
  72.   VGAMed     = 1;  { 640x350 16 color 2 page }
  73.   VGAHi      = 2;  { 640x480 16 color 1 page }
  74.   PC3270Hi   = 0;  { 720x350 1 page }
  75.   IBM8514LO  = 0;  { 640x480 256 colors }
  76.   IBM8514HI  = 1;  { 1024x768 256 colors }
  77.  
  78.   { Colors for SetPalette and SetAllPalette: }
  79.   Black        = 0;
  80.   Blue         = 1;
  81.   Green        = 2;
  82.   Cyan         = 3;
  83.   Red          = 4;
  84.   Magenta      = 5;
  85.   Brown        = 6;
  86.   LightGray    = 7;
  87.   DarkGray     = 8;
  88.   LightBlue    = 9;
  89.   LightGreen   = 10;
  90.   LightCyan    = 11;
  91.   LightRed     = 12;
  92.   LightMagenta = 13;
  93.   Yellow       = 14;
  94.   White        = 15;
  95.  
  96.   { colors for 8514 to set standard EGA colors w/o knowing their values }
  97.   EGABlack             = 0;       { dark colors }
  98.   EGABlue              = 1;
  99.   EGAGreen             = 2;
  100.   EGACyan              = 3;
  101.   EGARed               = 4;
  102.   EGAMagenta           = 5;
  103.   EGABrown             = 20;
  104.   EGALightgray         = 7;
  105.   EGADarkgray          = 56;      { light colors }
  106.   EGALightblue         = 57;
  107.   EGALightgreen        = 58;
  108.   EGALightcyan         = 59;
  109.   EGALightred          = 60;
  110.   EGALightmagenta      = 61;
  111.   EGAYellow            = 62;
  112.   EGAWhite             = 63;
  113.  
  114.   { Line styles and widths for Get/SetLineStyle: }
  115.   SolidLn    = 0;
  116.   DottedLn   = 1;
  117.   CenterLn   = 2;
  118.   DashedLn   = 3;
  119.   UserBitLn  = 4;       { User-defined line style }
  120.  
  121.   NormWidth  = 1;
  122.   ThickWidth = 3;
  123.  
  124.   { Set/GetTextStyle constants: }
  125.   DefaultFont   = 0;    { 8x8 bit mapped font }
  126.   TriplexFont   = 1;    { "Stroked" fonts }
  127.   SmallFont     = 2;
  128.   SansSerifFont = 3;
  129.   GothicFont    = 4;
  130.  
  131.   HorizDir   = 0;       { left to right }
  132.   VertDir    = 1;       { bottom to top }
  133.  
  134.   UserCharSize = 0;     { user-defined char size }
  135.  
  136.   { Clipping constants: }
  137.   ClipOn  = true;
  138.   ClipOff = false;
  139.  
  140.   { Bar3D constants: }
  141.   TopOn  = true;
  142.   TopOff = false;
  143.  
  144.   { Fill patterns for Get/SetFillStyle: }
  145.   EmptyFill       = 0;  { fills area in background color }
  146.   SolidFill       = 1;  { fills area in solid fill color }
  147.   LineFill        = 2;  { --- fill }
  148.   LtSlashFill     = 3;  { /// fill }
  149.   SlashFill       = 4;  { /// fill with thick lines }
  150.   BkSlashFill     = 5;  { \\\ fill with thick lines }
  151.   LtBkSlashFill   = 6;  { \\\ fill }
  152.   HatchFill       = 7;  { light hatch fill }
  153.   XHatchFill      = 8;  { heavy cross hatch fill }
  154.   InterleaveFill  = 9;  { interleaving line fill }
  155.   WideDotFill     = 10; { Widely spaced dot fill }
  156.   CloseDotFill    = 11; { Closely spaced dot fill }
  157.   UserFill        = 12; { user defined fill }
  158.  
  159.   { BitBlt operators for PutImage: }
  160.   NormalPut     = 0;    { MOV }       { left for 1.0 compatibility }
  161.   CopyPut       = 0;    { MOV }
  162.   XORPut        = 1;    { XOR }
  163.   OrPut         = 2;    { OR  }
  164.   AndPut        = 3;    { AND }
  165.   NotPut        = 4;    { NOT }
  166.  
  167.   { Horizontal and vertical justification for SetTextJustify: }
  168.   LeftText   = 0;
  169.   CenterText = 1;
  170.   RightText  = 2;
  171.  
  172.   BottomText = 0;
  173. { CenterText = 1; already defined above }
  174.   TopText    = 2;
  175.  
  176.  
  177. const
  178.   MaxColors = 15;
  179. type
  180.   PaletteType = record
  181.       Size   : byte;
  182.       Colors : array[0..MaxColors] of shortint;
  183.     end;
  184.  
  185.   LineSettingsType = record
  186.       LineStyle : word;
  187.       Pattern   : word;
  188.       Thickness : word;
  189.     end;
  190.  
  191.   TextSettingsType = record
  192.       Font      : word;
  193.       Direction : word;
  194.       CharSize  : word;
  195.       Horiz     : word;
  196.       Vert      : word;
  197.     end;
  198.  
  199.   FillSettingsType = record               { Pre-defined fill style }
  200.       Pattern : word;
  201.       Color   : word;
  202.     end;
  203.  
  204.   FillPatternType = array[1..8] of byte;  { User defined fill style }
  205.  
  206.   PointType = record
  207.       X, Y : integer;
  208.     end;
  209.  
  210.   ViewPortType = record
  211.       x1, y1, x2, y2 : integer;
  212.       Clip           : boolean;
  213.     end;
  214.  
  215.   ArcCoordsType = record
  216.       X, Y           : integer;
  217.       Xstart, Ystart : integer;
  218.       Xend, Yend     : integer;
  219.     end;
  220.  
  221.  
  222. var
  223.   GraphGetMemPtr  : Pointer;   { allows user to steal heap allocation }
  224.   GraphFreeMemPtr : Pointer;   { allows user to steal heap de-allocation }
  225.  
  226. { *** high-level error handling *** }
  227. function GraphErrorMsg(ErrorCode : integer) : String;
  228. function GraphResult : integer;
  229.  
  230. { *** detection, initialization and crt mode routines *** }
  231. procedure DetectGraph(var GraphDriver, GraphMode : integer);
  232. function GetDriverName : string;
  233.  
  234. procedure InitGraph(var GraphDriver : integer;
  235.                     var GraphMode   : integer;
  236.                         PathToDriver : String);
  237.  
  238. function RegisterBGIfont(Font : pointer) : integer;
  239. function RegisterBGIdriver(Driver : pointer) : integer;
  240. function InstallUserDriver(DriverFileName : string;
  241.                             AutoDetectPtr : pointer) : integer;
  242. function InstallUserFont(FontFileName : string) : integer;
  243. procedure SetGraphBufSize(BufSize : word);
  244. function GetMaxMode : integer;
  245. procedure GetModeRange(GraphDriver : integer; var LoMode, HiMode : integer);
  246. function GetModeName(GraphMode : integer) : string;
  247. procedure SetGraphMode(Mode : integer);
  248. function GetGraphMode : integer;
  249. procedure GraphDefaults;
  250. procedure RestoreCrtMode;
  251. procedure CloseGraph;
  252.  
  253. function  GetX : integer;
  254. function  GetY : integer;
  255. function  GetMaxX : integer;
  256. function  GetMaxY : integer;
  257.  
  258. { *** Screen, viewport, page routines *** }
  259. procedure ClearDevice;
  260. procedure SetViewPort(x1, y1, x2, y2 : integer; Clip : boolean);
  261. procedure GetViewSettings(var ViewPort : ViewPortType);
  262. procedure ClearViewPort;
  263. procedure SetVisualPage(Page : word);
  264. procedure SetActivePage(Page : word);
  265.  
  266. { *** point-oriented routines *** }
  267. procedure PutPixel(X, Y : integer; Pixel : word);
  268. function  GetPixel(X, Y : integer) : word;
  269.  
  270. { *** line-oriented routines *** }
  271. procedure SetWriteMode(WriteMode : integer);
  272. procedure LineTo(X, Y : integer);
  273. procedure LineRel(Dx, Dy : integer);
  274. procedure MoveTo(X, Y : integer);
  275. procedure MoveRel(Dx, Dy : integer);
  276. procedure Line(x1, y1, x2, y2 : integer);
  277. procedure GetLineSettings(var LineInfo : LineSettingsType);
  278. procedure SetLineStyle(LineStyle : word;
  279.                        Pattern   : word;
  280.                        Thickness : word);
  281.  
  282. { *** polygon, fills and figures *** }
  283. procedure Rectangle(x1, y1, x2, y2 : integer);
  284. procedure Bar(x1, y1, x2, y2 : integer);
  285. procedure Bar3D(x1, y1, x2, y2 : integer; Depth : word; Top : boolean);
  286. procedure DrawPoly(NumPoints : word; var PolyPoints);
  287. procedure FillPoly(NumPoints : word; var PolyPoints);
  288. procedure GetFillSettings(var FillInfo : FillSettingsType);
  289. procedure GetFillPattern(var FillPattern : FillPatternType);
  290. procedure SetFillStyle(Pattern : word; Color : word);
  291. procedure SetFillPattern(Pattern : FillPatternType; Color : word);
  292. procedure FloodFill(X, Y : integer; Border : word);
  293.  
  294. { *** arc, circle, and other curves *** }
  295. procedure Arc(X, Y : integer; StAngle, EndAngle, Radius : word);
  296. procedure GetArcCoords(var ArcCoords : ArcCoordsType);
  297. procedure Circle(X, Y : integer; Radius : word);
  298. procedure Ellipse(X, Y : integer;
  299.                   StAngle, EndAngle : word;
  300.                   XRadius, YRadius  : word);
  301. procedure FillEllipse(X, Y : integer;
  302.                       XRadius, YRadius  : word);
  303. procedure GetAspectRatio(var Xasp, Yasp : word);
  304. procedure SetAspectRatio(Xasp, Yasp : word);
  305. procedure PieSlice(X, Y : integer; StAngle, EndAngle, Radius : word);
  306. procedure Sector(X, Y : Integer;
  307.                  StAngle, EndAngle,
  308.                  XRadius, YRadius : word);
  309.  
  310.  
  311. { *** color and palette routines *** }
  312. procedure SetBkColor(ColorNum : word);
  313. procedure SetColor(Color : word);
  314. function GetBkColor : word;
  315. function GetColor : word;
  316. procedure SetAllPalette(var Palette);
  317. procedure SetPalette(ColorNum : word; Color : shortint);
  318. procedure GetPalette(var Palette : PaletteType);
  319. function GetPaletteSize : integer;
  320. procedure GetDefaultPalette(var Palette : PaletteType);
  321. function GetMaxColor : word;
  322. procedure SetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue : integer);
  323.  
  324. { *** bit-image routines *** }
  325. function  ImageSize(x1, y1, x2, y2 : integer) : word;
  326. procedure GetImage(x1, y1, x2, y2 : integer; var BitMap);
  327. procedure PutImage(X, Y : integer; var BitMap; BitBlt : word);
  328.  
  329. { *** text routines *** }
  330. procedure GetTextSettings(var TextInfo : TextSettingsType);
  331. procedure OutText(TextString : string);
  332. procedure OutTextXY(X, Y : integer; TextString : string);
  333. procedure SetTextJustify(Horiz, Vert : word);
  334. procedure SetTextStyle(Font, Direction : word; CharSize : word);
  335. procedure SetUserCharSize(MultX, DivX, MultY, DivY : word);
  336. function  TextHeight(TextString : string) : word;
  337. function  TextWidth(TextString : string) : word;
  338.