grlib.h 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. //*****************************************************************************
  2. //
  3. // grlib.h - Prototypes for the low level primitives provided by the graphics
  4. // library.
  5. //
  6. // Copyright (c) 2007-2010 Texas Instruments Incorporated. All rights reserved.
  7. // Software License Agreement
  8. //
  9. // Texas Instruments (TI) is supplying this software for use solely and
  10. // exclusively on TI's microcontroller products. The software is owned by
  11. // TI and/or its suppliers, and is protected under applicable copyright
  12. // laws. You may not combine this software with "viral" open-source
  13. // software in order to form a larger program.
  14. //
  15. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  16. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  17. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  19. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  20. // DAMAGES, FOR ANY REASON WHATSOEVER.
  21. //
  22. // This is part of revision 6288 of the Stellaris Graphics Library.
  23. //
  24. //*****************************************************************************
  25. #ifndef __GRLIB_H__
  26. #define __GRLIB_H__
  27. //*****************************************************************************
  28. //
  29. //! \addtogroup primitives_api
  30. //! @{
  31. //
  32. //*****************************************************************************
  33. //*****************************************************************************
  34. //
  35. // If building with a C++ compiler, make all of the definitions in this header
  36. // have a C binding.
  37. //
  38. //*****************************************************************************
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43. //*****************************************************************************
  44. //
  45. //! This structure defines the extents of a rectangle. All points greater than
  46. //! or equal to the minimum and less than or equal to the maximum are part of
  47. //! the rectangle.
  48. //
  49. //*****************************************************************************
  50. typedef struct
  51. {
  52. //
  53. //! The minimum X coordinate of the rectangle.
  54. //
  55. short sXMin;
  56. //
  57. //! The minimum Y coordinate of the rectangle.
  58. //
  59. short sYMin;
  60. //
  61. //! The maximum X coordinate of the rectangle.
  62. //
  63. short sXMax;
  64. //
  65. //! The maximum Y coordinate of the rectangle.
  66. //
  67. short sYMax;
  68. }
  69. tRectangle;
  70. //*****************************************************************************
  71. //
  72. //! This structure defines the characteristics of a display driver.
  73. //
  74. //*****************************************************************************
  75. typedef struct
  76. {
  77. //
  78. //! The size of this structure.
  79. //
  80. int lSize;
  81. //
  82. //! A pointer to display driver-specific data.
  83. //
  84. void *pvDisplayData;
  85. //
  86. //! The width of this display.
  87. //
  88. unsigned short usWidth;
  89. //
  90. //! The height of this display.
  91. //
  92. unsigned short usHeight;
  93. //
  94. //! A pointer to the function to draw a pixel on this display.
  95. //
  96. void (*pfnPixelDraw)(void *pvDisplayData, int lX, int lY,
  97. unsigned int ulValue);
  98. //
  99. //! A pointer to the function to draw multiple pixels on this display.
  100. //
  101. void (*pfnPixelDrawMultiple)(void *pvDisplayData, int lX, int lY,
  102. int lX0, int lCount, int lBPP,
  103. const unsigned char *pucData,
  104. const unsigned char *pucPalette);
  105. //
  106. //! A pointer to the function to draw a horizontal line on this display.
  107. //
  108. void (*pfnLineDrawH)(void *pvDisplayData, int lX1, int lX2, int lY,
  109. unsigned int ulValue);
  110. //
  111. //! A pointer to the function to draw a vertical line on this display.
  112. //
  113. void (*pfnLineDrawV)(void *pvDisplayData, int lX, int lY1, int lY2,
  114. unsigned int ulValue);
  115. //
  116. //! A pointer to the function to draw a filled rectangle on this display.
  117. //
  118. void (*pfnRectFill)(void *pvDisplayData, const tRectangle *pRect,
  119. unsigned int ulValue);
  120. //
  121. //! A pointer to the function to translate 24-bit RGB colors to
  122. //! display-specific colors.
  123. //
  124. unsigned int (*pfnColorTranslate)(void *pvDisplayData,
  125. unsigned int ulValue);
  126. //
  127. //! A pointer to the function to flush any cached drawing operations on
  128. //! this display.
  129. //
  130. void (*pfnFlush)(void *pvDisplayData);
  131. }
  132. tDisplay;
  133. //*****************************************************************************
  134. //
  135. //! This structure describes a font used for drawing text onto the screen.
  136. //
  137. //*****************************************************************************
  138. typedef struct
  139. {
  140. //
  141. //! The format of the font. Can be one of FONT_FMT_UNCOMPRESSED or
  142. //! FONT_FMT_PIXEL_RLE.
  143. //
  144. unsigned char ucFormat;
  145. //
  146. //! The maximum width of a character; this is the width of the widest
  147. //! character in the font, though any individual character may be narrower
  148. //! than this width.
  149. //
  150. unsigned char ucMaxWidth;
  151. //
  152. //! The height of the character cell; this may be taller than the font data
  153. //! for the characters (to provide inter-line spacing).
  154. //
  155. unsigned char ucHeight;
  156. //
  157. //! The offset between the top of the character cell and the baseline of
  158. //! the glyph. The baseline is the bottom row of a capital letter, below
  159. //! which only the descenders of the lower case letters occur.
  160. //
  161. unsigned char ucBaseline;
  162. //
  163. //! The offset within pucData to the data for each character in the font.
  164. //
  165. unsigned short pusOffset[96];
  166. //
  167. //! A pointer to the data for the font.
  168. //
  169. const unsigned char *pucData;
  170. }
  171. tFont;
  172. //*****************************************************************************
  173. //
  174. //! Indicates that the font data is stored in an uncompressed format.
  175. //
  176. //*****************************************************************************
  177. #define FONT_FMT_UNCOMPRESSED 0x00
  178. //*****************************************************************************
  179. //
  180. //! Indicates that the font data is stored using a pixel-based RLE format.
  181. //
  182. //*****************************************************************************
  183. #define FONT_FMT_PIXEL_RLE 0x01
  184. //*****************************************************************************
  185. //
  186. //! Indicates that the image data is not compressed and represents each pixel
  187. //! with a single bit.
  188. //
  189. //*****************************************************************************
  190. #define IMAGE_FMT_1BPP_UNCOMP 0x01
  191. //*****************************************************************************
  192. //
  193. //! Indicates that the image data is not compressed and represents each pixel
  194. //! with four bits.
  195. //
  196. //*****************************************************************************
  197. #define IMAGE_FMT_4BPP_UNCOMP 0x04
  198. //*****************************************************************************
  199. //
  200. //! Indicates that the image data is not compressed and represents each pixel
  201. //! with eight bits.
  202. //
  203. //*****************************************************************************
  204. #define IMAGE_FMT_8BPP_UNCOMP 0x08
  205. //*****************************************************************************
  206. //
  207. //! Indicates that the image data is compressed and represents each pixel with
  208. //! a single bit.
  209. //
  210. //*****************************************************************************
  211. #define IMAGE_FMT_1BPP_COMP 0x81
  212. //*****************************************************************************
  213. //
  214. //! Indicates that the image data is compressed and represents each pixel with
  215. //! four bits.
  216. //
  217. //*****************************************************************************
  218. #define IMAGE_FMT_4BPP_COMP 0x84
  219. //*****************************************************************************
  220. //
  221. //! Indicates that the image data is compressed and represents each pixel with
  222. //! eight bits.
  223. //
  224. //*****************************************************************************
  225. #define IMAGE_FMT_8BPP_COMP 0x88
  226. #define IMAGE_FMT_16BPP_UNCOMP 0x10
  227. #define IMAGE_FMT_16BPP_COMP 0x90
  228. #define IMAGE_FMT_24BPP_UNCOMP 0x20
  229. #define IMAGE_FMT_24BPP_COMP 0xA0
  230. //*****************************************************************************
  231. //
  232. //! This structure defines a drawing context to be used to draw onto the
  233. //! screen. Multiple drawing contexts may exist at any time.
  234. //
  235. //*****************************************************************************
  236. typedef struct
  237. {
  238. //
  239. //! The size of this structure.
  240. //
  241. int lSize;
  242. //
  243. //! The screen onto which drawing operations are performed.
  244. //
  245. const tDisplay *pDisplay;
  246. //
  247. //! The clipping region to be used when drawing onto the screen.
  248. //
  249. tRectangle sClipRegion;
  250. //
  251. //! The color used to draw primitives onto the screen.
  252. //
  253. unsigned int ulForeground;
  254. //
  255. //! The background color used to draw primitives onto the screen.
  256. //
  257. unsigned int ulBackground;
  258. //
  259. //! The font used to render text onto the screen.
  260. //
  261. const tFont *pFont;
  262. }
  263. tContext;
  264. //*****************************************************************************
  265. //
  266. //! Sets the background color to be used.
  267. //!
  268. //! \param pContext is a pointer to the drawing context to modify.
  269. //! \param ulValue is the 24-bit RGB color to be used.
  270. //!
  271. //! This function sets the background color to be used for drawing operations
  272. //! in the specified drawing context.
  273. //!
  274. //! \return None.
  275. //
  276. //*****************************************************************************
  277. #define GrContextBackgroundSet(pContext, ulValue) \
  278. do \
  279. { \
  280. tContext *pC = pContext; \
  281. pC->ulBackground = DpyColorTranslate(pC->pDisplay, ulValue); \
  282. } \
  283. while(0)
  284. //*****************************************************************************
  285. //
  286. //! Sets the background color to be used.
  287. //!
  288. //! \param pContext is a pointer to the drawing context to modify.
  289. //! \param ulValue is the display driver-specific color to be used.
  290. //!
  291. //! This function sets the background color to be used for drawing operations
  292. //! in the specified drawing context, using a color that has been previously
  293. //! translated to a driver-specific color (for example, via
  294. //! DpyColorTranslate()).
  295. //!
  296. //! \return None.
  297. //
  298. //*****************************************************************************
  299. #define GrContextBackgroundSetTranslated(pContext, ulValue) \
  300. do \
  301. { \
  302. tContext *pC = pContext; \
  303. pC->ulBackground = ulValue; \
  304. } \
  305. while(0)
  306. //*****************************************************************************
  307. //
  308. //! Gets the width of the display being used by this drawing context.
  309. //!
  310. //! \param pContext is a pointer to the drawing context to query.
  311. //!
  312. //! This function returns the width of the display that is being used by this
  313. //! drawing context.
  314. //!
  315. //! \return Returns the width of the display in pixels.
  316. //
  317. //*****************************************************************************
  318. #define GrContextDpyWidthGet(pContext) \
  319. (DpyWidthGet((pContext)->pDisplay))
  320. //*****************************************************************************
  321. //
  322. //! Gets the height of the display being used by this drawing context.
  323. //!
  324. //! \param pContext is a pointer to the drawing context to query.
  325. //!
  326. //! This function returns the height of the display that is being used by this
  327. //! drawing context.
  328. //!
  329. //! \return Returns the height of the display in pixels.
  330. //
  331. //*****************************************************************************
  332. #define GrContextDpyHeightGet(pContext) \
  333. (DpyHeightGet((pContext)->pDisplay))
  334. //*****************************************************************************
  335. //
  336. //! Sets the font to be used.
  337. //!
  338. //! \param pContext is a pointer to the drawing context to modify.
  339. //! \param pFnt is a pointer to the font to be used.
  340. //!
  341. //! This function sets the font to be used for string drawing operations in the
  342. //! specified drawing context.
  343. //!
  344. //! \return None.
  345. //
  346. //*****************************************************************************
  347. #define GrContextFontSet(pContext, pFnt) \
  348. do \
  349. { \
  350. tContext *pC = pContext; \
  351. const tFont *pF = pFnt; \
  352. pC->pFont = pF; \
  353. } \
  354. while(0)
  355. //*****************************************************************************
  356. //
  357. //! Sets the foreground color to be used.
  358. //!
  359. //! \param pContext is a pointer to the drawing context to modify.
  360. //! \param ulValue is the 24-bit RGB color to be used.
  361. //!
  362. //! This function sets the color to be used for drawing operations in the
  363. //! specified drawing context.
  364. //!
  365. //! \return None.
  366. //
  367. //*****************************************************************************
  368. #define GrContextForegroundSet(pContext, ulValue) \
  369. do \
  370. { \
  371. tContext *pC = pContext; \
  372. pC->ulForeground = DpyColorTranslate(pC->pDisplay, ulValue); \
  373. } \
  374. while(0)
  375. //*****************************************************************************
  376. //
  377. //! Sets the foreground color to be used.
  378. //!
  379. //! \param pContext is a pointer to the drawing context to modify.
  380. //! \param ulValue is the display driver-specific color to be used.
  381. //!
  382. //! This function sets the foreground color to be used for drawing operations
  383. //! in the specified drawing context, using a color that has been previously
  384. //! translated to a driver-specific color (for example, via
  385. //! DpyColorTranslate()).
  386. //!
  387. //! \return None.
  388. //
  389. //*****************************************************************************
  390. #define GrContextForegroundSetTranslated(pContext, ulValue) \
  391. do \
  392. { \
  393. tContext *pC = pContext; \
  394. pC->ulForeground = ulValue; \
  395. } \
  396. while(0)
  397. //*****************************************************************************
  398. //
  399. //! Flushes any cached drawing operations.
  400. //!
  401. //! \param pContext is a pointer to the drawing context to use.
  402. //!
  403. //! This function flushes any cached drawing operations. For display drivers
  404. //! that draw into a local frame buffer before writing to the actual display,
  405. //! calling this function will cause the display to be updated to match the
  406. //! contents of the local frame buffer.
  407. //!
  408. //! \return None.
  409. //
  410. //*****************************************************************************
  411. #define GrFlush(pContext) \
  412. do \
  413. { \
  414. const tContext *pC = pContext; \
  415. DpyFlush(pC->pDisplay); \
  416. } \
  417. while(0)
  418. //*****************************************************************************
  419. //
  420. //! Gets the baseline of a font.
  421. //!
  422. //! \param pFont is a pointer to the font to query.
  423. //!
  424. //! This function determines the baseline position of a font. The baseline is
  425. //! the offset between the top of the font and the bottom of the capital
  426. //! letters. The only font data that exists below the baseline are the
  427. //! descenders on some lower-case letters (such as ``y'').
  428. //!
  429. //! \return Returns the baseline of the font, in pixels.
  430. //
  431. //*****************************************************************************
  432. #define GrFontBaselineGet(pFont) \
  433. ((pFont)->ucBaseline)
  434. //*****************************************************************************
  435. //
  436. //! Gets the height of a font.
  437. //!
  438. //! \param pFont is a pointer to the font to query.
  439. //!
  440. //! This function determines the height of a font. The height is the offset
  441. //! between the top of the font and the bottom of the font, including any
  442. //! ascenders and descenders.
  443. //!
  444. //! \return Returns the height of the font, in pixels.
  445. //
  446. //*****************************************************************************
  447. #define GrFontHeightGet(pFont) \
  448. ((pFont)->ucHeight)
  449. //*****************************************************************************
  450. //
  451. //! Gets the maximum width of a font.
  452. //!
  453. //! \param pFont is a pointer to the font to query.
  454. //!
  455. //! This function determines the maximum width of a font. The maximum width is
  456. //! the width of the widest individual character in the font.
  457. //!
  458. //! \return Returns the maximum width of the font, in pixels.
  459. //
  460. //*****************************************************************************
  461. #define GrFontMaxWidthGet(pFont) \
  462. ((pFont)->ucMaxWidth)
  463. //*****************************************************************************
  464. //
  465. //! Gets the number of colors in an image.
  466. //!
  467. //! \param pucImage is a pointer to the image to query.
  468. //!
  469. //! This function determines the number of colors in the palette of an image.
  470. //! This is only valid for 4bpp and 8bpp images; 1bpp images do not contain a
  471. //! palette.
  472. //!
  473. //! \return Returns the number of colors in the image.
  474. //
  475. //*****************************************************************************
  476. #define GrImageColorsGet(pucImage) \
  477. (((unsigned char *)pucImage)[5] + 1)
  478. //*****************************************************************************
  479. //
  480. //! Gets the height of an image.
  481. //!
  482. //! \param pucImage is a pointer to the image to query.
  483. //!
  484. //! This function determines the height of an image in pixels.
  485. //!
  486. //! \return Returns the height of the image in pixels.
  487. //
  488. //*****************************************************************************
  489. #define GrImageHeightGet(pucImage) \
  490. ((unsigned short)(*(pucImage+4) << 8) | *(pucImage+3))
  491. //*****************************************************************************
  492. //
  493. //! Gets the width of an image.
  494. //!
  495. //! \param pucImage is a pointer to the image to query.
  496. //!
  497. //! This function determines the width of an image in pixels.
  498. //!
  499. //! \return Returns the width of the image in pixels.
  500. //
  501. //*****************************************************************************
  502. #define GrImageWidthGet(pucImage) \
  503. ((unsigned short)(*(pucImage+2) << 8) | *(pucImage+1))
  504. //*****************************************************************************
  505. //
  506. //! Determines the size of the buffer for a 1 BPP off-screen image.
  507. //!
  508. //! \param lWidth is the width of the image in pixels.
  509. //! \param lHeight is the height of the image in pixels.
  510. //!
  511. //! This function determines the size of the memory buffer required to hold a
  512. //! 1 BPP off-screen image of the specified geometry.
  513. //!
  514. //! \return Returns the number of bytes required by the image.
  515. //
  516. //*****************************************************************************
  517. #define GrOffScreen1BPPSize(lWidth, lHeight) \
  518. (5 + (((lWidth + 7) / 8) * lHeight))
  519. //*****************************************************************************
  520. //
  521. //! Determines the size of the buffer for a 4 BPP off-screen image.
  522. //!
  523. //! \param lWidth is the width of the image in pixels.
  524. //! \param lHeight is the height of the image in pixels.
  525. //!
  526. //! This function determines the size of the memory buffer required to hold a
  527. //! 4 BPP off-screen image of the specified geometry.
  528. //!
  529. //! \return Returns the number of bytes required by the image.
  530. //
  531. //*****************************************************************************
  532. #define GrOffScreen4BPPSize(lWidth, lHeight) \
  533. (6 + (16 * 3) + (((lWidth + 1) / 2) * lHeight))
  534. //*****************************************************************************
  535. //
  536. //! Determines the size of the buffer for a 16 BPP off-screen image.
  537. //!
  538. //! \param lWidth is the width of the image in pixels.
  539. //! \param lHeight is the height of the image in pixels.
  540. //!
  541. //! This function determines the size of the memory buffer required to hold a
  542. //! 16 BPP off-screen image of the specified geometry.
  543. //!
  544. //! \return Returns the number of bytes required by the image.
  545. //
  546. //*****************************************************************************
  547. #define GrOffScreen16BPPSize(lWidth, lHeight) \
  548. (4 + (16*2) + (lWidth * lHeight * 2))
  549. //*****************************************************************************
  550. //
  551. //! Determines the size of the buffer for a 24 BPP off-screen image.
  552. //!
  553. //! \param lWidth is the width of the image in pixels.
  554. //! \param lHeight is the height of the image in pixels.
  555. //!
  556. //! This function determines the size of the memory buffer required to hold a
  557. //! 16 BPP off-screen image of the specified geometry.
  558. //!
  559. //! \return Returns the number of bytes required by the image.
  560. //
  561. //*****************************************************************************
  562. #define GrOffScreen24BPPSize(lWidth, lHeight, pack) \
  563. (4 + (8*4) + (lWidth * lHeight * (3+pack)))
  564. //*****************************************************************************
  565. //
  566. //! Determines the size of the buffer for an 8 BPP off-screen image.
  567. //!
  568. //! \param lWidth is the width of the image in pixels.
  569. //! \param lHeight is the height of the image in pixels.
  570. //!
  571. //! This function determines the size of the memory buffer required to hold an
  572. //! 8 BPP off-screen image of the specified geometry.
  573. //!
  574. //! \return Returns the number of bytes required by the image.
  575. //
  576. //*****************************************************************************
  577. #define GrOffScreen8BPPSize(lWidth, lHeight) \
  578. (6 + (256 * 3) + (lWidth * lHeight))
  579. //*****************************************************************************
  580. //
  581. //! Draws a pixel.
  582. //!
  583. //! \param pContext is a pointer to the drawing context to use.
  584. //! \param lX is the X coordinate of the pixel.
  585. //! \param lY is the Y coordinate of the pixel.
  586. //!
  587. //! This function draws a pixel if it resides within the clipping region.
  588. //!
  589. //! \return None.
  590. //
  591. //*****************************************************************************
  592. #define GrPixelDraw(pContext, lX, lY) \
  593. do \
  594. { \
  595. const tContext *pC = pContext; \
  596. if((lX >= pC->sClipRegion.sXMin) && \
  597. (lX <= pC->sClipRegion.sXMax) && \
  598. (lY >= pC->sClipRegion.sYMin) && \
  599. (lY <= pC->sClipRegion.sYMax)) \
  600. { \
  601. DpyPixelDraw(pC->pDisplay, lX, lY, pC->ulForeground); \
  602. } \
  603. } \
  604. while(0)
  605. //*****************************************************************************
  606. //
  607. //! Gets the baseline of a string.
  608. //!
  609. //! \param pContext is a pointer to the drawing context to query.
  610. //!
  611. //! This function determines the baseline position of a string. The baseline
  612. //! is the offset between the top of the string and the bottom of the capital
  613. //! letters. The only string data that exists below the baseline are the
  614. //! descenders on some lower-case letters (such as ``y'').
  615. //!
  616. //! \return Returns the baseline of the string, in pixels.
  617. //
  618. //*****************************************************************************
  619. #define GrStringBaselineGet(pContext) \
  620. ((pContext)->pFont->ucBaseline)
  621. //*****************************************************************************
  622. //
  623. //! Draws a centered string.
  624. //!
  625. //! \param pContext is a pointer to the drawing context to use.
  626. //! \param pcString is a pointer to the string to be drawn.
  627. //! \param lLength is the number of characters from the string that should be
  628. //! drawn on the screen.
  629. //! \param lX is the X coordinate of the center of the string position on the
  630. //! screen.
  631. //! \param lY is the Y coordinate of the center of the string position on the
  632. //! screen.
  633. //! \param bOpaque is \b true if the background of each character should be
  634. //! drawn and \b false if it should not (leaving the background as is).
  635. //!
  636. //! This function draws a string of test on the screen centered upon the
  637. //! provided position. The \e lLength parameter allows a portion of the
  638. //! string to be examined without having to insert a NULL character at the
  639. //! stopping point (which would not be possible if the string was located in
  640. //! flash); specifying a length of -1 will cause the entire string to be
  641. //! rendered (subject to clipping).
  642. //!
  643. //! \return None.
  644. //
  645. //*****************************************************************************
  646. #define GrStringDrawCentered(pContext, pcString, lLength, lX, lY, bOpaque) \
  647. do \
  648. { \
  649. const tContext *pC = pContext; \
  650. const char *pcStr = pcString; \
  651. \
  652. GrStringDraw(pC, pcStr, lLength, \
  653. (lX) - (GrStringWidthGet(pC, pcStr, lLength) / 2), \
  654. (lY) - (pC->pFont->ucBaseline / 2), bOpaque); \
  655. } \
  656. while(0)
  657. //*****************************************************************************
  658. //
  659. //! Gets the height of a string.
  660. //!
  661. //! \param pContext is a pointer to the drawing context to query.
  662. //!
  663. //! This function determines the height of a string. The height is the offset
  664. //! between the top of the string and the bottom of the string, including any
  665. //! ascenders and descenders. Note that this will not account for the case
  666. //! where the string in question does not have any characters that use
  667. //! descenders but the font in the drawing context does contain characters with
  668. //! descenders.
  669. //!
  670. //! \return Returns the height of the string, in pixels.
  671. //
  672. //*****************************************************************************
  673. #define GrStringHeightGet(pContext) \
  674. ((pContext)->pFont->ucHeight)
  675. //*****************************************************************************
  676. //
  677. //! Gets the maximum width of a character in a string.
  678. //!
  679. //! \param pContext is a pointer to the drawing context to query.
  680. //!
  681. //! This function determines the maximum width of a character in a string. The
  682. //! maximum width is the width of the widest individual character in the font
  683. //! used to render the string, which may be wider than the widest character
  684. //! that is used to render a particular string.
  685. //!
  686. //! \return Returns the maximum width of a character in a string, in pixels.
  687. //
  688. //*****************************************************************************
  689. #define GrStringMaxWidthGet(pContext) \
  690. ((pContext)->pFont->ucMaxWidth)
  691. //*****************************************************************************
  692. //
  693. // A set of color definitions. This set is the subset of the X11 colors (from
  694. // rgb.txt) that are supported by typical web browsers.
  695. //
  696. //*****************************************************************************
  697. #define ClrAliceBlue 0x00F0F8FF
  698. #define ClrAntiqueWhite 0x00FAEBD7
  699. #define ClrAqua 0x0000FFFF
  700. #define ClrAquamarine 0x007FFFD4
  701. #define ClrAzure 0x00F0FFFF
  702. #define ClrBeige 0x00F5F5DC
  703. #define ClrBisque 0x00FFE4C4
  704. #define ClrBlack 0x00000000
  705. #define ClrBlanchedAlmond 0x00FFEBCD
  706. #define ClrBlue 0x000000FF
  707. #define ClrBlueViolet 0x008A2BE2
  708. #define ClrBrown 0x00A52A2A
  709. #define ClrBurlyWood 0x00DEB887
  710. #define ClrCadetBlue 0x005F9EA0
  711. #define ClrChartreuse 0x007FFF00
  712. #define ClrChocolate 0x00D2691E
  713. #define ClrCoral 0x00FF7F50
  714. #define ClrCornflowerBlue 0x006495ED
  715. #define ClrCornsilk 0x00FFF8DC
  716. #define ClrCrimson 0x00DC143C
  717. #define ClrCyan 0x0000FFFF
  718. #define ClrDarkBlue 0x0000008B
  719. #define ClrDarkCyan 0x00008B8B
  720. #define ClrDarkGoldenrod 0x00B8860B
  721. #define ClrDarkGray 0x00A9A9A9
  722. #define ClrDarkGreen 0x00006400
  723. #define ClrDarkKhaki 0x00BDB76B
  724. #define ClrDarkMagenta 0x008B008B
  725. #define ClrDarkOliveGreen 0x00556B2F
  726. #define ClrDarkOrange 0x00FF8C00
  727. #define ClrDarkOrchid 0x009932CC
  728. #define ClrDarkRed 0x008B0000
  729. #define ClrDarkSalmon 0x00E9967A
  730. #define ClrDarkSeaGreen 0x008FBC8F
  731. #define ClrDarkSlateBlue 0x00483D8B
  732. #define ClrDarkSlateGray 0x002F4F4F
  733. #define ClrDarkTurquoise 0x0000CED1
  734. #define ClrDarkViolet 0x009400D3
  735. #define ClrDeepPink 0x00FF1493
  736. #define ClrDeepSkyBlue 0x0000BFFF
  737. #define ClrDimGray 0x00696969
  738. #define ClrDodgerBlue 0x001E90FF
  739. #define ClrFireBrick 0x00B22222
  740. #define ClrFloralWhite 0x00FFFAF0
  741. #define ClrForestGreen 0x00228B22
  742. #define ClrFuchsia 0x00FF00FF
  743. #define ClrGainsboro 0x00DCDCDC
  744. #define ClrGhostWhite 0x00F8F8FF
  745. #define ClrGold 0x00FFD700
  746. #define ClrGoldenrod 0x00DAA520
  747. #define ClrGray 0x00808080
  748. #define ClrGreen 0x00008000
  749. #define ClrGreenYellow 0x00ADFF2F
  750. #define ClrHoneydew 0x00F0FFF0
  751. #define ClrHotPink 0x00FF69B4
  752. #define ClrIndianRed 0x00CD5C5C
  753. #define ClrIndigo 0x004B0082
  754. #define ClrIvory 0x00FFFFF0
  755. #define ClrKhaki 0x00F0E68C
  756. #define ClrLavender 0x00E6E6FA
  757. #define ClrLavenderBlush 0x00FFF0F5
  758. #define ClrLawnGreen 0x007CFC00
  759. #define ClrLemonChiffon 0x00FFFACD
  760. #define ClrLightBlue 0x00ADD8E6
  761. #define ClrLightCoral 0x00F08080
  762. #define ClrLightCyan 0x00E0FFFF
  763. #define ClrLightGoldenrodYellow 0x00FAFAD2
  764. #define ClrLightGreen 0x0090EE90
  765. #define ClrLightGrey 0x00D3D3D3
  766. #define ClrLightPink 0x00FFB6C1
  767. #define ClrLightSalmon 0x00FFA07A
  768. #define ClrLightSeaGreen 0x0020B2AA
  769. #define ClrLightSkyBlue 0x0087CEFA
  770. #define ClrLightSlateGray 0x00778899
  771. #define ClrLightSteelBlue 0x00B0C4DE
  772. #define ClrLightYellow 0x00FFFFE0
  773. #define ClrLime 0x0000FF00
  774. #define ClrLimeGreen 0x0032CD32
  775. #define ClrLinen 0x00FAF0E6
  776. #define ClrMagenta 0x00FF00FF
  777. #define ClrMaroon 0x00800000
  778. #define ClrMediumAquamarine 0x0066CDAA
  779. #define ClrMediumBlue 0x000000CD
  780. #define ClrMediumOrchid 0x00BA55D3
  781. #define ClrMediumPurple 0x009370DB
  782. #define ClrMediumSeaGreen 0x003CB371
  783. #define ClrMediumSlateBlue 0x007B68EE
  784. #define ClrMediumSpringGreen 0x0000FA9A
  785. #define ClrMediumTurquoise 0x0048D1CC
  786. #define ClrMediumVioletRed 0x00C71585
  787. #define ClrMidnightBlue 0x00191970
  788. #define ClrMintCream 0x00F5FFFA
  789. #define ClrMistyRose 0x00FFE4E1
  790. #define ClrMoccasin 0x00FFE4B5
  791. #define ClrNavajoWhite 0x00FFDEAD
  792. #define ClrNavy 0x00000080
  793. #define ClrOldLace 0x00FDF5E6
  794. #define ClrOlive 0x00808000
  795. #define ClrOliveDrab 0x006B8E23
  796. #define ClrOrange 0x00FFA500
  797. #define ClrOrangeRed 0x00FF4500
  798. #define ClrOrchid 0x00DA70D6
  799. #define ClrPaleGoldenrod 0x00EEE8AA
  800. #define ClrPaleGreen 0x0098FB98
  801. #define ClrPaleTurquoise 0x00AFEEEE
  802. #define ClrPaleVioletRed 0x00DB7093
  803. #define ClrPapayaWhip 0x00FFEFD5
  804. #define ClrPeachPuff 0x00FFDAB9
  805. #define ClrPeru 0x00CD853F
  806. #define ClrPink 0x00FFC0CB
  807. #define ClrPlum 0x00DDA0DD
  808. #define ClrPowderBlue 0x00B0E0E6
  809. #define ClrPurple 0x00800080
  810. #define ClrRed 0x00FF0000
  811. #define ClrRosyBrown 0x00BC8F8F
  812. #define ClrRoyalBlue 0x004169E1
  813. #define ClrSaddleBrown 0x008B4513
  814. #define ClrSalmon 0x00FA8072
  815. #define ClrSandyBrown 0x00F4A460
  816. #define ClrSeaGreen 0x002E8B57
  817. #define ClrSeashell 0x00FFF5EE
  818. #define ClrSienna 0x00A0522D
  819. #define ClrSilver 0x00C0C0C0
  820. #define ClrSkyBlue 0x0087CEEB
  821. #define ClrSlateBlue 0x006A5ACD
  822. #define ClrSlateGray 0x00708090
  823. #define ClrSnow 0x00FFFAFA
  824. #define ClrSpringGreen 0x0000FF7F
  825. #define ClrSteelBlue 0x004682B4
  826. #define ClrTan 0x00D2B48C
  827. #define ClrTeal 0x00008080
  828. #define ClrThistle 0x00D8BFD8
  829. #define ClrTomato 0x00FF6347
  830. #define ClrTurquoise 0x0040E0D0
  831. #define ClrViolet 0x00EE82EE
  832. #define ClrWheat 0x00F5DEB3
  833. #define ClrWhite 0x00FFFFFF
  834. #define ClrWhiteSmoke 0x00F5F5F5
  835. #define ClrYellow 0x00FFFF00
  836. #define ClrYellowGreen 0x009ACD32
  837. //*****************************************************************************
  838. //
  839. // Masks and shifts to aid in color format translation by drivers.
  840. //
  841. //*****************************************************************************
  842. #define ClrRedMask 0x00FF0000
  843. #define ClrRedShift 16
  844. #define ClrGreenMask 0x0000FF00
  845. #define ClrGreenShift 8
  846. #define ClrBlueMask 0x000000FF
  847. #define ClrBlueShift 0
  848. //*****************************************************************************
  849. //
  850. // Prototypes for the predefined fonts in the graphics library. ..Cm.. is the
  851. // computer modern font, which is a serif font. ..Cmsc.. is the computer
  852. // modern small-caps font, which is also a serif font. ..Cmss.. is the
  853. // computer modern sans-serif font.
  854. //
  855. //*****************************************************************************
  856. extern const tFont g_sFontCm12;
  857. extern const tFont g_sFontCm12b;
  858. extern const tFont g_sFontCm12i;
  859. extern const tFont g_sFontCm14;
  860. extern const tFont g_sFontCm14b;
  861. extern const tFont g_sFontCm14i;
  862. extern const tFont g_sFontCm16;
  863. extern const tFont g_sFontCm16b;
  864. extern const tFont g_sFontCm16i;
  865. extern const tFont g_sFontCm18;
  866. extern const tFont g_sFontCm18b;
  867. extern const tFont g_sFontCm18i;
  868. extern const tFont g_sFontCm20;
  869. extern const tFont g_sFontCm20b;
  870. extern const tFont g_sFontCm20i;
  871. extern const tFont g_sFontCm22;
  872. extern const tFont g_sFontCm22b;
  873. extern const tFont g_sFontCm22i;
  874. extern const tFont g_sFontCm24;
  875. extern const tFont g_sFontCm24b;
  876. extern const tFont g_sFontCm24i;
  877. extern const tFont g_sFontCm26;
  878. extern const tFont g_sFontCm26b;
  879. extern const tFont g_sFontCm26i;
  880. extern const tFont g_sFontCm28;
  881. extern const tFont g_sFontCm28b;
  882. extern const tFont g_sFontCm28i;
  883. extern const tFont g_sFontCm30;
  884. extern const tFont g_sFontCm30b;
  885. extern const tFont g_sFontCm30i;
  886. extern const tFont g_sFontCm32;
  887. extern const tFont g_sFontCm32b;
  888. extern const tFont g_sFontCm32i;
  889. extern const tFont g_sFontCm34;
  890. extern const tFont g_sFontCm34b;
  891. extern const tFont g_sFontCm34i;
  892. extern const tFont g_sFontCm36;
  893. extern const tFont g_sFontCm36b;
  894. extern const tFont g_sFontCm36i;
  895. extern const tFont g_sFontCm38;
  896. extern const tFont g_sFontCm38b;
  897. extern const tFont g_sFontCm38i;
  898. extern const tFont g_sFontCm40;
  899. extern const tFont g_sFontCm40b;
  900. extern const tFont g_sFontCm40i;
  901. extern const tFont g_sFontCm42;
  902. extern const tFont g_sFontCm42b;
  903. extern const tFont g_sFontCm42i;
  904. extern const tFont g_sFontCm44;
  905. extern const tFont g_sFontCm44b;
  906. extern const tFont g_sFontCm44i;
  907. extern const tFont g_sFontCm46;
  908. extern const tFont g_sFontCm46b;
  909. extern const tFont g_sFontCm46i;
  910. extern const tFont g_sFontCm48;
  911. extern const tFont g_sFontCm48b;
  912. extern const tFont g_sFontCm48i;
  913. extern const tFont g_sFontCmsc12;
  914. extern const tFont g_sFontCmsc14;
  915. extern const tFont g_sFontCmsc16;
  916. extern const tFont g_sFontCmsc18;
  917. extern const tFont g_sFontCmsc20;
  918. extern const tFont g_sFontCmsc22;
  919. extern const tFont g_sFontCmsc24;
  920. extern const tFont g_sFontCmsc26;
  921. extern const tFont g_sFontCmsc28;
  922. extern const tFont g_sFontCmsc30;
  923. extern const tFont g_sFontCmsc32;
  924. extern const tFont g_sFontCmsc34;
  925. extern const tFont g_sFontCmsc36;
  926. extern const tFont g_sFontCmsc38;
  927. extern const tFont g_sFontCmsc40;
  928. extern const tFont g_sFontCmsc42;
  929. extern const tFont g_sFontCmsc44;
  930. extern const tFont g_sFontCmsc46;
  931. extern const tFont g_sFontCmsc48;
  932. extern const tFont g_sFontCmss12;
  933. extern const tFont g_sFontCmss12b;
  934. extern const tFont g_sFontCmss12i;
  935. extern const tFont g_sFontCmss14;
  936. extern const tFont g_sFontCmss14b;
  937. extern const tFont g_sFontCmss14i;
  938. extern const tFont g_sFontCmss16;
  939. extern const tFont g_sFontCmss16b;
  940. extern const tFont g_sFontCmss16i;
  941. extern const tFont g_sFontCmss18;
  942. extern const tFont g_sFontCmss18b;
  943. extern const tFont g_sFontCmss18i;
  944. extern const tFont g_sFontCmss20;
  945. extern const tFont g_sFontCmss20b;
  946. extern const tFont g_sFontCmss20i;
  947. extern const tFont g_sFontCmss22;
  948. extern const tFont g_sFontCmss22b;
  949. extern const tFont g_sFontCmss22i;
  950. extern const tFont g_sFontCmss24;
  951. extern const tFont g_sFontCmss24b;
  952. extern const tFont g_sFontCmss24i;
  953. extern const tFont g_sFontCmss26;
  954. extern const tFont g_sFontCmss26b;
  955. extern const tFont g_sFontCmss26i;
  956. extern const tFont g_sFontCmss28;
  957. extern const tFont g_sFontCmss28b;
  958. extern const tFont g_sFontCmss28i;
  959. extern const tFont g_sFontCmss30;
  960. extern const tFont g_sFontCmss30b;
  961. extern const tFont g_sFontCmss30i;
  962. extern const tFont g_sFontCmss32;
  963. extern const tFont g_sFontCmss32b;
  964. extern const tFont g_sFontCmss32i;
  965. extern const tFont g_sFontCmss34;
  966. extern const tFont g_sFontCmss34b;
  967. extern const tFont g_sFontCmss34i;
  968. extern const tFont g_sFontCmss36;
  969. extern const tFont g_sFontCmss36b;
  970. extern const tFont g_sFontCmss36i;
  971. extern const tFont g_sFontCmss38;
  972. extern const tFont g_sFontCmss38b;
  973. extern const tFont g_sFontCmss38i;
  974. extern const tFont g_sFontCmss40;
  975. extern const tFont g_sFontCmss40b;
  976. extern const tFont g_sFontCmss40i;
  977. extern const tFont g_sFontCmss42;
  978. extern const tFont g_sFontCmss42b;
  979. extern const tFont g_sFontCmss42i;
  980. extern const tFont g_sFontCmss44;
  981. extern const tFont g_sFontCmss44b;
  982. extern const tFont g_sFontCmss44i;
  983. extern const tFont g_sFontCmss46;
  984. extern const tFont g_sFontCmss46b;
  985. extern const tFont g_sFontCmss46i;
  986. extern const tFont g_sFontCmss48;
  987. extern const tFont g_sFontCmss48b;
  988. extern const tFont g_sFontCmss48i;
  989. extern const tFont g_sFontCmtt12;
  990. extern const tFont g_sFontCmtt14;
  991. extern const tFont g_sFontCmtt16;
  992. extern const tFont g_sFontCmtt18;
  993. extern const tFont g_sFontCmtt20;
  994. extern const tFont g_sFontCmtt22;
  995. extern const tFont g_sFontCmtt24;
  996. extern const tFont g_sFontCmtt26;
  997. extern const tFont g_sFontCmtt28;
  998. extern const tFont g_sFontCmtt30;
  999. extern const tFont g_sFontCmtt32;
  1000. extern const tFont g_sFontCmtt34;
  1001. extern const tFont g_sFontCmtt36;
  1002. extern const tFont g_sFontCmtt38;
  1003. extern const tFont g_sFontCmtt40;
  1004. extern const tFont g_sFontCmtt42;
  1005. extern const tFont g_sFontCmtt44;
  1006. extern const tFont g_sFontCmtt46;
  1007. extern const tFont g_sFontCmtt48;
  1008. extern const tFont g_sFontFixed6x8;
  1009. //*****************************************************************************
  1010. //
  1011. // Language identifiers supported by the string table processing functions.
  1012. //
  1013. //*****************************************************************************
  1014. #define GrLangZhPRC 0x0804 // Chinese (PRC)
  1015. #define GrLangZhTW 0x0404 // Chinese (Taiwan)
  1016. #define GrLangEnUS 0x0409 // English (United States)
  1017. #define GrLangEnUK 0x0809 // English (United Kingdom)
  1018. #define GrLangEnAUS 0x0C09 // English (Australia)
  1019. #define GrLangEnCA 0x1009 // English (Canada)
  1020. #define GrLangEnNZ 0x1409 // English (New Zealand)
  1021. #define GrLangFr 0x040C // French (Standard)
  1022. #define GrLangDe 0x0407 // German (Standard)
  1023. #define GrLangHi 0x0439 // Hindi
  1024. #define GrLangIt 0x0410 // Italian (Standard)
  1025. #define GrLangJp 0x0411 // Japanese
  1026. #define GrLangKo 0x0412 // Korean
  1027. #define GrLangEsMX 0x080A // Spanish (Mexico)
  1028. #define GrLangEsSP 0x0C0A // Spanish (Spain)
  1029. #define GrLangSwKE 0x0441 // Swahili (Kenya)
  1030. #define GrLangUrIN 0x0820 // Urdu (India)
  1031. #define GrLangUrPK 0x0420 // Urdu (Pakistan)
  1032. //*****************************************************************************
  1033. //
  1034. //! Translates a 24-bit RGB color to a display driver-specific color.
  1035. //!
  1036. //! \param pDisplay is the pointer to the display driver structure for the
  1037. //! display to operate upon.
  1038. //! \param ulValue is the 24-bit RGB color. The least-significant byte is the
  1039. //! blue channel, the next byte is the green channel, and the third byte is the
  1040. //! red channel.
  1041. //!
  1042. //! This function translates a 24-bit RGB color into a value that can be
  1043. //! written into the display's frame buffer in order to reproduce that color,
  1044. //! or the closest possible approximation of that color.
  1045. //!
  1046. //! \return Returns the display-driver specific color.
  1047. //
  1048. //*****************************************************************************
  1049. #define DpyColorTranslate(pDisplay, ulValue) \
  1050. ((pDisplay)->pfnColorTranslate((pDisplay)->pvDisplayData, ulValue))
  1051. //*****************************************************************************
  1052. //
  1053. //! Flushes cached drawing operations.
  1054. //!
  1055. //! \param pDisplay is the pointer to the display driver structure for the
  1056. //! display to operate upon.
  1057. //!
  1058. //! This function flushes any cached drawing operations on a display.
  1059. //!
  1060. //! \return None.
  1061. //
  1062. //*****************************************************************************
  1063. #define DpyFlush(pDisplay) \
  1064. do \
  1065. { \
  1066. const tDisplay *pD = pDisplay; \
  1067. pD->pfnFlush(pD->pvDisplayData); \
  1068. } \
  1069. while(0)
  1070. //*****************************************************************************
  1071. //
  1072. //! Gets the height of the display.
  1073. //!
  1074. //! \param pDisplay is a pointer to the display driver structure for the
  1075. //! display to query.
  1076. //!
  1077. //! This function determines the height of the display.
  1078. //!
  1079. //! \return Returns the height of the display in pixels.
  1080. //
  1081. //*****************************************************************************
  1082. #define DpyHeightGet(pDisplay) \
  1083. ((pDisplay)->usHeight)
  1084. //*****************************************************************************
  1085. //
  1086. //! Draws a horizontal line on a display.
  1087. //!
  1088. //! \param pDisplay is the pointer to the display driver structure for the
  1089. //! display to operate upon.
  1090. //! \param lX1 is the starting X coordinate of the line.
  1091. //! \param lX2 is the ending X coordinate of the line.
  1092. //! \param lY is the Y coordinate of the line.
  1093. //! \param ulValue is the color to draw the line.
  1094. //!
  1095. //! This function draws a horizontal line on a display. This assumes that
  1096. //! clipping has already been performed, and that both end points of the line
  1097. //! are within the extents of the display.
  1098. //!
  1099. //! \return None.
  1100. //
  1101. //*****************************************************************************
  1102. #define DpyLineDrawH(pDisplay, lX1, lX2, lY, ulValue) \
  1103. do \
  1104. { \
  1105. const tDisplay *pD = pDisplay; \
  1106. pD->pfnLineDrawH(pD->pvDisplayData, lX1, lX2, lY, ulValue); \
  1107. } \
  1108. while(0)
  1109. //*****************************************************************************
  1110. //
  1111. //! Draws a vertical line on a display.
  1112. //!
  1113. //! \param pDisplay is the pointer to the display driver structure for the
  1114. //! display to operate upon.
  1115. //! \param lX is the X coordinate of the line.
  1116. //! \param lY1 is the starting Y coordinate of the line.
  1117. //! \param lY2 is the ending Y coordinate of the line.
  1118. //! \param ulValue is the color to draw the line.
  1119. //!
  1120. //! This function draws a vertical line on a display. This assumes that
  1121. //! clipping has already been performed, and that both end points of the line
  1122. //! are within the extents of the display.
  1123. //!
  1124. //! \return None.
  1125. //
  1126. //*****************************************************************************
  1127. #define DpyLineDrawV(pDisplay, lX, lY1, lY2, ulValue) \
  1128. do \
  1129. { \
  1130. const tDisplay *pD = pDisplay; \
  1131. pD->pfnLineDrawV(pD->pvDisplayData, lX, lY1, lY2, ulValue); \
  1132. } \
  1133. while(0)
  1134. //*****************************************************************************
  1135. //
  1136. //! Draws a pixel on a display.
  1137. //!
  1138. //! \param pDisplay is the pointer to the display driver structure for the
  1139. //! display to operate upon.
  1140. //! \param lX is the X coordinate of the pixel.
  1141. //! \param lY is the Y coordinate of the pixel.
  1142. //! \param ulValue is the color to draw the pixel.
  1143. //!
  1144. //! This function draws a pixel on a display. This assumes that clipping has
  1145. //! already been performed.
  1146. //!
  1147. //! \return None.
  1148. //
  1149. //*****************************************************************************
  1150. #define DpyPixelDraw(pDisplay, lX, lY, ulValue) \
  1151. do \
  1152. { \
  1153. const tDisplay *pD = pDisplay; \
  1154. pD->pfnPixelDraw(pD->pvDisplayData, lX, lY, ulValue); \
  1155. } \
  1156. while(0)
  1157. //*****************************************************************************
  1158. //
  1159. //! Draws a horizontal sequence of pixels on a display.
  1160. //!
  1161. //! \param pDisplay is the pointer to the display driver structure for the
  1162. //! display to operate upon.
  1163. //! \param lX is the X coordinate of the first pixel.
  1164. //! \param lY is the Y coordinate of the first pixel.
  1165. //! \param lX0 is sub-pixel offset within the pixel data, which is valid for 1
  1166. //! or 4 bit per pixel formats.
  1167. //! \param lCount is the number of pixels to draw.
  1168. //! \param lBPP is the number of bits per pixel; must be 1, 4, or 8.
  1169. //! \param pucData is a pointer to the pixel data. For 1 and 4 bit per pixel
  1170. //! formats, the most significant bit(s) represent the left-most pixel.
  1171. //! \param pucPalette is a pointer to the palette used to draw the pixels.
  1172. //!
  1173. //! This function draws a horizontal sequence of pixels on a display, using the
  1174. //! supplied palette. For 1 bit per pixel format, the palette contains
  1175. //! pre-translated colors; for 4 and 8 bit per pixel formats, the palette
  1176. //! contains 24-bit RGB values that must be translated before being written to
  1177. //! the display.
  1178. //!
  1179. //! \return None.
  1180. //
  1181. //*****************************************************************************
  1182. #define DpyPixelDrawMultiple(pDisplay, lX, lY, lX0, lCount, lBPP, pucData, \
  1183. pucPalette) \
  1184. do \
  1185. { \
  1186. const tDisplay *pD = pDisplay; \
  1187. pD->pfnPixelDrawMultiple(pD->pvDisplayData, lX, lY, lX0, lCount, \
  1188. lBPP, pucData, pucPalette); \
  1189. } \
  1190. while(0)
  1191. //*****************************************************************************
  1192. //
  1193. //! Fills a rectangle on a display.
  1194. //!
  1195. //! \param pDisplay is the pointer to the display driver structure for the
  1196. //! display to operate upon.
  1197. //! \param pRect is a pointer to the structure describing the rectangle to
  1198. //! fill.
  1199. //! \param ulValue is the color to fill the rectangle.
  1200. //!
  1201. //! This function fills a rectangle on the display. This assumes that clipping
  1202. //! has already been performed, and that all sides of the rectangle are within
  1203. //! the extents of the display.
  1204. //!
  1205. //! \return None.
  1206. //
  1207. //*****************************************************************************
  1208. #define DpyRectFill(pDisplay, pRect, ulValue) \
  1209. do \
  1210. { \
  1211. const tDisplay *pD = pDisplay; \
  1212. pD->pfnRectFill(pD->pvDisplayData, pRect, ulValue); \
  1213. } \
  1214. while(0)
  1215. //*****************************************************************************
  1216. //
  1217. //! Gets the width of the display.
  1218. //!
  1219. //! \param pDisplay is a pointer to the display driver structure for the
  1220. //! display to query.
  1221. //!
  1222. //! This function determines the width of the display.
  1223. //!
  1224. //! \return Returns the width of the display in pixels.
  1225. //
  1226. //*****************************************************************************
  1227. #define DpyWidthGet(pDisplay) \
  1228. ((pDisplay)->usWidth)
  1229. //*****************************************************************************
  1230. //
  1231. //! Determines if a point lies within a given rectangle.
  1232. //!
  1233. //! \param pRect is a pointer to the rectangle which the point is to be checked
  1234. //! against.
  1235. //! \param lX is the X coordinate of the point to be checked.
  1236. //! \param lY is the Y coordinate of the point to be checked.
  1237. //!
  1238. //! This function determines whether point (lX, lY) lies within the rectangle
  1239. //! described by \e pRect.
  1240. //!
  1241. //! \return Returns 1 if the point is within the rectangle or 0 otherwise.
  1242. //
  1243. //*****************************************************************************
  1244. #define GrRectContainsPoint(pRect, lX, lY) \
  1245. ((((lX) >= (pRect)->sXMin) && ((lX) <= (pRect)->sXMax) && \
  1246. ((lY) >= (pRect)->sYMin) && ((lY) <= (pRect)->sYMax)) ? 1 : 0)
  1247. //*****************************************************************************
  1248. //
  1249. // Prototypes for the graphics library functions.
  1250. //
  1251. //*****************************************************************************
  1252. extern void GrCircleDraw(const tContext *pContext, int lX, int lY,
  1253. int lRadius);
  1254. extern void GrCircleFill(const tContext *pContext, int lX, int lY,
  1255. int lRadius);
  1256. extern void GrContextClipRegionSet(tContext *pContext, tRectangle *pRect);
  1257. extern void GrContextInit(tContext *pContext, const tDisplay *pDisplay);
  1258. extern void GrImageDraw(const tContext *pContext,
  1259. const unsigned char *pucImage, int lX, int lY);
  1260. extern void GrLineDraw(const tContext *pContext, int lX1, int lY1, int lX2,
  1261. int lY2);
  1262. extern void GrLineDrawH(const tContext *pContext, int lX1, int lX2, int lY);
  1263. extern void GrLineDrawV(const tContext *pContext, int lX, int lY1, int lY2);
  1264. extern void GrOffScreen1BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
  1265. int lWidth, int lHeight);
  1266. extern void GrOffScreen4BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
  1267. int lWidth, int lHeight);
  1268. extern void GrOffScreen4BPPPaletteSet(tDisplay *pDisplay,
  1269. unsigned int *pulPalette,
  1270. unsigned int ulOffset,
  1271. unsigned int ulCount);
  1272. extern void GrOffScreen8BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
  1273. int lWidth, int lHeight);
  1274. extern void GrOffScreen8BPPPaletteSet(tDisplay *pDisplay,
  1275. unsigned int *pulPalette,
  1276. unsigned int ulOffset,
  1277. unsigned int ulCount);
  1278. extern void GrOffScreen16BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
  1279. int lWidth, int lHeight);
  1280. extern void GrOffScreen24BPPInit(tDisplay *pDisplay, unsigned char *pucImage,
  1281. int lWidth, int lHeight);
  1282. extern void GrRectDraw(const tContext *pContext, const tRectangle *pRect);
  1283. extern void GrRectFill(const tContext *pContext, const tRectangle *pRect);
  1284. extern void GrStringDraw(const tContext *pContext, const char *pcString,
  1285. int lLength, int lX, int lY,
  1286. unsigned int bOpaque);
  1287. extern int GrStringWidthGet(const tContext *pContext, const char *pcString,
  1288. int lLength);
  1289. extern void GrStringTableSet(const void *pvTable);
  1290. unsigned int GrStringLanguageSet(unsigned short usLangID);
  1291. unsigned int GrStringGet(int iIndex, char *pcData, unsigned int ulSize);
  1292. extern int GrRectOverlapCheck(tRectangle *psRect1, tRectangle *psRect2);
  1293. extern int GrRectIntersectGet(tRectangle *psRect1, tRectangle *psRect2,
  1294. tRectangle *psIntersect);
  1295. //*****************************************************************************
  1296. //
  1297. // Mark the end of the C bindings section for C++ compilers.
  1298. //
  1299. //*****************************************************************************
  1300. #ifdef __cplusplus
  1301. }
  1302. #endif
  1303. //*****************************************************************************
  1304. //
  1305. // Close the Doxygen group.
  1306. //! @}
  1307. //
  1308. //*****************************************************************************
  1309. #endif // __GRLIB_H__