gfvgraph.pas 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. { $Id$ }
  2. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  3. { }
  4. { System independent GFV GRAPHICS UNIT }
  5. { }
  6. { Copyright (c) 1999 by Leon de Boer }
  7. { [email protected] - primary e-mail address }
  8. { [email protected] - backup e-mail address }
  9. { }
  10. { This unit provides the interlink between the graphics }
  11. { used in GFV and the graphics API for the different }
  12. { operating systems. }
  13. { }
  14. {****************[ THIS CODE IS FREEWARE ]*****************}
  15. { }
  16. { This sourcecode is released for the purpose to }
  17. { promote the pascal language on all platforms. You may }
  18. { redistribute it and/or modify with the following }
  19. { DISCLAIMER. }
  20. { }
  21. { This SOURCE CODE is distributed "AS IS" WITHOUT }
  22. { WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR }
  23. { ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
  24. { }
  25. {*****************[ SUPPORTED PLATFORMS ]******************}
  26. { 16 and 32 Bit compilers }
  27. { DOS - Turbo Pascal 7.0 + (16 Bit) }
  28. { DPMI - Turbo Pascal 7.0 + (16 Bit) }
  29. { - FPC 0.9912+ (GO32V2) (32 Bit) }
  30. { WINDOWS - Turbo Pascal 7.0 + (16 Bit) }
  31. { - Delphi 1.0+ (16 Bit) }
  32. { WIN95/NT - Delphi 2.0+ (32 Bit) }
  33. { - Virtual Pascal 2.0+ (32 Bit) }
  34. { - Speedsoft Sybil 2.0+ (32 Bit) }
  35. { - FPC 0.9912+ (32 Bit) }
  36. { OS2 - Virtual Pascal 1.0+ (32 Bit) }
  37. { - Speed Pascal 1.0+ (32 Bit) }
  38. { }
  39. {*****************[ REVISION HISTORY ]*********************}
  40. { Version Date Fix }
  41. { ------- --------- ---------------------------------- }
  42. { 1.00 26 Nov 99 Unit started from relocated code }
  43. { originally from views.pas }
  44. {**********************************************************}
  45. UNIT GFVGraph;
  46. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  47. INTERFACE
  48. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  49. {====Include file to sort compiler platform out =====================}
  50. {$I Platform.inc}
  51. {====================================================================}
  52. {==== Compiler directives ===========================================}
  53. {$IFNDEF PPC_FPC} { FPC doesn't support these switches }
  54. {$F-} { Near far calls are okay }
  55. {$A+} { Word Align Data }
  56. {$B-} { Allow short circuit boolean evaluations }
  57. {$O+} { This unit may be overlaid }
  58. {$G+} { 286 Code optimization - if you're on an 8088 get a real computer }
  59. {$E+} { Emulation is on }
  60. {$N-} { No 80x87 code generation }
  61. {$ENDIF}
  62. {$X+} { Extended syntax is ok }
  63. {$R-} { Disable range checking }
  64. {$S-} { Disable Stack Checking }
  65. {$I-} { Disable IO Checking }
  66. {$Q-} { Disable Overflow Checking }
  67. {$V-} { Turn off strict VAR strings }
  68. {====================================================================}
  69. {***************************************************************************}
  70. { PUBLIC CONSTANTS }
  71. {***************************************************************************}
  72. {---------------------------------------------------------------------------}
  73. { STANDARD COLOUR CONSTANTS }
  74. {---------------------------------------------------------------------------}
  75. CONST
  76. Black = 0; { Black }
  77. Blue = 1; { Blue }
  78. Green = 2; { Green }
  79. Cyan = 3; { Cyan }
  80. Red = 4; { Red }
  81. Magenta = 5; { Magenta }
  82. Brown = 6; { Brown }
  83. LightGray = 7; { Light grey }
  84. DarkGray = 8; { Dark grey }
  85. LightBlue = 9; { Light blue }
  86. LightGreen = 10; { Light green }
  87. LightCyan = 11; { Light cyan }
  88. LightRed = 12; { Light red }
  89. LightMagenta = 13; { Light magenta }
  90. Yellow = 14; { Yellow }
  91. White = 15; { White }
  92. {---------------------------------------------------------------------------}
  93. { WRITE MODE CONSTANTS }
  94. {---------------------------------------------------------------------------}
  95. CONST
  96. NormalPut = 0; { Normal overwrite }
  97. CopyPut = 0; { Normal put image }
  98. AndPut = 1; { AND colour write }
  99. OrPut = 2; { OR colour write }
  100. XorPut = 3; { XOR colour write }
  101. NotPut = 4; { NOT colour write }
  102. {---------------------------------------------------------------------------}
  103. { CLIP CONTROL CONSTANTS }
  104. {---------------------------------------------------------------------------}
  105. CONST
  106. ClipOn = True; { Clipping on }
  107. ClipOff = False; { Clipping off }
  108. {---------------------------------------------------------------------------}
  109. { VIDEO CARD DETECTION CONSTANTS }
  110. {---------------------------------------------------------------------------}
  111. CONST
  112. Detect = 0; { Detect video }
  113. {---------------------------------------------------------------------------}
  114. { TEXT JUSTIFICATION CONSTANTS }
  115. {---------------------------------------------------------------------------}
  116. CONST
  117. LeftText = 0; { Left justify }
  118. CenterText = 1; { Centre justify }
  119. RightText = 2; { Right justify }
  120. BottomText = 0; { Bottom justify }
  121. TopText = 2; { Top justify }
  122. {---------------------------------------------------------------------------}
  123. { FILL PATTERN CONSTANTS }
  124. {---------------------------------------------------------------------------}
  125. CONST
  126. EmptyFill = 0; { No fill pattern }
  127. SolidFill = 1; { Solid colour }
  128. LineFill = 2; { Line fill }
  129. LtSlashFill = 3; { Fwd slash line type }
  130. SlashFill = 4; { Fwd slash pattern }
  131. BkSlashFill = 5; { Back slash pattern }
  132. LtBkSlashFill = 6; { Back slash line type }
  133. HatchFill = 7; { Hatch pattern }
  134. XHatchFill = 8; { Cross hatch pattern }
  135. InterleaveFill = 9; { Interleaved pattern }
  136. WideDotFill = 10; { Wide dot pattern }
  137. CloseDotFill = 11; { Close dot pattern }
  138. UserFill = 12; { User defined fill }
  139. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  140. {---------------------------------------------------------------------------}
  141. { WIN/NT STANDARD TColorRef CONSTANTS TO MATCH COLOUR CONSTANTS }
  142. {---------------------------------------------------------------------------}
  143. CONST
  144. rgb_Black = $00000000; { 0 = Black }
  145. rgb_Blue = $007F0000; { 1 = Blue }
  146. rgb_Green = $00007F00; { 2 = Green }
  147. rgb_Cyan = $007F7F00; { 3 = Cyan }
  148. rgb_Red = $0000007F; { 4 = Red }
  149. rgb_Magenta = $007F7F00; { 5 = Magenta }
  150. rgb_Brown = $00007F7F; { 6 = Brown }
  151. rgb_LightGray = $00AFAFAF; { 7 = LightGray }
  152. rgb_DarkGray = $004F4F4F; { 8 = DarkGray }
  153. rgb_LightBlue = $00FF0000; { 9 = Light Blue }
  154. rgb_LightGreen = $0000FF00; { 10 = Light Green }
  155. rgb_LightCyan = $00FFFF00; { 11 = Light Cyan }
  156. rgb_LightRed = $000000FF; { 12 = Light Red }
  157. rgb_LightMagenta = $00FFFF00; { 13 = Light Magenta }
  158. rgb_Yellow = $0000FFFF; { 14 = Yellow }
  159. rgb_White = $00FFFFFF; { 15 = White }
  160. {$ENDIF}
  161. {***************************************************************************}
  162. { PUBLIC TYPE DEFINITIONS }
  163. {***************************************************************************}
  164. {---------------------------------------------------------------------------}
  165. { ViewPortType RECORD DEFINITION }
  166. {---------------------------------------------------------------------------}
  167. TYPE
  168. ViewPortType = PACKED RECORD
  169. X1, Y1, X2, Y2: Integer; { Corners of viewport }
  170. Clip : Boolean; { Clip status }
  171. END;
  172. {***************************************************************************}
  173. { INTERFACE ROUTINES }
  174. {***************************************************************************}
  175. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  176. { GRAPHICS MODE CONTROL ROUTINES }
  177. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  178. {-SetWriteMode-------------------------------------------------------
  179. Sets the current write mode constant all subsequent draws etc. are
  180. then via the set mode.
  181. 26Nov99 LdB
  182. ---------------------------------------------------------------------}
  183. PROCEDURE SetWriteMode (Mode: Byte);
  184. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  185. { VIEWPORT CONTROL ROUTINES }
  186. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  187. {-GetViewSettings----------------------------------------------------
  188. Returns the current viewport and clip parameters in the variable.
  189. 26Nov99 LdB
  190. ---------------------------------------------------------------------}
  191. PROCEDURE GetViewSettings (Var CurrentViewPort: ViewPortType);
  192. {-SetViewPort--------------------------------------------------------
  193. Set the current viewport and clip parameters to that requested.
  194. 26Nov99 LdB
  195. ---------------------------------------------------------------------}
  196. PROCEDURE SetViewPort (X1, Y1, X2, Y2: Integer; Clip: Boolean);
  197. {***************************************************************************}
  198. { INITIALIZED PUBLIC VARIABLES }
  199. {***************************************************************************}
  200. {---------------------------------------------------------------------------}
  201. { INITIALIZED DOS/DPMI/WIN/NT/OS2 VARIABLES }
  202. {---------------------------------------------------------------------------}
  203. CONST
  204. WriteMode : Byte = 0; { Current write mode }
  205. SysScreenWidth : Integer = 640; { Default screen width }
  206. SysScreenHeight: Integer = 480; { Default screen height}
  207. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  208. IMPLEMENTATION
  209. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  210. {***************************************************************************}
  211. { PRIVATE INITIALIZED VARIABLES }
  212. {***************************************************************************}
  213. {---------------------------------------------------------------------------}
  214. { DOS/DPMI/WIN/NT/OS2 INITIALIZED VARIABLES }
  215. {---------------------------------------------------------------------------}
  216. CONST
  217. Cxp : Integer = 0; { Current x position }
  218. Cyp : Integer = 0; { Current y position }
  219. ViewPort: ViewPortType = (X1:0; Y1:0; X2: 639;
  220. Y2: 479; Clip: True); { Default viewport }
  221. {***************************************************************************}
  222. { INTERFACE ROUTINES }
  223. {***************************************************************************}
  224. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  225. { GRAPHICS MODE CONTROL ROUTINES }
  226. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  227. {---------------------------------------------------------------------------}
  228. { SetWriteMode -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 09Aug99 LdB }
  229. {---------------------------------------------------------------------------}
  230. PROCEDURE SetWriteMode (Mode: Byte);
  231. BEGIN
  232. WriteMode := Mode; { Hold writemode value }
  233. END;
  234. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  235. { VIEW PORT CONTROL ROUTINES }
  236. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  237. {---------------------------------------------------------------------------}
  238. { GetViewSettings -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 09Aug99 LdB }
  239. {---------------------------------------------------------------------------}
  240. PROCEDURE GetViewSettings (Var CurrentViewPort: ViewPortType);
  241. BEGIN
  242. CurrentViewPort := ViewPort; { Return view port }
  243. END;
  244. {---------------------------------------------------------------------------}
  245. { SetViewPort -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 09Aug99 LdB }
  246. {---------------------------------------------------------------------------}
  247. PROCEDURE SetViewPort (X1, Y1, X2, Y2: Integer; Clip: Boolean);
  248. BEGIN
  249. If (X1 < 0) Then X1 := 0; { X1 negative fix }
  250. If (X1 > SysScreenWidth) Then
  251. X1 := SysScreenWidth; { X1 off screen fix }
  252. If (Y1 < 0) Then Y1 := 0; { Y1 negative fix }
  253. If (Y1 > SysScreenHeight) Then
  254. Y1 := SysScreenHeight; { Y1 off screen fix }
  255. If (X2 < 0) Then X2 := 0; { X2 negative fix }
  256. If (X2 > SysScreenWidth) Then X2 := SysScreenWidth;{ X2 off screen fix }
  257. If (Y2 < 0) Then Y2 := 0; { Y2 negative fix }
  258. If (Y2 > SysScreenHeight) Then
  259. Y2 := SysScreenHeight; { Y2 off screen fix }
  260. ViewPort.X1 := X1; { Set X1 port value }
  261. ViewPort.Y1 := Y1; { Set Y1 port value }
  262. ViewPort.X2 := X2; { Set X2 port value }
  263. ViewPort.Y2 := Y2; { Set Y2 port value }
  264. ViewPort.Clip := Clip; { Set port clip value }
  265. Cxp := X1; { Set current x pos }
  266. Cyp := Y1; { Set current y pos }
  267. END;
  268. END.
  269. {
  270. $Log$
  271. Revision 1.2 2000-08-24 12:00:21 marco
  272. * CVS log and ID tags
  273. }