CGDirectDisplay.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. {
  2. * CGDirectDisplay.h
  3. * CoreGraphics
  4. *
  5. * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit CGDirectDisplay;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,CFBase,CFArray,CFDictionary,CGContext,CGBase,CGGeometry,CGErrors;
  90. {$ALIGN POWER}
  91. {
  92. * The following construct is present to avoid problems with some Apple tools.
  93. * API in this module is not available in Mac OS Classic variations!
  94. }
  95. type
  96. CGDirectDisplayID = ^SInt32; { an opaque 32-bit type }
  97. CGDirectDisplayIDPtr = ^CGDirectDisplayID; { when a var xx:CGDirectDisplayID parameter can be nil, it is changed to xx: CGDirectDisplayIDPtr }
  98. type
  99. CGDirectPaletteRef = ^SInt32; { an opaque 32-bit type }
  100. CGDirectPaletteRefPtr = ^CGDirectPaletteRef; { when a var xx:CGDirectPaletteRef parameter can be nil, it is changed to xx: CGDirectPaletteRefPtr }
  101. type
  102. CGDisplayCount = UInt32;
  103. type
  104. CGTableCount = UInt32;
  105. type
  106. CGDisplayCoord = SInt32;
  107. type
  108. CGByteValue = SInt8;
  109. CGByteValuePtr = ^CGByteValue;
  110. type
  111. CGOpenGLDisplayMask = UInt32;
  112. type
  113. CGBeamPosition = UInt32;
  114. type
  115. CGMouseDelta = SInt32;
  116. type
  117. CGRefreshRate = double;
  118. type
  119. CGCaptureOptions = UInt32;
  120. type
  121. CGDisplayErr = CGError;
  122. const
  123. CGDisplayNoErr = kCGErrorSuccess;
  124. kCGDirectMainDisplay = nil;
  125. { Returns the display ID of the current main display }
  126. function CGMainDisplayID: CGDirectDisplayID; external name '_CGMainDisplayID';
  127. {
  128. * Mechanisms used to find screen IDs
  129. * An array length (maxDisplays) and array of CGDirectDisplayIDs are passed in.
  130. * Up to maxDisplays of the array are filled in with the displays meeting the
  131. * specified criteria. The actual number of displays filled in is returned in
  132. * dspyCnt.
  133. *
  134. * If the dspys array is NULL, maxDisplays is ignored, and *dspyCnt is filled
  135. * in with the number of displays meeting the function's requirements.
  136. }
  137. function CGGetDisplaysWithPoint( point: CGPoint; maxDisplays: CGDisplayCount; dspys: CGDirectDisplayIDPtr; var dspyCnt: CGDisplayCount ): CGDisplayErr; external name '_CGGetDisplaysWithPoint';
  138. function CGGetDisplaysWithRect( rect: CGRect; maxDisplays: CGDisplayCount; dspys: CGDirectDisplayIDPtr; var dspyCnt: CGDisplayCount ): CGDisplayErr; external name '_CGGetDisplaysWithRect';
  139. function CGGetDisplaysWithOpenGLDisplayMask( mask: CGOpenGLDisplayMask; maxDisplays: CGDisplayCount; dspys: CGDirectDisplayIDPtr; var dspyCnt: CGDisplayCount ): CGDisplayErr; external name '_CGGetDisplaysWithOpenGLDisplayMask';
  140. {
  141. * Get lists of displays. Use this to determine display IDs
  142. *
  143. * If the activeDspys array is NULL, maxDisplays is ignored, and *dspyCnt is filled
  144. * in with the number of displays meeting the function's requirements.
  145. *
  146. * The first display returned in the list is the main display,
  147. * the one with the menu bar.
  148. * When mirroring, this will be the largest drawable display in the mirror,
  149. * set, or if all are the same size, the one with the deepest pixel depth.
  150. }
  151. function CGGetActiveDisplayList( maxDisplays: CGDisplayCount; activeDspys: CGDirectDisplayIDPtr; var dspyCnt: CGDisplayCount ): CGDisplayErr; external name '_CGGetActiveDisplayList';
  152. {
  153. * With hardware mirroring, a display may be on-line,
  154. * but not necessarily active, or drawable.
  155. * Programs which manipulate display settings such as the
  156. * palette or gamma tables need access to all displays in use,
  157. * including hardware mirrors which are not drawable.
  158. }
  159. function CGGetOnlineDisplayList( maxDisplays: CGDisplayCount; onlineDspys: CGDirectDisplayIDPtr; var dspyCnt: CGDisplayCount ): CGDisplayErr; external name '_CGGetOnlineDisplayList';
  160. { Map a display to an OpenGL display mask; returns 0 on invalid display }
  161. function CGDisplayIDToOpenGLDisplayMask( display: CGDirectDisplayID ): CGOpenGLDisplayMask; external name '_CGDisplayIDToOpenGLDisplayMask';
  162. {
  163. * Map an OpenGL display mask to a display.
  164. * Returns kCGNullDirectDisplay if a bit doesn't
  165. * match a display.
  166. * Passing in multiple bits results in an arbitrary match.
  167. }
  168. function CGOpenGLDisplayMaskToDisplayID( mask: CGOpenGLDisplayMask ): CGDirectDisplayID; external name '_CGOpenGLDisplayMaskToDisplayID';
  169. { Return screen size and origin in global coords; Empty rect if display is invalid }
  170. function CGDisplayBounds( display: CGDirectDisplayID ): CGRect; external name '_CGDisplayBounds';
  171. function CGDisplayPixelsWide( display: CGDirectDisplayID ): size_t; external name '_CGDisplayPixelsWide';
  172. function CGDisplayPixelsHigh( display: CGDirectDisplayID ): size_t; external name '_CGDisplayPixelsHigh';
  173. {
  174. * Display mode selection
  175. * Display modes are represented as CFDictionaries
  176. * All dictionaries and arrays returned via these mechanisms are
  177. * owned by the framework and should not be released. The framework
  178. * will not release them out from under your application.
  179. *
  180. * Values associated with the following keys are CFNumber types.
  181. * With CFNumberGetValue(), use kCFNumberLongType for best results.
  182. * kCGDisplayRefreshRate encodes a double value, so to get the fractional
  183. * refresh rate use kCFNumberDoubleType.
  184. }
  185. {
  186. * Keys used in mode dictionaries. Source C strings shown won't change.
  187. * Some CFM environments cannot import data variables, and so
  188. * the definitions are provided directly.
  189. *
  190. * These keys are used only within the scope of the mode dictionaries,
  191. * so further uniquing, as by prefix, of the source string is not needed.
  192. }
  193. {$ifc USE_CFSTR_CONSTANT_MACROS}
  194. {$definec kCGDisplayWidth CFSTRP('Width')}
  195. {$endc}
  196. {$ifc USE_CFSTR_CONSTANT_MACROS}
  197. {$definec kCGDisplayHeight CFSTRP('Height')}
  198. {$endc}
  199. {$ifc USE_CFSTR_CONSTANT_MACROS}
  200. {$definec kCGDisplayMode CFSTRP('Mode')}
  201. {$endc}
  202. {$ifc USE_CFSTR_CONSTANT_MACROS}
  203. {$definec kCGDisplayBitsPerPixel CFSTRP('BitsPerPixel')}
  204. {$endc}
  205. {$ifc USE_CFSTR_CONSTANT_MACROS}
  206. {$definec kCGDisplayBitsPerSample CFSTRP('BitsPerSample')}
  207. {$endc}
  208. {$ifc USE_CFSTR_CONSTANT_MACROS}
  209. {$definec kCGDisplaySamplesPerPixel CFSTRP('SamplesPerPixel')}
  210. {$endc}
  211. {$ifc USE_CFSTR_CONSTANT_MACROS}
  212. {$definec kCGDisplayRefreshRate CFSTRP('RefreshRate')}
  213. {$endc}
  214. {$ifc USE_CFSTR_CONSTANT_MACROS}
  215. {$definec kCGDisplayModeUsableForDesktopGUI CFSTRP('UsableForDesktopGUI')}
  216. {$endc}
  217. {$ifc USE_CFSTR_CONSTANT_MACROS}
  218. {$definec kCGDisplayIOFlags CFSTRP('IOFlags')}
  219. {$endc}
  220. {$ifc USE_CFSTR_CONSTANT_MACROS}
  221. {$definec kCGDisplayBytesPerRow CFSTRP('kCGDisplayBytesPerRow')}
  222. {$endc}
  223. {
  224. * Keys to describe optional properties of display modes.
  225. *
  226. * The key will only be present if the property applies,
  227. * and will be associated with a value of kCFBooleanTrue.
  228. * Keys not relevant to a particular display mode will not
  229. * appear in the mode dictionary.
  230. *
  231. * These strings must remain unchanged in future releases, of course.
  232. }
  233. { Set if display mode doesn't need a confirmation dialog to be set }
  234. {$ifc USE_CFSTR_CONSTANT_MACROS}
  235. {$definec kCGDisplayModeIsSafeForHardware CFSTRP('kCGDisplayModeIsSafeForHardware')}
  236. {$endc}
  237. { The following keys reflect interesting bits of the IOKit display mode flags }
  238. {$ifc USE_CFSTR_CONSTANT_MACROS}
  239. {$definec kCGDisplayModeIsInterlaced CFSTRP('kCGDisplayModeIsInterlaced')}
  240. {$endc}
  241. {$ifc USE_CFSTR_CONSTANT_MACROS}
  242. {$definec kCGDisplayModeIsStretched CFSTRP('kCGDisplayModeIsStretched')}
  243. {$endc}
  244. {$ifc USE_CFSTR_CONSTANT_MACROS}
  245. {$definec kCGDisplayModeIsTelevisionOutput CFSTRP('kCGDisplayModeIsTelevisionOutput')}
  246. {$endc}
  247. {
  248. * Return a CFArray of CFDictionaries describing all display modes.
  249. * Returns NULL if the display is invalid.
  250. }
  251. function CGDisplayAvailableModes( display: CGDirectDisplayID ): CFArrayRef; external name '_CGDisplayAvailableModes';
  252. {
  253. * Try to find a display mode of specified depth with dimensions equal or greater than
  254. * specified.
  255. * If no depth match is found, try for the next larger depth with dimensions equal or greater
  256. * than specified. If no luck, then just return the current mode.
  257. *
  258. * exactmatch, if not NULL, is set to 'true' if an exact match in width, height, and depth is found,
  259. * and 'false' otherwise.
  260. *
  261. * CGDisplayBestModeForParametersAndRefreshRateWithProperty searches the list, looking for
  262. * display modes with the specified property. The property should be one of:
  263. * kCGDisplayModeIsSafeForHardware;
  264. * kCGDisplayModeIsInterlaced;
  265. * kCGDisplayModeIsStretched;
  266. * kCGDisplayModeIsTelevisionOutput
  267. *
  268. * Returns NULL if display is invalid.
  269. }
  270. function CGDisplayBestModeForParameters( display: CGDirectDisplayID; bitsPerPixel: size_t; width: size_t; height: size_t; var exactMatch: boolean_t ): CFDictionaryRef; external name '_CGDisplayBestModeForParameters';
  271. function CGDisplayBestModeForParametersAndRefreshRate( display: CGDirectDisplayID; bitsPerPixel: size_t; width: size_t; height: size_t; refresh: CGRefreshRate; var exactMatch: boolean_t ): CFDictionaryRef; external name '_CGDisplayBestModeForParametersAndRefreshRate';
  272. function CGDisplayBestModeForParametersAndRefreshRateWithProperty( display: CGDirectDisplayID; bitsPerPixel: size_t; width: size_t; height: size_t; refresh: CGRefreshRate; property: CFStringRef; var exactMatch: boolean_t ): CFDictionaryRef; external name '_CGDisplayBestModeForParametersAndRefreshRateWithProperty';
  273. {
  274. * Return a CFDictionary describing the current display mode.
  275. * Returns NULL if display is invalid.
  276. }
  277. function CGDisplayCurrentMode( display: CGDirectDisplayID ): CFDictionaryRef; external name '_CGDisplayCurrentMode';
  278. {
  279. * Switch display mode. Note that after switching,
  280. * display parameters and addresses may change.
  281. * The selected display mode persists for the life of the program, and automatically
  282. * reverts to the permanent setting made by Preferences when the program terminates.
  283. * The mode dictionary passed in must be a dictionary vended by other CGDirectDisplay
  284. * APIs such as CGDisplayBestModeForParameters() and CGDisplayAvailableModes().
  285. *
  286. * The mode dictionary passed in must be a dictionary vended by other CGDirectDisplay
  287. * APIs such as CGDisplayBestModeForParameters() and CGDisplayAvailableModes().
  288. *
  289. * When changing display modes of displays in a mirroring set, other displays in
  290. * the mirroring set will be set to a display mode capable of mirroring the bounds
  291. * of the largest display being explicitly set.
  292. }
  293. function CGDisplaySwitchToMode( display: CGDirectDisplayID; mode: CFDictionaryRef ): CGDisplayErr; external name '_CGDisplaySwitchToMode';
  294. { Query parameters for current mode }
  295. function CGDisplayBitsPerPixel( display: CGDirectDisplayID ): size_t; external name '_CGDisplayBitsPerPixel';
  296. function CGDisplayBitsPerSample( display: CGDirectDisplayID ): size_t; external name '_CGDisplayBitsPerSample';
  297. function CGDisplaySamplesPerPixel( display: CGDirectDisplayID ): size_t; external name '_CGDisplaySamplesPerPixel';
  298. function CGDisplayBytesPerRow( display: CGDirectDisplayID ): size_t; external name '_CGDisplayBytesPerRow';
  299. {
  300. * Set a display gamma/transfer function from a formula specifying
  301. * min and max values and a gamma for each channel.
  302. * Gamma values must be greater than 0.0.
  303. * To get an antigamma of 1.6, one would specify a value of (1.0 / 1.6)
  304. * Min values must be greater than or equal to 0.0 and less than 1.0.
  305. * Max values must be greater than 0.0 and less than or equal to 1.0.
  306. * Out of range values, or Max greater than or equal to Min result
  307. * in a kCGSRangeCheck error.
  308. *
  309. * Values are computed by sampling a function for a range of indices from 0 through 1:
  310. * value = Min + ((Max - Min) * pow(index, Gamma))
  311. * The resulting values are converted to a machine specific format
  312. * and loaded into hardware.
  313. }
  314. type
  315. CGGammaValue = Float32;
  316. CGGammaValuePtr = ^CGGammaValue;
  317. function CGSetDisplayTransferByFormula( display: CGDirectDisplayID; redMin: CGGammaValue; redMax: CGGammaValue; redGamma: CGGammaValue; greenMin: CGGammaValue; greenMax: CGGammaValue; greenGamma: CGGammaValue; blueMin: CGGammaValue; blueMax: CGGammaValue; blueGamma: CGGammaValue ): CGDisplayErr; external name '_CGSetDisplayTransferByFormula';
  318. function CGGetDisplayTransferByFormula( display: CGDirectDisplayID; var redMin: CGGammaValue; var redMax: CGGammaValue; var redGamma: CGGammaValue; var greenMin: CGGammaValue; var greenMax: CGGammaValue; var greenGamma: CGGammaValue; var blueMin: CGGammaValue; var blueMax: CGGammaValue; var blueGamma: CGGammaValue ): CGDisplayErr; external name '_CGGetDisplayTransferByFormula';
  319. {
  320. * Returns the capacity, or nunber of entries, in the camma table for the specified
  321. * display. If 'display' is invalid, returns 0.
  322. }
  323. function CGDisplayGammaTableCapacity( display: CGDirectDisplayID ): CGTableCount; external name '_CGDisplayGammaTableCapacity'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  324. {
  325. * Set a display gamma/transfer function using tables of data for each channel.
  326. * Values within each table should have values in the range of 0.0 through 1.0.
  327. * The same table may be passed in for red, green, and blue channels. 'tableSize'
  328. * indicates the number of entries in each table.
  329. * The tables are interpolated as needed to generate the number of samples needed
  330. * by hardware.
  331. }
  332. function CGSetDisplayTransferByTable( display: CGDirectDisplayID; tableSize: CGTableCount; redTable: {const} CGGammaValuePtr; greenTable: {const} CGGammaValuePtr; blueTable: {const} CGGammaValuePtr ): CGDisplayErr; external name '_CGSetDisplayTransferByTable';
  333. {
  334. * Get transfer tables. Capacity should contain the number of samples each
  335. * array can hold, and *sampleCount is filled in with the number of samples
  336. * actually copied in.
  337. }
  338. function CGGetDisplayTransferByTable( display: CGDirectDisplayID; capacity: CGTableCount; redTable: CGGammaValuePtr; greenTable: CGGammaValuePtr; blueTable: CGGammaValuePtr; var sampleCount: CGTableCount ): CGDisplayErr; external name '_CGGetDisplayTransferByTable';
  339. { As a convenience, allow setting of the gamma table by byte values }
  340. function CGSetDisplayTransferByByteTable( display: CGDirectDisplayID; tableSize: CGTableCount; redTable: {const} CGByteValuePtr; greenTable: {const} CGByteValuePtr; blueTable: {const} CGByteValuePtr ): CGDisplayErr; external name '_CGSetDisplayTransferByByteTable';
  341. { Restore gamma tables of system displays to the user's ColorSync specified values }
  342. procedure CGDisplayRestoreColorSyncSettings; external name '_CGDisplayRestoreColorSyncSettings';
  343. {
  344. * Options used with CGDisplayCaptureWithOptions and CGCaptureAllDisplaysWithOptions
  345. }
  346. const
  347. kCGCaptureNoOptions = 0; { Default behavior }
  348. kCGCaptureNoFill = 1 shl 0; { Disables fill with black on display capture }
  349. { Display capture and release }
  350. function CGDisplayIsCaptured( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsCaptured';
  351. function CGDisplayCapture( display: CGDirectDisplayID ): CGDisplayErr; external name '_CGDisplayCapture';
  352. function CGDisplayCaptureWithOptions( display: CGDirectDisplayID; options: CGCaptureOptions ): CGDisplayErr; external name '_CGDisplayCaptureWithOptions'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  353. function CGDisplayRelease( display: CGDirectDisplayID ): CGDisplayErr; external name '_CGDisplayRelease';
  354. {
  355. * Capture all displays; this has the nice effect of providing an immersive
  356. * environment, and preventing other apps from trying to adjust themselves
  357. * to display changes only needed by your app.
  358. }
  359. function CGCaptureAllDisplays: CGDisplayErr; external name '_CGCaptureAllDisplays';
  360. function CGCaptureAllDisplaysWithOptions( options: CGCaptureOptions ): CGDisplayErr; external name '_CGCaptureAllDisplaysWithOptions'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  361. {
  362. * Release all captured displays, and restore the display modes to the
  363. * user's preferences. May be used in conjunction with CGDisplayCapture()
  364. * or CGCaptureAllDisplays().
  365. }
  366. function CGReleaseAllDisplays: CGDisplayErr; external name '_CGReleaseAllDisplays';
  367. {
  368. * Returns CoreGraphics raw shield window ID or NULL if not shielded
  369. * This value may be used with drawing surface APIs.
  370. }
  371. function CGShieldingWindowID( display: CGDirectDisplayID ): UnivPtr; external name '_CGShieldingWindowID';
  372. {
  373. * Returns the window level used for the shield window.
  374. * This value may be used with Cocoa windows to position the
  375. * Cocoa window in the same window level as the shield window.
  376. }
  377. function CGShieldingWindowLevel: SInt32; external name '_CGShieldingWindowLevel';
  378. {
  379. * Returns base address of display or NULL for an invalid display.
  380. * If the display has not been captured, the returned address may refer
  381. * to read-only memory.
  382. }
  383. function CGDisplayBaseAddress( display: CGDirectDisplayID ): UnivPtr; external name '_CGDisplayBaseAddress';
  384. {
  385. * return address for X,Y in global coordinates;
  386. * (0,0) represents the upper left corner of the main display.
  387. * returns NULL for an invalid display or out of bounds coordinates
  388. * If the display has not been captured, the returned address may refer
  389. * to read-only memory.
  390. }
  391. function CGDisplayAddressForPosition( display: CGDirectDisplayID; x: CGDisplayCoord; y: CGDisplayCoord ): UnivPtr; external name '_CGDisplayAddressForPosition';
  392. { Mouse Cursor controls }
  393. function CGDisplayHideCursor( display: CGDirectDisplayID ): CGDisplayErr; external name '_CGDisplayHideCursor'; { increments hide cursor count }
  394. function CGDisplayShowCursor( display: CGDirectDisplayID ): CGDisplayErr; external name '_CGDisplayShowCursor'; { decrements hide cursor count }
  395. {
  396. * Move the cursor to the specified point relative to the display origin
  397. * (the upper left corner of the display). Returns CGDisplayNoErr on success.
  398. * No events are generated as a result of this move.
  399. * Points that would lie outside the desktop are clipped to the desktop.
  400. }
  401. function CGDisplayMoveCursorToPoint( display: CGDirectDisplayID; point: CGPoint ): CGDisplayErr; external name '_CGDisplayMoveCursorToPoint';
  402. {
  403. * Report the mouse position change associated with the last mouse move event
  404. * recieved by this application.
  405. }
  406. procedure CGGetLastMouseDelta( var deltaX: CGMouseDelta; var deltaY: CGMouseDelta ); external name '_CGGetLastMouseDelta';
  407. { Palette controls (8 bit pseudocolor only) }
  408. {
  409. * Returns TRUE if the current display mode supports palettes.
  410. * Display must not be a hardware mirror of another, and should
  411. * have a depth of 8 bits per pixel for this to return TRUE.
  412. }
  413. function CGDisplayCanSetPalette( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayCanSetPalette';
  414. {
  415. * Set a palette. The current gamma function is applied to the palette
  416. * elements before being loaded into hardware. The display must not be
  417. * a hardware mirror of another, and should have a depth of 8 bits per pixel.
  418. * Setting the palette on the active, or primary display in a hardware
  419. * mirroring set affects all displays in that set.
  420. }
  421. function CGDisplaySetPalette( display: CGDirectDisplayID; palette: CGDirectPaletteRef ): CGDisplayErr; external name '_CGDisplaySetPalette';
  422. {
  423. * Wait until the beam position is outside the range specified by upperScanLine and lowerScanLine.
  424. * Note that if upperScanLine and lowerScanLine encompass the entire display height,
  425. * the function returns an error.
  426. * lowerScanLine must be greater than or equal to upperScanLine.
  427. *
  428. * Some display systems may not conventional video vertical and horizontal sweep in painting.
  429. * These displays report a kCGDisplayRefreshRate of 0 in the CFDictionaryRef returned by
  430. * CGDisplayCurrentMode(). On such displays, this function returns at once.
  431. *
  432. * Some drivers may not implement support for this mechanism.
  433. * On such displays, this function returns at once.
  434. *
  435. * Returns CGDisplayNoErr on success, and an error if display or upperScanLine and
  436. * lowerScanLine are invalid.
  437. *
  438. * The app should set the values of upperScanLine and lowerScanLine to allow enough lead time
  439. * for the drawing operation to complete. A common strategy is to wait for the beam to pass
  440. * the bottom of the drawing area, allowing almost a full vertical sweep period to perform drawing.
  441. * To do this, set upperScanLine to 0, and set lowerScanLine to the bottom of the bounding box:
  442. * lowerScanLine = (CGBeamPosition)(cgrect.origin.y + cgrect.size.height);
  443. *
  444. * IOKit may implement this as a spin-loop on the beam position call used for CGDisplayBeamPosition().
  445. * On such system the function is CPU bound, and subject to all the usual scheduling pre-emption.
  446. * In particular, attempting to wait for the beam to hit a specific scanline may be an exercise in frustration.
  447. *
  448. * These functions are advisary in nature, and depend on IOKit and hardware specific drivers to implement
  449. * support. If you need extremely precise timing, or access to vertical blanking interrupts,
  450. * you should consider writing a device driver to tie into hardware-specific capabilities.
  451. }
  452. function CGDisplayWaitForBeamPositionOutsideLines( display: CGDirectDisplayID; upperScanLine: CGBeamPosition; lowerScanLine: CGBeamPosition ): CGDisplayErr; external name '_CGDisplayWaitForBeamPositionOutsideLines';
  453. {
  454. * Returns the current beam position on the display. If display is invalid,
  455. * or the display does not implement conventional video vertical and horizontal
  456. * sweep in painting, or the driver does not implement this functionality, 0 is returned.
  457. }
  458. function CGDisplayBeamPosition( display: CGDirectDisplayID ): CGBeamPosition; external name '_CGDisplayBeamPosition';
  459. {
  460. * Obtain a CGContextRef suitable for drawing to a captured display.
  461. *
  462. * Returns a drawing context suitable for use on the display device.
  463. * The context is owned by the device, and should not be released by
  464. * the caller.
  465. *
  466. * The context remains valid while the display is captured, and the
  467. * display configuration is unchanged. Releasing the captured display
  468. * or reconfiguring the display invalidates the drawing context.
  469. *
  470. * An application may register a display reconfiguration callback to determine
  471. * when the display configuration is changing via CGRegisterDisplayReconfigurationProc().
  472. *
  473. * After a display configuration change, or on capturing a display, call this
  474. * function to obtain a current drawing context.
  475. *
  476. * If the display has not been captured, this function returns NULL.
  477. }
  478. function CGDisplayGetDrawingContext( display: CGDirectDisplayID ): CGContextRef; external name '_CGDisplayGetDrawingContext'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  479. end.