listbox.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. //*****************************************************************************
  2. //
  3. // listbox.h - Prototypes for the listbox 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 __LISTBOX_H__
  25. #define __LISTBOX_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup listbox_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 listbox 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. //! LISTBOX_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The 24-bit RGB color used as the background for the listbox.
  60. //
  61. unsigned int ulBackgroundColor;
  62. //
  63. //! The 24-bit RGB color used as the background for the selected entry
  64. //! in the listbox.
  65. //
  66. unsigned int ulSelectedBackgroundColor;
  67. //
  68. //! The 24-bit RGB color used to draw text on this listbox.
  69. //
  70. unsigned int ulTextColor;
  71. //
  72. //! The 24-bit RGB color used to draw the selected text on this listbox.
  73. //
  74. unsigned int ulSelectedTextColor;
  75. //
  76. //! The 24-bit RGB color used to outline this listbox, if
  77. //! LISTBOX_STYLE_OUTLINE is selected.
  78. //
  79. unsigned int ulOutlineColor;
  80. //
  81. //! A pointer to the font used to render the listbox text.
  82. //
  83. const tFont *pFont;
  84. //
  85. //! A pointer to the array of string pointers representing the contents of
  86. //! the list box.
  87. //
  88. const char **ppcText;
  89. //
  90. //! The number of elements in the array pointed to by pccText.
  91. //
  92. unsigned short usMaxEntries;
  93. //
  94. //! The number of elements in the array pointed to by pccText which are
  95. //! currently populated with strings.
  96. //
  97. unsigned short usPopulated;
  98. //
  99. //! The index of the string currently selected in the list box. If no
  100. //! selection has been made, this will be set to 0xFFFF (-1).
  101. //
  102. short sSelected;
  103. //
  104. //! The index of the string that appears at the top of the list box. This
  105. //! is used by the widget class to control scrolling of the box content.
  106. //! This is an internal variable and must not be modified by an application
  107. //! using this widget class.
  108. //
  109. unsigned short usStartEntry;
  110. //
  111. //! The index of the oldest entry in the ppcText array. This is used by the
  112. //! widget class to determine where to add a new string if the array is
  113. //! full and the listbox has style LISTBOX_STYLE_WRAP. This is an internal
  114. //! variable and must not be modified by an application using this widget
  115. //! class.
  116. //
  117. unsigned short usOldestEntry;
  118. //
  119. //! A flag which we use to determine whether to change the selected element
  120. //! when the pointer is lifted. The listbox will change the selection if
  121. //! no scrolling was performed since the last WIDGET_MSG_PTR_DOWN was
  122. //! received. This is an internal variable and must not be modified by
  123. //! an application using this widget class.
  124. //
  125. unsigned short usScrolled;
  126. //
  127. //! The Y coordinate of the last pointer position we received. This is an
  128. //! internal variable used to manage scrolling of the listbox contents and
  129. //! must not be modified by an application using this widget class.
  130. //
  131. int lPointerY;
  132. //
  133. //! A pointer to the application-supplied callback function. This function
  134. //! will be called each time the selected element in the list box changes.
  135. //! The sSelIndex parameter contains the index of the selected string in
  136. //! ppcText array or, if no element is selected, 0xFFFF (-1).
  137. //
  138. void (*pfnOnChange)(tWidget *pWidget, short sSelIndex);
  139. }
  140. tListBoxWidget;
  141. //*****************************************************************************
  142. //
  143. //! This flag indicates that the listbox should be outlined. If enabled, the
  144. //! widget is drawn with a two pixel border, the outer, single pixel rectangle
  145. //! of which is in the color found in the ulOutlineColor field of the widget
  146. //! structure and the inner rectangle in color ulBackgroundColor.
  147. //
  148. //*****************************************************************************
  149. #define LISTBOX_STYLE_OUTLINE 0x00000001
  150. //*****************************************************************************
  151. //
  152. //! This flag indicates that the listbox is not interactive but merely displays
  153. //! strings. Scrolling of the listbox content is supported when this flag is
  154. //! set but widgets using this style do not make callbacks to the application
  155. //! and do not support selection and deselection of entries. This may be used
  156. //! if a listbox is intended, for example, as a text output or status reporting
  157. //! control.
  158. //
  159. //*****************************************************************************
  160. #define LISTBOX_STYLE_LOCKED 0x00000002
  161. //*****************************************************************************
  162. //
  163. //! This flag controls the behavior of the listbox if a new string is added
  164. //! when the string table (ppcText) is already full. If this style is set, the
  165. //! oldest string in the table is replaced with new one and, if the discarded
  166. //! string was currently displayed, the display positions will be fixed up to
  167. //! ensure that the (new) oldest string remains at the top of the listbox. If
  168. //! this style is not set, the attempt to set a new string will fail if the
  169. //! table is full.
  170. //
  171. //*****************************************************************************
  172. #define LISTBOX_STYLE_WRAP 0x00000004
  173. //*****************************************************************************
  174. //
  175. //! Declares an initialized listbox widget data structure.
  176. //!
  177. //! \param pParent is a pointer to the parent widget.
  178. //! \param pNext is a pointer to the sibling widget.
  179. //! \param pChild is a pointer to the first child widget.
  180. //! \param pDisplay is a pointer to the display on which to draw the listbox.
  181. //! \param lX is the X coordinate of the upper left corner of the listbox.
  182. //! \param lY is the Y coordinate of the upper left corner of the listbox.
  183. //! \param lWidth is the width of the listbox.
  184. //! \param lHeight is the height of the listbox.
  185. //! \param ulStyle is the style to be applied to the listbox.
  186. //! \param ulBgColor is the background color for the listbox.
  187. //! \param ulSelBgColor is the background color for the selected element in the
  188. //! listbox.
  189. //! \param ulTextColor is the color used to draw text on the listbox.
  190. //! \param ulSelTextColor is the color used to draw the selected element text
  191. //! in the listbox.
  192. //! \param ulOutlineColor is the color used to outline the listbox.
  193. //! \param pFont is a pointer to the font to be used to draw text on the
  194. //! listbox.
  195. //! \param ppcText is a pointer to the string table for the listbox.
  196. //! \param usMaxEntries provides the number of entries in the \e ppcText array
  197. //! and represents the maximum number of strings the listbox can hold.
  198. //! \param usPopulatedEntries indicates the number of entries in the \e ppcText
  199. //! array that currently hold valid string for the listbox.
  200. //! \param pfnOnChange is a pointer to the application callback for the listbox.
  201. //!
  202. //! This macro provides an initialized listbox widget data structure, which can
  203. //! be used to construct the widget tree at compile time in global variables
  204. //! (as opposed to run-time via function calls). This must be assigned to a
  205. //! variable, such as:
  206. //!
  207. //! \verbatim
  208. //! tListBoxWidget g_sListBox = ListBoxStruct(...);
  209. //! \endverbatim
  210. //!
  211. //! Or, in an array of variables:
  212. //!
  213. //! \verbatim
  214. //! tListBoxWidget g_psListBox[] =
  215. //! {
  216. //! ListBoxStruct(...),
  217. //! ListBoxStruct(...)
  218. //! };
  219. //! \endverbatim
  220. //!
  221. //! \e ulStyle is the logical OR of the following:
  222. //!
  223. //! - \b #LISTBOX_STYLE_OUTLINE to indicate that the listbox should be outlined.
  224. //! - \b #LISTBOX_STYLE_LOCKED to indicate that the listbox should ignore user
  225. //! input and merely display its contents.
  226. //! - \b #LISTBOX_STYLE_WRAP to indicate that the listbox should discard the
  227. //! oldest string it contains if asked to add a new string while the string
  228. //! table is already full.
  229. //!
  230. //! \return Nothing; this is not a function.
  231. //
  232. //*****************************************************************************
  233. #define ListBoxStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  234. lHeight, ulStyle, ulBgColor, ulSelBgColor, \
  235. ulTextColor, ulSelTextColor, ulOutlineColor, pFont, \
  236. ppcText, usMaxEntries, usPopulatedEntries, \
  237. pfnOnChange) \
  238. { \
  239. { \
  240. sizeof(tListBoxWidget), \
  241. (tWidget *)(pParent), \
  242. (tWidget *)(pNext), \
  243. (tWidget *)(pChild), \
  244. pDisplay, \
  245. { \
  246. lX, \
  247. lY, \
  248. (lX) + (lWidth) - 1, \
  249. (lY) + (lHeight) - 1 \
  250. }, \
  251. ListBoxMsgProc \
  252. }, \
  253. ulStyle, \
  254. ulBgColor, \
  255. ulSelBgColor, \
  256. ulTextColor, \
  257. ulSelTextColor, \
  258. ulOutlineColor, \
  259. pFont, \
  260. ppcText, \
  261. usMaxEntries, \
  262. usPopulatedEntries, \
  263. (short)0xFFFF, \
  264. 0, \
  265. 0, \
  266. 0, \
  267. 0, \
  268. pfnOnChange \
  269. }
  270. //*****************************************************************************
  271. //
  272. //! Declares an initialized variable containing a listbox widget data structure.
  273. //!
  274. //! \param sName is the name of the variable to be declared.
  275. //! \param pParent is a pointer to the parent widget.
  276. //! \param pNext is a pointer to the sibling widget.
  277. //! \param pChild is a pointer to the first child widget.
  278. //! \param pDisplay is a pointer to the display on which to draw the listbox.
  279. //! \param lX is the X coordinate of the upper left corner of the listbox.
  280. //! \param lY is the Y coordinate of the upper left corner of the listbox.
  281. //! \param lWidth is the width of the listbox.
  282. //! \param lHeight is the height of the listbox.
  283. //! \param ulStyle is the style to be applied to the listbox.
  284. //! \param ulBgColor is the background color for the listbox.
  285. //! \param ulSelBgColor is the background color for the selected element in the
  286. //! listbox.
  287. //! \param ulTextColor is the color used to draw text on the listbox.
  288. //! \param ulSelTextColor is the color used to draw the selected element
  289. //! text in the listbox.
  290. //! \param ulOutlineColor is the color used to outline the listbox.
  291. //! \param pFont is a pointer to the font to be used to draw text on the
  292. //! listbox.
  293. //! \param ppcText is a pointer to the string table for the listbox.
  294. //! \param usMaxEntries provides the number of entries in the \e ppcText array
  295. //! and represents the maximum number of strings the listbox can hold.
  296. //! \param usPopulatedEntries indicates the number of entries in the \e ppcText
  297. //! array that currently hold valid string for the listbox.
  298. //! \param pfnOnChange is a pointer to the application callback for the listbox.
  299. //!
  300. //! This macro declares a variable containing an initialized listbox widget data
  301. //! structure, which can be used to construct the widget tree at compile time
  302. //! in global variables (as opposed to run-time via function calls).
  303. //!
  304. //! \e ulStyle is the logical OR of the following:
  305. //!
  306. //! - \b #LISTBOX_STYLE_OUTLINE to indicate that the listbox should be outlined.
  307. //! - \b #LISTBOX_STYLE_LOCKED to indicate that the listbox should ignore user
  308. //! input and merely display its contents.
  309. //! - \b #LISTBOX_STYLE_WRAP to indicate that the listbox should discard the
  310. //! oldest string it contains if asked to add a new string while the string
  311. //! table is already full.
  312. //!
  313. //! \return Nothing; this is not a function.
  314. //
  315. //*****************************************************************************
  316. #define ListBox(sName, pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  317. lHeight, ulStyle, ulBgColor, ulSelBgColor, ulTextColor, \
  318. ulSelTextColor, ulOutlineColor, pFont, ppcText, usMaxEntries,\
  319. usPopulatedEntries, pfnOnChange) \
  320. tListBoxWidget sName = \
  321. ListBoxStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, lHeight, \
  322. ulStyle, ulBgColor, ulSelBgColor, ulTextColor, \
  323. ulSelTextColor, ulOutlineColor, pFont, ppcText, \
  324. usMaxEntries, usPopulatedEntries, pfnOnChange)
  325. //*****************************************************************************
  326. //
  327. //! Sets the function to call when the listbox selection changes.
  328. //!
  329. //! \param pWidget is a pointer to the listbox widget to modify.
  330. //! \param pfnCallback is a pointer to the function to call.
  331. //!
  332. //! This function sets the function to be called when the selected element in
  333. //! this listbox changes. If style \b #LISTBOX_STYLE_LOCKED is selected, or
  334. //! the callback function pointer set is NULL, no callbacks will be made.
  335. //!
  336. //! \return None.
  337. //
  338. //*****************************************************************************
  339. #define ListBoxCallbackSet(pWidget, pfnCallback) \
  340. do \
  341. { \
  342. tListBoxWidget *pW = pWidget; \
  343. pW->pfnOnChange = pfnCallback; \
  344. } \
  345. while(0)
  346. //*****************************************************************************
  347. //
  348. //! Sets the background color of a listbox widget.
  349. //!
  350. //! \param pWidget is a pointer to the listbox widget to be modified.
  351. //! \param ulColor is the 24-bit RGB color to use for the listbox background.
  352. //!
  353. //! This function changes the color used for the listbox background on the
  354. //! display. The display is not updated until the next paint request.
  355. //!
  356. //! \return None.
  357. //
  358. //*****************************************************************************
  359. #define ListBoxBackgroundColorSet(pWidget, ulColor) \
  360. do \
  361. { \
  362. tListBoxWidget *pW = pWidget; \
  363. pW->ulBackgroundColor = ulColor; \
  364. } \
  365. while(0)
  366. //*****************************************************************************
  367. //
  368. //! Sets the background color of the selected element in a listbox widget.
  369. //!
  370. //! \param pWidget is a pointer to the listbox widget to be modified.
  371. //! \param ulColor is the 24-bit RGB color to use for the background of the
  372. //! selected element.
  373. //!
  374. //! This function changes the color used for the background of the selected
  375. //! line of text on the display. The display is not updated until the next
  376. //! paint request.
  377. //!
  378. //! \return None.
  379. //
  380. //*****************************************************************************
  381. #define ListBoxSelectedBackgroundColorSet(pWidget, ulColor) \
  382. do \
  383. { \
  384. tListBoxWidget *pW = pWidget; \
  385. pW->ulSelectedBackgroundColor = ulColor; \
  386. } \
  387. while(0)
  388. //*****************************************************************************
  389. //
  390. //! Sets the font for a listbox widget.
  391. //!
  392. //! \param pWidget is a pointer to the listbox widget to modify.
  393. //! \param pFnt is a pointer to the font to use to draw text on the listbox.
  394. //!
  395. //! This function changes the font used to draw text on the listbox. The
  396. //! display is not updated until the next paint request.
  397. //!
  398. //! \return None.
  399. //
  400. //*****************************************************************************
  401. #define ListBoxFontSet(pWidget, pFnt) \
  402. do \
  403. { \
  404. tListBoxWidget *pW = pWidget; \
  405. const tFont *pF = pFnt; \
  406. pW->pFont = pF; \
  407. } \
  408. while(0)
  409. //*****************************************************************************
  410. //
  411. //! Sets the outline color of a listbox widget.
  412. //!
  413. //! \param pWidget is a pointer to the listbox widget to be modified.
  414. //! \param ulColor is the 24-bit RGB color to use to outline the listbox.
  415. //!
  416. //! This function changes the color used to outline the listbox on the display.
  417. //! The display is not updated until the next paint request.
  418. //!
  419. //! \return None.
  420. //
  421. //*****************************************************************************
  422. #define ListBoxOutlineColorSet(pWidget, ulColor) \
  423. do \
  424. { \
  425. tListBoxWidget *pW = pWidget; \
  426. pW->ulOutlineColor = ulColor; \
  427. } \
  428. while(0)
  429. //*****************************************************************************
  430. //
  431. //! Disables outlining of a listbox widget.
  432. //!
  433. //! \param pWidget is a pointer to the listbox widget to modify.
  434. //!
  435. //! This function disables the outlining of a listbox widget. The display is
  436. //! not updated until the next paint request.
  437. //!
  438. //! \return None.
  439. //
  440. //*****************************************************************************
  441. #define ListBoxOutlineOff(pWidget) \
  442. do \
  443. { \
  444. tListBoxWidget *pW = pWidget; \
  445. pW->ulStyle &= ~(LISTBOX_STYLE_OUTLINE); \
  446. } \
  447. while(0)
  448. //*****************************************************************************
  449. //
  450. //! Enables outlining of a listbox widget.
  451. //!
  452. //! \param pWidget is a pointer to the listbox widget to modify.
  453. //!
  454. //! This function enables the outlining of a listbox widget. The display is not
  455. //! updated until the next paint request.
  456. //!
  457. //! \return None.
  458. //
  459. //*****************************************************************************
  460. #define ListBoxOutlineOn(pWidget) \
  461. do \
  462. { \
  463. tListBoxWidget *pW = pWidget; \
  464. pW->ulStyle |= LISTBOX_STYLE_OUTLINE; \
  465. } \
  466. while(0)
  467. //*****************************************************************************
  468. //
  469. //! Sets the text color of a listbox widget.
  470. //!
  471. //! \param pWidget is a pointer to the listbox widget to be modified.
  472. //! \param ulColor is the 24-bit RGB color to use to draw text on the listbox.
  473. //!
  474. //! This function changes the color used to draw text on the listbox on the
  475. //! display. The display is not updated until the next paint request.
  476. //!
  477. //! \return None.
  478. //
  479. //*****************************************************************************
  480. #define ListBoxTextColorSet(pWidget, ulColor) \
  481. do \
  482. { \
  483. tListBoxWidget *pW = pWidget; \
  484. pW->ulTextColor = ulColor; \
  485. } \
  486. while(0)
  487. //*****************************************************************************
  488. //
  489. //! Sets the text color of the selected element in a listbox widget.
  490. //!
  491. //! \param pWidget is a pointer to the listbox widget to be modified.
  492. //! \param ulColor is the 24-bit RGB color to use to draw the selected text
  493. //! on the listbox.
  494. //!
  495. //! This function changes the color used to draw the selected element text
  496. //! on the display. The display is not updated until the next paint request.
  497. //!
  498. //! \return None.
  499. //
  500. //*****************************************************************************
  501. #define ListBoxSelectedTextColorSet(pWidget, ulColor) \
  502. do \
  503. { \
  504. tListBoxWidget *pW = pWidget; \
  505. pW->ulSelectedTextColor = ulColor; \
  506. } \
  507. while(0)
  508. //*****************************************************************************
  509. //
  510. //! Changes the text associated with an element in the listbox widget.
  511. //!
  512. //! \param pWidget is a pointer to the listbox widget to be modified.
  513. //! \param pcTxt is a pointer to the new text string.
  514. //! \param ulIndex is the index of the element whose string is to be replaced.
  515. //!
  516. //! This function replaces the string associated with one of the listbox
  517. //! elements. This call should only be used to replace a string for an
  518. //! already-populated element. To add a new string, use ListBoxTextAdd().
  519. //! The display is not updated until the next paint request.
  520. //!
  521. //! \return None.
  522. //
  523. //*****************************************************************************
  524. #define ListBoxTextSet(pWidget, pcTxt, ulIndex) \
  525. do \
  526. { \
  527. tListBoxWidget *pW = pWidget; \
  528. const char *pcT = pcTxt; \
  529. if(ulIndex < pW->usMaxEntries) \
  530. { \
  531. pW->ppcText[ulIndex] = pcT; \
  532. } \
  533. } \
  534. while(0)
  535. //*****************************************************************************
  536. //
  537. //! Locks a listbox making it ignore attempts to select elements.
  538. //!
  539. //! \param pWidget is a pointer to the listbox widget to modify.
  540. //!
  541. //! This function locks a listbox widget and makes it ignore attempts to
  542. //! select or deselect an element. When locked, a listbox acts as a passive
  543. //! indicator. Strings may be added and the selected element changed via
  544. //! calls to ListBoxSelectioSet() but pointer activity will not change the
  545. //! selection and no callbacks will be made. In this mode, the user may still
  546. //! use the pointer to scroll the content of the listbox assuming it contains
  547. //! more strings that can be displayed in the widget area.
  548. //!
  549. //! \return None.
  550. //
  551. //*****************************************************************************
  552. #define ListBoxLock(pWidget) \
  553. do \
  554. { \
  555. tListBoxWidget *pW = pWidget; \
  556. pW->ulStyle |= LISTBOX_STYLE_LOCKED; \
  557. } \
  558. while(0)
  559. //*****************************************************************************
  560. //
  561. //! Unlocks a listbox making it respond to pointer input.
  562. //!
  563. //! \param pWidget is a pointer to the listbox widget to modify.
  564. //!
  565. //! This function unlocks a listbox widget. When unlocked, a listbox will
  566. //! respond to pointer input by setting its selected element appropriately and
  567. //! informing the application of changes via callbacks.
  568. //!
  569. //! \return None.
  570. //
  571. //*****************************************************************************
  572. #define ListBoxUnlock(pWidget) \
  573. do \
  574. { \
  575. tListBoxWidget *pW = pWidget; \
  576. pW->ulStyle &= ~(LISTBOX_STYLE_LOCKED); \
  577. } \
  578. while(0)
  579. //*****************************************************************************
  580. //
  581. //! Enables wrapping in a listbox.
  582. //!
  583. //! \param pWidget is a pointer to the listbox widget to modify.
  584. //!
  585. //! This function enables text wrapping in a listbox widget. With wrapping
  586. //! enabled, calls to ListBoxTextAdd() made when the widget string table is
  587. //! full will discard the oldest string in favor of the new one. If wrapping
  588. //! is disabled, these calls will fail.
  589. //!
  590. //! \return None.
  591. //
  592. //*****************************************************************************
  593. #define ListBoxWrapEnable(pWidget) \
  594. do \
  595. { \
  596. tListBoxWidget *pW = pWidget; \
  597. pW->ulStyle &= ~(LISTBOX_STYLE_WRAP); \
  598. } \
  599. while(0)
  600. //*****************************************************************************
  601. //
  602. //! Disables text wrapping in a listbox.
  603. //!
  604. //! \param pWidget is a pointer to the listbox widget to modify.
  605. //!
  606. //! This function disables text wrapping in a listbox widget. With wrapping
  607. //! enabled, calls to ListBoxTextAdd() made when the widget string table is
  608. //! full will discard the oldest string in favor of the new one. If wrapping
  609. //! is disabled, these calls will fail.
  610. //!
  611. //! \return None.
  612. //
  613. //*****************************************************************************
  614. #define ListBoxWrapDisable(pWidget) \
  615. do \
  616. { \
  617. tListBoxWidget *pW = pWidget; \
  618. pW->ulStyle |= LISTBOX_STYLE_WRAP; \
  619. } \
  620. while(0)
  621. //*****************************************************************************
  622. //
  623. //! Empties the listbox.
  624. //!
  625. //! \param pWidget is a pointer to the listbox widget to modify.
  626. //!
  627. //! This function removes all text from a listbox widget. The display is not
  628. //! updated until the next paint request.
  629. //!
  630. //! \return None.
  631. //
  632. //*****************************************************************************
  633. #define ListBoxClear(pWidget) \
  634. do \
  635. { \
  636. tListBoxWidget *pW = pWidget; \
  637. pW->usPopulated = 0; \
  638. pW->sSelected = (short)0xFFFF; \
  639. pW->usStartEntry = 0; \
  640. pW->usOldestEntry = 0; \
  641. } \
  642. while(0)
  643. //*****************************************************************************
  644. //
  645. //! Sets the current selection within the listbox.
  646. //!
  647. //! \param pWidget is a pointer to the listbox widget to modify.
  648. //! \param sSel is the index of the item to select.
  649. //!
  650. //! This function selects an item within the list box. The display is not
  651. //! updated until the next paint request.
  652. //!
  653. //! \return None.
  654. //
  655. //*****************************************************************************
  656. #define ListBoxSelectionSet(pWidget, sSel) \
  657. do \
  658. { \
  659. tListBoxWidget *pW = pWidget; \
  660. if((sSel) < pW->usPopulated) \
  661. { \
  662. pW->sSelected = (sSel); \
  663. } \
  664. } \
  665. while(0)
  666. //*****************************************************************************
  667. //
  668. //! Gets the index of the current selection within the listbox.
  669. //!
  670. //! \param pWidget is a pointer to the listbox widget to be queried.
  671. //!
  672. //! This function returns the index of the item currently selected in a
  673. //! listbox. If no selection has been made, 0xFFFF (-1) is returned.
  674. //!
  675. //! \return None.
  676. //
  677. //*****************************************************************************
  678. #define ListBoxSelectionGet(pWidget) (((tListBoxWidget *)(pWidget))->sSelected)
  679. //*****************************************************************************
  680. //
  681. // Prototypes for the listbox widget APIs.
  682. //
  683. //*****************************************************************************
  684. extern int ListBoxMsgProc(tWidget *pWidget, unsigned int ulMsg,
  685. unsigned int ulParam1, unsigned int ulParam2);
  686. extern void ListBoxInit(tListBoxWidget *pWidget, const tDisplay *pDisplay,
  687. const char **ppcText, unsigned short usMaxEntries,
  688. unsigned short usPopulatedEntries, int lX, int lY,
  689. int lWidth, int lHeight);
  690. extern int ListBoxTextAdd(tListBoxWidget *pWidget, const char *pcTxt);
  691. //*****************************************************************************
  692. //
  693. // Mark the end of the C bindings section for C++ compilers.
  694. //
  695. //*****************************************************************************
  696. #ifdef __cplusplus
  697. }
  698. #endif
  699. //*****************************************************************************
  700. //
  701. // Close the Doxygen group.
  702. //! @}
  703. //
  704. //*****************************************************************************
  705. #endif // __LISTBOX_H__