text_input.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <gui/view.h>
  3. /* Text input anonymous structure */
  4. typedef struct TextInput TextInput;
  5. typedef void (*TextInputCallback)(void* context, char* text);
  6. /* Allocate and initialize text input
  7. * This text input is used to enter string
  8. */
  9. TextInput* text_input_alloc();
  10. /* Deinitialize and free text input
  11. * @param text_input - Text input instance
  12. */
  13. void text_input_free(TextInput* text_input);
  14. /* Get text input view
  15. * @param text_input - Text input instance
  16. * @return View instance that can be used for embedding
  17. */
  18. View* text_input_get_view(TextInput* text_input);
  19. /* Deinitialize and free text input
  20. * @param text_input - Text input instance
  21. * @param callback - callback fn
  22. * @param callback_context - callback context
  23. * @param text - text buffer to use
  24. * @param max_text_length - text buffer length
  25. */
  26. void text_input_set_result_callback(
  27. TextInput* text_input,
  28. TextInputCallback callback,
  29. void* callback_context,
  30. char* text,
  31. uint8_t max_text_length);
  32. /* Set text input header text
  33. * @param text input - Text input instance
  34. * @param text - text to be shown
  35. */
  36. void text_input_set_header_text(TextInput* text_input, const char* text);