dialog.h 1.8 KB

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