imgbutton.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. //*****************************************************************************
  2. //
  3. // imgbutton.h - Prototypes for the image button 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 __IMGBUTTON_H__
  25. #define __IMGBUTTON_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup imgbutton_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 image button 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. //! IB_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The color to use for foreground pixels when a 1bpp image or text is in
  60. //! use. This value is ignored for all other image bit depths.
  61. //
  62. unsigned int ulForegroundColor;
  63. //
  64. //! The color to use for background pixels when the button is pressed
  65. //! and a 1bpp image is in use. This value is ignored for all other image
  66. //! bit depths. If IB_STYLE_FILL is specified, this is also the color that
  67. //! will be used to fill the widget when it is in the pressed state.
  68. //
  69. unsigned int ulPressedColor;
  70. //
  71. //! The color to use for background pixels when the button is released
  72. //! and a 1bpp image is in use. This value is ignored for all other image
  73. //! bit depths. If IB_STYLE_FILL is specified, this is also the color that
  74. //! will be used to fill the widget when it is in the unpressed state.
  75. //
  76. unsigned int ulBackgroundColor;
  77. //
  78. //! A pointer to the font used to render the button text, if
  79. //! IB_STYLE_TEXT is selected.
  80. //
  81. const tFont *pFont;
  82. //
  83. //! A pointer to the text to draw on this push button, if IB_STYLE_TEXT is
  84. //! selected.
  85. //
  86. const char *pcText;
  87. //
  88. //! A pointer to the image to be drawn onto this image button, if
  89. //! IB_STYLE_IMG is selected.
  90. //
  91. const unsigned char *pucImage;
  92. //
  93. //! A pointer to the image to be drawn onto this image button when it is
  94. //! pressed.
  95. //
  96. const unsigned char *pucPressImage;
  97. //
  98. //! A pointer to the image to be drawn above the background image for
  99. //! the button.
  100. //
  101. const unsigned char *pucKeycapImage;
  102. //! The number of pixels to move the keycap image horizontally when the
  103. //! button is drawn in its pressed state.
  104. //
  105. short sXOffset;
  106. //
  107. //! The number of pixels to move the keycap image vertically when the
  108. //! button is drawn in its pressed state.
  109. //
  110. short sYOffset;
  111. //
  112. //! The number of pointer events to delay before starting to auto-repeat,
  113. //! if IB_STYLE_AUTO_REPEAT is selected. The amount of time to which this
  114. //! corresponds is dependent upon the rate at which pointer events are
  115. //! generated by the pointer driver.
  116. //
  117. unsigned short usAutoRepeatDelay;
  118. //
  119. //! The number of pointer events between button presses generated by the
  120. //! auto-repeat function, if IB_STYLE_AUTO_REPEAT is selected. The amount
  121. //! of time to which this corresponds is dependent up on the rate at which
  122. //! pointer events are generated by the pointer driver.
  123. //
  124. unsigned short usAutoRepeatRate;
  125. //
  126. //! The number of pointer events that have occurred. This is used when
  127. //! IB_STYLE_AUTO_REPEAT is selected to generate the auto-repeat events.
  128. //
  129. unsigned int ulAutoRepeatCount;
  130. //
  131. //! A pointer to the function to be called when the button is pressed.
  132. //! This is repeatedly called when IB_STYLE_AUTO_REPEAT is selected.
  133. //
  134. void (*pfnOnClick)(tWidget *pWidget);
  135. }
  136. tImageButtonWidget;
  137. //*****************************************************************************
  138. //
  139. //! This flag indicates that the image button should be filled.
  140. //
  141. //*****************************************************************************
  142. #define IB_STYLE_FILL 0x00000002
  143. //*****************************************************************************
  144. //
  145. //! This flag indicates that the image button should have text drawn on it.
  146. //
  147. //*****************************************************************************
  148. #define IB_STYLE_TEXT 0x00000004
  149. //*****************************************************************************
  150. //
  151. //! This flag indicates that the background image is to be disabled.
  152. //
  153. //*****************************************************************************
  154. #define IB_STYLE_IMAGE_OFF 0x00000008
  155. //*****************************************************************************
  156. //
  157. //! This flag indicates that the keycap image is to be disabled.
  158. //
  159. //*****************************************************************************
  160. #define IB_STYLE_KEYCAP_OFF 0x00000010
  161. //*****************************************************************************
  162. //
  163. //! This flag indicates that the image button should auto-repeat, generating
  164. //! repeated click events while it is pressed.
  165. //
  166. //*****************************************************************************
  167. #define IB_STYLE_AUTO_REPEAT 0x00000020
  168. //*****************************************************************************
  169. //
  170. //! This flag indicates that the image button is pressed.
  171. //
  172. //*****************************************************************************
  173. #define IB_STYLE_PRESSED 0x00000040
  174. //*****************************************************************************
  175. //
  176. //! This flag indicates that the image button callback should be made when
  177. //! the button is released rather than when it is pressed. This does not
  178. //! affect the operation of auto repeat buttons.
  179. //
  180. //*****************************************************************************
  181. #define IB_STYLE_RELEASE_NOTIFY 0x00000080
  182. //*****************************************************************************
  183. //
  184. //! Declares an initialized image button widget data structure.
  185. //!
  186. //! \param pParent is a pointer to the parent widget.
  187. //! \param pNext is a pointer to the sibling widget.
  188. //! \param pChild is a pointer to the first child widget.
  189. //! \param pDisplay is a pointer to the display on which to draw the push
  190. //! button.
  191. //! \param lX is the X coordinate of the upper left corner of the image button.
  192. //! \param lY is the Y coordinate of the upper left corner of the image button.
  193. //! \param lWidth is the width of the image button.
  194. //! \param lHeight is the height of the image button.
  195. //! \param ulStyle is the style to be applied to the image button.
  196. //! \param ulForeColor is the color to be used for foreground pixels when
  197. //! a 1bpp image or text is being drawn. It is ignored for all other image bit
  198. //! depths.
  199. //! \param ulPressColor is the color to be used for foreground pixels when
  200. //! the button is pressed and a 1bpp image is being drawn. It is ignored for
  201. //! all other image bit depths.
  202. //! \param ulBackColor is the color to be used for background pixels when
  203. //! the button is released and a 1bpp image is being drawn. It is ignored for
  204. //! all other image bit depths.
  205. //! \param pFont is a pointer to the font to be used to draw text on the button.
  206. //! \param pcText is a pointer to the text to draw on this button.
  207. //! \param pucImage is a pointer to the image to draw on the background of
  208. //! this image button when it is in the released state.
  209. //! \param pucPressImage is a pointer to the image to draw on the background of
  210. //! this image button when it is in the pressed state.
  211. //! \param pucKeycapImage is a pointer to the image to draw as the keycap of the
  212. //! on top of the image button, on top of the background image.
  213. //! \param sXOff is the horizontal offset to apply when drawing the keycap image
  214. //! on the button when in the pressed state.
  215. //! \param sYOff is the vertical offset to apply when drawing the keycap image
  216. //! on the button when in the pressed state.
  217. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  218. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  219. //! generated.
  220. //! \param pfnOnClick is a pointer to the function that is called when the push
  221. //! button is pressed.
  222. //!
  223. //! This macro provides an initialized image button widget data structure,
  224. //! which can be used to construct the widget tree at compile time in global
  225. //! variables (as opposed to run-time via function calls). This must be
  226. //! assigned to a variable, such as:
  227. //!
  228. //! \verbatim
  229. //! tImageButtonWidget g_sImageButton = ImageButtonStruct(...);
  230. //! \endverbatim
  231. //!
  232. //! Or, in an array of variables:
  233. //!
  234. //! \verbatim
  235. //! tImageButtonWidget g_psImageButtons[] =
  236. //! {
  237. //! ImageButtonStruct(...),
  238. //! ImageButtonStruct(...)
  239. //! };
  240. //! \endverbatim
  241. //!
  242. //! \e ulStyle is the logical OR of the following:
  243. //!
  244. //! - \b #IB_STYLE_TEXT to indicate that text should be drawn on the button.
  245. //! - \b #IB_STYLE_FILL to indicate that the background of the button should
  246. //! be filled with color.
  247. //! - \b #IB_STYLE_KEYCAP_OFF to indicate that the keycap image should not be
  248. //! drawn.
  249. //! - \b #IB_STYLE_IMAGE_OFF to indicate that the background image should not be
  250. //! drawn.
  251. //! - \b #IB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  252. //! - \b #IB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  253. //! when the button is released. If absent, the callback is called when the
  254. //! button is initially pressed.
  255. //!
  256. //! \return Nothing; this is not a function.
  257. //
  258. //*****************************************************************************
  259. #define ImageButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  260. lWidth, lHeight, ulStyle, ulForeColor, \
  261. ulPressColor, ulBackColor, pFont, pcText, pucImage,\
  262. pucPressImage, pucKeycapImage, sXOff, sYOff, \
  263. usAutoRepeatDelay, usAutoRepeatRate, pfnOnClick) \
  264. { \
  265. { \
  266. sizeof(tImageButtonWidget), \
  267. (tWidget *)(pParent), \
  268. (tWidget *)(pNext), \
  269. (tWidget *)(pChild), \
  270. pDisplay, \
  271. { \
  272. lX, \
  273. lY, \
  274. (lX) + (lWidth) - 1, \
  275. (lY) + (lHeight) - 1 \
  276. }, \
  277. ImageButtonMsgProc \
  278. }, \
  279. ulStyle, \
  280. ulForeColor, \
  281. ulPressColor, \
  282. ulBackColor, \
  283. pFont, \
  284. pcText, \
  285. pucImage, \
  286. pucPressImage, \
  287. pucKeycapImage, \
  288. sXOff, \
  289. sYOff, \
  290. usAutoRepeatDelay, \
  291. usAutoRepeatRate, \
  292. 0, \
  293. pfnOnClick \
  294. }
  295. //*****************************************************************************
  296. //
  297. //! Declares an initialized variable containing a image button widget data
  298. //! structure.
  299. //!
  300. //! \param sName is the name of the variable to be declared.
  301. //! \param pParent is a pointer to the parent widget.
  302. //! \param pNext is a pointer to the sibling widget.
  303. //! \param pChild is a pointer to the first child widget.
  304. //! \param pDisplay is a pointer to the display on which to draw the push
  305. //! button.
  306. //! \param lX is the X coordinate of the upper left corner of the image button.
  307. //! \param lY is the Y coordinate of the upper left corner of the image button.
  308. //! \param lWidth is the width of the image button.
  309. //! \param lHeight is the height of the image button.
  310. //! \param ulStyle is the style to be applied to the image button.
  311. //! \param ulForeColor is the color to be used for foreground pixels when
  312. //! a 1bpp image is being drawn. It is ignored for all other image bit depths.
  313. //! \param ulPressColor is the color to be used for foreground pixels when
  314. //! the button is pressed and a 1bpp image is being drawn. It is ignored for
  315. //! all other image bit depths.
  316. //! \param ulBackColor is the color to be used for background pixels when
  317. //! the button is released and a 1bpp image is being drawn. It is ignored for
  318. //! all other image bit depths.
  319. //! \param pFont is a pointer to the font to be used to draw text on the button.
  320. //! \param pcText is a pointer to the text to draw on this button.
  321. //! \param pucImage is a pointer to the image to draw on the background of
  322. //! this image button when it is in the released state.
  323. //! \param pucPressImage is a pointer to the image to draw on the background of
  324. //! this image button when it is in the pressed state.
  325. //! \param pucKeycapImage is a pointer to the image to draw as the keycap of the
  326. //! on top of the image button, on top of the background image.
  327. //! \param sXOff is the horizontal offset to apply when drawing the keycap image
  328. //! on the button when in the pressed state.
  329. //! \param sYOff is the vertical offset to apply when drawing the keycap image
  330. //! on the button when in the pressed state.
  331. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  332. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  333. //! generated.
  334. //! \param pfnOnClick is a pointer to the function that is called when the push
  335. //! button is pressed.
  336. //!
  337. //! This macro provides an initialized image button widget data structure,
  338. //! which can be used to construct the widget tree at compile time in global
  339. //! variables (as opposed to run-time via function calls).
  340. //!
  341. //! \e ulStyle is the logical OR of the following:
  342. //!
  343. //! - \b #IB_STYLE_TEXT to indicate that text should be drawn on the button.
  344. //! - \b #IB_STYLE_FILL to indicate that the background of the button should
  345. //! be filled with color.
  346. //! - \b #IB_STYLE_KEYCAP_OFF to indicate that the keycap image should not be
  347. //! drawn.
  348. //! - \b #IB_STYLE_IMAGE_OFF to indicate that the background image should not be
  349. //! drawn.
  350. //! - \b #IB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  351. //! - \b #IB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  352. //! when the button is released. If absent, the callback is called when the
  353. //! button is initially pressed.
  354. //!
  355. //! \return Nothing; this is not a function.
  356. //
  357. //*****************************************************************************
  358. #define ImageButton(sName, pParent, pNext, pChild, pDisplay, lX, lY, \
  359. lWidth, lHeight, ulStyle, ulForeColor, ulPressColor, \
  360. ulBackColor, pFont, pcText, pucImage, pucPressImage, \
  361. pucKeycapImage, sXOff, sYOff, usAutoRepeatDelay, \
  362. usAutoRepeatRate, pfnOnClick) \
  363. tImageButtonWidget sName = \
  364. ImageButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  365. lWidth, lHeight, ulStyle, ulForeColor, \
  366. ulPressColor, ulBackColor, pFont, pcText, \
  367. pucImage, pucPressImage, pucKeycapImage, \
  368. sXOff, sYOff, usAutoRepeatDelay, \
  369. usAutoRepeatRate, pfnOnClick)
  370. //*****************************************************************************
  371. //
  372. //! Sets the auto-repeat delay for a image button widget.
  373. //!
  374. //! \param pWidget is a pointer to the image button widget to modify.
  375. //! \param usDelay is the number of pointer events before auto-repeat starts.
  376. //!
  377. //! This function sets the delay before auto-repeat begins. Unpredictable
  378. //! behavior will occur if this is called while the image button is pressed.
  379. //!
  380. //! \return None.
  381. //
  382. //*****************************************************************************
  383. #define ImageButtonAutoRepeatDelaySet(pWidget, usDelay) \
  384. do \
  385. { \
  386. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  387. pW->usAutoRepeatDelay = usDelay; \
  388. } \
  389. while(0)
  390. //*****************************************************************************
  391. //
  392. //! Disables auto-repeat for a image button widget.
  393. //!
  394. //! \param pWidget is a pointer to the image button widget to modify.
  395. //!
  396. //! This function disables the auto-repeat behavior of a image button.
  397. //!
  398. //! \return None.
  399. //
  400. //*****************************************************************************
  401. #define ImageButtonAutoRepeatOff(pWidget) \
  402. do \
  403. { \
  404. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  405. pW->ulStyle &= ~(IB_STYLE_AUTO_REPEAT); \
  406. } \
  407. while(0)
  408. //*****************************************************************************
  409. //
  410. //! Enables auto-repeat for a image button widget.
  411. //!
  412. //! \param pWidget is a pointer to the image button widget to modify.
  413. //!
  414. //! This function enables the auto-repeat behavior of a image button.
  415. //! Unpredictable behavior will occur if this is called while the image button
  416. //! is pressed.
  417. //!
  418. //! \return None.
  419. //
  420. //*****************************************************************************
  421. #define ImageButtonAutoRepeatOn(pWidget) \
  422. do \
  423. { \
  424. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  425. pW->ulStyle |= IB_STYLE_AUTO_REPEAT; \
  426. } \
  427. while(0)
  428. //*****************************************************************************
  429. //
  430. //! Sets the auto-repeat rate for a image button widget.
  431. //!
  432. //! \param pWidget is a pointer to the image button widget to modify.
  433. //! \param usRate is the number of pointer events between auto-repeat events.
  434. //!
  435. //! This function sets the rate at which auto-repeat events occur.
  436. //! Unpredictable behavior will occur if this is called while the image button
  437. //! is pressed.
  438. //!
  439. //! \return None.
  440. //
  441. //*****************************************************************************
  442. #define ImageButtonAutoRepeatRateSet(pWidget, usRate) \
  443. do \
  444. { \
  445. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  446. pW->usAutoRepeatRate = usRate; \
  447. } \
  448. while(0)
  449. //*****************************************************************************
  450. //
  451. //! Sets the function to call when this image button widget is pressed.
  452. //!
  453. //! \param pWidget is a pointer to the image button widget to modify.
  454. //! \param pfnOnClik is a pointer to the function to call.
  455. //!
  456. //! This function sets the function to be called when this image button is
  457. //! pressed. The supplied function is called when the image button is first
  458. //! pressed, and then repeated while the image button is pressed if auto-repeat
  459. //! is enabled.
  460. //!
  461. //! \return None.
  462. //
  463. //*****************************************************************************
  464. #define ImageButtonCallbackSet(pWidget, pfnOnClik) \
  465. do \
  466. { \
  467. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  468. pW->pfnOnClick = pfnOnClik; \
  469. } \
  470. while(0)
  471. //*****************************************************************************
  472. //
  473. //! Sets the fill color of a image button widget.
  474. //!
  475. //! \param pWidget is a pointer to the image button widget to be modified.
  476. //! \param ulColor is the 24-bit RGB color to use to fill the image button.
  477. //!
  478. //! This function changes the color used to fill the background of the image
  479. //! button on the display. This is a duplicate of ImageButtonBackgroundColorSet
  480. //! which is left for backwards compatibility. The display is not updated
  481. //! until the next paint request.
  482. //!
  483. //! \return None.
  484. //
  485. //*****************************************************************************
  486. #define ImageButtonFillColorSet(pWidget, ulColor) \
  487. do \
  488. { \
  489. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  490. pW->ulBackgroundColor = ulColor; \
  491. } \
  492. while(0)
  493. //*****************************************************************************
  494. //
  495. //! Disables filling of a image button widget.
  496. //!
  497. //! \param pWidget is a pointer to the image button widget to modify.
  498. //!
  499. //! This function disables the filling of a image button widget. The display is
  500. //! not updated until the next paint request.
  501. //!
  502. //! \return None.
  503. //
  504. //*****************************************************************************
  505. #define ImageButtonFillOff(pWidget) \
  506. do \
  507. { \
  508. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  509. pW->ulStyle &= ~(IB_STYLE_FILL); \
  510. } \
  511. while(0)
  512. //*****************************************************************************
  513. //
  514. //! Enables filling of a image button widget.
  515. //!
  516. //! \param pWidget is a pointer to the image button widget to modify.
  517. //!
  518. //! This function enables the filling of a image button widget. The display is
  519. //! not updated until the next paint request.
  520. //!
  521. //! \return None.
  522. //
  523. //*****************************************************************************
  524. #define ImageButtonFillOn(pWidget) \
  525. do \
  526. { \
  527. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  528. pW->ulStyle |= IB_STYLE_FILL; \
  529. } \
  530. while(0)
  531. //*****************************************************************************
  532. //
  533. //! Enables the background image for an image button widget.
  534. //!
  535. //! \param pWidget is a pointer to the image button widget to modify.
  536. //!
  537. //! This function enables the drawing of the background image on an image button
  538. //! widget. The display is not updated until the next paint request.
  539. //!
  540. //! \return None.
  541. //
  542. //*****************************************************************************
  543. #define ImageButtonImageOn(pWidget) \
  544. do \
  545. { \
  546. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  547. pW->ulStyle &= ~(IB_STYLE_IMAGE_OFF); \
  548. } \
  549. while(0)
  550. //*****************************************************************************
  551. //
  552. //! Disables the background image for an image button widget.
  553. //!
  554. //! \param pWidget is a pointer to the image button widget to modify.
  555. //!
  556. //! This function disables the drawing of the background image on an image
  557. //! button widget. The display is not updated until the next paint request.
  558. //!
  559. //! \return None.
  560. //
  561. //*****************************************************************************
  562. #define ImageButtonImageOff(pWidget) \
  563. do \
  564. { \
  565. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  566. pW->ulStyle |= IB_STYLE_IMAGE_OFF; \
  567. } \
  568. while(0)
  569. //*****************************************************************************
  570. //
  571. //! Enables the keycap image for an image button widget.
  572. //!
  573. //! \param pWidget is a pointer to the image button widget to modify.
  574. //!
  575. //! This function enables the drawing of the keycap image on an image button
  576. //! widget. The display is not updated until the next paint request.
  577. //!
  578. //! \return None.
  579. //
  580. //*****************************************************************************
  581. #define ImageButtonKeycapOn(pWidget) \
  582. do \
  583. { \
  584. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  585. pW->ulStyle &= ~(IB_STYLE_KEYCAP_OFF); \
  586. } \
  587. while(0)
  588. //*****************************************************************************
  589. //
  590. //! Disables the keycap image for an image button widget.
  591. //!
  592. //! \param pWidget is a pointer to the image button widget to modify.
  593. //!
  594. //! This function disables the drawing of the keycap image on an image button
  595. //! widget. The display is not updated until the next paint request.
  596. //!
  597. //! \return None.
  598. //
  599. //*****************************************************************************
  600. #define ImageButtonKeycapOff(pWidget) \
  601. do \
  602. { \
  603. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  604. pW->ulStyle |= IB_STYLE_KEYCAP_OFF; \
  605. } \
  606. while(0)
  607. //*****************************************************************************
  608. //
  609. //! Changes the image drawn on a image button widget.
  610. //!
  611. //! \param pWidget is a pointer to the image button widget to be modified.
  612. //! \param pImg is a pointer to the image to draw onto the image button.
  613. //!
  614. //! This function changes the image that is drawn onto the background of the
  615. //! image button in its unpressed state. The display is not updated until the
  616. //! next paint request.
  617. //!
  618. //! \return None.
  619. //
  620. //*****************************************************************************
  621. #define ImageButtonImageSet(pWidget, pImg) \
  622. do \
  623. { \
  624. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  625. const unsigned char *pI = pImg; \
  626. pW->pucImage = pI; \
  627. } \
  628. while(0)
  629. //*****************************************************************************
  630. //
  631. //! Changes the image drawn on a image button widget when it is pressed.
  632. //!
  633. //! \param pWidget is a pointer to the image button widget to be modified.
  634. //! \param pImg is a pointer to the image to draw onto the image button when it
  635. //! is pressed.
  636. //!
  637. //! This function changes the image that is drawn onto the background of the
  638. //! image button in its pressed state. The display is not updated until the
  639. //! next paint request.
  640. //!
  641. //! \return None.
  642. //
  643. //*****************************************************************************
  644. #define ImageButtonImagePressedSet(pWidget, pImg) \
  645. do \
  646. { \
  647. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  648. const unsigned char *pI = pImg; \
  649. pW->pucPressImage = pI; \
  650. } \
  651. while(0)
  652. //*****************************************************************************
  653. //
  654. //! Changes the keycap image drawn on a image button widget.
  655. //!
  656. //! \param pWidget is a pointer to the image button widget to be modified.
  657. //! \param pImg is a pointer to the image to draw onto the image button.
  658. //!
  659. //! This function changes the image that is drawn onto the top of the push
  660. //! button. The display is not updated until the next paint request.
  661. //!
  662. //! \return None.
  663. //
  664. //*****************************************************************************
  665. #define ImageButtonImageKeycapSet(pWidget, pImg) \
  666. do \
  667. { \
  668. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  669. const unsigned char *pI = (pImg); \
  670. pW->pucKeycapImage = pI; \
  671. } \
  672. while(0)
  673. //*****************************************************************************
  674. //
  675. //! Changes the keycap image offset position on an image button widget.
  676. //!
  677. //! \param pWidget is a pointer to the image button widget to be modified.
  678. //! \param sX is the signed horizontal position offset for the keycap image
  679. //! when the image button is pressed. Positive values move the image right.
  680. //! \param sY is the signed vertical position offset for the keycap image
  681. //! when the image button is pressed. Positive values move the image down.
  682. //!
  683. //! This function changes the position that the keycap image is drawn at when
  684. //! the image button is pressed. The keycap image is moved iX pixels right and
  685. //! iY pixels down from the center position if the image button is pressed.
  686. //! This feature can be used to support 3D buttons. The display is not
  687. //! updated until the next paint request.
  688. //!
  689. //! \return None.
  690. //
  691. //*****************************************************************************
  692. #define ImageButtonKeycapOffsetSet(pWidget, sX, sY) \
  693. do \
  694. { \
  695. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  696. pW->sXOffset = (short)(sX); \
  697. pW->sYOffset = (short)(sY); \
  698. } \
  699. while(0)
  700. //*****************************************************************************
  701. //
  702. //! Sets the color of background pixels when using 1bpp images.
  703. //!
  704. //! \param pWidget is a pointer to the image button widget to be modified.
  705. //! \param ulColor is the background color to use.
  706. //!
  707. //! This function changes the color that is used to draw background pixels when
  708. //! a 1bpp image is rendered on the button and the button is in the released
  709. //! state. The value is ignored for all other image bit depths. The display
  710. //! is not updated until the next paint request.
  711. //!
  712. //! \return None.
  713. //
  714. //*****************************************************************************
  715. #define ImageButtonBackgroundColorSet(pWidget, ulColor) \
  716. do \
  717. { \
  718. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  719. pW->ulBackgroundColor = (ulColor); \
  720. } \
  721. while(0)
  722. //*****************************************************************************
  723. //
  724. //! Sets the color of foreground pixels when using 1bpp images.
  725. //!
  726. //! \param pWidget is a pointer to the image button widget to be modified.
  727. //! \param ulColor is the foreground color to use.
  728. //!
  729. //! This function changes the color that is used to draw foreground pixels when
  730. //! a 1bpp image or text string is rendered on the button. The value is
  731. //! ignored for all other image bit depths. The display is not updated until
  732. //! the next paint request.
  733. //!
  734. //! \return None.
  735. //
  736. //*****************************************************************************
  737. #define ImageButtonForegroundColorSet(pWidget, ulColor) \
  738. do \
  739. { \
  740. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  741. pW->ulForegroundColor = (ulColor); \
  742. } \
  743. while(0)
  744. //*****************************************************************************
  745. //
  746. //! Sets the color of foreground pixels when the button is pressed and when
  747. //! using 1bpp images.
  748. //!
  749. //! \param pWidget is a pointer to the image button widget to be modified.
  750. //! \param ulColor is the pressed foreground color to use.
  751. //!
  752. //! This function changes the color that is used to draw foreground pixels when
  753. //! a 1bpp image is rendered on the button and the button is in the pressed
  754. //! state. The value is ignored for all other image bit depths. The display
  755. //! is not updated until the next paint request.
  756. //!
  757. //! \return None.
  758. //
  759. //*****************************************************************************
  760. #define ImageButtonPressedColorSet(pWidget, ulColor) \
  761. do \
  762. { \
  763. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  764. pW->ulPressedColor = (ulColor); \
  765. } \
  766. while(0)
  767. //*****************************************************************************
  768. //
  769. //! Changes the text drawn on a image button widget.
  770. //!
  771. //! \param pWidget is a pointer to the image button widget to be modified.
  772. //! \param pcTxt is a pointer to the text to draw onto the image button.
  773. //!
  774. //! This function changes the text that is drawn onto the image button. The
  775. //! display is not updated until the next paint request.
  776. //!
  777. //! \return None.
  778. //
  779. //*****************************************************************************
  780. #define ImageButtonTextSet(pWidget, pcTxt) \
  781. do \
  782. { \
  783. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  784. const char *pcT = pcTxt; \
  785. pW->pcText = pcT; \
  786. } \
  787. while(0)
  788. //*****************************************************************************
  789. //
  790. //! Disables the text on a image button widget.
  791. //!
  792. //! \param pWidget is a pointer to the image button widget to modify.
  793. //!
  794. //! This function disables the drawing of text on a image button widget. The
  795. //! display is not updated until the next paint request.
  796. //!
  797. //! \return None.
  798. //
  799. //*****************************************************************************
  800. #define ImageButtonTextOff(pWidget) \
  801. do \
  802. { \
  803. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  804. pW->ulStyle &= ~(IB_STYLE_TEXT); \
  805. } \
  806. while(0)
  807. //*****************************************************************************
  808. //
  809. //! Enables the text on a image button widget.
  810. //!
  811. //! \param pWidget is a pointer to the image button widget to modify.
  812. //!
  813. //! This function enables the drawing of text on a image button widget. The
  814. //! display is not updated until the next paint request.
  815. //!
  816. //! \return None.
  817. //
  818. //*****************************************************************************
  819. #define ImageButtonTextOn(pWidget) \
  820. do \
  821. { \
  822. tImageButtonWidget *pW = (tImageButtonWidget *)(pWidget); \
  823. pW->ulStyle |= IB_STYLE_TEXT; \
  824. } \
  825. while(0)
  826. //*****************************************************************************
  827. //
  828. // Prototypes for the image button widget APIs.
  829. //
  830. //*****************************************************************************
  831. extern int ImageButtonMsgProc(tWidget *pWidget, unsigned int ulMsg,
  832. unsigned int ulParam1,
  833. unsigned int ulParam2);
  834. extern void ImageButtonInit(tImageButtonWidget *pWidget,
  835. const tDisplay *pDisplay, int lX, int lY,
  836. int lWidth, int lHeight);
  837. //*****************************************************************************
  838. //
  839. // Mark the end of the C bindings section for C++ compilers.
  840. //
  841. //*****************************************************************************
  842. #ifdef __cplusplus
  843. }
  844. #endif
  845. //*****************************************************************************
  846. //
  847. // Close the Doxygen group.
  848. //! @}
  849. //
  850. //*****************************************************************************
  851. #endif // __IMGBUTTON_H__