dialog.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <gui/view.h>
  3. /* Dialog anonymous structure */
  4. typedef struct Dialog Dialog;
  5. /* Dialog result */
  6. typedef enum {
  7. DialogResultLeft,
  8. DialogResultRight,
  9. } DialogResult;
  10. /* Dialog result callback type
  11. * @warning comes from GUI thread
  12. */
  13. typedef void (*DialogResultCallback)(DialogResult result, void* context);
  14. /* Allocate and initialize dialog
  15. * This dialog used to ask simple questions like Yes/
  16. */
  17. Dialog* dialog_alloc();
  18. /* Deinitialize and free dialog
  19. * @param dialog - Dialog instance
  20. */
  21. void dialog_free(Dialog* dialog);
  22. /* Get dialog view
  23. * @param dialog - Dialog instance
  24. * @return View instance that can be used for embedding
  25. */
  26. View* dialog_get_view(Dialog* dialog);
  27. /* Set dialog result callback
  28. * @param dialog - Dialog instance
  29. * @param callback - result callback function
  30. */
  31. void dialog_set_result_callback(Dialog* dialog, DialogResultCallback callback);
  32. /* Set dialog context
  33. * @param dialog - Dialog instance
  34. * @param context - context pointer, will be passed to result callback
  35. */
  36. void dialog_set_context(Dialog* dialog, void* context);
  37. /* Set dialog header text
  38. * @param dialog - Dialog instance
  39. * @param text - text to be shown
  40. */
  41. void dialog_set_header_text(Dialog* dialog, const char* text);
  42. /* Set dialog text
  43. * @param dialog - Dialog instance
  44. * @param text - text to be shown
  45. */
  46. void dialog_set_text(Dialog* dialog, const char* text);
  47. /* Set left button text
  48. * @param dialog - Dialog instance
  49. * @param text - text to be shown
  50. */
  51. void dialog_set_left_button_text(Dialog* dialog, const char* text);
  52. /* Set right button text
  53. * @param dialog - Dialog instance
  54. * @param text - text to be shown
  55. */
  56. void dialog_set_right_button_text(Dialog* dialog, const char* text);