The official µGFX library repository.

gwin_radio.h 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * This file is subject to the terms of the GFX License. If a copy of
  3. * the license was not distributed with this file, you can obtain one at:
  4. *
  5. * http://ugfx.org/license.html
  6. */
  7. /**
  8. * @file src/gwin/gwin_radio.h
  9. * @brief GWIN Graphic window subsystem header file.
  10. *
  11. * @defgroup RadioButton RadioButton
  12. * @ingroup Widgets
  13. *
  14. * @brief RadioButton widget.
  15. *
  16. * @details RadioButtons need to be grouped together. This is archived by passing a group parameter through
  17. * @p gwinRadioCreate().
  18. *
  19. * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
  20. * @pre GWIN_NEED_RADIO must be set to TRUE in your gfxconf.h
  21. * @{
  22. */
  23. #ifndef _GWIN_RADIO_H
  24. #define _GWIN_RADIO_H
  25. /* This file is included within "src/gwin/gwin_widget.h" */
  26. /**
  27. * @brief The Event Type for a Radio Event
  28. */
  29. #define GEVENT_GWIN_RADIO (GEVENT_GWIN_CTRL_FIRST+3)
  30. /**
  31. * @brief A Button Event
  32. * @note There are currently no GEventGWinRadio listening flags - use 0 as the flags to @p gwinAttachListener()
  33. */
  34. typedef struct GEventGWinRadio {
  35. GEventType type; // The type of this event (GEVENT_GWIN_RADIO)
  36. GHandle gwin; // The radio button that has been depressed
  37. #if GWIN_WIDGET_TAGS
  38. WidgetTag tag; // The radio tag
  39. #endif
  40. uint16_t group; // The group for this radio button
  41. } GEventGWinRadio;
  42. /**
  43. * @brief The internal radio button object flags
  44. * @note Used only for writing a custom draw routine.
  45. * @{
  46. */
  47. #define GRADIO_FLG_PRESSED 0x01
  48. /** @} */
  49. /**
  50. * @brief The radio button widget structure
  51. * @note Do not use the members directly - treat it as a black-box.
  52. */
  53. typedef struct GRadioObject {
  54. GWidgetObject w;
  55. #if GINPUT_NEED_TOGGLE
  56. uint16_t toggle;
  57. #endif
  58. uint16_t group;
  59. } GRadioObject;
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. /**
  64. * @brief Create a radio widget.
  65. * @return NULL if there is no resultant drawing area, otherwise a window handle.
  66. *
  67. * @param[in] g The GDisplay to display this window on
  68. * @param[in] gb The GRadioObject structure to initialise. If this is NULL the structure is dynamically allocated.
  69. * @param[in] pInit The initialisation parameters
  70. * @param[in] group The group of radio buttons this radio button belongs to.
  71. *
  72. * @note Only one radio button in any group is ever pressed at one time. Pressing one radio button will
  73. * release all others in the group.
  74. * @note The drawing color and the background color get set to the current defaults. If you haven't called
  75. * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
  76. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
  77. * is no default font and text drawing operations will no nothing.
  78. * @note A radio button remembers its normal drawing state. If there is a window manager then it is automatically
  79. * redrawn if the window is moved or its visibility state is changed.
  80. * @note A radio button supports mouse and a toggle input.
  81. * @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will
  82. * forget the previous toggle. When assigning a toggle the role parameter must be 0.
  83. *
  84. * @api
  85. */
  86. GHandle gwinGRadioCreate(GDisplay *g, GRadioObject *gb, const GWidgetInit *pInit, uint16_t group);
  87. #define gwinRadioCreate(w, pInit, gr) gwinGRadioCreate(GDISP, w, pInit, gr)
  88. /**
  89. * @brief Press this radio button (and by definition unset any others in the group)
  90. *
  91. * @param[in] gh The window handle (must be a radio widget)
  92. *
  93. * @api
  94. */
  95. void gwinRadioPress(GHandle gh);
  96. /**
  97. * @brief Is the radio button currently pressed
  98. * @return TRUE if the button is pressed
  99. *
  100. * @param[in] gh The window handle (must be a radio widget)
  101. *
  102. * @api
  103. */
  104. bool_t gwinRadioIsPressed(GHandle gh);
  105. /**
  106. * @brief Find the currently pressed radio button in the specified group
  107. * @return The handle of the pressed radio button or NULL if none are pressed
  108. *
  109. * @param[in] group The radio button group to be examined
  110. *
  111. * @return The handle of the currently pressed radio button
  112. *
  113. * @api
  114. */
  115. GHandle gwinRadioGetActive(uint16_t group);
  116. /**
  117. * @defgroup Renderings_Radiobutton Renderings
  118. *
  119. * @brief Built-in rendering functions for the radiobutton widget.
  120. *
  121. * @details These function may be passed to @p gwinSetCustomDraw() to get different radiobutton drawing styles.
  122. *
  123. * @note In your custom radiobutton drawing function you may optionally call these
  124. * standard functions and then draw your extra details on top.
  125. * @note These custom drawing routines don't have to worry about setting clipping as the framework
  126. * sets clipping to the object window prior to calling these routines.
  127. *
  128. * @{
  129. */
  130. /**
  131. * @brief The default rendering function for the radiobutton widget
  132. *
  133. * @param[in] gw The widget object (must be a button radioobject)
  134. * @param[in] param A parameter passed in from the user. Ignored by this function.
  135. *
  136. * @api
  137. */
  138. void gwinRadioDraw_Radio(GWidgetObject *gw, void *param);
  139. /**
  140. * @brief Renders the radiobutton in form of a regular rectangular button
  141. *
  142. * @param[in] gw The widget object (must be a button radioobject)
  143. * @param[in] param A parameter passed in from the user. Ignored by this function.
  144. *
  145. * @api
  146. */
  147. void gwinRadioDraw_Button(GWidgetObject *gw, void *param);
  148. /**
  149. * @brief Used to render tabbed menus.
  150. *
  151. * @details Multiple radiobutton widgets can be placed right next to each other and be used to implement
  152. * a tabbed menu using this rendering function.
  153. *
  154. * @note This exists for legacy reasons. Have a look at the @p Tabset widget instead.
  155. *
  156. * @param[in] gw The widget object (must be a button radioobject)
  157. * @param[in] param A parameter passed in from the user. Ignored by this function.
  158. *
  159. * @api
  160. */
  161. void gwinRadioDraw_Tab(GWidgetObject *gw, void *param);
  162. /** @} */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* _GWIN_RADIO_H */
  167. /** @} */