dialog.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * @file dialog.h
  3. * GUI: Dialog 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 Dialog Dialog;
  12. /** Dialog result */
  13. typedef enum {
  14. DialogResultLeft,
  15. DialogResultRight,
  16. DialogResultBack,
  17. } DialogResult;
  18. /** Dialog result callback type
  19. * @warning comes from GUI thread
  20. */
  21. typedef void (*DialogResultCallback)(DialogResult result, void* context);
  22. /** Allocate and initialize dialog
  23. *
  24. * This dialog used to ask simple questions like Yes/
  25. *
  26. * @return Dialog instance
  27. */
  28. Dialog* dialog_alloc();
  29. /** Deinitialize and free dialog
  30. *
  31. * @param dialog Dialog instance
  32. */
  33. void dialog_free(Dialog* dialog);
  34. /** Get dialog view
  35. *
  36. * @param dialog Dialog instance
  37. *
  38. * @return View instance that can be used for embedding
  39. */
  40. View* dialog_get_view(Dialog* dialog);
  41. /** Set dialog result callback
  42. *
  43. * @param dialog Dialog instance
  44. * @param callback result callback function
  45. */
  46. void dialog_set_result_callback(Dialog* dialog, DialogResultCallback callback);
  47. /** Set dialog context
  48. *
  49. * @param dialog Dialog instance
  50. * @param context context pointer, will be passed to result callback
  51. */
  52. void dialog_set_context(Dialog* dialog, void* context);
  53. /** Set dialog header text
  54. *
  55. * @param dialog Dialog instance
  56. * @param text text to be shown
  57. */
  58. void dialog_set_header_text(Dialog* dialog, const char* text);
  59. /** Set dialog text
  60. *
  61. * @param dialog Dialog instance
  62. * @param text text to be shown
  63. */
  64. void dialog_set_text(Dialog* dialog, const char* text);
  65. /** Set left button text
  66. *
  67. * @param dialog Dialog instance
  68. * @param text text to be shown
  69. */
  70. void dialog_set_left_button_text(Dialog* dialog, const char* text);
  71. /** Set right button text
  72. *
  73. * @param dialog Dialog instance
  74. * @param text text to be shown
  75. */
  76. void dialog_set_right_button_text(Dialog* dialog, const char* text);
  77. #ifdef __cplusplus
  78. }
  79. #endif