widget.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //*****************************************************************************
  2. //
  3. // widget.h - Prototypes for the widget base "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 __WIDGET_H__
  25. #define __WIDGET_H__
  26. //*****************************************************************************
  27. //
  28. //! \addtogroup widget_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 generic widget. This structure is the base
  45. //! ``class'' for all other widgets.
  46. //
  47. //*****************************************************************************
  48. typedef struct __Widget
  49. {
  50. //
  51. //! The size of this structure. This will be the size of the full
  52. //! structure, not just the generic widget subset.
  53. //
  54. int lSize;
  55. //
  56. //! A pointer to this widget's parent widget.
  57. //
  58. struct __Widget *pParent;
  59. //
  60. //! A pointer to this widget's first sibling widget.
  61. //
  62. struct __Widget *pNext;
  63. //
  64. //! A pointer to this widget's first child widget.
  65. //
  66. struct __Widget *pChild;
  67. //
  68. //! A pointer to the display on which this widget resides.
  69. //
  70. const tDisplay *pDisplay;
  71. //
  72. //! The rectangle that encloses this widget.
  73. //
  74. tRectangle sPosition;
  75. //
  76. //! The procedure that handles messages sent to this widget.
  77. //
  78. int (*pfnMsgProc)(struct __Widget *pWidget, unsigned int ulMessage,
  79. unsigned int ulParam1, unsigned int ulParam2);
  80. }
  81. tWidget;
  82. //*****************************************************************************
  83. //
  84. //! The widget at the root of the widget tree. This can be used when
  85. //! constructing a widget tree at compile time (used as the pParent argument to
  86. //! a widget declaration) or as the pWidget argument to an API (such as
  87. //! WidgetPaint() to paint the entire widget tree).
  88. //
  89. //*****************************************************************************
  90. #define WIDGET_ROOT &g_sRoot
  91. //*****************************************************************************
  92. //
  93. //! This message is sent to indicate that the widget should draw itself on the
  94. //! display. Neither \e ulParam1 nor \e ulParam2 are used by this message.
  95. //! This message is delivered in top-down order.
  96. //
  97. //*****************************************************************************
  98. #define WIDGET_MSG_PAINT 0x00000001
  99. //*****************************************************************************
  100. //
  101. //! This message is sent to indicate that the pointer is now down. \e ulParam1
  102. //! is the X coordinate of the location where the pointer down event occurred,
  103. //! and \e ulParam2 is the Y coordinate. This message is delivered in
  104. //! bottom-up order.
  105. //
  106. //*****************************************************************************
  107. #define WIDGET_MSG_PTR_DOWN 0x00000002
  108. //*****************************************************************************
  109. //
  110. //! This message is sent to indicate that the pointer has moved while being
  111. //! down. \e ulParam1 is the X coordinate of the new pointer location, and
  112. //! \e ulParam2 is the Y coordinate. This message is delivered in bottom-up
  113. //! order.
  114. //
  115. //*****************************************************************************
  116. #define WIDGET_MSG_PTR_MOVE 0x00000003
  117. //*****************************************************************************
  118. //
  119. //! This message is sent to indicate that the pointer is now up. \e ulParam1
  120. //! is the X coordinate of the location where the pointer up event occurred,
  121. //! and \e ulParam2 is the Y coordinate. This message is delivered in
  122. //! bottom-up order.
  123. //
  124. //*****************************************************************************
  125. #define WIDGET_MSG_PTR_UP 0x00000004
  126. //*****************************************************************************
  127. //
  128. //! Requests a redraw of the widget tree.
  129. //!
  130. //! \param pWidget is a pointer to the widget tree to paint.
  131. //!
  132. //! This function sends a \b #WIDGET_MSG_PAINT message to the given widgets,
  133. //! and all of the widget beneath it, so that they will draw or redraw
  134. //! themselves on the display. The actual drawing will occur when this message
  135. //! is retrieved from the message queue and processed.
  136. //!
  137. //! \return Returns 1 if the message was added to the message queue and 0 if it
  138. //! cound not be added (due to the queue being full).
  139. //
  140. //*****************************************************************************
  141. #define WidgetPaint(pWidget) \
  142. WidgetMessageQueueAdd(pWidget, WIDGET_MSG_PAINT, 0, 0, 0, 0)
  143. //*****************************************************************************
  144. //
  145. // Prototypes for the generic widget handling functions.
  146. //
  147. //*****************************************************************************
  148. extern tWidget g_sRoot;
  149. extern int WidgetDefaultMsgProc(tWidget *pWidget, unsigned int ulMessage,
  150. unsigned int ulParam1,
  151. unsigned int ulParam2);
  152. extern void WidgetAdd(tWidget *pParent, tWidget *pWidget);
  153. extern void WidgetRemove(tWidget *pWidget);
  154. extern unsigned int WidgetMessageSendPreOrder(tWidget *pWidget,
  155. unsigned int ulMessage,
  156. unsigned int ulParam1,
  157. unsigned int ulParam2,
  158. unsigned int bStopOnSuccess);
  159. extern unsigned int WidgetMessageSendPostOrder(tWidget *pWidget,
  160. unsigned int ulMessage,
  161. unsigned int ulParam1,
  162. unsigned int ulParam2,
  163. unsigned int bStopOnSuccess);
  164. extern int WidgetMessageQueueAdd(tWidget *pWidget, unsigned int ulMessage,
  165. unsigned int ulParam1,
  166. unsigned int ulParam2,
  167. unsigned int bPostOrder,
  168. unsigned int bStopOnSuccess);
  169. extern void WidgetMessageQueueProcess(void);
  170. extern int WidgetPointerMessage(unsigned int ulMessage, int lX, int lY);
  171. extern void WidgetMutexInit(unsigned char *pcMutex);
  172. extern unsigned int WidgetMutexGet(unsigned char *pcMutex);
  173. extern void WidgetMutexPut(unsigned char *pcMutex);
  174. //*****************************************************************************
  175. //
  176. // Mark the end of the C bindings section for C++ compilers.
  177. //
  178. //*****************************************************************************
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182. //*****************************************************************************
  183. //
  184. // Close the Doxygen group.
  185. //! @}
  186. //
  187. //*****************************************************************************
  188. #endif // __WIDGET_H__