dialog_ex.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. } DialogExResult;
  18. /** DialogEx result callback type
  19. * @warning comes from GUI thread
  20. */
  21. typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
  22. /** Allocate and initialize dialog
  23. *
  24. * This dialog used to ask simple questions
  25. *
  26. * @return DialogEx instance
  27. */
  28. DialogEx* dialog_ex_alloc();
  29. /** Deinitialize and free dialog
  30. *
  31. * @param dialog_ex DialogEx instance
  32. */
  33. void dialog_ex_free(DialogEx* dialog_ex);
  34. /** Get dialog view
  35. *
  36. * @param dialog_ex DialogEx instance
  37. *
  38. * @return View instance that can be used for embedding
  39. */
  40. View* dialog_ex_get_view(DialogEx* dialog_ex);
  41. /** Set dialog result callback
  42. *
  43. * @param dialog_ex DialogEx instance
  44. * @param callback result callback function
  45. */
  46. void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
  47. /** Set dialog context
  48. *
  49. * @param dialog_ex DialogEx instance
  50. * @param context context pointer, will be passed to result callback
  51. */
  52. void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
  53. /** Set dialog header text
  54. *
  55. * If text is null, dialog header will not be rendered
  56. *
  57. * @param dialog_ex DialogEx instance
  58. * @param text text to be shown, can be multiline
  59. * @param x x position
  60. * @param y y position
  61. * @param horizontal horizontal text aligment
  62. * @param vertical vertical text aligment
  63. */
  64. void dialog_ex_set_header(
  65. DialogEx* dialog_ex,
  66. const char* text,
  67. uint8_t x,
  68. uint8_t y,
  69. Align horizontal,
  70. Align vertical);
  71. /** Set dialog text
  72. *
  73. * If text is null, dialog text will not be rendered
  74. *
  75. * @param dialog_ex DialogEx instance
  76. * @param text text to be shown, can be multiline
  77. * @param x x position
  78. * @param y y position
  79. * @param horizontal horizontal text aligment
  80. * @param vertical vertical text aligment
  81. */
  82. void dialog_ex_set_text(
  83. DialogEx* dialog_ex,
  84. const char* text,
  85. uint8_t x,
  86. uint8_t y,
  87. Align horizontal,
  88. Align vertical);
  89. /** Set dialog icon
  90. *
  91. * If x or y is negative, dialog icon will not be rendered
  92. *
  93. * @param dialog_ex DialogEx instance
  94. * @param x x position
  95. * @param y y position
  96. * @param icon The icon
  97. * @param name icon to be shown
  98. */
  99. void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
  100. /** Set left button text
  101. *
  102. * If text is null, left button will not be rendered and processed
  103. *
  104. * @param dialog_ex DialogEx instance
  105. * @param text text to be shown
  106. */
  107. void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
  108. /** Set center button text
  109. *
  110. * If text is null, center button will not be rendered and processed
  111. *
  112. * @param dialog_ex DialogEx instance
  113. * @param text text to be shown
  114. */
  115. void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
  116. /** Set right button text
  117. *
  118. * If text is null, right button will not be rendered and processed
  119. *
  120. * @param dialog_ex DialogEx instance
  121. * @param text text to be shown
  122. */
  123. void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
  124. /** Clean dialog
  125. *
  126. * @param dialog_ex DialogEx instance
  127. */
  128. void dialog_ex_clean(DialogEx* dialog_ex);
  129. #ifdef __cplusplus
  130. }
  131. #endif