text_input.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. * @param clear_default_text - clear text from text_buffer on first OK event
  37. */
  38. void text_input_set_result_callback(
  39. TextInput* text_input,
  40. TextInputCallback callback,
  41. void* callback_context,
  42. char* text_buffer,
  43. size_t text_buffer_size,
  44. bool clear_default_text);
  45. /**
  46. * @brief Set text input header text
  47. *
  48. * @param text input - Text input instance
  49. * @param text - text to be shown
  50. */
  51. void text_input_set_header_text(TextInput* text_input, const char* text);
  52. #ifdef __cplusplus
  53. }
  54. #endif