dialog_ex.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 like Yes/
  20. */
  21. DialogEx* dialog_ex_alloc();
  22. /* Deinitialize and free dialog
  23. * @param dialog - DialogEx instance
  24. */
  25. void dialog_ex_free(DialogEx* dialog_ex);
  26. /* Get dialog view
  27. * @param dialog - DialogEx instance
  28. * @return View instance that can be used for embedding
  29. */
  30. View* dialog_ex_get_view(DialogEx* dialog_ex);
  31. /* Set dialog result callback
  32. * @param dialog_ex - DialogEx instance
  33. * @param callback - result callback function
  34. */
  35. void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
  36. /* Set dialog context
  37. * @param dialog_ex - DialogEx instance
  38. * @param context - context pointer, will be passed to result callback
  39. */
  40. void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
  41. /* Set dialog header text
  42. * If text is null, dialog header will not be rendered
  43. * @param dialog - DialogEx instance
  44. * @param text - text to be shown, can be multiline
  45. * @param x, y - text position
  46. * @param horizontal, vertical - text aligment
  47. */
  48. void dialog_ex_set_header(
  49. DialogEx* dialog_ex,
  50. const char* text,
  51. uint8_t x,
  52. uint8_t y,
  53. Align horizontal,
  54. Align vertical);
  55. /* Set dialog text
  56. * If text is null, dialog text will not be rendered
  57. * @param dialog - DialogEx instance
  58. * @param text - text to be shown, can be multiline
  59. * @param x, y - text position
  60. * @param horizontal, vertical - text aligment
  61. */
  62. void dialog_ex_set_text(
  63. DialogEx* dialog_ex,
  64. const char* text,
  65. uint8_t x,
  66. uint8_t y,
  67. Align horizontal,
  68. Align vertical);
  69. /* Set dialog icon
  70. * If x or y is negative, dialog icon will not be rendered
  71. * @param dialog - DialogEx instance
  72. * @param x, y - icon position
  73. * @param name - icon to be shown
  74. */
  75. void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
  76. /* Set left button text
  77. * If text is null, left button will not be rendered and processed
  78. * @param dialog - DialogEx instance
  79. * @param text - text to be shown
  80. */
  81. void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
  82. /* Set center button text
  83. * If text is null, center button will not be rendered and processed
  84. * @param dialog - DialogEx instance
  85. * @param text - text to be shown
  86. */
  87. void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
  88. /* Set right button text
  89. * If text is null, right button will not be rendered and processed
  90. * @param dialog - DialogEx instance
  91. * @param text - text to be shown
  92. */
  93. void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
  94. #ifdef __cplusplus
  95. }
  96. #endif