widget.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * @file widget.h
  3. * GUI: Widget view module API
  4. */
  5. #pragma once
  6. #include "widget_elements/widget_element_i.h"
  7. typedef struct Widget Widget;
  8. typedef struct WidgetElement WidgetElement;
  9. /** Allocate Widget that holds Widget Elements
  10. *
  11. * @return Widget instance
  12. */
  13. Widget* widget_alloc();
  14. /** Free Widget
  15. * @note this function free allocated Widget Elements
  16. *
  17. * @param widget Widget instance
  18. */
  19. void widget_free(Widget* widget);
  20. /** Clear Widget
  21. *
  22. * @param widget Widget instance
  23. */
  24. void widget_clear(Widget* widget);
  25. /** Get Widget view
  26. *
  27. * @param widget Widget instance
  28. *
  29. * @return View instance
  30. */
  31. View* widget_get_view(Widget* widget);
  32. /** Add Multi String Element
  33. *
  34. * @param widget Widget instance
  35. * @param x x coordinate
  36. * @param y y coordinate
  37. * @param horizontal Align instance
  38. * @param vertical Align instance
  39. * @param font Font instance
  40. * @param[in] text The text
  41. */
  42. void widget_add_string_multiline_element(
  43. Widget* widget,
  44. uint8_t x,
  45. uint8_t y,
  46. Align horizontal,
  47. Align vertical,
  48. Font font,
  49. const char* text);
  50. /** Add String Element
  51. *
  52. * @param widget Widget instance
  53. * @param x x coordinate
  54. * @param y y coordinate
  55. * @param horizontal Align instance
  56. * @param vertical Align instance
  57. * @param font Font instance
  58. * @param[in] text The text
  59. */
  60. void widget_add_string_element(
  61. Widget* widget,
  62. uint8_t x,
  63. uint8_t y,
  64. Align horizontal,
  65. Align vertical,
  66. Font font,
  67. const char* text);
  68. /** Add Text Box Element
  69. *
  70. * @param widget Widget instance
  71. * @param x x coordinate
  72. * @param y y coordinate
  73. * @param width width to fit text
  74. * @param height height to fit text
  75. * @param horizontal Align instance
  76. * @param vertical Align instance
  77. * @param[in] text Formatted text. The following formats are available:
  78. * "\e#Bold text\e#" - bold font is used
  79. * "\e*Monospaced text\e*" - monospaced font is used
  80. * "\e#Inversed text\e#" - white text on black background
  81. */
  82. void widget_add_text_box_element(
  83. Widget* widget,
  84. uint8_t x,
  85. uint8_t y,
  86. uint8_t width,
  87. uint8_t height,
  88. Align horizontal,
  89. Align vertical,
  90. const char* text);
  91. /** Add Button Element
  92. *
  93. * @param widget Widget instance
  94. * @param button_type GuiButtonType instance
  95. * @param text text on allocated button
  96. * @param callback ButtonCallback instance
  97. * @param context pointer to context
  98. */
  99. void widget_add_button_element(
  100. Widget* widget,
  101. GuiButtonType button_type,
  102. const char* text,
  103. ButtonCallback callback,
  104. void* context);
  105. /** Add Icon Element
  106. *
  107. * @param widget Widget instance
  108. * @param x top left x coordinate
  109. * @param y top left y coordinate
  110. * @param icon Icon instance
  111. */
  112. void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon);
  113. /** Add Frame Element
  114. *
  115. * @param widget Widget instance
  116. * @param x top left x coordinate
  117. * @param y top left y coordinate
  118. * @param width frame width
  119. * @param height frame height
  120. * @param radius frame radius
  121. */
  122. void widget_add_frame_element(
  123. Widget* widget,
  124. uint8_t x,
  125. uint8_t y,
  126. uint8_t width,
  127. uint8_t height,
  128. uint8_t radius);