dialog.h 1.8 KB

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