canvas.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. //*****************************************************************************
  2. //
  3. // canvas.h - Prototypes for the canvas widget.
  4. //
  5. // Copyright (c) 2008-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 6288 of the Stellaris Graphics Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __CANVAS_H__
  25. #define __CANVAS_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup canvas_api
  29. //! @{
  30. //
  31. //*****************************************************************************
  32. //*****************************************************************************
  33. //
  34. // If building with a C++ compiler, make all of the definitions in this header
  35. // have a C binding.
  36. //
  37. //*****************************************************************************
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. //*****************************************************************************
  43. //
  44. //! The structure that describes a canvas widget.
  45. //
  46. //*****************************************************************************
  47. typedef struct
  48. {
  49. //
  50. //! The generic widget information.
  51. //
  52. tWidget sBase;
  53. //
  54. //! The style for this widget. This is a set of flags defined by
  55. //! CANVAS_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The 24-bit RGB color used to fill this canvas, if CANVAS_STYLE_FILL is
  60. //! selected, and to use as the background color if
  61. //! CANVAS_STYLE_TEXT_OPAQUE is selected.
  62. //
  63. unsigned int ulFillColor;
  64. //
  65. //! The 24-bit RGB color used to outline this canvas, if
  66. //! CANVAS_STYLE_OUTLINE is selected.
  67. //
  68. unsigned int ulOutlineColor;
  69. //
  70. //! The 24-bit RGB color used to draw text on this canvas, if
  71. //! CANVAS_STYLE_TEXT is selected.
  72. //
  73. unsigned int ulTextColor;
  74. //
  75. //! A pointer to the font used to render the canvas text, if
  76. //! CANVAS_STYLE_TEXT is selected.
  77. //
  78. const tFont *pFont;
  79. //
  80. //! A pointer to the text to draw on this canvas, if CANVAS_STYLE_TEXT is
  81. //! selected.
  82. //
  83. const char *pcText;
  84. //
  85. //! A pointer to the image to be drawn onto this canvas, if
  86. //! CANVAS_STYLE_IMG is selected.
  87. //
  88. const unsigned char *pucImage;
  89. //
  90. //! A pointer to the application-supplied drawing function used to draw
  91. //! onto this canvas, if CANVAS_STYLE_APP_DRAWN is selected.
  92. //
  93. void (*pfnOnPaint)(tWidget *pWidget, tContext *pContext);
  94. }
  95. tCanvasWidget;
  96. //*****************************************************************************
  97. //
  98. //! This flag indicates that the canvas should be outlined.
  99. //
  100. //*****************************************************************************
  101. #define CANVAS_STYLE_OUTLINE 0x00000001
  102. //*****************************************************************************
  103. //
  104. //! This flag indicates that the canvas should be filled.
  105. //
  106. //*****************************************************************************
  107. #define CANVAS_STYLE_FILL 0x00000002
  108. //*****************************************************************************
  109. //
  110. //! This flag indicates that the canvas should have text drawn on it.
  111. //
  112. //*****************************************************************************
  113. #define CANVAS_STYLE_TEXT 0x00000004
  114. //*****************************************************************************
  115. //
  116. //! This flag indicates that the canvas should have an image drawn on it.
  117. //
  118. //*****************************************************************************
  119. #define CANVAS_STYLE_IMG 0x00000008
  120. //*****************************************************************************
  121. //
  122. //! This flag indicates that the canvas is drawn using the application-supplied
  123. //! drawing function.
  124. //
  125. //*****************************************************************************
  126. #define CANVAS_STYLE_APP_DRAWN 0x00000010
  127. //*****************************************************************************
  128. //
  129. //! This flag indicates that the canvas text should be drawn opaque (in other
  130. //! words, drawing the background pixels as well as the foreground pixels).
  131. //
  132. //*****************************************************************************
  133. #define CANVAS_STYLE_TEXT_OPAQUE \
  134. 0x00000020
  135. //*****************************************************************************
  136. //
  137. //! This flag indicates that canvas text should be left-aligned. By default,
  138. //! text is centered in both X and Y within the canvas bounding rectangle.
  139. //
  140. //*****************************************************************************
  141. #define CANVAS_STYLE_TEXT_LEFT \
  142. 0x00000040
  143. //*****************************************************************************
  144. //
  145. //! This flag indicates that canvas text should be right-aligned. By default,
  146. //! text is centered in both X and Y within the canvas bounding rectangle.
  147. //
  148. //*****************************************************************************
  149. #define CANVAS_STYLE_TEXT_RIGHT \
  150. 0x00000080
  151. //*****************************************************************************
  152. //
  153. //! This flag indicates that canvas text should be top-aligned. By default,
  154. //! text is centered in both X and Y within the canvas bounding rectangle.
  155. //
  156. //*****************************************************************************
  157. #define CANVAS_STYLE_TEXT_TOP \
  158. 0x00000100
  159. //*****************************************************************************
  160. //
  161. //! This flag indicates that canvas text should be bottom-aligned. By default,
  162. //! text is centered in both X and Y within the canvas bounding rectangle.
  163. //
  164. //*****************************************************************************
  165. #define CANVAS_STYLE_TEXT_BOTTOM \
  166. 0x00000200
  167. //*****************************************************************************
  168. //
  169. //! This flag indicates that canvas text should be centered horizontally. By
  170. //! default, text is centered in both X and Y within the canvas bounding
  171. //! rectangle.
  172. //
  173. //*****************************************************************************
  174. #define CANVAS_STYLE_TEXT_HCENTER \
  175. 0x00000000
  176. //*****************************************************************************
  177. //
  178. //! This flag indicates that canvas text should be centered vertically. By
  179. //! default, text is centered in both X and Y within the canvas bounding
  180. //! rectangle.
  181. //
  182. //*****************************************************************************
  183. #define CANVAS_STYLE_TEXT_VCENTER \
  184. 0x00000000
  185. //*****************************************************************************
  186. //
  187. // Masks used to extract the text alignment flags from the widget style.
  188. //
  189. //*****************************************************************************
  190. #define CANVAS_STYLE_ALIGN_MASK (CANVAS_STYLE_TEXT_LEFT | \
  191. CANVAS_STYLE_TEXT_RIGHT | \
  192. CANVAS_STYLE_TEXT_TOP | \
  193. CANVAS_STYLE_TEXT_BOTTOM)
  194. #define CANVAS_STYLE_ALIGN_HMASK \
  195. (CANVAS_STYLE_TEXT_LEFT | \
  196. CANVAS_STYLE_TEXT_RIGHT)
  197. #define CANVAS_STYLE_ALIGN_VMASK \
  198. (CANVAS_STYLE_TEXT_TOP | \
  199. CANVAS_STYLE_TEXT_BOTTOM)
  200. //*****************************************************************************
  201. //
  202. //! Declares an initialized canvas widget data structure.
  203. //!
  204. //! \param pParent is a pointer to the parent widget.
  205. //! \param pNext is a pointer to the sibling widget.
  206. //! \param pChild is a pointer to the first child widget.
  207. //! \param pDisplay is a pointer to the display on which to draw the canvas.
  208. //! \param lX is the X coordinate of the upper left corner of the canvas.
  209. //! \param lY is the Y coordinate of the upper left corner of the canvas.
  210. //! \param lWidth is the width of the canvas.
  211. //! \param lHeight is the height of the canvas.
  212. //! \param ulStyle is the style to be applied to the canvas.
  213. //! \param ulFillColor is the color used to fill in the canvas.
  214. //! \param ulOutlineColor is the color used to outline the canvas.
  215. //! \param ulTextColor is the color used to draw text on the canvas.
  216. //! \param pFont is a pointer to the font to be used to draw text on the
  217. //! canvas.
  218. //! \param pcText is a pointer to the text to draw on this canvas.
  219. //! \param pucImage is a pointer to the image to draw on this canvas.
  220. //! \param pfnOnPaint is a pointer to the application function to draw onto
  221. //! this canvas.
  222. //!
  223. //! This macro provides an initialized canvas widget data structure, which can
  224. //! be used to construct the widget tree at compile time in global variables
  225. //! (as opposed to run-time via function calls). This must be assigned to a
  226. //! variable, such as:
  227. //!
  228. //! \verbatim
  229. //! tCanvasWidget g_sCanvas = CanvasStruct(...);
  230. //! \endverbatim
  231. //!
  232. //! Or, in an array of variables:
  233. //!
  234. //! \verbatim
  235. //! tCanvasWidget g_psCanvas[] =
  236. //! {
  237. //! CanvasStruct(...),
  238. //! CanvasStruct(...)
  239. //! };
  240. //! \endverbatim
  241. //!
  242. //! \e ulStyle is the logical OR of the following:
  243. //!
  244. //! - \b #CANVAS_STYLE_OUTLINE to indicate that the canvas should be outlined.
  245. //! - \b #CANVAS_STYLE_FILL to indicate that the canvas should be filled.
  246. //! - \b #CANVAS_STYLE_TEXT to indicate that the canvas should have text drawn
  247. //! on it (using \e pFont and \e pcText).
  248. //! - \b #CANVAS_STYLE_IMG to indicate that the canvas should have an image
  249. //! drawn on it (using \e pucImage).
  250. //! - \b #CANVAS_STYLE_APP_DRAWN to indicate that the canvas should be drawn
  251. //! with the application-supplied drawing function (using \e pfnOnPaint).
  252. //! - \b #CANVAS_STYLE_TEXT_OPAQUE to indicate that the canvas text should be
  253. //! drawn opaque (in other words, drawing the background pixels).
  254. //! - \b #CANVAS_STYLE_TEXT_LEFT to indicate that the canvas text should be
  255. //! left aligned within the widget bounding rectangle.
  256. //! - \b #CANVAS_STYLE_TEXT_HCENTER to indicate that the canvas text should be
  257. //! horizontally centered within the widget bounding rectangle.
  258. //! - \b #CANVAS_STYLE_TEXT_RIGHT to indicate that the canvas text should be
  259. //! right aligned within the widget bounding rectangle.
  260. //! - \b #CANVAS_STYLE_TEXT_TOP to indicate that the canvas text should be
  261. //! top aligned within the widget bounding rectangle.
  262. //! - \b #CANVAS_STYLE_TEXT_VCENTER to indicate that the canvas text should be
  263. //! vertically centered within the widget bounding rectangle.
  264. //! - \b #CANVAS_STYLE_TEXT_BOTTOM to indicate that the canvas text should be
  265. //! bottom aligned within the widget bounding rectangle.
  266. //!
  267. //! \return Nothing; this is not a function.
  268. //
  269. //*****************************************************************************
  270. #define CanvasStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  271. lHeight, ulStyle, ulFillColor, ulOutlineColor, \
  272. ulTextColor, pFont, pcText, pucImage, pfnOnPaint) \
  273. { \
  274. { \
  275. sizeof(tCanvasWidget), \
  276. (tWidget *)(pParent), \
  277. (tWidget *)(pNext), \
  278. (tWidget *)(pChild), \
  279. pDisplay, \
  280. { \
  281. lX, \
  282. lY, \
  283. (lX) + (lWidth) - 1, \
  284. (lY) + (lHeight) - 1 \
  285. }, \
  286. CanvasMsgProc \
  287. }, \
  288. ulStyle, \
  289. ulFillColor, \
  290. ulOutlineColor, \
  291. ulTextColor, \
  292. pFont, \
  293. pcText, \
  294. pucImage, \
  295. pfnOnPaint \
  296. }
  297. //*****************************************************************************
  298. //
  299. //! Declares an initialized variable containing a canvas widget data structure.
  300. //!
  301. //! \param sName is the name of the variable to be declared.
  302. //! \param pParent is a pointer to the parent widget.
  303. //! \param pNext is a pointer to the sibling widget.
  304. //! \param pChild is a pointer to the first child widget.
  305. //! \param pDisplay is a pointer to the display on which to draw the canvas.
  306. //! \param lX is the X coordinate of the upper left corner of the canvas.
  307. //! \param lY is the Y coordinate of the upper left corner of the canvas.
  308. //! \param lWidth is the width of the canvas.
  309. //! \param lHeight is the height of the canvas.
  310. //! \param ulStyle is the style to be applied to the canvas.
  311. //! \param ulFillColor is the color used to fill in the canvas.
  312. //! \param ulOutlineColor is the color used to outline the canvas.
  313. //! \param ulTextColor is the color used to draw text on the canvas.
  314. //! \param pFont is a pointer to the font to be used to draw text on the
  315. //! canvas.
  316. //! \param pcText is a pointer to the text to draw on this canvas.
  317. //! \param pucImage is a pointer to the image to draw on this canvas.
  318. //! \param pfnOnPaint is a pointer to the application function to draw onto
  319. //! this canvas.
  320. //!
  321. //! This macro declares a variable containing an initialized canvas widget data
  322. //! structure, which can be used to construct the widget tree at compile time
  323. //! in global variables (as opposed to run-time via function calls).
  324. //!
  325. //! \e ulStyle is the logical OR of the following:
  326. //!
  327. //! - \b #CANVAS_STYLE_OUTLINE to indicate that the canvas should be outlined.
  328. //! - \b #CANVAS_STYLE_FILL to indicate that the canvas should be filled.
  329. //! - \b #CANVAS_STYLE_TEXT to indicate that the canvas should have text drawn
  330. //! on it (using \e pFont and \e pcText).
  331. //! - \b #CANVAS_STYLE_IMG to indicate that the canvas should have an image
  332. //! drawn on it (using \e pucImage).
  333. //! - \b #CANVAS_STYLE_APP_DRAWN to indicate that the canvas should be drawn
  334. //! with the application-supplied drawing function (using \e pfnOnPaint).
  335. //! - \b #CANVAS_STYLE_TEXT_OPAQUE to indicate that the canvas text should be
  336. //! drawn opaque (in other words, drawing the background pixels).
  337. //! - \b #CANVAS_STYLE_TEXT_LEFT to indicate that the canvas text should be
  338. //! left aligned within the widget bounding rectangle.
  339. //! - \b #CANVAS_STYLE_TEXT_HCENTER to indicate that the canvas text should be
  340. //! horizontally centered within the widget bounding rectangle.
  341. //! - \b #CANVAS_STYLE_TEXT_RIGHT to indicate that the canvas text should be
  342. //! right aligned within the widget bounding rectangle.
  343. //! - \b #CANVAS_STYLE_TEXT_TOP to indicate that the canvas text should be
  344. //! top aligned within the widget bounding rectangle.
  345. //! - \b #CANVAS_STYLE_TEXT_VCENTER to indicate that the canvas text should be
  346. //! vertically centered within the widget bounding rectangle.
  347. //! - \b #CANVAS_STYLE_TEXT_BOTTOM to indicate that the canvas text should be
  348. //! bottom aligned within the widget bounding rectangle.
  349. //!
  350. //! \return Nothing; this is not a function.
  351. //
  352. //*****************************************************************************
  353. #define Canvas(sName, pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  354. lHeight, ulStyle, ulFillColor, ulOutlineColor, ulTextColor, \
  355. pFont, pcText, pucImage, pfnOnPaint) \
  356. tCanvasWidget sName = \
  357. CanvasStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  358. lHeight, ulStyle, ulFillColor, ulOutlineColor, \
  359. ulTextColor, pFont, pcText, pucImage, pfnOnPaint)
  360. //*****************************************************************************
  361. //
  362. //! Disables application drawing of a canvas widget.
  363. //!
  364. //! \param pWidget is a pointer to the canvas widget to modify.
  365. //!
  366. //! This function disables the use of the application callback to draw on a
  367. //! canvas widget. The display is not updated until the next paint request.
  368. //!
  369. //! \return None.
  370. //
  371. //*****************************************************************************
  372. #define CanvasAppDrawnOff(pWidget) \
  373. do \
  374. { \
  375. tCanvasWidget *pW = pWidget; \
  376. pW->ulStyle &= ~(CANVAS_STYLE_APP_DRAWN); \
  377. } \
  378. while(0)
  379. //*****************************************************************************
  380. //
  381. //! Enables application drawing of a canvas widget.
  382. //!
  383. //! \param pWidget is a pointer to the canvas widget to modify.
  384. //!
  385. //! This function enables the use of the application callback to draw on a
  386. //! canvas widget. The display is not updated until the next paint request.
  387. //!
  388. //! \return None.
  389. //
  390. //*****************************************************************************
  391. #define CanvasAppDrawnOn(pWidget) \
  392. do \
  393. { \
  394. tCanvasWidget *pW = pWidget; \
  395. pW->ulStyle |= CANVAS_STYLE_APP_DRAWN; \
  396. } \
  397. while(0)
  398. //*****************************************************************************
  399. //
  400. //! Sets the function to call when this canvas widget is drawn.
  401. //!
  402. //! \param pWidget is a pointer to the canvas widget to modify.
  403. //! \param pfnOnPnt is a pointer to the function to call.
  404. //!
  405. //! This function sets the function to be called when this canvas is drawn and
  406. //! \b CANVAS_STYLE_APP_DRAWN is selected.
  407. //!
  408. //! \return None.
  409. //
  410. //*****************************************************************************
  411. #define CanvasCallbackSet(pWidget, pfnOnPnt) \
  412. do \
  413. { \
  414. tCanvasWidget *pW = pWidget; \
  415. pW->pfnOnPaint = pfnOnPnt; \
  416. } \
  417. while(0)
  418. //*****************************************************************************
  419. //
  420. //! Sets the fill color of a canvas widget.
  421. //!
  422. //! \param pWidget is a pointer to the canvas widget to be modified.
  423. //! \param ulColor is the 24-bit RGB color to use to fill the canvas.
  424. //!
  425. //! This function changes the color used to fill the canvas on the display.
  426. //! The display is not updated until the next paint request.
  427. //!
  428. //! \return None.
  429. //
  430. //*****************************************************************************
  431. #define CanvasFillColorSet(pWidget, ulColor) \
  432. do \
  433. { \
  434. tCanvasWidget *pW = pWidget; \
  435. pW->ulFillColor = ulColor; \
  436. } \
  437. while(0)
  438. //*****************************************************************************
  439. //
  440. //! Disables filling of a canvas widget.
  441. //!
  442. //! \param pWidget is a pointer to the canvas widget to modify.
  443. //!
  444. //! This function disables the filling of a canvas widget. The display is not
  445. //! updated until the next paint request.
  446. //!
  447. //! \return None.
  448. //
  449. //*****************************************************************************
  450. #define CanvasFillOff(pWidget) \
  451. do \
  452. { \
  453. tCanvasWidget *pW = pWidget; \
  454. pW->ulStyle &= ~(CANVAS_STYLE_FILL); \
  455. } \
  456. while(0)
  457. //*****************************************************************************
  458. //
  459. //! Enables filling of a canvas widget.
  460. //!
  461. //! \param pWidget is a pointer to the canvas widget to modify.
  462. //!
  463. //! This function enables the filling of a canvas widget. The display is not
  464. //! updated until the next paint request.
  465. //!
  466. //! \return None.
  467. //
  468. //*****************************************************************************
  469. #define CanvasFillOn(pWidget) \
  470. do \
  471. { \
  472. tCanvasWidget *pW = pWidget; \
  473. pW->ulStyle |= CANVAS_STYLE_FILL; \
  474. } \
  475. while(0)
  476. //*****************************************************************************
  477. //
  478. //! Sets the font for a canvas widget.
  479. //!
  480. //! \param pWidget is a pointer to the canvas widget to modify.
  481. //! \param pFnt is a pointer to the font to use to draw text on the canvas.
  482. //!
  483. //! This function changes the font used to draw text on the canvas. The
  484. //! display is not updated until the next paint request.
  485. //!
  486. //! \return None.
  487. //
  488. //*****************************************************************************
  489. #define CanvasFontSet(pWidget, pFnt) \
  490. do \
  491. { \
  492. tCanvasWidget *pW = pWidget; \
  493. const tFont *pF = pFnt; \
  494. pW->pFont = pF; \
  495. } \
  496. while(0)
  497. //*****************************************************************************
  498. //
  499. //! Changes the image drawn on a canvas widget.
  500. //!
  501. //! \param pWidget is a pointer to the canvas widget to be modified.
  502. //! \param pImg is a pointer to the image to draw onto the canvas.
  503. //!
  504. //! This function changes the image that is drawn onto the canvas. The display
  505. //! is not updated until the next paint request.
  506. //!
  507. //! \return None.
  508. //
  509. //*****************************************************************************
  510. #define CanvasImageSet(pWidget, pImg) \
  511. do \
  512. { \
  513. tCanvasWidget *pW = pWidget; \
  514. const unsigned char *pI = pImg; \
  515. pW->pucImage = pI; \
  516. } \
  517. while(0)
  518. //*****************************************************************************
  519. //
  520. //! Disables the image on a canvas widget.
  521. //!
  522. //! \param pWidget is a pointer to the canvas widget to modify.
  523. //!
  524. //! This function disables the drawing of an image on a canvas widget. The
  525. //! display is not updated until the next paint request.
  526. //!
  527. //! \return None.
  528. //
  529. //*****************************************************************************
  530. #define CanvasImageOff(pWidget) \
  531. do \
  532. { \
  533. tCanvasWidget *pW = pWidget; \
  534. pW->ulStyle &= ~(CANVAS_STYLE_IMG); \
  535. } \
  536. while(0)
  537. //*****************************************************************************
  538. //
  539. //! Enables the image on a canvas widget.
  540. //!
  541. //! \param pWidget is a pointer to the canvas widget to modify.
  542. //!
  543. //! This function enables the drawing of an image on a canvas widget. The
  544. //! display is not updated until the next paint request.
  545. //!
  546. //! \return None.
  547. //
  548. //*****************************************************************************
  549. #define CanvasImageOn(pWidget) \
  550. do \
  551. { \
  552. tCanvasWidget *pW = pWidget; \
  553. pW->ulStyle |= CANVAS_STYLE_IMG; \
  554. } \
  555. while(0)
  556. //*****************************************************************************
  557. //
  558. //! Sets the outline color of a canvas widget.
  559. //!
  560. //! \param pWidget is a pointer to the canvas widget to be modified.
  561. //! \param ulColor is the 24-bit RGB color to use to outline the canvas.
  562. //!
  563. //! This function changes the color used to outline the canvas on the display.
  564. //! The display is not updated until the next paint request.
  565. //!
  566. //! \return None.
  567. //
  568. //*****************************************************************************
  569. #define CanvasOutlineColorSet(pWidget, ulColor) \
  570. do \
  571. { \
  572. tCanvasWidget *pW = pWidget; \
  573. pW->ulOutlineColor = ulColor; \
  574. } \
  575. while(0)
  576. //*****************************************************************************
  577. //
  578. //! Disables outlining of a canvas widget.
  579. //!
  580. //! \param pWidget is a pointer to the canvas widget to modify.
  581. //!
  582. //! This function disables the outlining of a canvas widget. The display is
  583. //! not updated until the next paint request.
  584. //!
  585. //! \return None.
  586. //
  587. //*****************************************************************************
  588. #define CanvasOutlineOff(pWidget) \
  589. do \
  590. { \
  591. tCanvasWidget *pW = pWidget; \
  592. pW->ulStyle &= ~(CANVAS_STYLE_OUTLINE); \
  593. } \
  594. while(0)
  595. //*****************************************************************************
  596. //
  597. //! Enables outlining of a canvas widget.
  598. //!
  599. //! \param pWidget is a pointer to the canvas widget to modify.
  600. //!
  601. //! This function enables the outlining of a canvas widget. The display is not
  602. //! updated until the next paint request.
  603. //!
  604. //! \return None.
  605. //
  606. //*****************************************************************************
  607. #define CanvasOutlineOn(pWidget) \
  608. do \
  609. { \
  610. tCanvasWidget *pW = pWidget; \
  611. pW->ulStyle |= CANVAS_STYLE_OUTLINE; \
  612. } \
  613. while(0)
  614. //*****************************************************************************
  615. //
  616. //! Sets the text color of a canvas widget.
  617. //!
  618. //! \param pWidget is a pointer to the canvas widget to be modified.
  619. //! \param ulColor is the 24-bit RGB color to use to draw text on the canvas.
  620. //!
  621. //! This function changes the color used to draw text on the canvas on the
  622. //! display. The display is not updated until the next paint request.
  623. //!
  624. //! \return None.
  625. //
  626. //*****************************************************************************
  627. #define CanvasTextColorSet(pWidget, ulColor) \
  628. do \
  629. { \
  630. tCanvasWidget *pW = pWidget; \
  631. pW->ulTextColor = ulColor; \
  632. } \
  633. while(0)
  634. //*****************************************************************************
  635. //
  636. //! Disables the text on a canvas widget.
  637. //!
  638. //! \param pWidget is a pointer to the canvas widget to modify.
  639. //!
  640. //! This function disables the drawing of text on a canvas widget. The display
  641. //! is not updated until the next paint request.
  642. //!
  643. //! \return None.
  644. //
  645. //*****************************************************************************
  646. #define CanvasTextOff(pWidget) \
  647. do \
  648. { \
  649. tCanvasWidget *pW = pWidget; \
  650. pW->ulStyle &= ~(CANVAS_STYLE_TEXT); \
  651. } \
  652. while(0)
  653. //*****************************************************************************
  654. //
  655. //! Enables the text on a canvas widget.
  656. //!
  657. //! \param pWidget is a pointer to the canvas widget to modify.
  658. //!
  659. //! This function enables the drawing of text on a canvas widget. The display
  660. //! is not updated until the next paint request.
  661. //!
  662. //! \return None.
  663. //
  664. //*****************************************************************************
  665. #define CanvasTextOn(pWidget) \
  666. do \
  667. { \
  668. tCanvasWidget *pW = pWidget; \
  669. pW->ulStyle |= CANVAS_STYLE_TEXT; \
  670. } \
  671. while(0)
  672. //*****************************************************************************
  673. //
  674. //! Disables opaque text on a canvas widget.
  675. //!
  676. //! \param pWidget is a pointer to the canvas widget to modify.
  677. //!
  678. //! This function disables the use of opaque text on this canvas. When not
  679. //! using opaque text, only the foreground pixels of the text are drawn on the
  680. //! screen, allowing the previously drawn pixels (such as the canvas image) to
  681. //! show through the text.
  682. //!
  683. //! \return None.
  684. //
  685. //*****************************************************************************
  686. #define CanvasTextOpaqueOff(pWidget) \
  687. do \
  688. { \
  689. tCanvasWidget *pW = pWidget; \
  690. pW->ulStyle &= ~(CANVAS_STYLE_TEXT_OPAQUE); \
  691. } \
  692. while(0)
  693. //*****************************************************************************
  694. //
  695. //! Enables opaque text on a canvas widget.
  696. //!
  697. //! \param pWidget is a pointer to the canvas widget to modify.
  698. //!
  699. //! This function enables the use of opaque text on this canvas. When using
  700. //! opaque text, both the foreground and background pixels of the text
  701. //! are drawn on the screen, blocking out the previously drawn pixels.
  702. //!
  703. //! \return None.
  704. //
  705. //*****************************************************************************
  706. #define CanvasTextOpaqueOn(pWidget) \
  707. do \
  708. { \
  709. tCanvasWidget *pW = pWidget; \
  710. pW->ulStyle |= CANVAS_STYLE_TEXT_OPAQUE; \
  711. } \
  712. while(0)
  713. //*****************************************************************************
  714. //
  715. //! Sets the text alignment for a canvas widget.
  716. //!
  717. //! \param pWidget is a pointer to the canvas widget to modify.
  718. //! \param ulAlign contains the required text alignment setting. This is a
  719. //! logical OR of style values \b #CANVAS_STYLE_TEXT_LEFT, \b
  720. //! #CANVAS_STYLE_TEXT_RIGHT, \b #CANVAS_STYLE_TEXT_HCENTER,
  721. //! \b #CANVAS_STYLE_TEXT_VCENTER, \b #CANVAS_STYLE_TEXT_TOP and
  722. //! \b #CANVAS_STYLE_TEXT_BOTTOM.
  723. //!
  724. //! This function sets the alignment of the text drawn inside the widget.
  725. //! Independent alignment options for horizontal and vertical placement allow
  726. //! the text to be positioned in one of 9 positions within the boinding box
  727. //! of the widget. The display is not updated until the next paint request.
  728. //!
  729. //! \return None.
  730. //
  731. //*****************************************************************************
  732. #define CanvasTextAlignment(pWidget, ulAlign) \
  733. do \
  734. { \
  735. tCanvasWidget *pW = pWidget; \
  736. pW->ulStyle &= ~CANVAS_STYLE_ALIGN_MASK; \
  737. pW->ulStyle |= ((ulAlign) & CANVAS_STYLE_ALIGN_MASK); \
  738. } \
  739. while(0)
  740. //*****************************************************************************
  741. //
  742. //! Changes the text drawn on a canvas widget.
  743. //!
  744. //! \param pWidget is a pointer to the canvas widget to be modified.
  745. //! \param pcTxt is a pointer to the text to draw onto the canvas.
  746. //!
  747. //! This function changes the text that is drawn onto the canvas. The display
  748. //! is not updated until the next paint request.
  749. //!
  750. //! \return None.
  751. //
  752. //*****************************************************************************
  753. #define CanvasTextSet(pWidget, pcTxt) \
  754. do \
  755. { \
  756. tCanvasWidget *pW = pWidget; \
  757. const char *pcT = pcTxt; \
  758. pW->pcText = pcT; \
  759. } \
  760. while(0)
  761. //*****************************************************************************
  762. //
  763. // Prototypes for the canvas widget APIs.
  764. //
  765. //*****************************************************************************
  766. extern int CanvasMsgProc(tWidget *pWidget, unsigned int ulMsg,
  767. unsigned int ulParam1, unsigned int ulParam2);
  768. extern void CanvasInit(tCanvasWidget *pWidget, const tDisplay *pDisplay,
  769. int lX, int lY, int lWidth, int lHeight);
  770. //*****************************************************************************
  771. //
  772. // Mark the end of the C bindings section for C++ compilers.
  773. //
  774. //*****************************************************************************
  775. #ifdef __cplusplus
  776. }
  777. #endif
  778. //*****************************************************************************
  779. //
  780. // Close the Doxygen group.
  781. //! @}
  782. //
  783. //*****************************************************************************
  784. #endif // __CANVAS_H__