dialog_ex.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #pragma once
  2. #include <gui/view.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /** Dialog anonymous structure */
  7. typedef struct DialogEx DialogEx;
  8. /** DialogEx result */
  9. typedef enum {
  10. DialogExResultLeft,
  11. DialogExResultCenter,
  12. DialogExResultRight,
  13. } DialogExResult;
  14. /** DialogEx result callback type
  15. * @warning comes from GUI thread
  16. */
  17. typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
  18. /** Allocate and initialize dialog
  19. * This dialog used to ask simple questions
  20. * @return DialogEx instance
  21. */
  22. DialogEx* dialog_ex_alloc();
  23. /** Deinitialize and free dialog
  24. * @param dialog - DialogEx instance
  25. */
  26. void dialog_ex_free(DialogEx* dialog_ex);
  27. /** Get dialog view
  28. * @param dialog - DialogEx instance
  29. * @return View instance that can be used for embedding
  30. */
  31. View* dialog_ex_get_view(DialogEx* dialog_ex);
  32. /** Set dialog result callback
  33. * @param dialog_ex - DialogEx instance
  34. * @param callback - result callback function
  35. */
  36. void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
  37. /** Set dialog context
  38. * @param dialog_ex - DialogEx instance
  39. * @param context - context pointer, will be passed to result callback
  40. */
  41. void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
  42. /** Set dialog header text
  43. * If text is null, dialog header will not be rendered
  44. * @param dialog - DialogEx instance
  45. * @param text - text to be shown, can be multiline
  46. * @param x, y - text position
  47. * @param horizontal, vertical - text aligment
  48. */
  49. void dialog_ex_set_header(
  50. DialogEx* dialog_ex,
  51. const char* text,
  52. uint8_t x,
  53. uint8_t y,
  54. Align horizontal,
  55. Align vertical);
  56. /** Set dialog text
  57. * If text is null, dialog text will not be rendered
  58. * @param dialog - DialogEx instance
  59. * @param text - text to be shown, can be multiline
  60. * @param x, y - text position
  61. * @param horizontal, vertical - text aligment
  62. */
  63. void dialog_ex_set_text(
  64. DialogEx* dialog_ex,
  65. const char* text,
  66. uint8_t x,
  67. uint8_t y,
  68. Align horizontal,
  69. Align vertical);
  70. /** Set dialog icon
  71. * If x or y is negative, dialog icon will not be rendered
  72. * @param dialog - DialogEx instance
  73. * @param x, y - icon position
  74. * @param name - icon to be shown
  75. */
  76. void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
  77. /** Set left button text
  78. * If text is null, left button will not be rendered and processed
  79. * @param dialog - DialogEx instance
  80. * @param text - text to be shown
  81. */
  82. void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
  83. /** Set center button text
  84. * If text is null, center button will not be rendered and processed
  85. * @param dialog - DialogEx instance
  86. * @param text - text to be shown
  87. */
  88. void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
  89. /** Set right button text
  90. * If text is null, right button will not be rendered and processed
  91. * @param dialog - DialogEx instance
  92. * @param text - text to be shown
  93. */
  94. void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
  95. /** Clean dialog
  96. * @param dialog_ex DialogEx instance
  97. */
  98. void dialog_ex_clean(DialogEx* dialog_ex);
  99. #ifdef __cplusplus
  100. }
  101. #endif