text_input.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <gui/view.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Text input anonymous structure */
  7. typedef struct TextInput TextInput;
  8. typedef void (*TextInputCallback)(void* context);
  9. /**
  10. * @brief Allocate and initialize text input
  11. * This text input is used to enter string
  12. *
  13. */
  14. TextInput* text_input_alloc();
  15. /**
  16. * @brief Deinitialize and free text input
  17. *
  18. * @param text_input - Text input instance
  19. */
  20. void text_input_free(TextInput* text_input);
  21. /**
  22. * @brief Get text input view
  23. *
  24. * @param text_input - Text input instance
  25. * @return View instance that can be used for embedding
  26. */
  27. View* text_input_get_view(TextInput* text_input);
  28. /**
  29. * @brief Set text input result callback
  30. *
  31. * @param text_input - Text input instance
  32. * @param callback - callback fn
  33. * @param callback_context - callback context
  34. * @param text_buffer - pointer to YOUR text buffer, that we going to modify
  35. * @param text_buffer_size - YOUR text buffer size in bytes. Max string length will be text_buffer_size - 1.
  36. */
  37. void text_input_set_result_callback(
  38. TextInput* text_input,
  39. TextInputCallback callback,
  40. void* callback_context,
  41. char* text_buffer,
  42. size_t text_buffer_size);
  43. /**
  44. * @brief Set text input header text
  45. *
  46. * @param text input - Text input instance
  47. * @param text - text to be shown
  48. */
  49. void text_input_set_header_text(TextInput* text_input, const char* text);
  50. #ifdef __cplusplus
  51. }
  52. #endif