dialog_ex.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @file dialog_ex.h
  3. * GUI: DialogEx view module API
  4. */
  5. #pragma once
  6. #include <gui/view.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /** Dialog anonymous structure */
  11. typedef struct DialogEx DialogEx;
  12. /** DialogEx result */
  13. typedef enum {
  14. DialogExResultLeft,
  15. DialogExResultCenter,
  16. DialogExResultRight,
  17. DialogExPressLeft,
  18. DialogExPressCenter,
  19. DialogExPressRight,
  20. DialogExReleaseLeft,
  21. DialogExReleaseCenter,
  22. DialogExReleaseRight,
  23. } DialogExResult;
  24. /** DialogEx result callback type
  25. * @warning comes from GUI thread
  26. */
  27. typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
  28. /** Allocate and initialize dialog
  29. *
  30. * This dialog used to ask simple questions
  31. *
  32. * @return DialogEx instance
  33. */
  34. DialogEx* dialog_ex_alloc();
  35. /** Deinitialize and free dialog
  36. *
  37. * @param dialog_ex DialogEx instance
  38. */
  39. void dialog_ex_free(DialogEx* dialog_ex);
  40. /** Get dialog view
  41. *
  42. * @param dialog_ex DialogEx instance
  43. *
  44. * @return View instance that can be used for embedding
  45. */
  46. View* dialog_ex_get_view(DialogEx* dialog_ex);
  47. /** Set dialog result callback
  48. *
  49. * @param dialog_ex DialogEx instance
  50. * @param callback result callback function
  51. */
  52. void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
  53. /** Set dialog context
  54. *
  55. * @param dialog_ex DialogEx instance
  56. * @param context context pointer, will be passed to result callback
  57. */
  58. void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
  59. /** Set dialog header text
  60. *
  61. * If text is null, dialog header will not be rendered
  62. *
  63. * @param dialog_ex DialogEx instance
  64. * @param text text to be shown, can be multiline
  65. * @param x x position
  66. * @param y y position
  67. * @param horizontal horizontal text aligment
  68. * @param vertical vertical text aligment
  69. */
  70. void dialog_ex_set_header(
  71. DialogEx* dialog_ex,
  72. const char* text,
  73. uint8_t x,
  74. uint8_t y,
  75. Align horizontal,
  76. Align vertical);
  77. /** Set dialog text
  78. *
  79. * If text is null, dialog text will not be rendered
  80. *
  81. * @param dialog_ex DialogEx instance
  82. * @param text text to be shown, can be multiline
  83. * @param x x position
  84. * @param y y position
  85. * @param horizontal horizontal text aligment
  86. * @param vertical vertical text aligment
  87. */
  88. void dialog_ex_set_text(
  89. DialogEx* dialog_ex,
  90. const char* text,
  91. uint8_t x,
  92. uint8_t y,
  93. Align horizontal,
  94. Align vertical);
  95. /** Set dialog icon
  96. *
  97. * If x or y is negative, dialog icon will not be rendered
  98. *
  99. * @param dialog_ex DialogEx instance
  100. * @param x x position
  101. * @param y y position
  102. * @param icon The icon
  103. * @param name icon to be shown
  104. */
  105. void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
  106. /** Set left button text
  107. *
  108. * If text is null, left button will not be rendered and processed
  109. *
  110. * @param dialog_ex DialogEx instance
  111. * @param text text to be shown
  112. */
  113. void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
  114. /** Set center button text
  115. *
  116. * If text is null, center button will not be rendered and processed
  117. *
  118. * @param dialog_ex DialogEx instance
  119. * @param text text to be shown
  120. */
  121. void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
  122. /** Set right button text
  123. *
  124. * If text is null, right button will not be rendered and processed
  125. *
  126. * @param dialog_ex DialogEx instance
  127. * @param text text to be shown
  128. */
  129. void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
  130. /** Clean dialog
  131. *
  132. * @param dialog_ex DialogEx instance
  133. */
  134. void dialog_ex_reset(DialogEx* dialog_ex);
  135. /** Enable press/release events
  136. *
  137. * @param dialog_ex DialogEx instance
  138. */
  139. void dialog_ex_enable_extended_events(DialogEx* dialog_ex);
  140. /** Disable press/release events
  141. *
  142. * @param dialog_ex DialogEx instance
  143. */
  144. void dialog_ex_disable_extended_events(DialogEx* dialog_ex);
  145. #ifdef __cplusplus
  146. }
  147. #endif