The official µGFX library repository.

gwin_checkbox.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_checkbox.h
  9. * @brief GWIN Graphic window subsystem header file.
  10. *
  11. * @defgroup Checkbox Checkbox
  12. * @ingroup Widgets
  13. *
  14. * @brief CheckBox widget.
  15. *
  16. * @details GWIN allows it to easily create a group of checkbox buttons.
  17. *
  18. * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
  19. * @pre GWIN_NEED_CHECKBOX must be set to TRUE in your gfxconf.h
  20. * @{
  21. */
  22. #ifndef _GWIN_CHECKBOX_H
  23. #define _GWIN_CHECKBOX_H
  24. /* This file is included within "src/gwin/gwin_widget.h" */
  25. /*===========================================================================*/
  26. /* Driver constants. */
  27. /*===========================================================================*/
  28. #define GEVENT_GWIN_CHECKBOX (GEVENT_GWIN_CTRL_FIRST+2)
  29. /*===========================================================================*/
  30. /* Type definitions */
  31. /*===========================================================================*/
  32. typedef struct GEventGWinCheckbox {
  33. GEventType type; // The type of this event (GEVENT_GWIN_CHECKBOX)
  34. GHandle gwin; // The checkbox that has been depressed (actually triggered on release)
  35. #if GWIN_WIDGET_TAGS
  36. WidgetTag tag; // The checkbox tag
  37. #endif
  38. bool_t isChecked; // Is the checkbox currently checked or unchecked?
  39. } GEventGWinCheckbox;
  40. /**
  41. * @brief The internal checkbox flags
  42. * @note Used only for writing a custom draw routine.
  43. * @{
  44. */
  45. #define GCHECKBOX_FLG_CHECKED 0x01
  46. /** @} */
  47. /* A Checkbox window */
  48. typedef struct GCheckboxObject {
  49. GWidgetObject w;
  50. #if GINPUT_NEED_TOGGLE
  51. uint16_t toggle;
  52. #endif
  53. } GCheckboxObject;
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. /**
  58. * @brief Create a checkbox window.
  59. * @return NULL if there is no resultant drawing area, otherwise a window handle.
  60. *
  61. * @param[in] g The GDisplay to display this window on
  62. * @param[in] gb The GCheckboxObject structure to initialise. If this is NULL, the structure is dynamically allocated.
  63. * @param[in] pInit The initialization parameters to use
  64. *
  65. * @note The drawing color and the background color get set to the current defaults. If you haven't called
  66. * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
  67. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
  68. * is no default font and text drawing operations will no nothing.
  69. * @note A checkbox remembers its normal drawing state. If there is a window manager then it is automatically
  70. * redrawn if the window is moved or its visibility state is changed.
  71. * @note A checkbox supports mouse and a toggle input.
  72. * @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will
  73. * forget the previous toggle. When assigning a toggle the role parameter must be 0.
  74. *
  75. * @api
  76. */
  77. GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit *pInit);
  78. #define gwinCheckboxCreate(gb, pInit) gwinGCheckboxCreate(GDISP, gb, pInit)
  79. /**
  80. * @brief Set the state of a checkbox
  81. *
  82. * @param[in] gh The window handle (must be a checkbox window)
  83. * @param[in] isChecked TRUE to set the check, FALSE to uncheck.
  84. *
  85. * @api
  86. */
  87. void gwinCheckboxCheck(GHandle gh, bool_t isChecked);
  88. /**
  89. * @brief Get the state of a checkbox
  90. * @return TRUE if the checkbox is currently checked
  91. *
  92. * @param[in] gh The window handle (must be a checkbox window)
  93. *
  94. * @api
  95. */
  96. bool_t gwinCheckboxIsChecked(GHandle gh);
  97. /**
  98. * @defgroup Renderings_Checkbox Renderings
  99. *
  100. * @brief Built-in rendering functions for the checkbox widget.
  101. *
  102. * @details These function may be passed to @p gwinSetCustomDraw() to get different checkbox drawing styles.
  103. *
  104. * @note In your custom checkbox drawing function you may optionally call these
  105. * standard functions and then draw your extra details on top.
  106. * @note These custom drawing routines don't have to worry about setting clipping as the framework
  107. * sets clipping to the object window prior to calling these routines.
  108. *
  109. * @{
  110. */
  111. /**
  112. * @brief Renders a square checkbox where the text is on the right side of the checkbox.
  113. *
  114. * @param[in] gw The widget (must be a checkbox)
  115. * @param[in] param A parameter passed in from the user. Ignored by this function.
  116. *
  117. * @api
  118. */
  119. void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param);
  120. /**
  121. * @brief Renders a square checkbox where the text is on the left side of the checkbox.
  122. *
  123. * @param[in] gw The widget (must be a checkbox)
  124. * @param[in] param A parameter passed in from the user. Ignored by this function.
  125. *
  126. * @api
  127. */
  128. void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param);
  129. /**
  130. * @brief Renders a checkbox in form of a rectangular button with the text inside of it.
  131. *
  132. * @details This behaves like a button that can be toggled.
  133. *
  134. * @param[in] gw The widget (must be a checkbox)
  135. * @param[in] param A parameter passed in from the user. Ignored by this function.
  136. *
  137. * @api
  138. */
  139. void gwinCheckboxDraw_Button(GWidgetObject *gw, void *param);
  140. /** @} */
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif /* _GWIN_CHECKBOX_H */
  145. /** @} */