text_input.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /** Allocate and initialize text input
  10. * This text input is used to enter string
  11. * @return TextInput instance
  12. */
  13. TextInput* text_input_alloc();
  14. /** Deinitialize and free text input
  15. * @param text_input - TextInput instance
  16. */
  17. void text_input_free(TextInput* text_input);
  18. /** Clean text input view
  19. * Note: this function does not free memory
  20. * @param text_input - Text input instance
  21. */
  22. void text_input_clean(TextInput* text_input);
  23. /** Get text input view
  24. * @param text_input - TextInput instance
  25. * @return View instance that can be used for embedding
  26. */
  27. View* text_input_get_view(TextInput* text_input);
  28. /** Set text input result callback
  29. * @param text_input - TextInput instance
  30. * @param callback - callback fn
  31. * @param callback_context - callback context
  32. * @param text_buffer - pointer to YOUR text buffer, that we going to modify
  33. * @param text_buffer_size - YOUR text buffer size in bytes. Max string length will be text_buffer_size - 1.
  34. * @param clear_default_text - clear text from text_buffer on first OK event
  35. */
  36. void text_input_set_result_callback(
  37. TextInput* text_input,
  38. TextInputCallback callback,
  39. void* callback_context,
  40. char* text_buffer,
  41. size_t text_buffer_size,
  42. bool clear_default_text);
  43. /** Set text input header text
  44. * @param text_input - TextInput instance
  45. * @param text - text to be shown
  46. */
  47. void text_input_set_header_text(TextInput* text_input, const char* text);
  48. #ifdef __cplusplus
  49. }
  50. #endif