slider.h 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. //*****************************************************************************
  2. //
  3. // slider.h - Prototypes for the slider widget class.
  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 __SLIDER_H__
  25. #define __SLIDER_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup slider_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 slider 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. //! SL_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The 24-bit RGB color used to fill this slider, if SL_STYLE_FILL is
  60. //! selected, and to use as the background color if SL_STYLE_TEXT_OPAQUE is
  61. //! selected.
  62. //
  63. unsigned int ulFillColor;
  64. //
  65. //! The 24-bit RGB color used to fill the background portion of the slider
  66. //! if SL_STYLE_FILL is selected, and to use as the background color if
  67. //! SL_STYLE_TEXT_OPAQUE is selected.
  68. //
  69. unsigned int ulBackgroundFillColor;
  70. //
  71. //! The 24-bit RGB color used to outline this slider, if
  72. //! SL_STYLE_OUTLINE is selected.
  73. //
  74. unsigned int ulOutlineColor;
  75. //
  76. //! The 24-bit RGB color used to draw text on the "active" portion of
  77. //! this slider, if SL_STYLE_TEXT is selected.
  78. //
  79. unsigned int ulTextColor;
  80. //
  81. //! The 24-bit RGB color used to draw text on the background portion of
  82. //! this slider, if SL_STYLE_TEXT is selected.
  83. //
  84. unsigned int ulBackgroundTextColor;
  85. //
  86. //! A pointer to the font used to render the slider text, if
  87. //! SL_STYLE_TEXT is selected.
  88. //
  89. const tFont *pFont;
  90. //
  91. //! A pointer to the text to draw on this slider, if SL_STYLE_TEXT is
  92. //! selected.
  93. //
  94. const char *pcText;
  95. //
  96. //! A pointer to the image to be drawn onto this slider, if
  97. //! SL_STYLE_IMG is selected.
  98. //
  99. const unsigned char *pucImage;
  100. //
  101. //! A pointer to the image to be drawn onto this slider background if
  102. //! SL_STYLE_BACKG_IMG is selected.
  103. //
  104. const unsigned char *pucBackgroundImage;
  105. //
  106. //! A pointer to the function to be called when the state of the slider
  107. //! changes.
  108. //
  109. void (*pfnOnChange)(tWidget *pWidget, int lValue);
  110. //
  111. //! The value represented by the slider at its zero position. This
  112. //! value is returned if a horizontal slider is pulled to the far left or
  113. //! a vertical slider is pulled to the bottom of widget's bounding
  114. //! rectangle.
  115. //
  116. int lMin;
  117. //
  118. //! The value represented by the slider at its maximum position. This value
  119. //! is returned if a horizontal slider is pulled to the far right or a
  120. //! vertical slider is pulled to the top of the widget's bounding
  121. //! rectangle.
  122. //
  123. int lMax;
  124. //
  125. //! The current slider value scaled according to the minimum and maximum
  126. //! values for the control.
  127. //
  128. int lValue;
  129. //
  130. //! This internal work variable stores the pixel position representing the
  131. //! current slider value.
  132. //
  133. short sPos;
  134. }
  135. tSliderWidget;
  136. //*****************************************************************************
  137. //
  138. //! This flag indicates that the slider should be outlined.
  139. //
  140. //*****************************************************************************
  141. #define SL_STYLE_OUTLINE 0x00000001
  142. //*****************************************************************************
  143. //
  144. //! This flag indicates that the active portion of the slider should be filled.
  145. //
  146. //*****************************************************************************
  147. #define SL_STYLE_FILL 0x00000002
  148. //*****************************************************************************
  149. //
  150. //! This flag indicates that the background portion of the slider should be
  151. //! filled.
  152. //
  153. //*****************************************************************************
  154. #define SL_STYLE_BACKG_FILL 0x00000004
  155. //*****************************************************************************
  156. //
  157. //! This flag indicates that the slider should have text drawn on top of the
  158. //! active portion.
  159. //
  160. //*****************************************************************************
  161. #define SL_STYLE_TEXT 0x00000008
  162. //*****************************************************************************
  163. //
  164. //! This flag indicates that the slider should have text drawn on top of the
  165. //! background portion.
  166. //
  167. //*****************************************************************************
  168. #define SL_STYLE_BACKG_TEXT 0x00000010
  169. //*****************************************************************************
  170. //
  171. //! This flag indicates that the slider should have an image drawn on it.
  172. //
  173. //*****************************************************************************
  174. #define SL_STYLE_IMG 0x00000020
  175. //*****************************************************************************
  176. //
  177. //! This flag indicates that the slider should have an image drawn on its
  178. //! background.
  179. //
  180. //*****************************************************************************
  181. #define SL_STYLE_BACKG_IMG 0x00000040
  182. //*****************************************************************************
  183. //
  184. //! This flag indicates that the slider text should be drawn opaque (in
  185. //! other words, drawing the background pixels as well as the foreground
  186. //! pixels) in the active portion of the slider.
  187. //
  188. //*****************************************************************************
  189. #define SL_STYLE_TEXT_OPAQUE 0x00000080
  190. //*****************************************************************************
  191. //
  192. //! This flag indicates that the slider text should be drawn opaque (in
  193. //! other words, drawing the background pixels as well as the foreground
  194. //! pixels) in the background portion of the slider.
  195. //
  196. //*****************************************************************************
  197. #define SL_STYLE_BACKG_TEXT_OPAQUE 0x00000100
  198. //*****************************************************************************
  199. //
  200. //! This flag indicates that the slider is vertical rather than horizontal. If
  201. //! the flag is absent, the slider is assumed to operate horizontally with the
  202. //! reported value increasing from left to right. If set, the reported value
  203. //! increases from the bottom of the widget towards the top.
  204. //
  205. //*****************************************************************************
  206. #define SL_STYLE_VERTICAL 0x00000200
  207. //*****************************************************************************
  208. //
  209. //! This flag causes the slider to ignore pointer input and act as a passive
  210. //! indicator. An application may set its value and repaint it as normal but
  211. //! its value will not be changed in response to any touchscreen activity.
  212. //
  213. //*****************************************************************************
  214. #define SL_STYLE_LOCKED 0x00000400
  215. //*****************************************************************************
  216. //
  217. //! Declares an initialized slider widget data structure.
  218. //!
  219. //! \param pParent is a pointer to the parent widget.
  220. //! \param pNext is a pointer to the sibling widget.
  221. //! \param pChild is a pointer to the first child widget.
  222. //! \param pDisplay is a pointer to the display on which to draw the slider.
  223. //! \param lX is the X coordinate of the upper left corner of the slider.
  224. //! \param lY is the Y coordinate of the upper left corner of the slider.
  225. //! \param lWidth is the width of the slider.
  226. //! \param lHeight is the height of the slider.
  227. //! \param lMin is the minimum value for the slider (corresponding to the left
  228. //! or bottom position).
  229. //! \param lMax is the maximum value for the slider (corresponding to the right
  230. //! or top position).
  231. //! \param lValue is the initial value of the slider. This must lie in the
  232. //! range defined by \e lMin and \e lMax.
  233. //! \param ulStyle is the style to be applied to the slider.
  234. //! \param ulFillColor is the color used to fill in the slider.
  235. //! \param ulBackgroundFillColor is the color used to fill the background area
  236. //! of the slider.
  237. //! \param ulOutlineColor is the color used to outline the slider.
  238. //! \param ulTextColor is the color used to draw text on the slider.
  239. //! \param ulBackgroundTextColor is the color used to draw text on the
  240. //! background portion of the slider.
  241. //! \param pFont is a pointer to the font to be used to draw text on the
  242. //! slider.
  243. //! \param pcText is a pointer to the text to draw on this slider.
  244. //! \param pucImage is a pointer to the image to draw on this slider.
  245. //! \param pucBackgroundImage is a pointer to the image to draw on the slider
  246. //! background.
  247. //! \param pfnOnChange is a pointer to the function that is called to notify
  248. //! the application of slider value changes.
  249. //!
  250. //! This macro provides an initialized slider widget data structure, which can
  251. //! be used to construct the widget tree at compile time in global variables
  252. //! (as opposed to run-time via function calls). This must be assigned to a
  253. //! variable, such as:
  254. //!
  255. //! \verbatim
  256. //! tSliderWidget g_sSlider = SliderStruct(...);
  257. //! \endverbatim
  258. //!
  259. //! Or, in an array of variables:
  260. //!
  261. //! \verbatim
  262. //! tSliderWidget g_psSliders[] =
  263. //! {
  264. //! SliderStruct(...),
  265. //! SliderStruct(...)
  266. //! };
  267. //! \endverbatim
  268. //!
  269. //! \e ulStyle is the logical OR of the following:
  270. //!
  271. //! - \b #SL_STYLE_OUTLINE to indicate that the slider should be outlined.
  272. //! - \b #SL_STYLE_FILL to indicate that the slider should be filled.
  273. //! - \b #SL_STYLE_BACKG_FILL to indicate that the background portion of the
  274. //! slider should be filled.
  275. //! - \b #SL_STYLE_TEXT to indicate that the slider should have text drawn
  276. //! on its active portion (using \e pFont and \e pcText).
  277. //! - \b #SL_STYLE_BACKG_TEXT to indicate that the slider should have text drawn
  278. //! on its background portion (using \e pFont and \e pcText).
  279. //! - \b #SL_STYLE_IMG to indicate that the slider should have an image
  280. //! drawn on it (using \e pucImage).
  281. //! - \b #SL_STYLE_BACKG_IMG to indicate that the slider should have an image
  282. //! drawn on its background (using \e pucBackgroundImage).
  283. //! - \b #SL_STYLE_TEXT_OPAQUE to indicate that the slider text should be
  284. //! drawn opaque (in other words, drawing the background pixels).
  285. //! - \b #SL_STYLE_BACKG_TEXT_OPAQUE to indicate that the slider text should be
  286. //! drawn opaque in the background portion of the widget. (in other words,
  287. //! drawing the background pixels).
  288. //! - \b #SL_STYLE_VERTICAL to indicate that this is a vertical slider
  289. //! rather than a horizontal one (the default if this style flag is not set).
  290. //! - \b #SL_STYLE_LOCKED to indicate that the slider is being used as an
  291. //! indicator and should ignore user input.
  292. //!
  293. //! \return Nothing; this is not a function.
  294. //
  295. //*****************************************************************************
  296. #define SliderStruct(pParent, pNext, pChild, pDisplay, lX, lY, lWidth, \
  297. lHeight, lMin, lMax, lValue, ulStyle, ulFillColor, \
  298. ulBackgroundFillColor, ulOutlineColor, ulTextColor, \
  299. ulBackgroundTextColor, pFont, pcText, pucImage, \
  300. pucBackgroundImage, pfnOnChange) \
  301. { \
  302. { \
  303. sizeof(tSliderWidget), \
  304. (tWidget *)(pParent), \
  305. (tWidget *)(pNext), \
  306. (tWidget *)(pChild), \
  307. pDisplay, \
  308. { \
  309. lX, \
  310. lY, \
  311. (lX) + (lWidth) - 1, \
  312. (lY) + (lHeight) - 1 \
  313. }, \
  314. SliderMsgProc \
  315. }, \
  316. ulStyle, \
  317. ulFillColor, \
  318. ulBackgroundFillColor, \
  319. ulOutlineColor, \
  320. ulTextColor, \
  321. ulBackgroundTextColor, \
  322. pFont, \
  323. pcText, \
  324. pucImage, \
  325. pucBackgroundImage, \
  326. pfnOnChange, \
  327. lMin, \
  328. lMax, \
  329. lValue, \
  330. 0 \
  331. }
  332. //*****************************************************************************
  333. //
  334. //! Declares an initialized variable containing a slider widget data structure.
  335. //!
  336. //! \param sName is the name of the variable to be declared.
  337. //! \param pParent is a pointer to the parent widget.
  338. //! \param pNext is a pointer to the sibling widget.
  339. //! \param pChild is a pointer to the first child widget.
  340. //! \param pDisplay is a pointer to the display on which to draw the slider.
  341. //! \param lX is the X coordinate of the upper left corner of the slider.
  342. //! \param lY is the Y coordinate of the upper left corner of the slider.
  343. //! \param lWidth is the width of the slider.
  344. //! \param lHeight is the height of the slider.
  345. //! \param lMin is the minimum value for the slider (corresponding to the left
  346. //! or bottom position).
  347. //! \param lMax is the maximum value for the slider (corresponding to the right
  348. //! or top position).
  349. //! \param lValue is the initial value of the slider. This must lie in the
  350. //! range defined by \e lMin and \e lMax.
  351. //! \param ulStyle is the style to be applied to the slider.
  352. //! \param ulFillColor is the color used to fill in the slider.
  353. //! \param ulBackgroundFillColor is the color used to fill in the background
  354. //! area of the slider.
  355. //! \param ulOutlineColor is the color used to outline the slider.
  356. //! \param ulTextColor is the color used to draw text on the slider.
  357. //! \param ulBackgroundTextColor is the color used to draw text on the
  358. //! background portion of the slider.
  359. //! \param pFont is a pointer to the font to be used to draw text on the slider.
  360. //! \param pcText is a pointer to the text to draw on this slider.
  361. //! \param pucImage is a pointer to the image to draw on this slider.
  362. //! \param pucBackgroundImage is a pointer to the image to draw on the slider
  363. //! background.
  364. //! \param pfnOnChange is a pointer to the function that is called to notify
  365. //! the application of slider value changes.
  366. //!
  367. //! This macro provides an initialized slider widget data structure, which can
  368. //! be used to construct the widget tree at compile time in global variables
  369. //! (as opposed to run-time via function calls).
  370. //!
  371. //! \e ulStyle is the logical OR of the following:
  372. //!
  373. //! - \b #SL_STYLE_OUTLINE to indicate that the slider should be outlined.
  374. //! - \b #SL_STYLE_FILL to indicate that the slider should be filled.
  375. //! - \b #SL_STYLE_BACKG_FILL to indicate that the background portion of the
  376. //! slider should be filled.
  377. //! - \b #SL_STYLE_TEXT to indicate that the slider should have text drawn
  378. //! on its active portion (using \e pFont and \e pcText).
  379. //! - \b #SL_STYLE_BACKG_TEXT to indicate that the slider should have text drawn
  380. //! on its background portion (using \e pFont and \e pcText).
  381. //! - \b #SL_STYLE_IMG to indicate that the slider should have an image
  382. //! drawn on it (using \e pucImage).
  383. //! - \b #SL_STYLE_BACKG_IMG to indicate that the slider should have an image
  384. //! drawn on its background (using \e pucBackgroundImage).
  385. //! - \b #SL_STYLE_TEXT_OPAQUE to indicate that the slider text should be
  386. //! drawn opaque (in other words, drawing the background pixels).
  387. //! - \b #SL_STYLE_BACKG_TEXT_OPAQUE to indicate that the slider text should be
  388. //! drawn opaque in the background portion of the widget. (in other words,
  389. //! drawing the background pixels).
  390. //! - \b #SL_STYLE_VERTICAL to indicate that this is a vertical slider
  391. //! rather than a horizontal one (the default if this style flag is not set).
  392. //! - \b #SL_STYLE_LOCKED to indicate that the slider is being used as an
  393. //! indicator and should ignore user input.
  394. //!
  395. //! \return Nothing; this is not a function.
  396. //
  397. //*****************************************************************************
  398. #define Slider(sName, pParent, pNext, pChild, pDisplay, lX, lY, \
  399. lWidth, lHeight, lMin, lMax, lValue, ulStyle, \
  400. ulFillColor, ulBackgroundFillColor, ulOutlineColor, \
  401. ulTextColor, ulBackgroundTextColor, pFont, pcText, \
  402. pucImage, pucBackgroundImage, pfnOnChange) \
  403. tSliderWidget sName = \
  404. SliderStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  405. lWidth, lHeight, lMin, lMax, lValue, \
  406. ulStyle, ulFillColor, ulBackgroundFillColor,\
  407. ulOutlineColor, ulTextColor, \
  408. ulBackgroundTextColor, pFont, pcText, \
  409. pucImage, pucBackgroundImage, pfnOnChange)
  410. //*****************************************************************************
  411. //
  412. //! Sets the function to call when this slider widget's value changes.
  413. //!
  414. //! \param pWidget is a pointer to the slider widget to modify.
  415. //! \param pfnCallback is a pointer to the function to call.
  416. //!
  417. //! This function sets the function to be called when the value represented by
  418. //! the slider changes.
  419. //!
  420. //! \return None.
  421. //
  422. //*****************************************************************************
  423. #define SliderCallbackSet(pWidget, pfnCallback) \
  424. do \
  425. { \
  426. tSliderWidget *pW = pWidget; \
  427. pW->pfnOnChange = pfnCallback; \
  428. } \
  429. while(0)
  430. //*****************************************************************************
  431. //
  432. //! Sets the fill color for the active area of a slider widget.
  433. //!
  434. //! \param pWidget is a pointer to the slider widget to be modified.
  435. //! \param ulColor is the 24-bit RGB color to use to fill the slider.
  436. //!
  437. //! This function changes the color used to fill the active are of the slider
  438. //! on the display. The display is not updated until the next paint request.
  439. //!
  440. //! \return None.
  441. //
  442. //*****************************************************************************
  443. #define SliderFillColorSet(pWidget, ulColor) \
  444. do \
  445. { \
  446. tSliderWidget *pW = pWidget; \
  447. pW->ulFillColor = ulColor; \
  448. } \
  449. while(0)
  450. //*****************************************************************************
  451. //
  452. //! Sets the fill color for the background area of a slider widget.
  453. //!
  454. //! \param pWidget is a pointer to the slider widget to be modified.
  455. //! \param ulColor is the 24-bit RGB color to use to fill the background area
  456. //! of the slider.
  457. //!
  458. //! This function changes the color used to fill the background area of the
  459. //! slider on the display. The display is not updated until the next paint
  460. //! request.
  461. //!
  462. //! \return None.
  463. //
  464. //*****************************************************************************
  465. #define SliderFillColorBackgroundedSet(pWidget, ulColor) \
  466. do \
  467. { \
  468. tSliderWidget *pW = pWidget; \
  469. pW->ulBackgroundFillColor = ulColor; \
  470. } \
  471. while(0)
  472. //*****************************************************************************
  473. //
  474. //! Disables filling of the active area of a slider widget.
  475. //!
  476. //! \param pWidget is a pointer to the slider widget to modify.
  477. //!
  478. //! This function disables the filling of the active area of a slider widget.
  479. //! The display is not updated until the next paint request.
  480. //!
  481. //! \return None.
  482. //
  483. //*****************************************************************************
  484. #define SliderFillOff(pWidget) \
  485. do \
  486. { \
  487. tSliderWidget *pW = pWidget; \
  488. pW->ulStyle &= ~(SL_STYLE_FILL); \
  489. } \
  490. while(0)
  491. //*****************************************************************************
  492. //
  493. //! Enables filling of the active area of a slider widget.
  494. //!
  495. //! \param pWidget is a pointer to the slider widget to modify.
  496. //!
  497. //! This function enables the filling of the active area of a slider widget.
  498. //! The display is not updated until the next paint request.
  499. //!
  500. //! \return None.
  501. //
  502. //*****************************************************************************
  503. #define SliderFillOn(pWidget) \
  504. do \
  505. { \
  506. tSliderWidget *pW = pWidget; \
  507. pW->ulStyle |= SL_STYLE_FILL; \
  508. } \
  509. while(0)
  510. //*****************************************************************************
  511. //
  512. //! Sets the font for a slider widget.
  513. //!
  514. //! \param pWidget is a pointer to the slider widget to modify.
  515. //! \param pFnt is a pointer to the font to use to draw text on the slider.
  516. //!
  517. //! This function changes the font used to draw text on the slider. The
  518. //! display is not updated until the next paint request.
  519. //!
  520. //! \return None.
  521. //
  522. //*****************************************************************************
  523. #define SliderFontSet(pWidget, pFnt) \
  524. do \
  525. { \
  526. tSliderWidget *pW = pWidget; \
  527. const tFont *pF = pFnt; \
  528. pW->pFont = pF; \
  529. } \
  530. while(0)
  531. //*****************************************************************************
  532. //
  533. //! Changes the image drawn on the active area of a slider widget.
  534. //!
  535. //! \param pWidget is a pointer to the slider widget to be modified.
  536. //! \param pImg is a pointer to the image to draw onto the slider.
  537. //!
  538. //! This function changes the image that is drawn on the active area of the
  539. //! slider. This image will be centered within the widget rectangle and the
  540. //! portion represented by the current slider value will be visible. The
  541. //! display is not updated until the next paint request.
  542. //!
  543. //! \return None.
  544. //
  545. //*****************************************************************************
  546. #define SliderImageSet(pWidget, pImg) \
  547. do \
  548. { \
  549. tSliderWidget *pW = pWidget; \
  550. const unsigned char *pI = pImg; \
  551. pW->pucImage = pI; \
  552. } \
  553. while(0)
  554. //*****************************************************************************
  555. //
  556. //! Changes the image drawn on the background area of a slider widget.
  557. //!
  558. //! \param pWidget is a pointer to the slider widget to be modified.
  559. //! \param pImg is a pointer to the image to draw onto the background area of
  560. //! the slider.
  561. //!
  562. //! This function changes the image that is drawn onto the background area of
  563. //! the slider. This image will be centered within the widget rectangle and
  564. //! the portion in the area not represented by the current slider value will
  565. //! be visible. The display is not updated until the next paint request.
  566. //!
  567. //! \return None.
  568. //
  569. //*****************************************************************************
  570. #define SliderBackgroundImageSet(pWidget, pImg) \
  571. do \
  572. { \
  573. tSliderWidget *pW = pWidget; \
  574. const unsigned char *pI = pImg; \
  575. pW->pucBackgroundImage = pI; \
  576. } \
  577. while(0)
  578. //*****************************************************************************
  579. //
  580. //! Disables the image on the active area of a slider widget.
  581. //!
  582. //! \param pWidget is a pointer to the slider widget to modify.
  583. //!
  584. //! This function disables the drawing of an image on the active area of a
  585. //! slider widget. The display is not updated until the next paint request.
  586. //!
  587. //! \return None.
  588. //
  589. //*****************************************************************************
  590. #define SliderImageOff(pWidget) \
  591. do \
  592. { \
  593. tSliderWidget *pW = pWidget; \
  594. pW->ulStyle &= ~(SL_STYLE_IMG); \
  595. } \
  596. while(0)
  597. //*****************************************************************************
  598. //
  599. //! Enables the image on the active area of a slider widget.
  600. //!
  601. //! \param pWidget is a pointer to the slider widget to modify.
  602. //!
  603. //! This function enables the drawing of an image on the active area of a
  604. //! slider widget. The display is not updated until the next paint request.
  605. //!
  606. //! \return None.
  607. //
  608. //*****************************************************************************
  609. #define SliderImageOn(pWidget) \
  610. do \
  611. { \
  612. tSliderWidget *pW = pWidget; \
  613. pW->ulStyle |= SL_STYLE_IMG; \
  614. } \
  615. while(0)
  616. //*****************************************************************************
  617. //
  618. //! Disables the image on the background area of a slider widget.
  619. //!
  620. //! \param pWidget is a pointer to the slider widget to modify.
  621. //!
  622. //! This function disables the drawing of an image on the background area of a
  623. //! slider widget. The display is not updated until the next paint request.
  624. //!
  625. //! \return None.
  626. //
  627. //*****************************************************************************
  628. #define SliderBackgroundImageOff(pWidget) \
  629. do \
  630. { \
  631. tSliderWidget *pW = pWidget; \
  632. pW->ulStyle &= ~(SL_STYLE_BACKG_IMG); \
  633. } \
  634. while(0)
  635. //*****************************************************************************
  636. //
  637. //! Enables the image on the background area of a slider widget.
  638. //!
  639. //! \param pWidget is a pointer to the slider widget to modify.
  640. //!
  641. //! This function enables the drawing of an image on the background area of a
  642. //! slider widget. The display is not updated until the next paint request.
  643. //!
  644. //! \return None.
  645. //
  646. //*****************************************************************************
  647. #define SliderBackgroundImageOn(pWidget) \
  648. do \
  649. { \
  650. tSliderWidget *pW = pWidget; \
  651. pW->ulStyle |= SL_STYLE_BACKG_IMG; \
  652. } \
  653. while(0)
  654. //*****************************************************************************
  655. //
  656. //! Sets the outline color of a slider widget.
  657. //!
  658. //! \param pWidget is a pointer to the slider widget to be modified.
  659. //! \param ulColor is the 24-bit RGB color to use to outline the slider.
  660. //!
  661. //! This function changes the color used to outline the slider on the
  662. //! display. The display is not updated until the next paint request.
  663. //!
  664. //! \return None.
  665. //
  666. //*****************************************************************************
  667. #define SliderOutlineColorSet(pWidget, ulColor) \
  668. do \
  669. { \
  670. tSliderWidget *pW = pWidget; \
  671. pW->ulOutlineColor = ulColor; \
  672. } \
  673. while(0)
  674. //*****************************************************************************
  675. //
  676. //! Disables outlining of a slider widget.
  677. //!
  678. //! \param pWidget is a pointer to the slider widget to modify.
  679. //!
  680. //! This function disables the outlining of a slider widget. The display
  681. //! is not updated until the next paint request.
  682. //!
  683. //! \return None.
  684. //
  685. //*****************************************************************************
  686. #define SliderOutlineOff(pWidget) \
  687. do \
  688. { \
  689. tSliderWidget *pW = pWidget; \
  690. pW->ulStyle &= ~(SL_STYLE_OUTLINE); \
  691. } \
  692. while(0)
  693. //*****************************************************************************
  694. //
  695. //! Enables outlining of a slider widget.
  696. //!
  697. //! \param pWidget is a pointer to the slider widget to modify.
  698. //!
  699. //! This function enables the outlining of a slider widget. The display
  700. //! is not updated until the next paint request.
  701. //!
  702. //! \return None.
  703. //
  704. //*****************************************************************************
  705. #define SliderOutlineOn(pWidget) \
  706. do \
  707. { \
  708. tSliderWidget *pW = pWidget; \
  709. pW->ulStyle |= SL_STYLE_OUTLINE; \
  710. } \
  711. while(0)
  712. //*****************************************************************************
  713. //
  714. //! Sets the text color of the active portion of a slider widget.
  715. //!
  716. //! \param pWidget is a pointer to the slider widget to be modified.
  717. //! \param ulColor is the 24-bit RGB color to use to draw text on the slider.
  718. //!
  719. //! This function changes the color used to draw text on the active portion of
  720. //! the slider on the display. The display is not updated until the next paint
  721. //! request.
  722. //!
  723. //! \return None.
  724. //
  725. //*****************************************************************************
  726. #define SliderTextColorSet(pWidget, ulColor) \
  727. do \
  728. { \
  729. tSliderWidget *pW = pWidget; \
  730. pW->ulTextColor = ulColor; \
  731. } \
  732. while(0)
  733. //*****************************************************************************
  734. //
  735. //! Sets the background text color of a slider widget.
  736. //!
  737. //! \param pWidget is a pointer to the slider widget to be modified.
  738. //! \param ulColor is the 24-bit RGB color to use to draw background text on
  739. //! the slider.
  740. //!
  741. //! This function changes the color used to draw text on the slider's
  742. //! background portion on the display. The display is not updated until the
  743. //! next paint request.
  744. //!
  745. //! \return None.
  746. //
  747. //*****************************************************************************
  748. #define SliderBackgroundTextColorSet(pWidget, ulColor) \
  749. do \
  750. { \
  751. tSliderWidget *pW = pWidget; \
  752. pW->ulBackgroundTextColor = ulColor; \
  753. } \
  754. while(0)
  755. //*****************************************************************************
  756. //
  757. //! Disables the text on the active portion of a slider widget.
  758. //!
  759. //! \param pWidget is a pointer to the slider widget to modify.
  760. //!
  761. //! This function disables the drawing of text on the active portion of a
  762. //! slider widget. The display is not updated until the next paint request.
  763. //!
  764. //! \return None.
  765. //
  766. //*****************************************************************************
  767. #define SliderTextOff(pWidget) \
  768. do \
  769. { \
  770. tSliderWidget *pW = pWidget; \
  771. pW->ulStyle &= ~(SL_STYLE_TEXT); \
  772. } \
  773. while(0)
  774. //*****************************************************************************
  775. //
  776. //! Enables the text on the active portion of a slider widget.
  777. //!
  778. //! \param pWidget is a pointer to the slider widget to modify.
  779. //!
  780. //! This function enables the drawing of text on the active portion of a slider
  781. //! widget. The display is not updated until the next paint request.
  782. //!
  783. //! \return None.
  784. //
  785. //*****************************************************************************
  786. #define SliderTextOn(pWidget) \
  787. do \
  788. { \
  789. tSliderWidget *pW = pWidget; \
  790. pW->ulStyle |= SL_STYLE_TEXT; \
  791. } \
  792. while(0)
  793. //*****************************************************************************
  794. //
  795. //! Disables opaque text on the active portion of a slider widget.
  796. //!
  797. //! \param pWidget is a pointer to the slider widget to modify.
  798. //!
  799. //! This function disables the use of opaque text on the active portion of this
  800. //! slider. When not using opaque text, only the foreground pixels of the text
  801. //! are drawn on the screen, allowing the previously drawn pixels (such as the
  802. //! slider image) to show through the text. Note that SL_STYLE_TEXT must also
  803. //! be cleared to disable text rendering on the slider active area.
  804. //!
  805. //! \return None.
  806. //
  807. //*****************************************************************************
  808. #define SliderTextOpaqueOff(pWidget) \
  809. do \
  810. { \
  811. tSliderWidget *pW = pWidget; \
  812. pW->ulStyle &= ~(SL_STYLE_TEXT_OPAQUE); \
  813. } \
  814. while(0)
  815. //*****************************************************************************
  816. //
  817. //! Enables opaque text on the active portion of a slider widget.
  818. //!
  819. //! \param pWidget is a pointer to the slider widget to modify.
  820. //!
  821. //! This function enables the use of opaque text on the active portion of this
  822. //! slider. When using opaque text, both the foreground and background pixels
  823. //! of the text are drawn on the screen, blocking out the previously drawn
  824. //! pixels. Note that SL_STYLE_TEXT must also be set to enable text
  825. //! rendering on the slider active area.
  826. //!
  827. //! \return None.
  828. //
  829. //*****************************************************************************
  830. #define SliderTextOpaqueOn(pWidget) \
  831. do \
  832. { \
  833. tSliderWidget *pW = pWidget; \
  834. pW->ulStyle |= SL_STYLE_TEXT_OPAQUE; \
  835. } \
  836. while(0)
  837. //*****************************************************************************
  838. //
  839. //! Disables the text on the background portion of a slider widget.
  840. //!
  841. //! \param pWidget is a pointer to the slider widget to modify.
  842. //!
  843. //! This function disables the drawing of text on the background portion of
  844. //! a slider widget. The display is not updated until the next paint request.
  845. //!
  846. //! \return None.
  847. //
  848. //*****************************************************************************
  849. #define SliderBackgroundTextOff(pWidget) \
  850. do \
  851. { \
  852. tSliderWidget *pW = pWidget; \
  853. pW->ulStyle &= ~(SL_STYLE_BACKG_TEXT); \
  854. } \
  855. while(0)
  856. //*****************************************************************************
  857. //
  858. //! Enables the text on the background portion of a slider widget.
  859. //!
  860. //! \param pWidget is a pointer to the slider widget to modify.
  861. //!
  862. //! This function enables the drawing of text on the background portion of a
  863. //! slider widget. The display is not updated until the next paint request.
  864. //!
  865. //! \return None.
  866. //
  867. //*****************************************************************************
  868. #define SliderBackgroundTextOn(pWidget) \
  869. do \
  870. { \
  871. tSliderWidget *pW = pWidget; \
  872. pW->ulStyle |= SL_STYLE_BACKG_TEXT; \
  873. } \
  874. while(0)
  875. //*****************************************************************************
  876. //
  877. //! Disables opaque background text on a slider widget.
  878. //!
  879. //! \param pWidget is a pointer to the slider widget to modify.
  880. //!
  881. //! This function disables the use of opaque text on the background portion of
  882. //! this slider. When not using opaque text, only the foreground pixels of the
  883. //! text are drawn on the screen, allowing the previously drawn pixels (such as
  884. //! the slider image) to show through the text. Note that SL_STYLE_BACKG_TEXT
  885. //! must also be cleared to disable text rendering on the slider background
  886. //! area.
  887. //!
  888. //! \return None.
  889. //
  890. //*****************************************************************************
  891. #define SliderBackgroundTextOpaqueOff(pWidget) \
  892. do \
  893. { \
  894. tSliderWidget *pW = pWidget; \
  895. pW->ulStyle &= ~(SL_STYLE_BACKG_TEXT_OPAQUE); \
  896. } \
  897. while(0)
  898. //*****************************************************************************
  899. //
  900. //! Enables opaque background text on a slider widget.
  901. //!
  902. //! \param pWidget is a pointer to the slider widget to modify.
  903. //!
  904. //! This function enables the use of opaque text on the background portion of
  905. //! this slider. When using opaque text, both the foreground and background
  906. //! pixels of the text are drawn on the screen, blocking out the previously
  907. //! drawn pixels. Note that SL_STYLE_BACKG_TEXT must also be set to enable
  908. //! text rendering on the slider background area.
  909. //!
  910. //! \return None.
  911. //
  912. //*****************************************************************************
  913. #define SliderBackgroundTextOpaqueOn(pWidget) \
  914. do \
  915. { \
  916. tSliderWidget *pW = pWidget; \
  917. pW->ulStyle |= SL_STYLE_BACKG_TEXT_OPAQUE; \
  918. } \
  919. while(0)
  920. //*****************************************************************************
  921. //
  922. //! Locks a slider making it ignore pointer input.
  923. //!
  924. //! \param pWidget is a pointer to the slider widget to modify.
  925. //!
  926. //! This function locks a slider widget and makes it ignore all pointer input.
  927. //! When locked, a slider acts as a passive indicator. Its value may be
  928. //! changed using SliderValueSet() and the value display updated using
  929. //! WidgetPaint() but no user interaction via the pointer will change the
  930. //! widget value.
  931. //!
  932. //! \return None.
  933. //
  934. //*****************************************************************************
  935. #define SliderLock(pWidget) \
  936. do \
  937. { \
  938. tSliderWidget *pW = pWidget; \
  939. pW->ulStyle |= SL_STYLE_LOCKED; \
  940. } \
  941. while(0)
  942. //*****************************************************************************
  943. //
  944. //! Unlocks a slider making it pay attention to pointer input.
  945. //!
  946. //! \param pWidget is a pointer to the slider widget to modify.
  947. //!
  948. //! This function unlocks a slider widget. When unlocked, a slider will
  949. //! respond to pointer input by setting its value appropriately and informing
  950. //! the application via callbacks.
  951. //!
  952. //! \return None.
  953. //
  954. //*****************************************************************************
  955. #define SliderUnlock(pWidget) \
  956. do \
  957. { \
  958. tSliderWidget *pW = pWidget; \
  959. pW->ulStyle &= ~(SL_STYLE_LOCKED); \
  960. } \
  961. while(0)
  962. //*****************************************************************************
  963. //
  964. //! Changes the text drawn on a slider widget.
  965. //!
  966. //! \param pWidget is a pointer to the slider widget to be modified.
  967. //! \param pcTxt is a pointer to the text to draw onto the slider.
  968. //!
  969. //! This function changes the text that is drawn onto the slider. The string
  970. //! is centered across the slider and straddles the active and background
  971. //! portions of the widget. The display is not updated until the next paint
  972. //! request.
  973. //!
  974. //! \return None.
  975. //
  976. //*****************************************************************************
  977. #define SliderTextSet(pWidget, pcTxt) \
  978. do \
  979. { \
  980. tSliderWidget *pW = pWidget; \
  981. const char *pcT = pcTxt; \
  982. pW->pcText = pcT; \
  983. } \
  984. while(0)
  985. //*****************************************************************************
  986. //
  987. //! Changes the value range for a slider widget.
  988. //!
  989. //! \param pWidget is a pointer to the slider widget to be modified.
  990. //! \param lMinimum is the minimum value that the slider will report.
  991. //! \param lMaximum is the maximum value that the slider will report.
  992. //!
  993. //! This function changes the range of a slider. Slider positions are reported
  994. //! in terms of this range with the current position of the slider on the
  995. //! display being scaled and translated into this range such that the minimum
  996. //! value represents the left position of a horizontal slider or the bottom
  997. //! position of a vertical slider and the maximum value represents the other
  998. //! end of the slider range. Note that this function does not cause the slider
  999. //! to be redrawn. The caller must call WidgetPaint() explicitly after this
  1000. //! call to ensure that the widget is redrawn.
  1001. //!
  1002. //! \return None.
  1003. //
  1004. //*****************************************************************************
  1005. #define SliderRangeSet(pWidget, lMinimum, lMaximum) \
  1006. do \
  1007. { \
  1008. tSliderWidget *pW = pWidget; \
  1009. pW->lMin = (lMinimum); \
  1010. pW->lMax = (lMaximum); \
  1011. } \
  1012. while(0)
  1013. //*****************************************************************************
  1014. //
  1015. //! Changes the minimum value for a slider widget.
  1016. //!
  1017. //! \param pWidget is a pointer to the slider widget to be modified.
  1018. //! \param lVal is the new value to set for the slider. This is in terms of
  1019. //! the value range currently set for the slider.
  1020. //!
  1021. //! This function changes the value that the slider will display the next time
  1022. //! the widget is painted. The caller is responsible for ensuring that the
  1023. //! value passed is within the range specified for the target widget. The
  1024. //! caller must call WidgetPaint() explicitly after this call to ensure that
  1025. //! the widget is redrawn.
  1026. //!
  1027. //! \return None.
  1028. //
  1029. //*****************************************************************************
  1030. #define SliderValueSet(pWidget, lVal) \
  1031. do \
  1032. { \
  1033. tSliderWidget *pW = pWidget; \
  1034. pW->lValue = (lVal); \
  1035. } \
  1036. while(0)
  1037. //*****************************************************************************
  1038. //
  1039. // Prototypes for the slider widget APIs.
  1040. //
  1041. //*****************************************************************************
  1042. extern int SliderMsgProc(tWidget *pWidget, unsigned int ulMsg,
  1043. unsigned int ulParam1, unsigned int ulParam2);
  1044. extern void SliderInit(tSliderWidget *pWidget,
  1045. const tDisplay *pDisplay, int lX, int lY, int lWidth,
  1046. int lHeight);
  1047. //*****************************************************************************
  1048. //
  1049. // Mark the end of the C bindings section for C++ compilers.
  1050. //
  1051. //*****************************************************************************
  1052. #ifdef __cplusplus
  1053. }
  1054. #endif
  1055. //*****************************************************************************
  1056. //
  1057. // Close the Doxygen group.
  1058. //! @}
  1059. //
  1060. //*****************************************************************************
  1061. #endif // __SLIDER_H__