text_input.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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, char* text);
  9. /* Allocate and initialize text input
  10. * This text input is used to enter string
  11. */
  12. TextInput* text_input_alloc();
  13. /* Deinitialize and free text input
  14. * @param text_input - Text input instance
  15. */
  16. void text_input_free(TextInput* text_input);
  17. /* Get text input view
  18. * @param text_input - Text input instance
  19. * @return View instance that can be used for embedding
  20. */
  21. View* text_input_get_view(TextInput* text_input);
  22. /* Deinitialize and free text input
  23. * @param text_input - Text input instance
  24. * @param callback - callback fn
  25. * @param callback_context - callback context
  26. * @param text - text buffer to use
  27. * @param max_text_length - text buffer length
  28. */
  29. void text_input_set_result_callback(
  30. TextInput* text_input,
  31. TextInputCallback callback,
  32. void* callback_context,
  33. char* text,
  34. uint8_t max_text_length);
  35. /* Set text input header text
  36. * @param text input - Text input instance
  37. * @param text - text to be shown
  38. */
  39. void text_input_set_header_text(TextInput* text_input, const char* text);
  40. #ifdef __cplusplus
  41. }
  42. #endif