pushbutton.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  1. //*****************************************************************************
  2. //
  3. // pushbutton.h - Prototypes for the push buttons.
  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 __PUSHBUTTON_H__
  25. #define __PUSHBUTTON_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup pushbutton_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 push 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. //! PB_STYLE_xxx.
  56. //
  57. unsigned int ulStyle;
  58. //
  59. //! The 24-bit RGB color used to fill this push button, if PB_STYLE_FILL is
  60. //! selected, and to use as the background color if PB_STYLE_TEXT_OPAQUE is
  61. //! selected.
  62. //
  63. unsigned int ulFillColor;
  64. //
  65. //! The 24-bit RGB color used to fill this push button when it is pressed,
  66. //! if PB_STYLE_FILL is selected, and to use as the background color if
  67. //! PB_STYLE_TEXT_OPAQUE is selected.
  68. //
  69. unsigned int ulPressFillColor;
  70. //
  71. //! The 24-bit RGB color used to outline this push button, if
  72. //! PB_STYLE_OUTLINE is selected.
  73. //
  74. unsigned int ulOutlineColor;
  75. //
  76. //! The 24-bit RGB color used to draw text on this push button, if
  77. //! PB_STYLE_TEXT is selected.
  78. //
  79. unsigned int ulTextColor;
  80. //
  81. //! A pointer to the font used to render the push button text, if
  82. //! PB_STYLE_TEXT is selected.
  83. //
  84. const tFont *pFont;
  85. //
  86. //! A pointer to the text to draw on this push button, if PB_STYLE_TEXT is
  87. //! selected.
  88. //
  89. const char *pcText;
  90. //
  91. //! A pointer to the image to be drawn onto this push button, if
  92. //! PB_STYLE_IMG is selected.
  93. //
  94. const unsigned char *pucImage;
  95. //
  96. //! A pointer to the image to be drawn onto this push button when it is
  97. //! pressed, if PB_STYLE_IMG is selected.
  98. //
  99. const unsigned char *pucPressImage;
  100. //
  101. //! The number of pointer events to delay before starting to auto-repeat,
  102. //! if PB_STYLE_AUTO_REPEAT is selected. The amount of time to which this
  103. //! corresponds is dependent upon the rate at which pointer events are
  104. //! generated by the pointer driver.
  105. //
  106. unsigned short usAutoRepeatDelay;
  107. //
  108. //! The number of pointer events between button presses generated by the
  109. //! auto-repeat function, if PB_STYLE_AUTO_REPEAT is selected. The amount
  110. //! of time to which this corresponds is dependent up on the rate at which
  111. //! pointer events are generated by the pointer driver.
  112. //
  113. unsigned short usAutoRepeatRate;
  114. //
  115. //! The number of pointer events that have occurred. This is used when
  116. //! PB_STYLE_AUTO_REPEAT is selected to generate the auto-repeat events.
  117. //
  118. unsigned int ulAutoRepeatCount;
  119. //
  120. //! A pointer to the function to be called when the button is pressed.
  121. //! This is repeatedly called when PB_STYLE_AUTO_REPEAT is selected.
  122. //
  123. void (*pfnOnClick)(tWidget *pWidget);
  124. }
  125. tPushButtonWidget;
  126. //*****************************************************************************
  127. //
  128. //! This flag indicates that the push button should be outlined.
  129. //
  130. //*****************************************************************************
  131. #define PB_STYLE_OUTLINE 0x00000001
  132. //*****************************************************************************
  133. //
  134. //! This flag indicates that the push button should be filled.
  135. //
  136. //*****************************************************************************
  137. #define PB_STYLE_FILL 0x00000002
  138. //*****************************************************************************
  139. //
  140. //! This flag indicates that the push button should have text drawn on it.
  141. //
  142. //*****************************************************************************
  143. #define PB_STYLE_TEXT 0x00000004
  144. //*****************************************************************************
  145. //
  146. //! This flag indicates that the push button should have an image drawn on it.
  147. //
  148. //*****************************************************************************
  149. #define PB_STYLE_IMG 0x00000008
  150. //*****************************************************************************
  151. //
  152. //! This flag indicates that the push button text should be drawn opaque (in
  153. //! other words, drawing the background pixels as well as the foreground
  154. //! pixels).
  155. //
  156. //*****************************************************************************
  157. #define PB_STYLE_TEXT_OPAQUE 0x00000010
  158. //*****************************************************************************
  159. //
  160. //! This flag indicates that the push button should auto-repeat, generating
  161. //! repeated click events while it is pressed.
  162. //
  163. //*****************************************************************************
  164. #define PB_STYLE_AUTO_REPEAT 0x00000020
  165. //*****************************************************************************
  166. //
  167. //! This flag indicates that the push button is pressed.
  168. //
  169. //*****************************************************************************
  170. #define PB_STYLE_PRESSED 0x00000040
  171. //*****************************************************************************
  172. //
  173. //! This flag indicates that the push button callback should be made when
  174. //! the button is released rather than when it is pressed. This does not
  175. //! affect the operation of auto repeat buttons.
  176. //
  177. //*****************************************************************************
  178. #define PB_STYLE_RELEASE_NOTIFY 0x00000080
  179. //*****************************************************************************
  180. //
  181. //! Declares an initialized circular push button widget data structure.
  182. //!
  183. //! \param pParent is a pointer to the parent widget.
  184. //! \param pNext is a pointer to the sibling widget.
  185. //! \param pChild is a pointer to the first child widget.
  186. //! \param pDisplay is a pointer to the display on which to draw the push
  187. //! button.
  188. //! \param lX is the X coordinate of the center of the push button.
  189. //! \param lY is the Y coordinate of the center of the push button.
  190. //! \param lR is the radius of the push button.
  191. //! \param ulStyle is the style to be applied to the push button.
  192. //! \param ulFillColor is the color used to fill in the push button.
  193. //! \param ulPressFillColor is the color used to fill in the push button when
  194. //! it is pressed.
  195. //! \param ulOutlineColor is the color used to outline the push button.
  196. //! \param ulTextColor is the color used to draw text on the push button.
  197. //! \param pFont is a pointer to the font to be used to draw text on the push
  198. //! button.
  199. //! \param pcText is a pointer to the text to draw on this push button.
  200. //! \param pucImage is a pointer to the image to draw on this push button.
  201. //! \param pucPressImage is a pointer to the image to draw on this push button
  202. //! when it is pressed.
  203. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  204. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  205. //! generated.
  206. //! \param pfnOnClick is a pointer to the function that is called when the push
  207. //! button is pressed.
  208. //!
  209. //! This macro provides an initialized circular push button widget data
  210. //! structure, which can be used to construct the widget tree at compile time
  211. //! in global variables (as opposed to run-time via function calls). This must
  212. //! be assigned to a variable, such as:
  213. //!
  214. //! \verbatim
  215. //! tPushButtonWidget g_sPushButton = CircularButtonStruct(...);
  216. //! \endverbatim
  217. //!
  218. //! Or, in an array of variables:
  219. //!
  220. //! \verbatim
  221. //! tPushButtonWidget g_psPushButtons[] =
  222. //! {
  223. //! CircularButtonStruct(...),
  224. //! CircularButtonStruct(...)
  225. //! };
  226. //! \endverbatim
  227. //!
  228. //! \e ulStyle is the logical OR of the following:
  229. //!
  230. //! - \b #PB_STYLE_OUTLINE to indicate that the push button should be outlined.
  231. //! - \b #PB_STYLE_FILL to indicate that the push button should be filled.
  232. //! - \b #PB_STYLE_TEXT to indicate that the push button should have text drawn
  233. //! on it (using \e pFont and \e pcText).
  234. //! - \b #PB_STYLE_IMG to indicate that the push button should have an image
  235. //! drawn on it (using \e pucImage).
  236. //! - \b #PB_STYLE_TEXT_OPAQUE to indicate that the push button text should be
  237. //! drawn opaque (in other words, drawing the background pixels).
  238. //! - \b #PB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  239. //! - \b #PB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  240. //! when the button is released. If absent, the callback is called when the
  241. //! button is initially pressed.
  242. //!
  243. //! \return Nothing; this is not a function.
  244. //
  245. //*****************************************************************************
  246. #define CircularButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, lR, \
  247. ulStyle, ulFillColor, ulPressFillColor, \
  248. ulOutlineColor, ulTextColor, pFont, pcText, \
  249. pucImage, pucPressImage, usAutoRepeatDelay, \
  250. usAutoRepeatRate, pfnOnClick) \
  251. { \
  252. { \
  253. sizeof(tPushButtonWidget), \
  254. (tWidget *)(pParent), \
  255. (tWidget *)(pNext), \
  256. (tWidget *)(pChild), \
  257. pDisplay, \
  258. { \
  259. (lX) - (lR), \
  260. (lY) - (lR), \
  261. (lX) + (lR), \
  262. (lY) + (lR) \
  263. }, \
  264. CircularButtonMsgProc \
  265. }, \
  266. ulStyle, \
  267. ulFillColor, \
  268. ulPressFillColor, \
  269. ulOutlineColor, \
  270. ulTextColor, \
  271. pFont, \
  272. pcText, \
  273. pucImage, \
  274. pucPressImage, \
  275. usAutoRepeatDelay, \
  276. usAutoRepeatRate, \
  277. 0, \
  278. pfnOnClick \
  279. }
  280. //*****************************************************************************
  281. //
  282. //! Declares an initialized variable containing a circular push button widget
  283. //! data structure.
  284. //!
  285. //! \param sName is the name of the variable to be declared.
  286. //! \param pParent is a pointer to the parent widget.
  287. //! \param pNext is a pointer to the sibling widget.
  288. //! \param pChild is a pointer to the first child widget.
  289. //! \param pDisplay is a pointer to the display on which to draw the push
  290. //! button.
  291. //! \param lX is the X coordinate of the center of the push button.
  292. //! \param lY is the Y coordinate of the center of the push button.
  293. //! \param lR is the radius of the push button.
  294. //! \param ulStyle is the style to be applied to the push button.
  295. //! \param ulFillColor is the color used to fill in the push button.
  296. //! \param ulPressFillColor is the color used to fill in the push button when
  297. //! it is pressed.
  298. //! \param ulOutlineColor is the color used to outline the push button.
  299. //! \param ulTextColor is the color used to draw text on the push button.
  300. //! \param pFont is a pointer to the font to be used to draw text on the push
  301. //! button.
  302. //! \param pcText is a pointer to the text to draw on this push button.
  303. //! \param pucImage is a pointer to the image to draw on this push button.
  304. //! \param pucPressImage is a pointer to the image to draw on this push button
  305. //! when it is pressed.
  306. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  307. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  308. //! generated.
  309. //! \param pfnOnClick is a pointer to the function that is called when the push
  310. //! button is pressed.
  311. //!
  312. //! This macro provides an initialized circular push button widget data
  313. //! structure, which can be used to construct the widget tree at compile time
  314. //! in global variables (as opposed to run-time via function calls).
  315. //!
  316. //! \e ulStyle is the logical OR of the following:
  317. //!
  318. //! - \b #PB_STYLE_OUTLINE to indicate that the push button should be outlined.
  319. //! - \b #PB_STYLE_FILL to indicate that the push button should be filled.
  320. //! - \b #PB_STYLE_TEXT to indicate that the push button should have text drawn
  321. //! on it (using \e pFont and \e pcText).
  322. //! - \b #PB_STYLE_IMG to indicate that the push button should have an image
  323. //! drawn on it (using \e pucImage).
  324. //! - \b #PB_STYLE_TEXT_OPAQUE to indicate that the push button text should be
  325. //! drawn opaque (in other words, drawing the background pixels).
  326. //! - \b #PB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  327. //! - \b #PB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  328. //! when the button is released. If absent, the callback is called when the
  329. //! button is initially pressed.
  330. //!
  331. //! \return Nothing; this is not a function.
  332. //
  333. //*****************************************************************************
  334. #define CircularButton(sName, pParent, pNext, pChild, pDisplay, lX, lY, lR, \
  335. ulStyle, ulFillColor, ulPressFillColor, \
  336. ulOutlineColor, ulTextColor, pFont, pcText, pucImage, \
  337. pucPressImage, usAutoRepeatDelay, usAutoRepeatRate, \
  338. pfnOnClick) \
  339. tPushButtonWidget sName = \
  340. CircularButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  341. lR, ulStyle, ulFillColor, ulPressFillColor, \
  342. ulOutlineColor, ulTextColor, pFont, pcText, \
  343. pucImage, pucPressImage, usAutoRepeatDelay, \
  344. usAutoRepeatRate, pfnOnClick)
  345. //*****************************************************************************
  346. //
  347. //! Declares an initialized rectangular push button widget data structure.
  348. //!
  349. //! \param pParent is a pointer to the parent widget.
  350. //! \param pNext is a pointer to the sibling widget.
  351. //! \param pChild is a pointer to the first child widget.
  352. //! \param pDisplay is a pointer to the display on which to draw the push
  353. //! button.
  354. //! \param lX is the X coordinate of the upper left corner of the push button.
  355. //! \param lY is the Y coordinate of the upper left corner of the push button.
  356. //! \param lWidth is the width of the push button.
  357. //! \param lHeight is the height of the push button.
  358. //! \param ulStyle is the style to be applied to the push button.
  359. //! \param ulFillColor is the color used to fill in the push button.
  360. //! \param ulPressFillColor is the color used to fill in the push button when
  361. //! it is pressed.
  362. //! \param ulOutlineColor is the color used to outline the push button.
  363. //! \param ulTextColor is the color used to draw text on the push button.
  364. //! \param pFont is a pointer to the font to be used to draw text on the push
  365. //! button.
  366. //! \param pcText is a pointer to the text to draw on this push button.
  367. //! \param pucImage is a pointer to the image to draw on this push button.
  368. //! \param pucPressImage is a pointer to the image to draw on this push button
  369. //! when it is pressed.
  370. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  371. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  372. //! generated.
  373. //! \param pfnOnClick is a pointer to the function that is called when the push
  374. //! button is pressed.
  375. //!
  376. //! This macro provides an initialized rectangular push button widget data
  377. //! structure, which can be used to construct the widget tree at compile time
  378. //! in global variables (as opposed to run-time via function calls). This must
  379. //! be assigned to a variable, such as:
  380. //!
  381. //! \verbatim
  382. //! tPushButtonWidget g_sPushButton = RectangularButtonStruct(...);
  383. //! \endverbatim
  384. //!
  385. //! Or, in an array of variables:
  386. //!
  387. //! \verbatim
  388. //! tPushButtonWidget g_psPushButtons[] =
  389. //! {
  390. //! RectangularButtonStruct(...),
  391. //! RectangularButtonStruct(...)
  392. //! };
  393. //! \endverbatim
  394. //!
  395. //! \e ulStyle is the logical OR of the following:
  396. //!
  397. //! - \b #PB_STYLE_OUTLINE to indicate that the push button should be outlined.
  398. //! - \b #PB_STYLE_FILL to indicate that the push button should be filled.
  399. //! - \b #PB_STYLE_TEXT to indicate that the push button should have text drawn
  400. //! on it (using \e pFont and \e pcText).
  401. //! - \b #PB_STYLE_IMG to indicate that the push button should have an image
  402. //! drawn on it (using \e pucImage).
  403. //! - \b #PB_STYLE_TEXT_OPAQUE to indicate that the push button text should be
  404. //! drawn opaque (in other words, drawing the background pixels).
  405. //! - \b #PB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  406. //! - \b #PB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  407. //! when the button is released. If absent, the callback is called when the
  408. //! button is initially pressed.
  409. //!
  410. //! \return Nothing; this is not a function.
  411. //
  412. //*****************************************************************************
  413. #define RectangularButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  414. lWidth, lHeight, ulStyle, ulFillColor, \
  415. ulPressFillColor, ulOutlineColor, \
  416. ulTextColor, pFont, pcText, pucImage, \
  417. pucPressImage, usAutoRepeatDelay, \
  418. usAutoRepeatRate, pfnOnClick) \
  419. { \
  420. { \
  421. sizeof(tPushButtonWidget), \
  422. (tWidget *)(pParent), \
  423. (tWidget *)(pNext), \
  424. (tWidget *)(pChild), \
  425. pDisplay, \
  426. { \
  427. lX, \
  428. lY, \
  429. (lX) + (lWidth) - 1, \
  430. (lY) + (lHeight) - 1 \
  431. }, \
  432. RectangularButtonMsgProc \
  433. }, \
  434. ulStyle, \
  435. ulFillColor, \
  436. ulPressFillColor, \
  437. ulOutlineColor, \
  438. ulTextColor, \
  439. pFont, \
  440. pcText, \
  441. pucImage, \
  442. pucPressImage, \
  443. usAutoRepeatDelay, \
  444. usAutoRepeatRate, \
  445. 0, \
  446. pfnOnClick \
  447. }
  448. //*****************************************************************************
  449. //
  450. //! Declares an initialized variable containing a rectangular push button
  451. //! widget data structure.
  452. //!
  453. //! \param sName is the name of the variable to be declared.
  454. //! \param pParent is a pointer to the parent widget.
  455. //! \param pNext is a pointer to the sibling widget.
  456. //! \param pChild is a pointer to the first child widget.
  457. //! \param pDisplay is a pointer to the display on which to draw the push
  458. //! button.
  459. //! \param lX is the X coordinate of the upper left corner of the push button.
  460. //! \param lY is the Y coordinate of the upper left corner of the push button.
  461. //! \param lWidth is the width of the push button.
  462. //! \param lHeight is the height of the push button.
  463. //! \param ulStyle is the style to be applied to the push button.
  464. //! \param ulFillColor is the color used to fill in the push button.
  465. //! \param ulPressFillColor is the color used to fill in the push button when
  466. //! it is pressed.
  467. //! \param ulOutlineColor is the color used to outline the push button.
  468. //! \param ulTextColor is the color used to draw text on the push button.
  469. //! \param pFont is a pointer to the font to be used to draw text on the push
  470. //! button.
  471. //! \param pcText is a pointer to the text to draw on this push button.
  472. //! \param pucImage is a pointer to the image to draw on this push button.
  473. //! \param pucPressImage is a pointer to the image to draw on this push button
  474. //! when it is pressed.
  475. //! \param usAutoRepeatDelay is the delay before starting auto-repeat.
  476. //! \param usAutoRepeatRate is the rate at which auto-repeat events are
  477. //! generated.
  478. //! \param pfnOnClick is a pointer to the function that is called when the push
  479. //! button is pressed.
  480. //!
  481. //! This macro provides an initialized rectangular push button widget data
  482. //! structure, which can be used to construct the widget tree at compile time
  483. //! in global variables (as opposed to run-time via function calls).
  484. //!
  485. //! \e ulStyle is the logical OR of the following:
  486. //!
  487. //! - \b #PB_STYLE_OUTLINE to indicate that the push button should be outlined.
  488. //! - \b #PB_STYLE_FILL to indicate that the push button should be filled.
  489. //! - \b #PB_STYLE_TEXT to indicate that the push button should have text drawn
  490. //! on it (using \e pFont and \e pcText).
  491. //! - \b #PB_STYLE_IMG to indicate that the push button should have an image
  492. //! drawn on it (using \e pucImage).
  493. //! - \b #PB_STYLE_TEXT_OPAQUE to indicate that the push button text should be
  494. //! drawn opaque (in other words, drawing the background pixels).
  495. //! - \b #PB_STYLE_AUTO_REPEAT to indicate that auto-repeat should be used.
  496. //! - \b #PB_STYLE_RELEASE_NOTIFY to indicate that the callback should be made
  497. //! when the button is released. If absent, the callback is called when the
  498. //! button is initially pressed.
  499. //!
  500. //! \return Nothing; this is not a function.
  501. //
  502. //*****************************************************************************
  503. #define RectangularButton(sName, pParent, pNext, pChild, pDisplay, lX, lY, \
  504. lWidth, lHeight, ulStyle, ulFillColor, \
  505. ulPressFillColor, ulOutlineColor, ulTextColor, \
  506. pFont, pcText, pucImage, pucPressImage, \
  507. usAutoRepeatDelay, usAutoRepeatRate, pfnOnClick) \
  508. tPushButtonWidget sName = \
  509. RectangularButtonStruct(pParent, pNext, pChild, pDisplay, lX, lY, \
  510. lWidth, lHeight, ulStyle, ulFillColor, \
  511. ulPressFillColor, ulOutlineColor, \
  512. ulTextColor, pFont, pcText, pucImage, \
  513. pucPressImage, usAutoRepeatDelay, \
  514. usAutoRepeatRate, pfnOnClick)
  515. //*****************************************************************************
  516. //
  517. //! Sets the auto-repeat delay for a push button widget.
  518. //!
  519. //! \param pWidget is a pointer to the push button widget to modify.
  520. //! \param usDelay is the number of pointer events before auto-repeat starts.
  521. //!
  522. //! This function sets the delay before auto-repeat begins. Unpredictable
  523. //! behavior will occur if this is called while the push button is pressed.
  524. //!
  525. //! \return None.
  526. //
  527. //*****************************************************************************
  528. #define PushButtonAutoRepeatDelaySet(pWidget, usDelay) \
  529. do \
  530. { \
  531. tPushButtonWidget *pW = pWidget; \
  532. pW->usAutoRepeatDelay = usDelay; \
  533. } \
  534. while(0)
  535. //*****************************************************************************
  536. //
  537. //! Disables auto-repeat for a push button widget.
  538. //!
  539. //! \param pWidget is a pointer to the push button widget to modify.
  540. //!
  541. //! This function disables the auto-repeat behavior of a push button.
  542. //!
  543. //! \return None.
  544. //
  545. //*****************************************************************************
  546. #define PushButtonAutoRepeatOff(pWidget) \
  547. do \
  548. { \
  549. tPushButtonWidget *pW = pWidget; \
  550. pW->ulStyle &= ~(PB_STYLE_AUTO_REPEAT); \
  551. } \
  552. while(0)
  553. //*****************************************************************************
  554. //
  555. //! Enables auto-repeat for a push button widget.
  556. //!
  557. //! \param pWidget is a pointer to the push button widget to modify.
  558. //!
  559. //! This function enables the auto-repeat behavior of a push button.
  560. //! Unpredictable behavior will occur if this is called while the push button
  561. //! is pressed.
  562. //!
  563. //! \return None.
  564. //
  565. //*****************************************************************************
  566. #define PushButtonAutoRepeatOn(pWidget) \
  567. do \
  568. { \
  569. tPushButtonWidget *pW = pWidget; \
  570. pW->ulStyle |= PB_STYLE_AUTO_REPEAT; \
  571. } \
  572. while(0)
  573. //*****************************************************************************
  574. //
  575. //! Sets the auto-repeat rate for a push button widget.
  576. //!
  577. //! \param pWidget is a pointer to the push button widget to modify.
  578. //! \param usRate is the number of pointer events between auto-repeat events.
  579. //!
  580. //! This function sets the rate at which auto-repeat events occur.
  581. //! Unpredictable behavior will occur if this is called while the push button
  582. //! is pressed.
  583. //!
  584. //! \return None.
  585. //
  586. //*****************************************************************************
  587. #define PushButtonAutoRepeatRateSet(pWidget, usRate) \
  588. do \
  589. { \
  590. tPushButtonWidget *pW = pWidget; \
  591. pW->usAutoRepeatRate = usRate; \
  592. } \
  593. while(0)
  594. //*****************************************************************************
  595. //
  596. //! Sets the function to call when this push button widget is pressed.
  597. //!
  598. //! \param pWidget is a pointer to the push button widget to modify.
  599. //! \param pfnOnClik is a pointer to the function to call.
  600. //!
  601. //! This function sets the function to be called when this push button is
  602. //! pressed. The supplied function is called when the push button is first
  603. //! pressed, and then repeated while the push button is pressed if auto-repeat
  604. //! is enabled.
  605. //!
  606. //! \return None.
  607. //
  608. //*****************************************************************************
  609. #define PushButtonCallbackSet(pWidget, pfnOnClik) \
  610. do \
  611. { \
  612. tPushButtonWidget *pW = pWidget; \
  613. pW->pfnOnClick = pfnOnClik; \
  614. } \
  615. while(0)
  616. //*****************************************************************************
  617. //
  618. //! Sets the fill color of a push button widget.
  619. //!
  620. //! \param pWidget is a pointer to the push button widget to be modified.
  621. //! \param ulColor is the 24-bit RGB color to use to fill the push button.
  622. //!
  623. //! This function changes the color used to fill the push button on the
  624. //! display. The display is not updated until the next paint request.
  625. //!
  626. //! \return None.
  627. //
  628. //*****************************************************************************
  629. #define PushButtonFillColorSet(pWidget, ulColor) \
  630. do \
  631. { \
  632. tPushButtonWidget *pW = pWidget; \
  633. pW->ulFillColor = ulColor; \
  634. } \
  635. while(0)
  636. //*****************************************************************************
  637. //
  638. //! Sets the fill color of a push button widget when it is pressed.
  639. //!
  640. //! \param pWidget is a pointer to the push button widget to be modified.
  641. //! \param ulColor is the 24-bit RGB color to use to fill the push button when
  642. //! it is pressed.
  643. //!
  644. //! This function changes the color used to fill the push button on the
  645. //! display when it is pressed. The display is not updated until the next
  646. //! paint request.
  647. //!
  648. //! \return None.
  649. //
  650. //*****************************************************************************
  651. #define PushButtonFillColorPressedSet(pWidget, ulColor) \
  652. do \
  653. { \
  654. tPushButtonWidget *pW = pWidget; \
  655. pW->ulPressFillColor = ulColor; \
  656. } \
  657. while(0)
  658. //*****************************************************************************
  659. //
  660. //! Disables filling of a push button widget.
  661. //!
  662. //! \param pWidget is a pointer to the push button widget to modify.
  663. //!
  664. //! This function disables the filling of a push button widget. The display is
  665. //! not updated until the next paint request.
  666. //!
  667. //! \return None.
  668. //
  669. //*****************************************************************************
  670. #define PushButtonFillOff(pWidget) \
  671. do \
  672. { \
  673. tPushButtonWidget *pW = pWidget; \
  674. pW->ulStyle &= ~(PB_STYLE_FILL); \
  675. } \
  676. while(0)
  677. //*****************************************************************************
  678. //
  679. //! Enables filling of a push button widget.
  680. //!
  681. //! \param pWidget is a pointer to the push button widget to modify.
  682. //!
  683. //! This function enables the filling of a push button widget. The display is
  684. //! not updated until the next paint request.
  685. //!
  686. //! \return None.
  687. //
  688. //*****************************************************************************
  689. #define PushButtonFillOn(pWidget) \
  690. do \
  691. { \
  692. tPushButtonWidget *pW = pWidget; \
  693. pW->ulStyle |= PB_STYLE_FILL; \
  694. } \
  695. while(0)
  696. //*****************************************************************************
  697. //
  698. //! Sets the font for a push button widget.
  699. //!
  700. //! \param pWidget is a pointer to the push button widget to modify.
  701. //! \param pFnt is a pointer to the font to use to draw text on the push
  702. //! button.
  703. //!
  704. //! This function changes the font used to draw text on the push button. The
  705. //! display is not updated until the next paint request.
  706. //!
  707. //! \return None.
  708. //
  709. //*****************************************************************************
  710. #define PushButtonFontSet(pWidget, pFnt) \
  711. do \
  712. { \
  713. tPushButtonWidget *pW = pWidget; \
  714. const tFont *pF = pFnt; \
  715. pW->pFont = pF; \
  716. } \
  717. while(0)
  718. //*****************************************************************************
  719. //
  720. //! Changes the image drawn on a push button widget.
  721. //!
  722. //! \param pWidget is a pointer to the push button widget to be modified.
  723. //! \param pImg is a pointer to the image to draw onto the push button.
  724. //!
  725. //! This function changes the image that is drawn onto the push button. The
  726. //! display is not updated until the next paint request.
  727. //!
  728. //! \return None.
  729. //
  730. //*****************************************************************************
  731. #define PushButtonImageSet(pWidget, pImg) \
  732. do \
  733. { \
  734. tPushButtonWidget *pW = pWidget; \
  735. const unsigned char *pI = pImg; \
  736. pW->pucImage = pI; \
  737. } \
  738. while(0)
  739. //*****************************************************************************
  740. //
  741. //! Changes the image drawn on a push button widget when it is pressed.
  742. //!
  743. //! \param pWidget is a pointer to the push button widget to be modified.
  744. //! \param pImg is a pointer to the image to draw onto the push button when it
  745. //! is pressed.
  746. //!
  747. //! This function changes the image that is drawn onto the push button when it
  748. //! is pressed. The display is not updated until the next paint request.
  749. //!
  750. //! \return None.
  751. //
  752. //*****************************************************************************
  753. #define PushButtonImagePressedSet(pWidget, pImg) \
  754. do \
  755. { \
  756. tPushButtonWidget *pW = pWidget; \
  757. const unsigned char *pI = pImg; \
  758. pW->pucPressImage = pI; \
  759. } \
  760. while(0)
  761. //*****************************************************************************
  762. //
  763. //! Disables the image on a push button widget.
  764. //!
  765. //! \param pWidget is a pointer to the push button widget to modify.
  766. //!
  767. //! This function disables the drawing of an image on a push button widget.
  768. //! The display is not updated until the next paint request.
  769. //!
  770. //! \return None.
  771. //
  772. //*****************************************************************************
  773. #define PushButtonImageOff(pWidget) \
  774. do \
  775. { \
  776. tPushButtonWidget *pW = pWidget; \
  777. pW->ulStyle &= ~(PB_STYLE_IMG); \
  778. } \
  779. while(0)
  780. //*****************************************************************************
  781. //
  782. //! Enables the image on a push button widget.
  783. //!
  784. //! \param pWidget is a pointer to the push button widget to modify.
  785. //!
  786. //! This function enables the drawing of an image on a push button widget. The
  787. //! display is not updated until the next paint request.
  788. //!
  789. //! \return None.
  790. //
  791. //*****************************************************************************
  792. #define PushButtonImageOn(pWidget) \
  793. do \
  794. { \
  795. tPushButtonWidget *pW = pWidget; \
  796. pW->ulStyle |= PB_STYLE_IMG; \
  797. } \
  798. while(0)
  799. //*****************************************************************************
  800. //
  801. //! Sets the outline color of a push button widget.
  802. //!
  803. //! \param pWidget is a pointer to the push button widget to be modified.
  804. //! \param ulColor is the 24-bit RGB color to use to outline the push button.
  805. //!
  806. //! This function changes the color used to outline the push button on the
  807. //! display. The display is not updated until the next paint request.
  808. //!
  809. //! \return None.
  810. //
  811. //*****************************************************************************
  812. #define PushButtonOutlineColorSet(pWidget, ulColor) \
  813. do \
  814. { \
  815. tPushButtonWidget *pW = pWidget; \
  816. pW->ulOutlineColor = ulColor; \
  817. } \
  818. while(0)
  819. //*****************************************************************************
  820. //
  821. //! Disables outlining of a push button widget.
  822. //!
  823. //! \param pWidget is a pointer to the push button widget to modify.
  824. //!
  825. //! This function disables the outlining of a push button widget. The display
  826. //! is not updated until the next paint request.
  827. //!
  828. //! \return None.
  829. //
  830. //*****************************************************************************
  831. #define PushButtonOutlineOff(pWidget) \
  832. do \
  833. { \
  834. tPushButtonWidget *pW = pWidget; \
  835. pW->ulStyle &= ~(PB_STYLE_OUTLINE); \
  836. } \
  837. while(0)
  838. //*****************************************************************************
  839. //
  840. //! Enables outlining of a push button widget.
  841. //!
  842. //! \param pWidget is a pointer to the push button widget to modify.
  843. //!
  844. //! This function enables the outlining of a push button widget. The display
  845. //! is not updated until the next paint request.
  846. //!
  847. //! \return None.
  848. //
  849. //*****************************************************************************
  850. #define PushButtonOutlineOn(pWidget) \
  851. do \
  852. { \
  853. tPushButtonWidget *pW = pWidget; \
  854. pW->ulStyle |= PB_STYLE_OUTLINE; \
  855. } \
  856. while(0)
  857. //*****************************************************************************
  858. //
  859. //! Sets the text color of a push button widget.
  860. //!
  861. //! \param pWidget is a pointer to the push button widget to be modified.
  862. //! \param ulColor is the 24-bit RGB color to use to draw text on the push
  863. //! button.
  864. //!
  865. //! This function changes the color used to draw text on the push button on the
  866. //! display. The display is not updated until the next paint request.
  867. //!
  868. //! \return None.
  869. //
  870. //*****************************************************************************
  871. #define PushButtonTextColorSet(pWidget, ulColor) \
  872. do \
  873. { \
  874. tPushButtonWidget *pW = pWidget; \
  875. pW->ulTextColor = ulColor; \
  876. } \
  877. while(0)
  878. //*****************************************************************************
  879. //
  880. //! Disables the text on a push button widget.
  881. //!
  882. //! \param pWidget is a pointer to the push button widget to modify.
  883. //!
  884. //! This function disables the drawing of text on a push button widget. The
  885. //! display is not updated until the next paint request.
  886. //!
  887. //! \return None.
  888. //
  889. //*****************************************************************************
  890. #define PushButtonTextOff(pWidget) \
  891. do \
  892. { \
  893. tPushButtonWidget *pW = pWidget; \
  894. pW->ulStyle &= ~(PB_STYLE_TEXT); \
  895. } \
  896. while(0)
  897. //*****************************************************************************
  898. //
  899. //! Enables the text on a push button widget.
  900. //!
  901. //! \param pWidget is a pointer to the push button widget to modify.
  902. //!
  903. //! This function enables the drawing of text on a push button widget. The
  904. //! display is not updated until the next paint request.
  905. //!
  906. //! \return None.
  907. //
  908. //*****************************************************************************
  909. #define PushButtonTextOn(pWidget) \
  910. do \
  911. { \
  912. tPushButtonWidget *pW = pWidget; \
  913. pW->ulStyle |= PB_STYLE_TEXT; \
  914. } \
  915. while(0)
  916. //*****************************************************************************
  917. //
  918. //! Disables opaque text on a push button widget.
  919. //!
  920. //! \param pWidget is a pointer to the push button widget to modify.
  921. //!
  922. //! This function disables the use of opaque text on this push button. When
  923. //! not using opaque text, only the foreground pixels of the text are drawn on
  924. //! the screen, allowing the previously drawn pixels (such as the push button
  925. //! image) to show through the text.
  926. //!
  927. //! \return None.
  928. //
  929. //*****************************************************************************
  930. #define PushButtonTextOpaqueOff(pWidget) \
  931. do \
  932. { \
  933. tPushButtonWidget *pW = pWidget; \
  934. pW->ulStyle &= ~(PB_STYLE_TEXT_OPAQUE); \
  935. } \
  936. while(0)
  937. //*****************************************************************************
  938. //
  939. //! Enables opaque text on a push button widget.
  940. //!
  941. //! \param pWidget is a pointer to the push button widget to modify.
  942. //!
  943. //! This function enables the use of opaque text on this push button. When
  944. //! using opaque text, both the foreground and background pixels of the text
  945. //! are drawn on the screen, blocking out the previously drawn pixels.
  946. //!
  947. //! \return None.
  948. //
  949. //*****************************************************************************
  950. #define PushButtonTextOpaqueOn(pWidget) \
  951. do \
  952. { \
  953. tPushButtonWidget *pW = pWidget; \
  954. pW->ulStyle |= PB_STYLE_TEXT_OPAQUE; \
  955. } \
  956. while(0)
  957. //*****************************************************************************
  958. //
  959. //! Changes the text drawn on a push button widget.
  960. //!
  961. //! \param pWidget is a pointer to the push button widget to be modified.
  962. //! \param pcTxt is a pointer to the text to draw onto the push button.
  963. //!
  964. //! This function changes the text that is drawn onto the push button. The
  965. //! display is not updated until the next paint request.
  966. //!
  967. //! \return None.
  968. //
  969. //*****************************************************************************
  970. #define PushButtonTextSet(pWidget, pcTxt) \
  971. do \
  972. { \
  973. tPushButtonWidget *pW = pWidget; \
  974. const char *pcT = pcTxt; \
  975. pW->pcText = pcT; \
  976. } \
  977. while(0)
  978. //*****************************************************************************
  979. //
  980. // Prototypes for the push button widget APIs.
  981. //
  982. //*****************************************************************************
  983. extern int RectangularButtonMsgProc(tWidget *pWidget, unsigned int ulMsg,
  984. unsigned int ulParam1,
  985. unsigned int ulParam2);
  986. extern void RectangularButtonInit(tPushButtonWidget *pWidget,
  987. const tDisplay *pDisplay, int lX, int lY,
  988. int lWidth, int lHeight);
  989. extern int CircularButtonMsgProc(tWidget *pWidget, unsigned int ulMsg,
  990. unsigned int ulParam1,
  991. unsigned int ulParam2);
  992. extern void CircularButtonInit(tPushButtonWidget *pWidget,
  993. const tDisplay *pDisplay, int lX, int lY,
  994. int lR);
  995. //*****************************************************************************
  996. //
  997. // Mark the end of the C bindings section for C++ compilers.
  998. //
  999. //*****************************************************************************
  1000. #ifdef __cplusplus
  1001. }
  1002. #endif
  1003. //*****************************************************************************
  1004. //
  1005. // Close the Doxygen group.
  1006. //! @}
  1007. //
  1008. //*****************************************************************************
  1009. #endif // __PUSHBUTTON_H__