container.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. //*****************************************************************************
  2. //
  3. // container.h - Prototypes for the container 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 __CONTAINER_H__
  25. #define __CONTAINER_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup container_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 container 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. //! CTR_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The 24-bit RGB color used to fill this container widget, if
  60. //! CTR_STYLE_FILL is selected, and to use as the background color if
  61. //! CTR_STYLE_TEXT_OPAQUE is selected.
  62. //
  63. unsigned int ulFillColor;
  64. //
  65. //! The 24-bit RGB color used to outline this container widget, if
  66. //! CTR_STYLE_OUTLINE is selected.
  67. //
  68. unsigned int ulOutlineColor;
  69. //
  70. //! The 24-bit RGB color used to draw text on this container widget, if
  71. //! CTR_STYLE_TEXT is selected.
  72. //
  73. unsigned int ulTextColor;
  74. //
  75. //! A pointer to the font used to render the container text, if
  76. //! CTR_STYLE_TEXT is selected.
  77. //
  78. const tFont *pFont;
  79. //
  80. //! A pointer to the text to draw on this container widget, if
  81. //! CTR_STYLE_TEXT is selected.
  82. //
  83. const char *pcText;
  84. }
  85. tContainerWidget;
  86. //*****************************************************************************
  87. //
  88. //! This flag indicates that the container widget should be outlined.
  89. //
  90. //*****************************************************************************
  91. #define CTR_STYLE_OUTLINE 0x00000001
  92. //*****************************************************************************
  93. //
  94. //! This flag indicates that the container widget should be filled.
  95. //
  96. //*****************************************************************************
  97. #define CTR_STYLE_FILL 0x00000002
  98. //*****************************************************************************
  99. //
  100. //! This flag indicates that the container widget should have text drawn on it.
  101. //
  102. //*****************************************************************************
  103. #define CTR_STYLE_TEXT 0x00000004
  104. //*****************************************************************************
  105. //
  106. //! This flag indicates that the container text should be drawn opaque (in
  107. //! other words, drawing the background pixels as well as the foreground
  108. //! pixels).
  109. //
  110. //*****************************************************************************
  111. #define CTR_STYLE_TEXT_OPAQUE 0x00000008
  112. //*****************************************************************************
  113. //
  114. //! This flag indicates that the container text should be drawn centered
  115. //! within the width of the container.
  116. //
  117. //*****************************************************************************
  118. #define CTR_STYLE_TEXT_CENTER 0x00000010
  119. //*****************************************************************************
  120. //
  121. //! Declares an initialized container widget data structure.
  122. //!
  123. //! \param pParent is a pointer to the parent widget.
  124. //! \param pNext is a pointer to the sibling widget.
  125. //! \param pChild is a pointer to the first child widget.
  126. //! \param pDisplay is a pointer to the display on which to draw the container
  127. //! widget.
  128. //! \param lX is the X coordinate of the upper left corner of the container
  129. //! widget.
  130. //! \param lY is the Y coordinate of the upper left corner of the container
  131. //! widget.
  132. //! \param lWidth is the width of the container widget.
  133. //! \param lHeight is the height of the container widget.
  134. //! \param ulStyle is the style to be applied to the container widget.
  135. //! \param ulFillColor is the color used to fill in the container widget.
  136. //! \param ulOutlineColor is the color used to outline the container widget.
  137. //! \param ulTextColor is the color used to draw text on the container widget.
  138. //! \param pFont is a pointer to the font to be used to draw text on the
  139. //! container widget.
  140. //! \param pcText is a pointer to the text to draw on the container widget.
  141. //!
  142. //! This macro provides an initialized container widget data structure, which
  143. //! can be used to construct the widget tree at compile time in global
  144. //! variables (as opposed to run-time via function calls). This must be
  145. //! assigned to a variable, such as:
  146. //!
  147. //! \verbatim
  148. //! tContainerWidget g_sContainer = ContainerStruct(...);
  149. //! \endverbatim
  150. //!
  151. //! Or, in an array of variables:
  152. //!
  153. //! \verbatim
  154. //! tContainerWidget g_psContainers[] =
  155. //! {
  156. //! ContainerStruct(...),
  157. //! ContainerStruct(...)
  158. //! };
  159. //! \endverbatim
  160. //!
  161. //! \e ulStyle is the logical OR of the following:
  162. //!
  163. //! - \b #CTR_STYLE_OUTLINE to indicate that the container widget should be
  164. //! outlined.
  165. //! - \b #CTR_STYLE_FILL to indicate that the container widget should be
  166. //! filled.
  167. //! - \b #CTR_STYLE_TEXT to indicate that the container widget should have text
  168. //! drawn on it (using \e pFont and \e pcText).
  169. //! - \b #CTR_STYLE_TEXT_OPAQUE to indicate that the container widget text
  170. //! should be drawn opaque (in other words, drawing the background pixels).
  171. //! - \b #CTR_STYLE_TEXT_CENTER to indicate that the container widget text
  172. //! should be drawn centered horizontally.
  173. //!
  174. //! \return Nothing; this is not a function.
  175. //
  176. //*****************************************************************************
  177. #define ContainerStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  178. lHeight, ulStyle, ulFillColor, ulOutlineColor, \
  179. ulTextColor, pFont, pcText) \
  180. { \
  181. { \
  182. sizeof(tContainerWidget), \
  183. (tWidget *)(pParent), \
  184. (tWidget *)(pNext), \
  185. (tWidget *)(pChild), \
  186. pDisplay, \
  187. { \
  188. lX, \
  189. lY, \
  190. (lX) + (lWidth) - 1, \
  191. (lY) + (lHeight) - 1 \
  192. }, \
  193. ContainerMsgProc \
  194. }, \
  195. ulStyle, \
  196. ulFillColor, \
  197. ulOutlineColor, \
  198. ulTextColor, \
  199. pFont, \
  200. pcText \
  201. }
  202. //*****************************************************************************
  203. //
  204. //! Declares an initialized variable containing a container widget data
  205. //! structure.
  206. //!
  207. //! \param sName is the name of the variable to be declared.
  208. //! \param pParent is a pointer to the parent widget.
  209. //! \param pNext is a pointer to the sibling widget.
  210. //! \param pChild is a pointer to the first child widget.
  211. //! \param pDisplay is a pointer to the display on which to draw the container
  212. //! widget.
  213. //! \param lX is the X coordinate of the upper left corner of the container
  214. //! widget.
  215. //! \param lY is the Y coordinate of the upper left corner of the container
  216. //! widget.
  217. //! \param lWidth is the width of the container widget.
  218. //! \param lHeight is the height of the container widget.
  219. //! \param ulStyle is the style to be applied to the container widget.
  220. //! \param ulFillColor is the color used to fill in the container widget.
  221. //! \param ulOutlineColor is the color used to outline the container widget.
  222. //! \param ulTextColor is the color used to draw text on the container widget.
  223. //! \param pFont is a pointer to the font to be used to draw text on the
  224. //! container widget.
  225. //! \param pcText is a poitner to the text to draw on the container widget.
  226. //!
  227. //! This macro provides an initialized container widget data structure, which
  228. //! can be used to construct the widget tree at compile time in global
  229. //! variables (as opposed to run-time via function calls).
  230. //!
  231. //! \e ulStyle is the logical OR of the following:
  232. //!
  233. //! - \b #CTR_STYLE_OUTLINE to indicate that the container widget should be
  234. //! outlined.
  235. //! - \b #CTR_STYLE_FILL to indicate that the container widget should be
  236. //! filled.
  237. //! - \b #CTR_STYLE_TEXT to indicate that the container widget should have text
  238. //! drawn on it (using \e pFont and \e pcText).
  239. //! - \b #CTR_STYLE_TEXT_OPAQUE to indicate that the container widget text
  240. //! should be drawn opaque (in other words, drawing the background pixels).
  241. //! - \b #CTR_STYLE_TEXT_CENTER to indicate that the container widget text
  242. //! should be drawn centered horizontally.
  243. //!
  244. //! \return Nothing; this is not a function.
  245. //
  246. //*****************************************************************************
  247. #define Container(sName, pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  248. lHeight, ulStyle, ulFillColor, ulOutlineColor, ulTextColor, \
  249. pFont, pcText) \
  250. tContainerWidget sName = \
  251. ContainerStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  252. lHeight, ulStyle, ulFillColor, ulOutlineColor, \
  253. ulTextColor, pFont, pcText)
  254. //*****************************************************************************
  255. //
  256. //! Sets the fill color of a container widget.
  257. //!
  258. //! \param pWidget is a pointer to the container widget to be modified.
  259. //! \param ulColor is the 24-bit RGB color to use to fill the container widget.
  260. //!
  261. //! This function changes the color used to fill the container widget on the
  262. //! display. The display is not updated until the next paint request.
  263. //!
  264. //! \return None.
  265. //
  266. //*****************************************************************************
  267. #define ContainerFillColorSet(pWidget, ulColor) \
  268. do \
  269. { \
  270. tContainerWidget *pW = pWidget; \
  271. pW->ulFillColor = ulColor; \
  272. } \
  273. while(0)
  274. //*****************************************************************************
  275. //
  276. //! Disables filling of a container widget.
  277. //!
  278. //! \param pWidget is a pointer to the container widget to modify.
  279. //!
  280. //! This function disables the filling of a container widget. The display is
  281. //! not updated until the next paint request.
  282. //!
  283. //! \return None.
  284. //
  285. //*****************************************************************************
  286. #define ContainerFillOff(pWidget) \
  287. do \
  288. { \
  289. tContainerWidget *pW = pWidget; \
  290. pW->ulStyle &= ~(CTR_STYLE_FILL); \
  291. } \
  292. while(0)
  293. //*****************************************************************************
  294. //
  295. //! Enables filling of a container widget.
  296. //!
  297. //! \param pWidget is a pointer to the container widget to modify.
  298. //!
  299. //! This function enables the filling of a container widget. The display is
  300. //! not updated until the next paint request.
  301. //!
  302. //! \return None.
  303. //
  304. //*****************************************************************************
  305. #define ContainerFillOn(pWidget) \
  306. do \
  307. { \
  308. tContainerWidget *pW = pWidget; \
  309. pW->ulStyle |= CTR_STYLE_FILL; \
  310. } \
  311. while(0)
  312. //*****************************************************************************
  313. //
  314. //! Sets the font for a container widget.
  315. //!
  316. //! \param pWidget is a pointer to the container widget to modify.
  317. //! \param pFnt is a pointer to the font to use to draw text on the container
  318. //! widget.
  319. //!
  320. //! This function changes the font used to draw text on the container widget.
  321. //! The display is not updated until the next paint request.
  322. //!
  323. //! \return None.
  324. //
  325. //*****************************************************************************
  326. #define ContainerFontSet(pWidget, pFnt) \
  327. do \
  328. { \
  329. tContainerWidget *pW = pWidget; \
  330. const tFont *pF = pFnt; \
  331. pW->pFont = pF; \
  332. } \
  333. while(0)
  334. //*****************************************************************************
  335. //
  336. //! Sets the outline color of a container widget.
  337. //!
  338. //! \param pWidget is a pointer to the container widget to be modified.
  339. //! \param ulColor is the 24-bit RGB color to use to outline the container
  340. //! widget.
  341. //!
  342. //! This function changes the color used to outline the container widget on the
  343. //! display. The display is not updated until the next paint request.
  344. //!
  345. //! \return None.
  346. //
  347. //*****************************************************************************
  348. #define ContainerOutlineColorSet(pWidget, ulColor) \
  349. do \
  350. { \
  351. tContainerWidget *pW = pWidget; \
  352. pW->ulOutlineColor = ulColor; \
  353. } \
  354. while(0)
  355. //*****************************************************************************
  356. //
  357. //! Disables outlining of a container widget.
  358. //!
  359. //! \param pWidget is a pointer to the container widget to modify.
  360. //!
  361. //! This function disables the outlining of a container widget. The display is
  362. //! not updated until the next paint request.
  363. //!
  364. //! \return None.
  365. //
  366. //*****************************************************************************
  367. #define ContainerOutlineOff(pWidget) \
  368. do \
  369. { \
  370. tContainerWidget *pW = pWidget; \
  371. pW->ulStyle &= ~(CTR_STYLE_OUTLINE); \
  372. } \
  373. while(0)
  374. //*****************************************************************************
  375. //
  376. //! Enables outlining of a container widget.
  377. //!
  378. //! \param pWidget is a pointer to the container widget to modify.
  379. //!
  380. //! This function enables the outlining of a container widget. The display is
  381. //! not updated until the next paint request.
  382. //!
  383. //! \return None.
  384. //
  385. //*****************************************************************************
  386. #define ContainerOutlineOn(pWidget) \
  387. do \
  388. { \
  389. tContainerWidget *pW = pWidget; \
  390. pW->ulStyle |= CTR_STYLE_OUTLINE; \
  391. } \
  392. while(0)
  393. //*****************************************************************************
  394. //
  395. //! Disables the centering of text on a container widget.
  396. //!
  397. //! \param pWidget is a pointer to the container widget to modify.
  398. //!
  399. //! This function disables the centering of text on a container widget. The
  400. //! display is not updated until the next paint request.
  401. //!
  402. //! \return None.
  403. //
  404. //*****************************************************************************
  405. #define ContainerTextCenterOff(pWidget) \
  406. do \
  407. { \
  408. tContainerWidget *pW = pWidget; \
  409. pW->ulStyle &= ~(CTR_STYLE_TEXT_CENTER); \
  410. } \
  411. while(0)
  412. //*****************************************************************************
  413. //
  414. //! Enables the centering of text on a container widget.
  415. //!
  416. //! \param pWidget is a pointer to the container widget to modify.
  417. //!
  418. //! This function enables the centering of text on a container widget. The
  419. //! display is not updated until the next paint request.
  420. //!
  421. //! \return None.
  422. //
  423. //*****************************************************************************
  424. #define ContainerTextCenterOn(pWidget) \
  425. do \
  426. { \
  427. tContainerWidget *pW = pWidget; \
  428. pW->ulStyle |= CTR_STYLE_TEXT_CENTER; \
  429. } \
  430. while(0)
  431. //*****************************************************************************
  432. //
  433. //! Sets the text color of a container widget.
  434. //!
  435. //! \param pWidget is a pointer to the container widget to be modified.
  436. //! \param ulColor is the 24-bit RGB color to use to draw text on the
  437. //! container widget.
  438. //!
  439. //! This function changes the color used to draw text on the container widget
  440. //! on the display. The display is not updated until the next paint request.
  441. //!
  442. //! \return None.
  443. //
  444. //*****************************************************************************
  445. #define ContainerTextColorSet(pWidget, ulColor) \
  446. do \
  447. { \
  448. tContainerWidget *pW = pWidget; \
  449. pW->ulTextColor = ulColor; \
  450. } \
  451. while(0)
  452. //*****************************************************************************
  453. //
  454. //! Disables the text on a container widget.
  455. //!
  456. //! \param pWidget is a pointer to the container widget to modify.
  457. //!
  458. //! This function disables the drawing of text on a container widget. The
  459. //! display is not updated until the next paint request.
  460. //!
  461. //! \return None.
  462. //
  463. //*****************************************************************************
  464. #define ContainerTextOff(pWidget) \
  465. do \
  466. { \
  467. tContainerWidget *pW = pWidget; \
  468. pW->ulStyle &= ~(CTR_STYLE_TEXT); \
  469. } \
  470. while(0)
  471. //*****************************************************************************
  472. //
  473. //! Enables the text on a container widget.
  474. //!
  475. //! \param pWidget is a pointer to the container widget to modify.
  476. //!
  477. //! This function enables the drawing of text on a container widget. The
  478. //! display is not updated until the next paint request.
  479. //!
  480. //! \return None.
  481. //
  482. //*****************************************************************************
  483. #define ContainerTextOn(pWidget) \
  484. do \
  485. { \
  486. tContainerWidget *pW = pWidget; \
  487. pW->ulStyle |= CTR_STYLE_TEXT; \
  488. } \
  489. while(0)
  490. //*****************************************************************************
  491. //
  492. //! Disables opaque text on a container widget.
  493. //!
  494. //! \param pWidget is a pointer to the container widget to modify.
  495. //!
  496. //! This function disables the use of opaque text on this container widget.
  497. //! When not using opaque text, only the foreground pixels of the text are
  498. //! drawn on the screen, allowing the previously drawn pixels (such as the
  499. //! background) to show through the text.
  500. //!
  501. //! \return None.
  502. //
  503. //*****************************************************************************
  504. #define ContainerTextOpaqueOff(pWidget) \
  505. do \
  506. { \
  507. tContainerWidget *pW = pWidget; \
  508. pW->ulStyle &= ~(CTR_STYLE_TEXT_OPAQUE); \
  509. } \
  510. while(0)
  511. //*****************************************************************************
  512. //
  513. //! Enables opaque text on a container widget.
  514. //!
  515. //! \param pWidget is a pointer to the container widget to modify.
  516. //!
  517. //! This function enables the use of opaque text on this container widget.
  518. //! When using opaque text, both the foreground and background pixels of the
  519. //! text are drawn on the screen, blocking out the previously drawn pixels.
  520. //!
  521. //! \return None.
  522. //
  523. //*****************************************************************************
  524. #define ContainerTextOpaqueOn(pWidget) \
  525. do \
  526. { \
  527. tContainerWidget *pW = pWidget; \
  528. pW->ulStyle |= CTR_STYLE_TEXT_OPAQUE; \
  529. } \
  530. while(0)
  531. //*****************************************************************************
  532. //
  533. //! Changes the text drawn on a container widget.
  534. //!
  535. //! \param pWidget is a pointer to the container widget to be modified.
  536. //! \param pcTxt is a pointer to the text to draw onto the container widget.
  537. //!
  538. //! This function changes the text that is drawn onto the container widget.
  539. //! The display is not updated until the next paint request.
  540. //!
  541. //! \return None.
  542. //
  543. //*****************************************************************************
  544. #define ContainerTextSet(pWidget, pcTxt) \
  545. do \
  546. { \
  547. tContainerWidget *pW = pWidget; \
  548. const char *pcT = pcTxt; \
  549. pW->pcText = pcT; \
  550. } \
  551. while(0)
  552. //*****************************************************************************
  553. //
  554. // Prototypes for the container widget APIs.
  555. //
  556. //*****************************************************************************
  557. extern int ContainerMsgProc(tWidget *pWidget, unsigned int ulMsg,
  558. unsigned int ulParam1, unsigned int ulParam2);
  559. extern void ContainerInit(tContainerWidget *pWidget, const tDisplay *pDisplay,
  560. int lX, int lY, int lWidth, int lHeight);
  561. //*****************************************************************************
  562. //
  563. // Mark the end of the C bindings section for C++ compilers.
  564. //
  565. //*****************************************************************************
  566. #ifdef __cplusplus
  567. }
  568. #endif
  569. //*****************************************************************************
  570. //
  571. // Close the Doxygen group.
  572. //! @}
  573. //
  574. //*****************************************************************************
  575. #endif // __CONTAINER_H__