text_input.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @file text_input.h
  3. * GUI: TextInput keybord view module API
  4. */
  5. #pragma once
  6. #include <gui/view.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /** Text input anonymous structure */
  11. typedef struct TextInput TextInput;
  12. typedef void (*TextInputCallback)(void* context);
  13. /** Allocate and initialize text input
  14. *
  15. * This text input is used to enter string
  16. *
  17. * @return TextInput instance
  18. */
  19. TextInput* text_input_alloc();
  20. /** Deinitialize and free text input
  21. *
  22. * @param text_input TextInput instance
  23. */
  24. void text_input_free(TextInput* text_input);
  25. /** Clean text input view Note: this function does not free memory
  26. *
  27. * @param text_input Text input instance
  28. */
  29. void text_input_clean(TextInput* text_input);
  30. /** Get text input view
  31. *
  32. * @param text_input TextInput instance
  33. *
  34. * @return View instance that can be used for embedding
  35. */
  36. View* text_input_get_view(TextInput* text_input);
  37. /** Set text input result callback
  38. *
  39. * @param text_input TextInput instance
  40. * @param callback callback fn
  41. * @param callback_context callback context
  42. * @param text_buffer pointer to YOUR text buffer, that we going
  43. * to modify
  44. * @param text_buffer_size YOUR text buffer size in bytes. Max string
  45. * length will be text_buffer_size-1.
  46. * @param clear_default_text clear text from text_buffer on first OK
  47. * event
  48. */
  49. void text_input_set_result_callback(
  50. TextInput* text_input,
  51. TextInputCallback callback,
  52. void* callback_context,
  53. char* text_buffer,
  54. size_t text_buffer_size,
  55. bool clear_default_text);
  56. /** Set text input header text
  57. *
  58. * @param text_input TextInput instance
  59. * @param text text to be shown
  60. */
  61. void text_input_set_header_text(TextInput* text_input, const char* text);
  62. #ifdef __cplusplus
  63. }
  64. #endif